From 85dc0facbc2b2de826978fac3768db7949a6b92f Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 12 Oct 2008 14:55:18 +0000 Subject: [PATCH] REPORT de la branche 1.1 : 477->494 --- doc/graphiques/maquette_1.svg | 22 +- img/waitbar.gif | Bin 0 -> 3748 bytes index.yaws | 1 + js/communication.js | 59 ++++- js/euphorik.js | 12 +- js/pageAbout.js | 9 +- js/pageAdmin.js | 204 ++++++------------ js/pageMinichat/commandes.js | 8 + js/pageMinichat/conversation.js | 4 +- js/pageStatique.js | 7 +- js/pages.js | 7 +- js/util.js | 4 +- modules/erl/euphorik_bd.erl | 30 +-- modules/erl/euphorik_bd_admin.erl | 50 ++++- .../erl/euphorik_minichat_conversation.erl | 13 +- modules/erl/euphorik_protocole.erl | 4 +- modules/erl/euphorik_requests.erl | 2 +- modules/include/euphorik_bd.hrl | 1 + styles/1/euphorik.css | 28 +++ styles/1/img/extraction.png | Bin 394 -> 397 bytes styles/1/img/extraction_complete.png | Bin 398 -> 380 bytes styles/1/img/extraction_complete_hover.png | Bin 393 -> 375 bytes styles/1/img/extraction_hover.png | Bin 392 -> 382 bytes styles/1/pageMinichat.css | 8 +- tools/start_yaws.sh | 2 +- tools/tools.rb | 9 +- 26 files changed, 262 insertions(+), 222 deletions(-) create mode 100644 img/waitbar.gif diff --git a/doc/graphiques/maquette_1.svg b/doc/graphiques/maquette_1.svg index f1491a1..650a440 100644 --- a/doc/graphiques/maquette_1.svg +++ b/doc/graphiques/maquette_1.svg @@ -29,9 +29,9 @@ objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="1.8955697" - inkscape:cx="560.42433" - inkscape:cy="704.00469" + inkscape:zoom="7.5822788" + inkscape:cx="532.83563" + inkscape:cy="896.76979" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -350,18 +350,18 @@ sodipodi:nodetypes="csssccccc" inkscape:export-ydpi="138.63892" inkscape:export-xdpi="138.63892" - inkscape:export-filename="/home/gburri/projets/euphorik/img/css1/extraction.png" + inkscape:export-filename="/home/gburri/projets/euphorik/branches/1.1/styles/1/img/extraction.png" id="path3233" d="M 531.65729,145.35293 C 529.36216,145.35293 527.50104,147.21405 527.50104,149.50918 C 527.50104,151.80431 529.36216,153.66543 531.65729,153.66543 C 533.95242,153.66543 535.81354,151.80431 535.81354,149.50918 C 535.81354,147.21405 533.95242,145.35293 531.65729,145.35293 z M 530.04764,146.86648 L 534.5789,149.44579 L 530.16777,152.15985 L 530.04764,146.86648 z" - style="opacity:1;fill:#841919;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> + style="opacity:0.5;fill:#841919;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> + style="opacity:0.5;fill:#ff6565;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> + style="opacity:0.5;fill:#841919;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> + style="opacity:0.5;fill:#ff6565;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline" /> )R6>ethB*_3Bw&em9yM~UFI-sWi5PPf%`?aVe!kr|_0 zg10FmA~%?(0Sbs|tVg!QU?qIfi}Khe~b|RfkfnQP8?508IU?t)DVFR5AE+s$2L1W^MJi9p*E$yN1@Zt~j|& zZ{2G1W8yOMP3Y$!Onic{X>cQV9pTm0Q}Cc~g7Y^YW)5+`b-$ofK+)vf=yQUMuF->B zciUstw$vQhy9H*6^Dj71eEaQV6y5)P%hp#{mi08e(I@J%Bj|?P!cTN3+s)R?>uW)t{O^ohpZ9@JWhRFpEzgF`a zNi8=CuahFLCYz_HqkPQWkL%=9G})*L6ZLnSp+Qm5O^b{4U~4gF!7EqJhhggcTo@E@ z{Azlv($DBRSA)^^+YgDFkG>#Yp!N-1IUIg1Y^OK+lrPrD1Me3XiAzchO}>-3GXxE~ zdnw~~CJ~(Flujn)WarwW0SLCpm5MEf(+Rs+1x{QVzl>ocsD^S&D>&R*BXN0sos2JU zcx)%7=(b3VdC!!Us`k3BhVG``=X6vXRiPY_jty&GPEPbpy`CsFva;M_eRyWgmWL-? z!gbtccvW*8RxUUDEQs+15dWG7kuFXm#D3Kq!`yny+_I_8LaL!IvgYW^V5M0o4g!OjAEy3rZgD8_Ag9fug|{dL*%@%PfBjERKcqJ6N2aj^;bQAcmTb zF#g)T=FE9eLnc*r*-lj&+c$bJFyv;K!9^eMt4DlsSf>blEap~9^0nKk7eV(f6Ydf- zz?liSY;ulWVt!WfKMIkMJSu{QqeB^2Ssaopzu4&kuN-OPX}}cmd6N3NO6@^ZKSluc z;wn2M!IL(rx|PwX>FRi<+i2KcrtGF^Z8_34HZ=~IeYEA|lum0zXY|@H+H&YqE13Rj z#oh1+TYjUR40|<9lW~EuoCWTULd-#EgkuUTKue@NgcKa~JSYyFekYokoJAmc zM`z>|!hu{{NPY>tG~2oSav78nz~U5CP(As%Koy7gsFv=aUx$z|#qtUfqNd(}TiYOP zZ!1@*I$E2Q4o@kDf@dx2(xCxa|H!x}u)%86zhBL{a{Be`4Zx-?*4r$#m9S=&+sP%7-z)*XTnQr!N$8sg z@j;Woye46v#^Z_QTb_U}+n-K8BwcwnEduQig6?`!w3a~m(dD>>EpJh*J*&Mc<9!-}deFIv5IxMxVf8x6n#M=T%U{HF-U38`|o z-JnI%Cew(k&6Hh2b?4Av_h<)YWI_gPwlIHVYW3F4dUgi0^6*17MwI z5lr!)5PVXk!6yXs`Z~YJLUXnQ@=PcHjok_UIz?nVbjJ&_}#V zaYchjC~K;vz^deux|S?admBSx(5iYaPc!R~X}X3wsl$(6j*Y&k)t__ZwB@$<@7!xa z>myDsjrd|CEbM2~1ew=IM@D>fR8f>2C=B7u{j-9DHoQuG3uc$ z3URxtvwK5pSCrZF=Dyw$*_g6?R5&&HvUdFrQ!C3Ea7c+up65_FFdm%Ys8&q>7JTD4;CS!~d=3VFxAr7H>}MB@lQs-@ z1Bkaj%*JR!J~9Sf + diff --git a/js/communication.js b/js/communication.js index 417e833..985aeed 100644 --- a/js/communication.js +++ b/js/communication.js @@ -19,13 +19,43 @@ // Regroupe la partie communication JSON client -> serveur de euphorik. // Voir : http://dev.euphorik.ch/wiki/euk/Protocole -/** - * @param funError un fonction executé lors d'un réponse 'error' de la part du serveur, peut être redéfinit pour une requête. +/** + * Les fonctions debutReq et finReq servent, par exemple, à afficher à l'utilisateur + * qu'une communication est en cours. + * @param funError un fonction executée lors d'un réponse 'error' de la part du serveur, peut être redéfinit pour une requête. + * @param funDebutReq fonction appelée au début d'une requête (facultatif) + * @param funFinReq fonction appelée à la fin d'une requête (facultatif) */ -euphorik.Communication = function(funError) { - this.funError = funError; +euphorik.Communication = function(funError, funDebutReq, funFinReq) { + this.funError = funError; + this.funDebutReq = funDebutReq; + this.funFinReq = funFinReq; +}; + +/** + * Charge un fichier depuis une url et retourne son contenu. + */ +euphorik.Communication.prototype.load = function(url) { + if (this.funDebutReq) { + this.funDebutReq(); + } + var contenu = ""; + $.ajax({async: false, url: url, success : function(page) { contenu += page; }}); + if (this.funFinReq) { + this.funFinReq(); + } + return contenu; }; - + +/** + * Effectue une requête JSON auprès du serveur. + * @param action une chaine spécifiant l'action, par exemple "put_message" + * @param json les données à envoyer associé à l'action, par exemple {"cookie" : "LKJDLAKSJBFLKASN", "nick" : "Paul", "content" : "Bonjour", "answer_to" : [] } + * @param funOk la fonction exécuté après réception des données du serveur + * @param funError la fonction exécuté si une erreur arrive (facultatif) + * @param asynchrone true pour une communication asychrone (facultatif, truepar défaut) + * @param paramsSupp un objet contenant des paramètres supplémentaire pour la fonction ajax de jQuery (facultatif) + */ euphorik.Communication.prototype.requete = function(action, json, funOk, funError, asynchrone, paramsSupp) { var thisCommunication = this; if (asynchrone === undefined) { @@ -35,7 +65,11 @@ euphorik.Communication.prototype.requete = function(action, json, funOk, funErro var mess = this.getBase(action); objectEach(json, function(nom, val) { mess[nom] = val; - }); + }); + + if (this.funDebutReq) { + this.funDebutReq(); + } paramsAjax = { async: asynchrone, @@ -44,7 +78,10 @@ euphorik.Communication.prototype.requete = function(action, json, funOk, funErro dataType: "json", data: { action : JSON.stringify(mess) }, success: - function(data) { + function(data) { + if (thisCommunication.funFinReq) { + thisCommunication.funFinReq(); + } if (data.reply === "error") { if (funError) { funError(data); @@ -54,9 +91,15 @@ euphorik.Communication.prototype.requete = function(action, json, funOk, funErro } else if (funOk) { funOk(data); } + }, + error: + function(data) { + if (thisCommunication.funFinReq) { + thisCommunication.funFinReq(); + } } }; - + if (paramsSupp) { objectEach(paramsSupp, function(nom, val) { paramsAjax[nom] = val; diff --git a/js/euphorik.js b/js/euphorik.js index 214c0f8..4d0d302 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -27,9 +27,13 @@ $(document).ready( var fragment = new Fragment(); var formateur = new euphorik.Formateur(); var util = new euphorik.Util(formateur); - var communication = new euphorik.Communication(function(data) { util.messageDialogue(data.error_message); }); + var communication = new euphorik.Communication( + function(data) { util.messageDialogue(data.error_message); }, + function() { $("#waitbar").show(); }, + function() { $("#waitbar").hide(); } + ); var client = new euphorik.Client(util, communication); - var pages = new euphorik.Pages(fragment); + var pages = new euphorik.Pages(fragment, communication); // connexion vers le serveur (utilise un cookie qui traine) client.connexionCookie(); @@ -61,10 +65,10 @@ $(document).ready( $("#footer .conditions").click(function(){ pages.afficherPage("conditions_utilisation"); }); pages.ajouterPage(new euphorik.PageMinichat(client, formateur, util, communication), true); - pages.ajouterPage(new euphorik.PageAdmin(client, formateur, util)); + pages.ajouterPage(new euphorik.PageAdmin(client, formateur, util, communication)); pages.ajouterPage(new euphorik.PageProfile(client, formateur, util)); pages.ajouterPage(new euphorik.PageRegister(client, formateur, util)); - pages.ajouterPage(new euphorik.PageAbout(client, formateur, util)); + pages.ajouterPage(new euphorik.PageAbout(client, formateur, util, communication)); pages.ajouterPage("conditions_utilisation"); pages.afficherPage(); diff --git a/js/pageAbout.js b/js/pageAbout.js index d51557c..733f77e 100644 --- a/js/pageAbout.js +++ b/js/pageAbout.js @@ -16,18 +16,17 @@ // You should have received a copy of the GNU General Public License // along with Euphorik. If not, see . -euphorik.PageAbout = function(client, formateur, util) { +euphorik.PageAbout = function(client, formateur, util, communication) { this.nom = "about"; this.client = client; this.formateur = formateur; - this.util = util; + this.util = util; + this.communication = communication; }; euphorik.PageAbout.prototype.contenu = function() { - var contenu = ""; - $.ajax({async: false, url: "pages/about.html", success : function(page) { contenu += page; }}); - + var contenu = this.communication.load("pages/about.html"); var email = this.util.rot13("znvygb:tert.oheev@tznvy.pbz"); return contenu.replace("{EMAIL}", "" + email + "").replace("{EMAIL_LIEN}", email); }; diff --git a/js/pageAdmin.js b/js/pageAdmin.js index fc1d51a..9ed847e 100644 --- a/js/pageAdmin.js +++ b/js/pageAdmin.js @@ -21,12 +21,13 @@ /*jslint laxbreak:true */ -euphorik.PageAdmin = function(client, formateur, util) { +euphorik.PageAdmin = function(client, formateur, util, communication) { this.nom = "admin"; this.client = client; this.formateur = formateur; this.util = util; + this.communication = communication; this.comet = new Comet("admin", euphorik.conf.versionProtocole); @@ -61,7 +62,7 @@ euphorik.PageAdmin.prototype.charger = function() { var thisPage = this; // la liste des trolls proposés par les ekMasters - this.trolls = new euphorik.Trolls(this.client, this.util, this.formateur); + this.trolls = new euphorik.Trolls(this.client, this.util, this.formateur, this.communication); this.waitEvent(); @@ -102,26 +103,13 @@ euphorik.PageAdmin.prototype.posterTroll = function() { return; } - var dataToSend = { - "header" : { "action" : "put_troll", "version" : euphorik.conf.versionProtocole }, - "cookie" : this.client.cookie, - "content" : content - }; - - jQuery.ajax({ - type: "POST", - url: "request", - dataType: "json", - data: this.util.jsonVersAction(dataToSend), - success: - function(data){ - if (data.reply === "ok") { - $("#page form#nouveauTroll input.troll").val(""); - } else if (data.reply === "error") { - thisPageAdmin.util.messageDialogue(data.error_message); - } - } - }); + this.communication.requete( + "put_troll", + {"cookie" : this.client.cookie, "content" : content}, + function(data) { + $("#page form#nouveauTroll input.troll").val(""); + } + ); }; /** @@ -133,63 +121,51 @@ euphorik.PageAdmin.prototype.majIPs = function() { } var thisPageAdmin = this; - - var dataToSend = { - "header" : { "action" : "list_banned_ips", "version" : euphorik.conf.versionProtocole }, - "cookie" : this.client.cookie - }; - - jQuery.ajax({ - type: "POST", - url: "request", - dataType: "json", - data: this.util.jsonVersAction(dataToSend), - success: - function(data) { - if (data.reply === "list_banned_ips") { - var XHTML = ""; - data.list.each(function(i, ip) { - XHTML += '
' + ip.ip + '|' + - '' + - ip.remaining_time + - '|'; - ip.users.each(function(j, user) { - XHTML += (j > 0 ? ", " : "") + - '' + thisPageAdmin.formateur.traitementComplet(user.nick) + '' + - (user.login === "" ? "" : ''); - }); - XHTML += 'débannir
'; - }); - - if (data.list.length === 0) { - XHTML += '

Aucune IP bannie

'; - } - - $("#ips").html(XHTML); - - $(".ban").each(function() { - var ip = $(".ip", this).html(); - $(".deban", this).click( - function() { - thisPageAdmin.util.messageDialogue("Êtes-vous sur de vouloir débannir l'IP ''" + ip + "'' ?", euphorik.Util.messageType.question, - {"Oui" : function() { - thisPageAdmin.deban(ip); - }, - "Non" : function(){} - } - ); + + this.communication.requete( + "list_banned_ips", + {"cookie" : this.client.cookie}, + function(data) { + var XHTML = ""; + data.list.each(function(i, ip) { + XHTML += '
' + ip.ip + '|' + + '' + + ip.remaining_time + + '|'; + ip.users.each(function(j, user) { + XHTML += (j > 0 ? ", " : "") + + '' + thisPageAdmin.formateur.traitementComplet(user.nick) + '' + + (user.login === "" ? "" : ''); + }); + XHTML += 'débannir
'; + }); + + if (data.list.length === 0) { + XHTML += '

Aucune IP bannie

'; + } + + $("#ips").html(XHTML); + + $(".ban").each(function() { + var ip = $(".ip", this).html(); + $(".deban", this).click( + function() { + thisPageAdmin.util.messageDialogue("Êtes-vous sur de vouloir débannir l'IP ''" + ip + "'' ?", euphorik.Util.messageType.question, + {"Oui" : function() { + thisPageAdmin.deban(ip); + }, + "Non" : function(){} } ); - }); - } else if (data.reply === "error") { - thisPageAdmin.util.messageDialogue(data.error_message); - } + } + ); + }); - // rafraichissement toutes les minutes (je sais c'est mal) - // le problème est le rafraichissement des temps restant de bannissement qui doit être fait du coté client - thisPageAdmin.timeoutIDmajIPs = setTimeout(function(){ thisPageAdmin.majIPs(); }, 60 * 1000); - } - }); + // rafraichissement toutes les minutes (je sais c'est mal) + // le problème est le rafraichissement des temps restant de bannissement qui doit être fait du coté client + thisPageAdmin.timeoutIDmajIPs = setTimeout(function(){ thisPageAdmin.majIPs(); }, 60 * 1000); + } + ); }; /** @@ -197,25 +173,11 @@ euphorik.PageAdmin.prototype.majIPs = function() { */ euphorik.PageAdmin.prototype.deban = function(ip) { var thisPageAdmin = this; - - var dataToSend = { - "header" : { "action" : "unban", "version" : euphorik.conf.versionProtocole }, - "cookie" : this.client.cookie, - "ip" : ip - }; - - jQuery.ajax({ - type: "POST", - url: "request", - dataType: "json", - data: this.util.jsonVersAction(dataToSend), - success: - function(data){ - if(data.reply === "error") { - thisPageAdmin.util.messageDialogue(data.error_message); - } - } - }); + + this.communication.requete( + "unban", + {"cookie" : this.client.cookie, "ip" : ip} + ); }; /** @@ -251,10 +213,11 @@ euphorik.Troll = function(content, author) { /////////////////////////////////////////////////////////////////////////////////////////////////// -euphorik.Trolls = function(client, util, formateur) { +euphorik.Trolls = function(client, util, formateur, communication) { this.client = client; this.util = util; this.formateur = formateur; + this.communication = communication; this.dernierTroll = 0; this.trolls = {}; @@ -352,51 +315,18 @@ euphorik.Trolls.prototype.supprimerTrollEvent = function(data) { }; euphorik.Trolls.prototype.modifier = function(id, content) { - var thisTrolls = this; - - var dataToSend = { - "header" : { "action" : "mod_troll", "version" : euphorik.conf.versionProtocole }, - "cookie" : this.client.cookie, - "troll_id" : id, - "content" : content - }; - - jQuery.ajax({ - type: "POST", - url: "request", - dataType: "json", - data: this.util.jsonVersAction(dataToSend), - success: - function(data) { - if (data.reply === "error") { - thisTrolls.util.messageDialogue(data.error_message); - } - } - }); + this.communication.requete( + "mod_troll", + {"cookie" : this.client.cookie, "troll_id" : id, "content" : content} + ); }; /** * Supprime un troll en fonction de son id. */ euphorik.Trolls.prototype.supprimer = function(id) { - var thisTrolls = this; - - var dataToSend = { - "header" : { "action" : "del_troll", "version" : euphorik.conf.versionProtocole }, - "cookie" : this.client.cookie, - "troll_id" : id - }; - - jQuery.ajax({ - type: "POST", - url: "request", - dataType: "json", - data: this.util.jsonVersAction(dataToSend), - success: - function(data) { - if (data.reply === "error") { - thisTrolls.util.messageDialogue(data.error_message); - } - } - }); + this.communication.requete( + "del_troll", + {"cookie" : this.client.cookie, "troll_id" : id} + ); }; diff --git a/js/pageMinichat/commandes.js b/js/pageMinichat/commandes.js index 014b9bb..3609e0d 100644 --- a/js/pageMinichat/commandes.js +++ b/js/pageMinichat/commandes.js @@ -71,6 +71,14 @@ euphorik.Commandes.liste = { pageMinichat.envoyerMessage("C'est pas faux"); return [euphorik.Commandes.statut.ok, '']; } + }, + "osef" : { + description : "Envoie le message \"On s'en fout !\"", + usage : "/osef", + exec : function(args, client, pageMinichat) { + pageMinichat.envoyerMessage("On s'en fout !"); + return [euphorik.Commandes.statut.ok, '']; + } } }; diff --git a/js/pageMinichat/conversation.js b/js/pageMinichat/conversation.js index acd7d67..60b22a6 100644 --- a/js/pageMinichat/conversation.js +++ b/js/pageMinichat/conversation.js @@ -291,11 +291,11 @@ euphorik.Conversation.prototype.flush = function() { var mess = thisConversation.messagesParId[messId]; if (mess) { mess.clientARepondu = true; - $("#conversations #" + mess.getId(thisConversation.getId())).addClass("repondu") + $("#conversations #" + mess.getId(thisConversation.getId())).addClass("repondu"); } }); } - }); + }); if (this.messages.length > 0) { this.idDernierMessageAffiche = this.messages[this.messages.length-1].id; diff --git a/js/pageStatique.js b/js/pageStatique.js index f5a4c2c..4580bf3 100644 --- a/js/pageStatique.js +++ b/js/pageStatique.js @@ -19,14 +19,13 @@ /** * Correspond à une page html statique se nommant ".html" et se trouvant dans "/pages/". */ -euphorik.PageStatique = function(nom) { +euphorik.PageStatique = function(nom, communication) { this.nom = nom; + this.communication = communication; }; euphorik.PageStatique.prototype.contenu = function() { - var contenu = ""; - $.ajax({async: false, url: "pages/" + this.nom + ".html", success : function(page) { contenu += page; }}); - return contenu; + return this.communication.load("pages/" + this.nom + ".html"); }; euphorik.PageStatique.prototype.charger = function() { diff --git a/js/pages.js b/js/pages.js index df515e6..2f0abfc 100644 --- a/js/pages.js +++ b/js/pages.js @@ -22,8 +22,9 @@ /** * Gestion des pages. */ -euphorik.Pages = function(fragment) { - this.fragment = fragment; +euphorik.Pages = function(fragment, communication) { + this.fragment = fragment; + this.communication = communication; this.pageCourante = undefined; this.pageDefaut = undefined; this.pages = {}; @@ -36,7 +37,7 @@ euphorik.Pages = function(fragment) { */ euphorik.Pages.prototype.ajouterPage = function(page, defaut) { if (typeof page === "string") { - page = new euphorik.PageStatique(page); + page = new euphorik.PageStatique(page, this.communication); } page.pages = this; // la magie des langages dynamiques : le foutoire diff --git a/js/util.js b/js/util.js index f5fca3f..4c9bd6a 100644 --- a/js/util.js +++ b/js/util.js @@ -186,9 +186,9 @@ euphorik.Util.prototype.infoBulle = function(message, element, position) { * Utilisé pour l'envoie de données avec la méthode ajax de jQuery. * Obsolète : à virer */ -euphorik.Util.prototype.jsonVersAction = function(json) { +/*euphorik.Util.prototype.jsonVersAction = function(json) { return { action : JSON.stringify(json) }; -}; +};*/ /** * Retourne un hash md5 d'une chaine, dépend de md5.js. diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 4fecb73..f1d5a60 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -79,7 +79,8 @@ elire_troll/0, % utiles : - resultat_transaction/1 + resultat_transaction/1, + get_tuples/3 % must be in a transaction ]). -import(qlc, [e/2, q/1, cursor/2]). -include("../include/euphorik_bd.hrl"). @@ -373,23 +374,22 @@ messages(N) -> messages(N, P) -> F = fun() -> % % #minichat{contenu = contenu_message(E)} - get_tuples_avant(minichat, reculer(minichat, mnesia:last(minichat), N * (P - 1)), N) + get_tuples(minichat, mnesia:table_info(minichat, size) - N * P + 1, N) end, resultat_transaction(mnesia:transaction(F)). -get_tuples_avant(Table, Id, N) -> - get_tuples_avant(Table, Id, N, []). -get_tuples_avant(_, '$end_of_table', _, Tuples) -> Tuples; -get_tuples_avant(_, _, 0, Tuples) -> - Tuples; -get_tuples_avant(Table, Id, N, Tuples) -> - [T] = mnesia:read({Table, Id}), - get_tuples_avant(Table, mnesia:prev(Table, Id), N - 1, [T | Tuples]). -reculer(_, '$end_of_table' = Fin, _) -> Fin; -reculer(_, Id, 0) -> Id; -reculer(Table, Id, N) -> - reculer(Table, mnesia:prev(Table, Id), N - 1). +get_tuples(Table, First_id, N) -> + lists:foldr( + fun(Id, Acc) -> + case mnesia:read({Table, Id}) of + [T] -> [T | Acc]; + _ -> Acc + end + end, + [], + lists:seq(First_id, First_id + N - 1) + ). % Renvoie les messages manquants pour la page P en sachant qu'il y a N message @@ -715,7 +715,7 @@ put_troll(User_id, Content) -> Nb_troll_poste_total >= ?NB_MAX_TROLL_WAITING -> max_troll_reached; true -> - Id = nouvel_id(minichat), + Id = nouvel_id(troll), mnesia:write(#troll{id = Id, id_user = User_id, date_create = now(), content = Content}), Id end; diff --git a/modules/erl/euphorik_bd_admin.erl b/modules/erl/euphorik_bd_admin.erl index 076a570..c370618 100644 --- a/modules/erl/euphorik_bd_admin.erl +++ b/modules/erl/euphorik_bd_admin.erl @@ -217,7 +217,26 @@ update(Version) -> % crée un backup avant l'application du patch % dans BD/backups nommé "backup" où et le numéro de la version. % 1 -> 2 -patch(1) -> +patch(1) -> + % Prend un chemin vers la feuille de style de type "css/1/euphorik.css" + % et renvoie "styles/1/euphorik.css" + Transforme_css = fun("css" ++ Reste) -> + "styles" ++ Reste; + (F) -> F + end, + Traiter_message = fun(M, Racine) -> + F = fun(F, M2) -> % seul moyen à ma connaissance pour faire de la récursion dans une lambda fonction, voir : http://www.nabble.com/Auto-generated-functions-td15279499.html + % met à jour la racine de chaque message qui répond à M + lists:foreach( + fun(M3) -> + mnesia:write(M2#minichat{racine_id = Racine}), + F(F, M3) + end, + euphorik_bd:enfants(M#minichat.id) + ) + end, + F(F, M, Racine) + end, % Prend un chemin vers la feuille de style de type "css/1/euphorik.css" % et renvoie "styles/1/euphorik.css" Transforme_css = fun("css" ++ Reste) -> @@ -269,13 +288,7 @@ patch(1) -> {atomic, _} -> ok end; % 2 -> 3 -patch(2) -> - % première étape : changer le type de la table minichat de set à ordered_set - % TODO : trouver un meilleur moyen que de passer par un backup - backup("tmp"), - create(), - restore("tmp"), - file:delete(dossier_backups() ++ "tmp"), +patch(2) -> mnesia:transform_table( troll, fun({troll, Id_troll, Id_user, Date_create, Date_post, Content}) -> @@ -292,11 +305,26 @@ patch(2) -> mnesia:transform_table( minichat, fun({minichat, Id, Auteur_id, Date, Pseudo, Contenu, _Troll_id, Racine_id}) -> - {minichat, Id, Auteur_id, Date, Pseudo, Contenu, Racine_id} + {minichat, Id, Auteur_id, Date, Pseudo, Contenu, Racine_id, normal} end, record_info(fields, minichat) - ), - creer_indexes(). % uniquement pour l'indice sur id_minichat de la table troll + ), + mnesia:transaction(fun() -> + % comble les trous entre les id non-contigues + lists:foreach(fun(Id) -> + case mnesia:read({minichat, Id}) of + [] -> + {ok, #user{profile = Profile}} = euphorik_bd:user_by_id(0), + mnesia:write(#minichat{id = Id, auteur_id = 0, date = undefined, pseudo = Profile#profile.pseudo, contenu = "Comblement...", racine_id = Id, status = deleted}); + _ -> rien + end + end, + lists:seq(1, mnesia:table_info(minichat, size)) + ), + % la table troll utilise maintenant son index et pas celui de la table minichat (correction d'un vieux bug) + mnesia:write(#counter{key = troll, value = mnesia:table_info(minichat, size)}) + end), + creer_indexes(). % uniquement pour l'indice sur id_minichat de la table troll % Renvoie le dossier dans lequel les backups sont effectué, ce dossier doit être en écriture. diff --git a/modules/erl/euphorik_minichat_conversation.erl b/modules/erl/euphorik_minichat_conversation.erl index 4d0b3a8..5cf9a0a 100755 --- a/modules/erl/euphorik_minichat_conversation.erl +++ b/modules/erl/euphorik_minichat_conversation.erl @@ -109,7 +109,7 @@ mise_en_forme_conversation(Messages) -> conversations_detailees(Racines, N, D, P) -> Conversations = map(fun({Racine, P_conv, Dernier}) -> conversation(Racine, N, Dernier, P_conv) end, Racines), Conversation_principale = resultat_transaction(transaction(fun() -> - Dernier_id = mnesia:last(minichat), + Dernier_id = mnesia:table_info(minichat, size), {CP, Plus} = conversation_principale(Dernier_id, Conversations, N, P), {[M || M <- CP, M > D], Plus} % filtre en fonction de D end)), @@ -142,18 +142,17 @@ conversation_principale(Id, Conversations, N, P) -> % @spec conversation_principale2(integer(), [integer()], integer(), integer()) -> [integer()] conversation_principale2(_, _, 0, _) -> []; -conversation_principale2('$end_of_table', _, _, _) -> +conversation_principale2(0, _, _, _) -> []; conversation_principale2(Id, Messages, N, S) -> - % traitement message par message (pas des plus performant :/) - Id_prev = mnesia:prev(minichat, Id), + % traitement message par message (pas des plus performant :/) Doit_etre_saute = any(fun(E) -> E == Id end, Messages), if Doit_etre_saute -> - conversation_principale2(Id_prev, Messages, N, S); % le message ne fait pas partie de la conversation + conversation_principale2(Id - 1, Messages, N, S); % le message ne fait pas partie de la conversation S =:= 0 -> - [Id | conversation_principale2(Id_prev, Messages, N - 1, S)]; % ok : le message fait partie de la conversation + [Id | conversation_principale2(Id - 1, Messages, N - 1, S)]; % ok : le message fait partie de la conversation true -> - conversation_principale2(Id_prev, Messages, N, S - 1) % on n'a pas encore atteint le début de la page + conversation_principale2(Id - 1, Messages, N, S - 1) % on n'a pas encore atteint le début de la page end. diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index 1fb3cc1..3706f68 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -308,7 +308,7 @@ wait_event_page_chat(User, Racines_conversations, Message_count, Last_message_id {Racine_id, _, _} = Racine, case euphorik_bd:message_by_id(Racine_id) of {ok, Mess} -> - json_message(Mess, euphorik_bd:parents(Racine), User); + json_message(Mess, euphorik_bd:parents(Racine_id), User); _ -> null end @@ -744,7 +744,7 @@ json_message(Mess, Repond_a, User) -> {struct, [ {id, Mess#minichat.id}, {user_id, User_mess#user.id}, - {date, format_date(Mess#minichat.date)}, + {date, case Mess#minichat.date of undefined -> "?"; _ -> format_date(Mess#minichat.date) end}, {system, Mess#minichat.auteur_id =:= 0}, {owner, Est_proprietaire}, {answered, A_repondu_a_message}, diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl index 1cd460a..3ec70f3 100755 --- a/modules/erl/euphorik_requests.erl +++ b/modules/erl/euphorik_requests.erl @@ -29,7 +29,7 @@ % Point d'entrée pour les requêtes AJAX sur http://www.euphorik.ch/request. -out(A) -> +out(A) -> IP = case inet:peername(A#arg.clisock) of {ok, {Adresse, _Port}} -> Adresse; _ -> inconnue diff --git a/modules/include/euphorik_bd.hrl b/modules/include/euphorik_bd.hrl index 0b04c4b..36ff1e6 100755 --- a/modules/include/euphorik_bd.hrl +++ b/modules/include/euphorik_bd.hrl @@ -57,6 +57,7 @@ pseudo, % chaine de caractère contenu, % chaine de caractère racine_id = undefined % la racine, par défaut correspond à l'id du message + status = normal % can be equal to normal, censored or deleted }). diff --git a/styles/1/euphorik.css b/styles/1/euphorik.css index 54aef62..59e8ab0 100755 --- a/styles/1/euphorik.css +++ b/styles/1/euphorik.css @@ -31,6 +31,34 @@ em.fort { font-weight: bold } +/***** Une barre de progression s'affichant lors des communications entre le client et le serveur *****/ +#waitbar { + text-align: center; + height: 16px; + width:100%; + position: fixed; + left: 0px; + top: 0px; + z-index: 500; +} +#waitbar .image { + background-image: url(../../img/waitbar.gif); + margin-top: 3px; + margin-right: 3px; + float: right; + height: 13px; + width: 105px; +} + +/***** Textile *****/ +em.leger { + font-style: italic +} +em.fort { + font-style: normal; + font-weight: bold +} + /***** Menu *****/ ul#menu { background-image: url(img/logo_fond.png); diff --git a/styles/1/img/extraction.png b/styles/1/img/extraction.png index 6140ab5dc739add4d137f88f057a7fb3883dceed..3f5828c9873009111cc01365b88b92956dd1373f 100644 GIT binary patch delta 296 zcmV+@0oVSD1C0ZaZhs0%L_t(2k&V(JPsBhF1>mo}3W7aBy5SdqfP^z7q#y{2e^lK+ zfkNX*&;(AOzyKPvhdGBrToK(~n%)Usvf1qHyv&<pI33Z%qgvxWG9Il(}w7WBnV{G5*#uKI18criE^-!)lWu zsR>~pH#kY5RiX1?i`0YwXSl}R;D1?QfzyGkNfW{WZgDu0zQ&?A_fqEryyHmc*%&W% ujITv{%+p=rcp*pfW+O;zG-&!?yY~kd%2I~2NUZk&0000L6RU4I})*;T@rBI0*N3Y**mlX z(IzWMu3RZYPhL=5}BJmYu^<*-`TYnV#-B3A=hTn}pNXI6DLBO8@KVP3QN~!Mj9^;m z+BzFM^=Lvk#UpN0Xj|y!up??h$Z(G(P6qsX+&wtMF;=)5rQUTfO}ZWs%j7;5&<%If r|K5u#-0XS$w;mCsH5wHCuig6vS4&jkmw}??00000NkvXXu0mjfbftzi diff --git a/styles/1/img/extraction_complete.png b/styles/1/img/extraction_complete.png index b4e91d6cf3c4a3c15668a4b89bc687ca0b9bd75a..9e99a89d7acccde7c57fc7c572ce1bbf439f332c 100644 GIT binary patch delta 280 zcmV+z0q6dX1N;JzZGQmyNkl$cs*l`W<;}C@0zzJUbt{^Am z5^TKZm_?ByVFcS#UM&(`H8s=I{jctCdb(PxW@FAX9AbuDykLpNP|C99b+uMw&K>$# zDPk2}oIf$gd?=;1gdWEe;0c#_3_nG@hZHUKzU>KDLn+U=!hgdg){i;QQfNqPz$*-; zyx}@@wTg!+ME?MqO~4XYvlOpXak~yoz<1o>1G~xUSv#DJIq&=ijX7`O6dQO+lYaMb zz77U(hJ(0TCM>Mx0Q)!_bKd>~_{5?O_sD7v%}QuEod9q*lybir&OG+^BQh>RL#r@v edEI~h-WN(rWD()$CB7E`0000p delta 298 zcmV+_0oDHe0*(WaZGQm^NklpE>pOPIu1j2=(zLc;<8baTTH$fD(1iuQq{daaG{@0Tpa;I;5bqdPzHO~= z9vT*+O=%S~tl+Wg-FF*TZA$CE02kPc)NO@nxFTG-Y*SkM1NgwSJno6_cPMca8fHBJ wPV1b{iq%cbHvjszmo0u3?6+GItbVI<2Q&-|Ks9yd8>-xlK-=NMyzHI|r5X<5^noHH>tXv+#E zmeG{+1|2#n<(kmqasaGwiin(XoZ=SUNOV-Ab-}1aU6<<@B?@QDZS&a z=&BXZLlM0TRNI1!ax)I)l`tS^uWHNA`Ack002ovPDHLkV1n~;f8YQB delta 293 zcmV+=0owle0*M2VZGQmzmlZ!+k*PK`F_eVk&1As%suSyRfq zo*Q&sr_Ff($twz<=O&INZn00&v)r^4#XU zg=_5fDvncVSOTCa!vP9FJs8q_l@?>~Bb4W6>}7T)PK&!GU&Xn|KuQRCUI@`x_i?Ngggj ge?~*o|GK?z0u#zftW^{|LI3~&07*qoM6N<$g3T6z8~^|S delta 292 zcmV+<0o(rm0*C{UZGQm;Nkl!%ms0tf`Kh|ZGDwt|<8nD5P-_x&rnuG6CpVS*W^sIkTpixt!DK$AGs4JVc zPR33>+7OQMfU6u@S2lCl615=|xWPS+2K;i|JvhN37C0ZJzUf|`^n5_vXZNvy&2U%! q@4cwO<&MXH8y!Jjqe0RC+Pz=Pxl|t input, +#page.minichat form#posterMessage p > span, +#page.minichat form#posterMessage p > button{ + vertical-align: middle; +} + #page.minichat.orderReverse form#posterMessage { padding-bottom: 10px; } @@ -116,7 +122,6 @@ background-image: url(img/return.png); background-repeat: no-repeat; background-position: 5px 2px; - vertical-align: top; margin-right: 5px; } #page.minichat form#posterMessage .smiles { @@ -125,7 +130,6 @@ background-image: url(../../img/bouton_smiles.png); background-repeat: no-repeat; background-position: 2px 2px; - vertical-align: top; margin-right: 5px; } /* La boite montrant les messages auquels l'utilisateur répond */ diff --git a/tools/start_yaws.sh b/tools/start_yaws.sh index d812137..216a5d1 100755 --- a/tools/start_yaws.sh +++ b/tools/start_yaws.sh @@ -1,4 +1,4 @@ #!/bin/bash # coding: utf-8 # screen est utilisé par exemple pour lancé une version de preproduction et permettre de la faire tourner après un délog -yaws --conf ./yaws.conf --sname yaws_dev --mnesiadir "../var/BD/" -I debian_yaws_dev +yaws --conf ./yaws.conf --sname yaws_dev --mnesiadir "../var/BD/" -I debian_yaws_dev diff --git a/tools/tools.rb b/tools/tools.rb index b437687..2992eb6 100644 --- a/tools/tools.rb +++ b/tools/tools.rb @@ -123,7 +123,6 @@ class MiseEnProd # Effectue la mise en préproduction. def miseEnPreProd copierFichiers() - copierVAR() lancerYaws() maj('yaws_dev') end @@ -137,11 +136,6 @@ class MiseEnProd set_droits_fichiers() end - # TODO - def copierVar - #TODO - end - def lancerYaws creer_rep("tools") system("rsync tools/yaws.conf #{@uri}:#{@rep}/tools") @@ -171,7 +165,8 @@ class MiseEnProd Dir.chdir('..') end - def creer_repertoire_var + def creer_repertoire_bd + log "création du répertoire de la base de données" # création du repertoire BD creer_rep('var') creer_rep('var/images') -- 2.43.0