version cagettepei

This commit is contained in:
pvincent
2021-08-29 21:31:16 +04:00
parent b14688417d
commit 8699728593
6 changed files with 197 additions and 186 deletions
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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();
+45 -35
View File
@@ -1,9 +1,9 @@
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 cnx:sys.db.Connection;
public var template:templo.Loader; public var template:templo.Loader;
public var maintain:Bool; public var maintain:Bool;
@@ -16,10 +16,10 @@ class BaseApp {
public var uri:String; public var uri:String;
public static var config:Config; 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
@@ -58,8 +67,8 @@ class BaseApp {
} }
public function initLang(lang:String) { public function initLang(lang:String) {
if (lang == null || lang == "")
if (lang == null || lang == "") lang = config.LANG; lang = config.LANG;
// Define template path // Define template path
var path; var path;
@@ -83,8 +92,8 @@ class BaseApp {
} }
function saveAndClose() { function saveAndClose() {
if (cnx == null)
if( cnx == null ) return; return;
if (session.sid != null) if (session.sid != null)
session.update(); session.update();
@@ -97,10 +106,12 @@ class BaseApp {
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);
} }
@@ -137,14 +148,13 @@ class BaseApp {
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 // this app is monolingual and doesn't manage i18n
if (App.config.LANG == "master") return; if (App.config.LANG == "master")
return;
// lang is taken from user object or from HTTP headers // lang is taken from user object or from HTTP headers
if (session.lang == null || !Lambda.has(App.config.LANGS, session.lang)) { if (session.lang == null || !Lambda.has(App.config.LANGS, session.lang)) {
@@ -155,7 +165,6 @@ class BaseApp {
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
@@ -170,7 +179,8 @@ class BaseApp {
} }
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;
@@ -189,8 +199,10 @@ class BaseApp {
// 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
@@ -200,7 +212,6 @@ class BaseApp {
// setup langage // setup langage
setupLang(); setupLang();
if (maintain && ((user != null && user.isAdmin()))) if (maintain && ((user != null && user.isAdmin())))
maintain = false; maintain = false;
@@ -214,9 +225,9 @@ class BaseApp {
// 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();
@@ -224,9 +235,7 @@ class BaseApp {
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 // dispatch / routing error
if (App.config.DEBUG) { if (App.config.DEBUG) {
#if neko #if neko
@@ -238,9 +247,7 @@ 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);
@@ -251,8 +258,12 @@ class BaseApp {
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;
default: false;
};
if (error)
rollback();
if (error) { if (error) {
session.addMessage(text, true); session.addMessage(text, true);
} else { } else {
@@ -274,9 +285,7 @@ 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) { public function logError(e:Dynamic, ?stack:String) {
var stack = if (stack != null) stack else haxe.CallStack.toString(haxe.CallStack.exceptionStack()); var stack = if (stack != null) stack else haxe.CallStack.toString(haxe.CallStack.exceptionStack());
@@ -316,7 +325,6 @@ class BaseApp {
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) "???");
@@ -380,9 +388,11 @@ 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;
} }
@@ -396,13 +406,13 @@ 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();
+2 -2
View File
@@ -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;
} }
+3 -3
View File
@@ -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