version cagettepei
This commit is contained in:
@@ -199,7 +199,7 @@
|
|||||||
<!--
|
<!--
|
||||||
::raw _("Cagette.net is made by <a href='https://www.alilo.fr' target='_blank'><img src='/img/alilo-trans-black.png' /></a>")::<br/>
|
::raw _("Cagette.net is made by <a href='https://www.alilo.fr' target='_blank'><img src='/img/alilo-trans-black.png' /></a>")::<br/>
|
||||||
-->
|
-->
|
||||||
<span>version ::VERSION::</span>
|
<span>version cagettepei-<a href="https://git.artcode.re/cagetters/cagettepei/src/tag/::VERSION::">::VERSION::</a></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "CagettePei",
|
"name": "cagette-pei",
|
||||||
"description": "le logiciel libre du circuit court",
|
"description": "le logiciel libre du circuit court",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+2
-1
@@ -16,7 +16,8 @@ class App extends sugoi.BaseApp {
|
|||||||
*/
|
*/
|
||||||
// public static var VERSION = ([0,9,2] : Version).withPre("july");
|
// public static var VERSION = ([0,9,2] : Version).withPre("july");
|
||||||
// public static var VERSION = ([0,9,2] : Version).withPre(MyMacros.getGitShortSHA(), MyMacros.getGitCommitDate());
|
// public static var VERSION = ([0,9,2] : Version).withPre(MyMacros.getGitShortSHA(), MyMacros.getGitCommitDate());
|
||||||
public static var VERSION = "cagette-péi " + MyMacros.getGitCommitDate();
|
// public static var VERSION = "cagette-péi " + MyMacros.getGitCommitDate();
|
||||||
|
public static var VERSION = "cagette-pei"; // empty yet, cf.BaseApp.loadConfig
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
|
|||||||
+136
-126
@@ -1,25 +1,25 @@
|
|||||||
package sugoi;
|
package sugoi;
|
||||||
|
|
||||||
import sugoi.i18n.TemplateTranslator;
|
import sugoi.i18n.TemplateTranslator;
|
||||||
import sugoi.Web;
|
import sugoi.Web;
|
||||||
|
|
||||||
class BaseApp {
|
class BaseApp {
|
||||||
|
public var cnx:sys.db.Connection;
|
||||||
|
public var template:templo.Loader;
|
||||||
|
public var maintain:Bool;
|
||||||
|
public var session:sugoi.db.Session;
|
||||||
|
public var view:View;
|
||||||
|
public var user:db.User;
|
||||||
|
public var params:Map<String, String>;
|
||||||
|
public var cookieName:String;
|
||||||
|
public var cookieDomain:String;
|
||||||
|
public var uri:String;
|
||||||
|
|
||||||
public var cnx : sys.db.Connection;
|
public static var config:Config;
|
||||||
public var template : templo.Loader;
|
|
||||||
public var maintain : Bool;
|
|
||||||
public var session : sugoi.db.Session;
|
|
||||||
public var view : View;
|
|
||||||
public var user : db.User;
|
|
||||||
public var params : Map<String,String>;
|
|
||||||
public var cookieName : String;
|
|
||||||
public var cookieDomain : String;
|
|
||||||
public var uri : String;
|
|
||||||
|
|
||||||
public static var config: Config;
|
// public static var classPathes = sugoi.tools.Macros.getClassPathes();
|
||||||
//public static var classPathes = sugoi.tools.Macros.getClassPathes();
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
|
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
}
|
}
|
||||||
@@ -28,24 +28,33 @@ class BaseApp {
|
|||||||
cookieDomain = "." + App.config.HOST;
|
cookieDomain = "." + App.config.HOST;
|
||||||
|
|
||||||
#if plugins
|
#if plugins
|
||||||
if( false ) sugoi.plugin.PlugIn.copyTpl();
|
if (false)
|
||||||
|
sugoi.plugin.PlugIn.copyTpl();
|
||||||
#end
|
#end
|
||||||
|
|
||||||
// This macro generates translated templates for each langage
|
// This macro generates translated templates for each langage
|
||||||
#if i18n_generation
|
#if i18n_generation
|
||||||
if( false ) TemplateTranslator.parse("lang/master");
|
if (false)
|
||||||
|
TemplateTranslator.parse("lang/master");
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadConfig() {
|
public function loadConfig() {
|
||||||
App.config = BaseApp.config = new sugoi.Config();
|
App.config = BaseApp.config = new sugoi.Config();
|
||||||
|
|
||||||
|
var PATH = Web.getCwd() + "../";
|
||||||
|
var json = haxe.Json.parse(sys.io.File.getContent(PATH + "package.json"));
|
||||||
|
App.VERSION = json.version;
|
||||||
|
|
||||||
|
App.log('configuration has been reloaded, VERSION=${App.VERSION}');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadTemplate( t : String ) {
|
public function loadTemplate(t:String) {
|
||||||
templo.Loader.OPTIMIZED = App.config.DEBUG == false;
|
templo.Loader.OPTIMIZED = App.config.DEBUG == false;
|
||||||
templo.Loader.BASE_DIR = App.config.TPL;
|
templo.Loader.BASE_DIR = App.config.TPL;
|
||||||
templo.Loader.TMP_DIR = App.config.TPL_TMP;
|
templo.Loader.TMP_DIR = App.config.TPL_TMP;
|
||||||
if ( t == null ) return null;
|
if (t == null)
|
||||||
|
return null;
|
||||||
#if neko
|
#if neko
|
||||||
return new templo.Loader(t, App.config.getBool("cachetpl"));
|
return new templo.Loader(t, App.config.getBool("cachetpl"));
|
||||||
#else
|
#else
|
||||||
@@ -53,39 +62,39 @@ class BaseApp {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTemplate( t : String ) {
|
public function setTemplate(t:String) {
|
||||||
template = t == null ? null : loadTemplate(t);
|
template = t == null ? null : loadTemplate(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initLang( lang : String ) {
|
public function initLang(lang:String) {
|
||||||
|
if (lang == null || lang == "")
|
||||||
|
lang = config.LANG;
|
||||||
|
|
||||||
if (lang == null || lang == "") lang = config.LANG;
|
// Define template path
|
||||||
|
|
||||||
//Define template path
|
|
||||||
var path;
|
var path;
|
||||||
if (!App.config.DEBUG){
|
if (!App.config.DEBUG) {
|
||||||
path = Web.getCwd() + "../lang/" + lang + "/";
|
path = Web.getCwd() + "../lang/" + lang + "/";
|
||||||
}else{
|
} else {
|
||||||
path = Web.getCwd() + "../lang/master/";
|
path = Web.getCwd() + "../lang/master/";
|
||||||
}
|
}
|
||||||
App.config.TPL = path + "tpl/";
|
App.config.TPL = path + "tpl/";
|
||||||
App.config.TPL_TMP = path + "tmp/";
|
App.config.TPL_TMP = path + "tmp/";
|
||||||
|
|
||||||
//init system locale
|
// init system locale
|
||||||
if ( !Sys.setTimeLocale("en_US.UTF-8") ) {
|
if (!Sys.setTimeLocale("en_US.UTF-8")) {
|
||||||
Sys.setTimeLocale("en");
|
Sys.setTimeLocale("en");
|
||||||
}
|
}
|
||||||
|
|
||||||
//init gettext translator
|
// init gettext translator
|
||||||
sugoi.i18n.Locale.init(lang);
|
sugoi.i18n.Locale.init(lang);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveAndClose() {
|
function saveAndClose() {
|
||||||
|
if (cnx == null)
|
||||||
if( cnx == null ) return;
|
return;
|
||||||
if( session.sid != null )
|
if (session.sid != null)
|
||||||
session.update();
|
session.update();
|
||||||
|
|
||||||
cnx.commit();
|
cnx.commit();
|
||||||
@@ -94,26 +103,28 @@ class BaseApp {
|
|||||||
untyped cnx.request = function(s) return null;
|
untyped cnx.request = function(s) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeTemplate( ?save ) {
|
function executeTemplate(?save) {
|
||||||
view.init();
|
view.init();
|
||||||
var result = template.execute(view);
|
var result = template.execute(view);
|
||||||
if ( save ) saveAndClose();
|
if (save)
|
||||||
|
saveAndClose();
|
||||||
#if php
|
#if php
|
||||||
//strange bug with templo in PHP
|
// strange bug with templo in PHP
|
||||||
if (result.substr(0, 4) == "null") result = result.substr(4);
|
if (result.substr(0, 4) == "null")
|
||||||
|
result = result.substr(4);
|
||||||
#end
|
#end
|
||||||
Sys.print(result);
|
Sys.print(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMeta( m : String, args : Array<Dynamic> ) {
|
function onMeta(m:String, args:Array<Dynamic>) {
|
||||||
switch( m ) {
|
switch (m) {
|
||||||
case "tpl":
|
case "tpl":
|
||||||
setTemplate(args[0]);
|
setTemplate(args[0]);
|
||||||
case "logged":
|
case "logged":
|
||||||
if ( user == null )
|
if (user == null)
|
||||||
throw sugoi.ControllerAction.RedirectAction("/?__redirect="+Web.getURI());
|
throw sugoi.ControllerAction.RedirectAction("/?__redirect=" + Web.getURI());
|
||||||
case "admin":
|
case "admin":
|
||||||
if( user == null || !user.isAdmin() )
|
if (user == null || !user.isAdmin())
|
||||||
throw sugoi.ControllerAction.RedirectAction("/");
|
throw sugoi.ControllerAction.RedirectAction("/");
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@@ -124,111 +135,109 @@ class BaseApp {
|
|||||||
*/
|
*/
|
||||||
function detectLang() {
|
function detectLang() {
|
||||||
var l = Web.getClientHeader("Accept-Language");
|
var l = Web.getClientHeader("Accept-Language");
|
||||||
if( l != null )
|
if (l != null)
|
||||||
for( l in l.split(",") ) {
|
for (l in l.split(",")) {
|
||||||
l = l.split(";")[0];
|
l = l.split(";")[0];
|
||||||
l = l.split("-")[0];
|
l = l.split("-")[0];
|
||||||
l = StringTools.trim(l);
|
l = StringTools.trim(l);
|
||||||
for( a in App.config.LANGS )
|
for (a in App.config.LANGS)
|
||||||
if( a == l )
|
if (a == l)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return App.config.LANG;
|
return App.config.LANG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup current app language
|
* Setup current app language
|
||||||
*/
|
*/
|
||||||
function setupLang() {
|
function setupLang() {
|
||||||
|
// this app is monolingual and doesn't manage i18n
|
||||||
|
if (App.config.LANG == "master")
|
||||||
|
return;
|
||||||
|
|
||||||
//this app is monolingual and doesn't manage i18n
|
// lang is taken from user object or from HTTP headers
|
||||||
if (App.config.LANG == "master") return;
|
if (session.lang == null || !Lambda.has(App.config.LANGS, session.lang)) {
|
||||||
|
|
||||||
//lang is taken from user object or from HTTP headers
|
|
||||||
if ( session.lang == null || !Lambda.has(App.config.LANGS, session.lang) ){
|
|
||||||
session.lang = (user == null) ? detectLang() : user.lang;
|
session.lang = (user == null) ? detectLang() : user.lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
//override if param is given
|
// override if param is given
|
||||||
var lang = params.get("lang");
|
var lang = params.get("lang");
|
||||||
if ( lang != null && Lambda.has(App.config.LANGS, lang) ){
|
if (lang != null && Lambda.has(App.config.LANGS, lang)) {
|
||||||
session.lang = lang;
|
session.lang = lang;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//init lang
|
// init lang
|
||||||
initLang(session.lang);
|
initLang(session.lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current application langage (2 letters lowercase)
|
* Get current application langage (2 letters lowercase)
|
||||||
*/
|
*/
|
||||||
public function getLang(){
|
public function getLang() {
|
||||||
return (session != null && session.lang != null && session.lang != "") ? session.lang : App.config.LANG;
|
return (session != null && session.lang != null && session.lang != "") ? session.lang : App.config.LANG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rollback() {
|
public function rollback() {
|
||||||
if( cnx != null ) cnx.rollback();
|
if (cnx != null)
|
||||||
|
cnx.rollback();
|
||||||
sys.db.Manager.cleanup();
|
sys.db.Manager.cleanup();
|
||||||
if( user != null && session != null )
|
if (user != null && session != null)
|
||||||
user = session.user;
|
user = session.user;
|
||||||
// does not reset session
|
// does not reset session
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCookie( oldCookie : String ){
|
public function setCookie(oldCookie:String) {
|
||||||
if( session != null && session.sid != null && session.sid != oldCookie ) {
|
if (session != null && session.sid != null && session.sid != oldCookie) {
|
||||||
Web.setHeader("Set-Cookie", cookieName+"=" + session.sid + "; path=/;");
|
Web.setHeader("Set-Cookie", cookieName + "=" + session.sid + "; path=/;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mainLoop() {
|
function mainLoop() {
|
||||||
params = Web.getParams();
|
params = Web.getParams();
|
||||||
|
|
||||||
//Get session
|
// Get session
|
||||||
var sids = [];
|
var sids = [];
|
||||||
var cookieSid = Web.getCookies().get(cookieName);
|
var cookieSid = Web.getCookies().get(cookieName);
|
||||||
if( params.exists("sid") ) sids.push(params.get("sid"));
|
if (params.exists("sid"))
|
||||||
if( cookieSid != null ) sids.push(cookieSid);
|
sids.push(params.get("sid"));
|
||||||
|
if (cookieSid != null)
|
||||||
|
sids.push(cookieSid);
|
||||||
session = sugoi.db.Session.init(sids);
|
session = sugoi.db.Session.init(sids);
|
||||||
|
|
||||||
//Check for maintenance
|
// Check for maintenance
|
||||||
maintain = sugoi.db.Variable.getInt("maintain") != 0;
|
maintain = sugoi.db.Variable.getInt("maintain") != 0;
|
||||||
user = session.user;
|
user = session.user;
|
||||||
|
|
||||||
//setup langage
|
// setup langage
|
||||||
setupLang();
|
setupLang();
|
||||||
|
|
||||||
|
if (maintain && ((user != null && user.isAdmin())))
|
||||||
if( maintain && ((user != null && user.isAdmin()) ) )
|
|
||||||
maintain = false;
|
maintain = false;
|
||||||
|
|
||||||
setCookie(cookieSid);
|
setCookie(cookieSid);
|
||||||
|
|
||||||
if( maintain ) {
|
if (maintain) {
|
||||||
setTemplate("maintain.mtt");
|
setTemplate("maintain.mtt");
|
||||||
executeTemplate();
|
executeTemplate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//dispatching
|
// dispatching
|
||||||
try {
|
try {
|
||||||
|
|
||||||
uri = Web.getURI();
|
uri = Web.getURI();
|
||||||
if ( StringTools.endsWith(uri, "/index.n") ) uri = uri.substr(0, -8);
|
if (StringTools.endsWith(uri, "/index.n"))
|
||||||
|
uri = uri.substr(0, -8);
|
||||||
|
|
||||||
//"before dispatch" callback
|
// "before dispatch" callback
|
||||||
beforeDispatch();
|
beforeDispatch();
|
||||||
|
|
||||||
var d = new haxe.web.Dispatch(uri, params);
|
var d = new haxe.web.Dispatch(uri, params);
|
||||||
d.onMeta = onMeta;
|
d.onMeta = onMeta;
|
||||||
d.dispatch(new controller.Main());
|
d.dispatch(new controller.Main());
|
||||||
|
} catch (e:haxe.web.Dispatch.DispatchError) {
|
||||||
} catch ( e : haxe.web.Dispatch.DispatchError ) {
|
// dispatch / routing error
|
||||||
|
if (App.config.DEBUG) {
|
||||||
//dispatch / routing error
|
|
||||||
if ( App.config.DEBUG ) {
|
|
||||||
#if neko
|
#if neko
|
||||||
neko.Lib.rethrow(e);
|
neko.Lib.rethrow(e);
|
||||||
#else
|
#else
|
||||||
@@ -238,32 +247,34 @@ class BaseApp {
|
|||||||
cnx.rollback();
|
cnx.rollback();
|
||||||
Web.redirect("/");
|
Web.redirect("/");
|
||||||
return;
|
return;
|
||||||
|
} catch (e:sugoi.ControllerAction) {
|
||||||
} catch ( e : sugoi.ControllerAction) {
|
switch (e) {
|
||||||
|
|
||||||
switch( e ) {
|
|
||||||
case RedirectAction(url):
|
case RedirectAction(url):
|
||||||
Web.redirect(url);
|
Web.redirect(url);
|
||||||
template = null;
|
template = null;
|
||||||
case ErrorAction(url, text), OkAction(url,text):
|
case ErrorAction(url, text), OkAction(url, text):
|
||||||
if( text == null ) {
|
if (text == null) {
|
||||||
text = url;
|
text = url;
|
||||||
url = Web.getURI();
|
url = Web.getURI();
|
||||||
}
|
}
|
||||||
Web.redirect(url);
|
Web.redirect(url);
|
||||||
var error = switch(e) { case ErrorAction(_): true; default: false; };
|
var error = switch (e) {
|
||||||
if( error ) rollback();
|
case ErrorAction(_): true;
|
||||||
if ( error ) {
|
default: false;
|
||||||
session.addMessage(text,true);
|
};
|
||||||
}else {
|
if (error)
|
||||||
|
rollback();
|
||||||
|
if (error) {
|
||||||
|
session.addMessage(text, true);
|
||||||
|
} else {
|
||||||
session.addMessage(text);
|
session.addMessage(text);
|
||||||
}
|
}
|
||||||
template = null;
|
template = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Render template
|
// Render template
|
||||||
if ( template == null ) {
|
if (template == null) {
|
||||||
saveAndClose();
|
saveAndClose();
|
||||||
} else {
|
} else {
|
||||||
executeTemplate(true); // will saveAndClose
|
executeTemplate(true); // will saveAndClose
|
||||||
@@ -274,12 +285,10 @@ class BaseApp {
|
|||||||
* Override this function if you want
|
* Override this function if you want
|
||||||
* to insert some actions
|
* to insert some actions
|
||||||
*/
|
*/
|
||||||
public function beforeDispatch() {
|
public function beforeDispatch() {}
|
||||||
|
|
||||||
}
|
public function logError(e:Dynamic, ?stack:String) {
|
||||||
|
var stack = if (stack != null) stack else haxe.CallStack.toString(haxe.CallStack.exceptionStack());
|
||||||
public function logError( e : Dynamic, ?stack : String ) {
|
|
||||||
var stack = if( stack != null ) stack else haxe.CallStack.toString(haxe.CallStack.exceptionStack());
|
|
||||||
var message = new StringBuf();
|
var message = new StringBuf();
|
||||||
message.add(Std.string(e));
|
message.add(Std.string(e));
|
||||||
message.add("\n");
|
message.add("\n");
|
||||||
@@ -288,43 +297,42 @@ class BaseApp {
|
|||||||
var e = new sugoi.db.Error();
|
var e = new sugoi.db.Error();
|
||||||
e.url = Web.getURI();
|
e.url = Web.getURI();
|
||||||
e.ip = Web.getClientIP();
|
e.ip = Web.getClientIP();
|
||||||
e.user = if( user != null ) user else null;
|
e.user = if (user != null) user else null;
|
||||||
e.date = Date.now();
|
e.date = Date.now();
|
||||||
e.userAgent = Web.getClientHeader("User-Agent");
|
e.userAgent = Web.getClientHeader("User-Agent");
|
||||||
e.error = message.toString();
|
e.error = message.toString();
|
||||||
e.insert();
|
e.insert();
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorHandler( e:Dynamic ) {
|
function errorHandler(e:Dynamic) {
|
||||||
try {
|
try {
|
||||||
var stack = haxe.CallStack.toString(haxe.CallStack.exceptionStack());
|
var stack = haxe.CallStack.toString(haxe.CallStack.exceptionStack());
|
||||||
// ROLLBACK and LOG
|
// ROLLBACK and LOG
|
||||||
if ( cnx != null ) {
|
if (cnx != null) {
|
||||||
cnx.rollback();
|
cnx.rollback();
|
||||||
logError(e,stack);
|
logError(e, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
//log also in a file, in case we don't have a valid connexion to DB
|
// log also in a file, in case we don't have a valid connexion to DB
|
||||||
Web.logMessage(e+"\n" + stack);
|
Web.logMessage(e + "\n" + stack);
|
||||||
|
|
||||||
maintain = true;
|
maintain = true;
|
||||||
view = new View();
|
view = new View();
|
||||||
view.message = Std.string(e);
|
view.message = Std.string(e);
|
||||||
if ( App.config.DEBUG || (user != null && user.isAdmin()) ) {
|
if (App.config.DEBUG || (user != null && user.isAdmin())) {
|
||||||
view.stack = stack;
|
view.stack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTemplate("error.mtt");
|
setTemplate("error.mtt");
|
||||||
executeTemplate(false);
|
executeTemplate(false);
|
||||||
|
} catch (e:Dynamic) {
|
||||||
} catch( e : Dynamic ) {
|
|
||||||
Sys.print("<pre>");
|
Sys.print("<pre>");
|
||||||
Sys.println("Error : "+try Std.string(e) catch( e : Dynamic ) "???");
|
Sys.println("Error : " + try Std.string(e) catch (e:Dynamic) "???");
|
||||||
Sys.println(haxe.CallStack.toString(haxe.CallStack.exceptionStack()));
|
Sys.println(haxe.CallStack.toString(haxe.CallStack.exceptionStack()));
|
||||||
try {
|
try {
|
||||||
if( cnx != null )
|
if (cnx != null)
|
||||||
sugoi.db.Error.manager.get(0,false);
|
sugoi.db.Error.manager.get(0, false);
|
||||||
} catch( e : Dynamic ) {
|
} catch (e:Dynamic) {
|
||||||
Sys.println("Initializing Database...");
|
Sys.println("Initializing Database...");
|
||||||
sys.db.Admin.initializeDatabase();
|
sys.db.Admin.initializeDatabase();
|
||||||
Sys.println("Done");
|
Sys.println("Done");
|
||||||
@@ -339,7 +347,7 @@ class BaseApp {
|
|||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
maintain = App.config.getBool("maintain");
|
maintain = App.config.getBool("maintain");
|
||||||
if( maintain ) {
|
if (maintain) {
|
||||||
view = new View();
|
view = new View();
|
||||||
setTemplate("maintain.mtt");
|
setTemplate("maintain.mtt");
|
||||||
executeTemplate(false);
|
executeTemplate(false);
|
||||||
@@ -348,23 +356,23 @@ class BaseApp {
|
|||||||
try {
|
try {
|
||||||
var dbstr = App.config.get("database");
|
var dbstr = App.config.get("database");
|
||||||
var dbreg = ~/([^:]+):\/\/([^:]+):([^@]*?)@([^:]+)(:[0-9]+)?\/(.*?)$/;
|
var dbreg = ~/([^:]+):\/\/([^:]+):([^@]*?)@([^:]+)(:[0-9]+)?\/(.*?)$/;
|
||||||
if( !dbreg.match(dbstr) )
|
if (!dbreg.match(dbstr))
|
||||||
throw "Configuration requires a valid database attribute, format is : mysql://user:password@host:port/dbname";
|
throw "Configuration requires a valid database attribute, format is : mysql://user:password@host:port/dbname";
|
||||||
var port = dbreg.matched(5);
|
var port = dbreg.matched(5);
|
||||||
var dbparams = {
|
var dbparams = {
|
||||||
user:dbreg.matched(2),
|
user: dbreg.matched(2),
|
||||||
pass:dbreg.matched(3),
|
pass: dbreg.matched(3),
|
||||||
host:dbreg.matched(4),
|
host: dbreg.matched(4),
|
||||||
port:port == null ? 3306 : Std.parseInt(port.substr(1)),
|
port: port == null ? 3306 : Std.parseInt(port.substr(1)),
|
||||||
database:dbreg.matched(6),
|
database: dbreg.matched(6),
|
||||||
socket:null
|
socket: null
|
||||||
};
|
};
|
||||||
cnx = sys.db.Mysql.connect(dbparams);
|
cnx = sys.db.Mysql.connect(dbparams);
|
||||||
} catch( e : Dynamic ) {
|
} catch (e:Dynamic) {
|
||||||
errorHandler(e);
|
errorHandler(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( App.config.SQL_LOG )
|
if (App.config.SQL_LOG)
|
||||||
cnx = new sugoi.tools.DebugConnection(cnx);
|
cnx = new sugoi.tools.DebugConnection(cnx);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -372,7 +380,7 @@ class BaseApp {
|
|||||||
function cloneApp() {
|
function cloneApp() {
|
||||||
// ensure that we have no variable initialized in app loop
|
// ensure that we have no variable initialized in app loop
|
||||||
var app = new App();
|
var app = new App();
|
||||||
var bapp : BaseApp = app;
|
var bapp:BaseApp = app;
|
||||||
bapp.cnx = cnx;
|
bapp.cnx = cnx;
|
||||||
bapp.view = new View();
|
bapp.view = new View();
|
||||||
App.current = app;
|
App.current = app;
|
||||||
@@ -380,13 +388,15 @@ class BaseApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
|
|
||||||
// Will close the connection
|
// Will close the connection
|
||||||
sys.db.Transaction.main(cnx, cloneApp, function(e) { var b : BaseApp = App.current; b.errorHandler(e); });
|
sys.db.Transaction.main(cnx, cloneApp, function(e) {
|
||||||
|
var b:BaseApp = App.current;
|
||||||
|
b.errorHandler(e);
|
||||||
|
});
|
||||||
App.current = null;
|
App.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendHeaders(){
|
function sendHeaders() {
|
||||||
Web.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
Web.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
||||||
Web.setHeader("Pragma", "no-cache");
|
Web.setHeader("Pragma", "no-cache");
|
||||||
Web.setHeader("Expires", "-1");
|
Web.setHeader("Expires", "-1");
|
||||||
@@ -396,28 +406,28 @@ class BaseApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function main() {
|
static function main() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this macro will parse the code and generate the allTexts.pot file
|
* this macro will parse the code and generate the allTexts.pot file
|
||||||
* which will be used as a template for translation files (*.po and *.mo)
|
* which will be used as a template for translation files (*.po and *.mo)
|
||||||
*/
|
*/
|
||||||
#if i18n_parsing
|
#if i18n_parsing
|
||||||
if( false ) sugoi.i18n.GetText.parse(["src", "lang/master","js","common"], "www/lang/allTexts.pot");
|
if (false)
|
||||||
|
sugoi.i18n.GetText.parse(["src", "lang/master", "js", "common"], "www/lang/allTexts.pot");
|
||||||
#end
|
#end
|
||||||
|
|
||||||
App.current = new App();
|
App.current = new App();
|
||||||
var a : BaseApp = App.current;
|
var a:BaseApp = App.current;
|
||||||
|
|
||||||
a.sendHeaders();
|
a.sendHeaders();
|
||||||
|
|
||||||
if( !a.init() ) {
|
if (!a.init()) {
|
||||||
a = null;
|
a = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a.run();
|
a.run();
|
||||||
a = null;
|
a = null;
|
||||||
#if neko
|
#if neko
|
||||||
if ( App.config.getInt("cache", 0) == 1 ) {
|
if (App.config.getInt("cache", 0) == 1) {
|
||||||
neko.Web.cacheModule(App.main);
|
neko.Web.cacheModule(App.main);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ class Mail implements IMail {
|
|||||||
public function setSender(email, ?name, ?userId) {
|
public function setSender(email, ?name, ?userId) {
|
||||||
if (!isValid(email))
|
if (!isValid(email))
|
||||||
throw "invalid sender email : \"" + email + "\"";
|
throw "invalid sender email : \"" + email + "\"";
|
||||||
|
var finalName = (name != null) ? thx.text.Diactrics.clean(name) : null;
|
||||||
sender = {name: name, email: email, userId: userId};
|
sender = {name: finalName, email: email, userId: userId};
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1538,7 +1538,7 @@ msgid ""
|
|||||||
"Group and user 'admin' created. Your email is 'admin@cagette.net' and your "
|
"Group and user 'admin' created. Your email is 'admin@cagette.net' and your "
|
||||||
"password is 'admin'"
|
"password is 'admin'"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Groupe et utilisateur 'admin' créé. Votre email est 'admin@cagette.net' et "
|
"Groupe et utilisateur 'admin' créé. Votre email est 'admin@cagettepei.re' et "
|
||||||
"votre mot de passe est 'admin'"
|
"votre mot de passe est 'admin'"
|
||||||
|
|
||||||
#: src/controller/Install.hx:4677
|
#: src/controller/Install.hx:4677
|
||||||
@@ -4551,7 +4551,7 @@ msgstr "Extrait non exhaustif des produits proposés :"
|
|||||||
|
|
||||||
#: lang/master/tpl/group/view.mtt:5027
|
#: lang/master/tpl/group/view.mtt:5027
|
||||||
msgid "http://www.cagette.net"
|
msgid "http://www.cagette.net"
|
||||||
msgstr "http://www.cagette.net"
|
msgstr "https://git.artcode.re/cagetters/cagettepei"
|
||||||
|
|
||||||
#: lang/master/tpl/group/view.mtt:5060
|
#: lang/master/tpl/group/view.mtt:5060
|
||||||
msgid "Cagette.net, the free software of food direct-selling"
|
msgid "Cagette.net, the free software of food direct-selling"
|
||||||
@@ -4618,7 +4618,7 @@ msgid ""
|
|||||||
"Cagette.net is made by <a href='https://www.alilo.fr' target='_blank'><img "
|
"Cagette.net is made by <a href='https://www.alilo.fr' target='_blank'><img "
|
||||||
"src='/img/alilo-trans-black.png' /></a>"
|
"src='/img/alilo-trans-black.png' /></a>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"CagettePéi est une fourche du logiciel Cagette.net réalisé par <a href='https://www.alilo.fr' "
|
"CagettePéi est un logiciel libre, fourche du logiciel Cagette "
|
||||||
"target='_blank'><img src='/img/alilo-trans-black.png' /></a>"
|
"target='_blank'><img src='/img/alilo-trans-black.png' /></a>"
|
||||||
|
|
||||||
#: lang/master/tpl/validate/user.mtt:2124
|
#: lang/master/tpl/validate/user.mtt:2124
|
||||||
|
|||||||
Reference in New Issue
Block a user