*.iws
*.beam
-var/
\ No newline at end of file
+var/
+/BD
+/data
\ No newline at end of file
y="359.74429"
x="77.082535"
id="tspan2541"
- sodipodi:role="line">formater</tspan></text>
+ sodipodi:role="line">formatter</tspan></text>
</g>
<g
style="display:inline"
<script type="text/javascript" src="js/communication.js" prod="delete"></script>\r
<script type="text/javascript" src="js/conf.js" prod="delete"></script>\r
<script type="text/javascript" src="js/util.js" prod="delete"></script>\r
- <script type="text/javascript" src="js/formater.js" prod="delete"></script>\r
+ <script type="text/javascript" src="js/formatter.js" prod="delete"></script>\r
<script type="text/javascript" src="js/pages.js" prod="delete"></script>\r
<script type="text/javascript" src="js/client.js" prod="delete"></script>\r
\r
* /nick <nouveau nick>
* Modifie le nick courant
*/
-euphorik.Commandes = function(client, pageMinichat, util, formater) {
+euphorik.Commandes = function(client, pageMinichat, util, formatter) {
var thisCommandes = this;
this.client = client;
this.pageMinichat = pageMinichat;
this.util = util;
- this.formater = formater;
+ this.formatter = formatter;
// construction du texte d'aide (liste des commandes) de manière statique
this.texteAide = "<div id=\"aideCommandes\"><h1>Commandes</h1><ul>";
objectEach(
euphorik.Commandes.liste,
function(name, commande) {
- thisCommandes.texteAide += "<li><span class=\"usage\">" + thisCommandes.formater.completeProcessing(commande.usage) + "</span> : " + thisCommandes.formater.completeProcessing(commande.description) + "</li>";
+ thisCommandes.texteAide += "<li><span class=\"usage\">" + thisCommandes.formatter.completeProcessing(commande.usage) + "</span> : " + thisCommandes.formatter.completeProcessing(commande.description) + "</li>";
}
);
this.texteAide += "</ul></div>";
this.id = Math.floor(Math.random() * 1000000).toString(36);\r
\r
this.util = this.conversations.util;\r
- this.formater = this.conversations.formater;\r
+ this.formatter = this.conversations.formatter;\r
this.client = this.conversations.client;\r
\r
this.idDernierMessageAffiche = 0;\r
* @racine un message représentant la racine de la conversation, vaut undefined pour la conversation générale\r
*/\r
euphorik.Conversation.prototype.setRacine = function(racineElement) {\r
- this.racine = new euphorik.Message(this.client, this.formater, racineElement);\r
+ this.racine = new euphorik.Message(this.client, this.formatter, racineElement);\r
};\r
\r
/**\r
/**\r
* Représente l'ensemble des conversations affichés.\r
*/\r
-euphorik.Conversations = function(client, formater, util, communication, fragment) {\r
+euphorik.Conversations = function(client, formatter, util, communication, fragment) {\r
this.client = client;\r
- this.formater = formater;\r
+ this.formatter = formatter;\r
this.util = util;\r
this.fragment = fragment;\r
\r
var message =\r
new euphorik.Message(\r
this.client,\r
- this.formater,\r
+ this.formatter,\r
element\r
);\r
\r
/**\r
* Représente un message.\r
*/\r
-euphorik.Message = function(client, formater, element) {\r
+euphorik.Message = function(client, formatter, element) {\r
this.client = client;\r
- this.formater = formater;\r
+ this.formatter = formatter;\r
\r
this.id = element.id;\r
this.auteurId = element.user_id;\r
\r
// construit l'identifiant de la personne\r
var identifiant =\r
- this.client.nickFormat === "nick" || this.login === "" ? this.formater.completeProcessing(this.nick) :\r
- (this.client.nickFormat === "login" ? this.formater.completeProcessing(this.login) :\r
- this.formater.completeProcessing(this.nick) + "<span class=\"login\">(" + this.formater.completeProcessing(this.login) +")</span>" );\r
+ this.client.nickFormat === "nick" || this.login === "" ? this.formatter.completeProcessing(this.nick) :\r
+ (this.client.nickFormat === "login" ? this.formatter.completeProcessing(this.login) :\r
+ this.formatter.completeProcessing(this.nick) + "<span class=\"login\">(" + this.formatter.completeProcessing(this.login) +")</span>" );\r
\r
var XHTMLrepondA = "";\r
var debut = true;\r
if (!debut) {\r
XHTMLrepondA += ", ";\r
}\r
- XHTMLrepondA += thisMessage.formater.completeProcessing(rep.nick);\r
+ XHTMLrepondA += thisMessage.formatter.completeProcessing(rep.nick);\r
debut = false;\r
});\r
if (XHTMLrepondA) {\r
"</span>" +\r
"<span class=\"delimitationEntete\"></span>" +\r
XHTMLrepondA +\r
- "<span class=\"contenu\">" + this.formater.completeProcessing(this.contenu, this.nick) + "</span>" +\r
+ "<span class=\"contenu\">" + this.formatter.completeProcessing(this.contenu, this.nick) + "</span>" +\r
"</div>";\r
};\r
$(document).ready(
function() {
var fragment = new Fragment();
- var formater = new euphorik.Formater();
- var util = new euphorik.Util(formater);
+ var formatter = new euphorik.Formatter();
+ var util = new euphorik.Util(formatter);
var communication = new euphorik.Communication(
function(data) { util.messageDialog(data.error_message); },
function() { util.showWaitBar(); },
$("#menu .register").click(function(){ pages.displayPage("register"); });
$("#menu .about").click(function(){ pages.displayPage("about"); });
- // TODO: simplification : such link[1] should be created and automatically open the right page without
+ // TODO : simplification : such link[1] should be created and automatically open the right page without
// explicitly add a page.
// [1] : <a class="pageLink" href="termes_of_use">Terms of use</a>
$("#footer .termsOfUse").click(function(){ pages.displayPage("terms_of_use"); });
- pages.addPage(new euphorik.PageMinichat(client, formater, util, communication), true);
- pages.addPage(new euphorik.PageAdmin(client, formater, util, communication));
- pages.addPage(new euphorik.PageProfile(client, formater, util));
- pages.addPage(new euphorik.PageRegister(client, formater, util));
- pages.addPage(new euphorik.PageAbout(client, formater, util, communication));
+ pages.addPage(new euphorik.PageMinichat(client, formatter, util, communication), true);
+ pages.addPage(new euphorik.PageAdmin(client, formatter, util, communication));
+ pages.addPage(new euphorik.PageProfile(client, formatter, util));
+ pages.addPage(new euphorik.PageRegister(client, formatter, util));
+ pages.addPage(new euphorik.PageAbout(client, formatter, util, communication));
pages.addPage("terms_of_use");
pages.displayPage(); // display the default page
+++ /dev/null
-// coding: utf-8\r
-// Copyright 2008 Grégory Burri\r
-//\r
-// This file is part of Euphorik.\r
-//\r
-// Euphorik is free software: you can redistribute it and/or modify\r
-// it under the terms of the GNU General Public License as published by\r
-// the Free Software Foundation, either version 3 of the License, or\r
-// (at your option) any later version.\r
-//\r
-// Euphorik is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-// GNU General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with Euphorik. If not, see <http://www.gnu.org/licenses/>.\r
-\r
-/*jslint laxbreak:true */\r
-\r
-/**\r
- * An object for text formatting like Wiki syntax or smiles substitution.\r
- * TODO : improve the performance of the smiles substitution\r
- */\r
-euphorik.Formater = function() {\r
- this.smiles = euphorik.conf.smiles;\r
- this.protocols = "http|https|ed2k";\r
- \r
- this.regexUrl = new RegExp("(?:(?:" + this.protocols + ")://|www\\.)[^ ]*", "gi");\r
- this.regexImg = new RegExp("^.*?\\.(gif|jpg|png|jpeg|bmp|tiff)$", "i");\r
- this.regexDomain = new RegExp("^(?:(?:" + this.protocols + ")://)(.*?)(?:$|/).*$", "i");\r
- this.regexTestIfProtocolExists = new RegExp("^(?:" + this.protocols + ")://.*$", "i");\r
- this.regexProtocolName = new RegExp("^(.*?)://");\r
-};\r
-\r
-/**\r
- * Formats a nick given by the user.\r
- * Trim and remove "{..}".\r
- * @param nick the given nick\r
- * @return the cleaned nick\r
- */\r
-euphorik.Formater.prototype.formatNick = function(nick) {\r
- return nick.replace(/\{|\}/g, "").trim();\r
-};\r
-\r
-euphorik.Formater.prototype.getSmilesHTML = function() {\r
- var XHTML = "";\r
- objectEach(this.smiles, function(name) {\r
- XHTML += "<img class=\"" + name + "\" src=\"img/smileys/" + name + ".gif\" alt =\"" + name + "\" />";\r
- });\r
- return XHTML;\r
-};\r
-\r
-/**\r
- * Complete fomratting process applied to a text.\r
- * - Remove HTML markups\r
- * - Substitutes wiki syntax with HTML\r
- * - Replaces URL with 'a' tag\r
- * - Replaces smiles with HTML\r
- * - Replaces the link to a conversation with HTML\r
- * @m the raw message\r
- * @nick optional, attaches the nick and the message to each images like "<pseudo> : <message>"\r
- */\r
-euphorik.Formater.prototype.completeProcessing = function(m, nick) {\r
- return this.processConversationLinks(this.processSmiles(this.traiterURL(this.traiterWikiSyntaxe(this.remplacerBalisesHTML(m)), nick)));\r
-};\r
-\r
-/**\r
- * Processes all conversation links.\r
- * The user can click on a conversation link to open it.\r
- * A link is a number in between brackets like that : "{5F}" where '5F' is the id of the root message.\r
- * This link will be turn in '<span class="conversationLink">{5F}</span>' which can be clicked to open the '5F' conversation.\r
- */\r
-euphorik.Formater.prototype.processConversationLinks = function(m) {\r
- return m.replace(\r
- /\{\w+\}/g,\r
- function(lien) {\r
- return "<span class=\"conversationLink\">" + lien + "</span>";\r
- }\r
- );\r
-};\r
-\r
-/**\r
- * Substitute the smiles (':)', ':P', etc.) with HTML.\r
- * FIXME : This function is very heavy, to optimize !\r
- * Average : 234ms\r
- */\r
-euphorik.Formater.prototype.processSmiles = function(m) { \r
- objectEach(this.smiles, function(name, smiles) {\r
- for (var i = 0; i < smiles.length; i++) {\r
- m = m.replace(smiles[i], "<img src=\"img/smileys/" + name + ".gif\" alt =\"" + name + "\" />");\r
- }\r
- });\r
- return m;\r
-};\r
-\r
-euphorik.Formater.prototype.remplacerBalisesHTML = function(m) {\r
- return m.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);\r
-};\r
-\r
-euphorik.Formater.prototype.traiterURL = function(m, nick) {\r
- var thisFormater = this;\r
- var traitementUrl = function(url) { \r
- // si ya pas de protocole on rajoute "http://"\r
- if (!thisFormater.regexTestIfProtocolExists.test(url)) {\r
- url = "http://" + url;\r
- }\r
- var extension = thisFormater.getShort(url);\r
- return "<a " + (extension[1] ? "title=\"" + (nick ? thisFormater.traiterPourFenetreLightBox(nick, url) + ": " : "") + thisFormateur.traiterPourFenetreLightBox(m, url) + "\"" + " rel=\"lightbox\"" : "") + " href=\"" + url + "\" >[" + extension[0] + "]</a>";\r
- };\r
- return m.replace(this.regexUrl, traitementUrl);\r
-};\r
-\r
-/**\r
- * Formatage en utilisant un sous-ensemble des règles de Textile : http://en.wikipedia.org/wiki/Textile_(markup_language).\r
- * par exemple _italic_ devient <i>italic</i>.\r
- */\r
-euphorik.Formater.prototype.traiterWikiSyntaxe = function(m) {\r
- return m.replace(\r
- /(?:^| )_(.*?)_(?:$| )/g,\r
- function(texte, c1, c2, c3) {\r
- return '<em>' + c1 + c2 + c3 + '</em>';\r
- }\r
- ).replace(\r
- /(?:^| )\*(.*?)\*(?:$| )/g,\r
- function(texte, c1, c2, c3) {\r
- return '<strong>' + c1 + c2 + c3 + '</strong>';\r
- }\r
- );\r
-};\r
-\r
-/**\r
- * Renvoie une version courte de l'url.\r
- * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient en.wikipedia.org\r
- */\r
-euphorik.Formater.prototype.getShort = function(url) {\r
- var estUneImage = false;\r
- var versionShort = null;\r
- var rechercheImg = this.regexImg.exec(url);\r
- \r
- if (rechercheImg) {\r
- versionShort = rechercheImg[1].toLowerCase();\r
- if (versionShort === "jpeg") {\r
- versionShort = "jpg"; // jpeg -> jpg\r
- }\r
- estUneImage = true;\r
- } else {\r
- var rechercheDomaine = this.regexDomain.exec(url);\r
- if (rechercheDomaine && rechercheDomaine.length >= 2) {\r
- versionShort = rechercheDomaine[1];\r
- } else {\r
- var protocolName = this.regexProtocolName.exec(url);\r
- if (protocolName && protocolName.length >= 2) {\r
- versionShort = protocolName[1];\r
- }\r
- }\r
- }\r
- \r
- return [versionShort ? versionShort : "url", estUneImage];\r
- };\r
- \r
-euphorik.Formater.prototype.supprimerSmiles = function(m) {\r
- objectEach(this.smiles, function(name, smiles) {\r
- for (var i = 0; i < smiles.length; i++) {\r
- m = m.replace(smiles[i], "");\r
- }\r
- });\r
- return m;\r
-};\r
-\r
-/**\r
- * Traite les nick et messages à être affiché dans le titre d'une image visualisé avec lightbox.\r
- * Supprime les smiles pour pas qu'ils puissent être remplacés par la fonction 'processSmiles'.\r
- * TODO : trouver un moyen pour que les smiles puissent être conservés\r
- */\r
-euphorik.Formater.prototype.traiterPourFenetreLightBox = function(M, urlCourante) {\r
- var thisFormater = this;\r
- var traitementUrl = function(url) {\r
- return "[" + thisFormater.getShort(url)[0] + (urlCourante === url ? "*" : "") + "]";\r
- };\r
- \r
- return this.remplacerBalisesHTML(this.supprimerSmiles(M)).replace(this.regexUrl, traitementUrl);\r
-};\r
--- /dev/null
+// coding: utf-8\r
+// Copyright 2008 Grégory Burri\r
+//\r
+// This file is part of Euphorik.\r
+//\r
+// Euphorik is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU General Public License as published by\r
+// the Free Software Foundation, either version 3 of the License, or\r
+// (at your option) any later version.\r
+//\r
+// Euphorik is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+// GNU General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with Euphorik. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+/*jslint laxbreak:true */\r
+\r
+/**\r
+ * An object for text formatting like Wiki syntax or smiles substitution.\r
+ * TODO : improve the performance of the smiles substitution\r
+ */\r
+euphorik.Formatter = function() {\r
+ this.smiles = euphorik.conf.smiles;\r
+ this.protocols = "http|https|ed2k";\r
+ \r
+ this.regexUrl = new RegExp("(?:(?:" + this.protocols + ")://|www\\.)[^ ]*", "gi");\r
+ this.regexImg = new RegExp("^.*?\\.(gif|jpg|png|jpeg|bmp|tiff)$", "i");\r
+ this.regexDomain = new RegExp("^(?:(?:" + this.protocols + ")://)(.*?)(?:$|/).*$", "i");\r
+ this.regexTestIfProtocolExists = new RegExp("^(?:" + this.protocols + ")://.*$", "i");\r
+ this.regexProtocolName = new RegExp("^(.*?)://");\r
+};\r
+\r
+/**\r
+ * Formats a nick given by the user.\r
+ * Trim and remove "{..}".\r
+ * @param nick the given nick\r
+ * @return the cleaned nick\r
+ */\r
+euphorik.Formatter.prototype.formatNick = function(nick) {\r
+ return nick.replace(/\{|\}/g, "").trim();\r
+};\r
+\r
+euphorik.Formatter.prototype.getSmilesHTML = function() {\r
+ var XHTML = "";\r
+ objectEach(this.smiles, function(name) {\r
+ XHTML += "<img class=\"" + name + "\" src=\"img/smileys/" + name + ".gif\" alt =\"" + name + "\" />";\r
+ });\r
+ return XHTML;\r
+};\r
+\r
+/**\r
+ * Complete formatting process applied to a text.\r
+ * - Remove HTML markups\r
+ * - Substitutes wiki syntax with HTML\r
+ * - Replaces URL with 'a' tag\r
+ * - Replaces smiles with HTML\r
+ * - Replaces the link to a conversation with HTML\r
+ * @m the raw message\r
+ * @nick optional, attaches the nick and the message to each images like "<pseudo> : <message>"\r
+ */\r
+euphorik.Formatter.prototype.completeProcessing = function(m, nick) {\r
+ return this.processConversationLinks(this.processSmiles(this.traiterURL(this.traiterWikiSyntaxe(this.remplacerBalisesHTML(m)), nick)));\r
+};\r
+\r
+/**\r
+ * Processes all conversation links.\r
+ * The user can click on a conversation link to open it.\r
+ * A link is a number in between brackets like that : "{5F}" where '5F' is the id of the root message.\r
+ * This link will be turn in '<span class="conversationLink">{5F}</span>' which can be clicked to open the '5F' conversation.\r
+ */\r
+euphorik.Formatter.prototype.processConversationLinks = function(m) {\r
+ return m.replace(\r
+ /\{\w+\}/g,\r
+ function(lien) {\r
+ return "<span class=\"conversationLink\">" + lien + "</span>";\r
+ }\r
+ );\r
+};\r
+\r
+/**\r
+ * Substitute the smiles (':)', ':P', etc.) with HTML.\r
+ * FIXME : This function is very heavy, to optimize !\r
+ * Average : 234ms\r
+ */\r
+euphorik.Formatter.prototype.processSmiles = function(m) {\r
+ objectEach(this.smiles, function(name, smiles) {\r
+ for (var i = 0; i < smiles.length; i++) {\r
+ m = m.replace(smiles[i], "<img src=\"img/smileys/" + name + ".gif\" alt =\"" + name + "\" />");\r
+ }\r
+ });\r
+ return m;\r
+};\r
+\r
+euphorik.Formatter.prototype.remplacerBalisesHTML = function(m) {\r
+ return m.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);\r
+};\r
+\r
+euphorik.Formatter.prototype.traiterURL = function(m, nick) {\r
+ var thisFormatter = this;\r
+ var traitementUrl = function(url) { \r
+ // si ya pas de protocole on rajoute "http://"\r
+ if (!thisFormatter.regexTestIfProtocolExists.test(url)) {\r
+ url = "http://" + url;\r
+ }\r
+ var extension = thisFormatter.getShort(url);\r
+ return "<a " + (extension[1] ? "title=\"" + (nick ? thisFormatter.traiterPourFenetreLightBox(nick, url) + ": " : "") + thisFormateur.traiterPourFenetreLightBox(m, url) + "\"" + " rel=\"lightbox\"" : "") + " href=\"" + url + "\" >[" + extension[0] + "]</a>";\r
+ };\r
+ return m.replace(this.regexUrl, traitementUrl);\r
+};\r
+\r
+/**\r
+ * Formatage en utilisant un sous-ensemble des règles de Textile : http://en.wikipedia.org/wiki/Textile_(markup_language).\r
+ * par exemple _italic_ devient <i>italic</i>.\r
+ */\r
+euphorik.Formatter.prototype.traiterWikiSyntaxe = function(m) {\r
+ return m.replace(\r
+ /(?:^| )_(.*?)_(?:$| )/g,\r
+ function(texte, c1, c2, c3) {\r
+ return '<em>' + c1 + c2 + c3 + '</em>';\r
+ }\r
+ ).replace(\r
+ /(?:^| )\*(.*?)\*(?:$| )/g,\r
+ function(texte, c1, c2, c3) {\r
+ return '<strong>' + c1 + c2 + c3 + '</strong>';\r
+ }\r
+ );\r
+};\r
+\r
+/**\r
+ * Renvoie une version courte de l'url.\r
+ * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient en.wikipedia.org\r
+ */\r
+euphorik.Formatter.prototype.getShort = function(url) {\r
+ var estUneImage = false;\r
+ var versionShort = null;\r
+ var rechercheImg = this.regexImg.exec(url);\r
+ \r
+ if (rechercheImg) {\r
+ versionShort = rechercheImg[1].toLowerCase();\r
+ if (versionShort === "jpeg") {\r
+ versionShort = "jpg"; // jpeg -> jpg\r
+ }\r
+ estUneImage = true;\r
+ } else {\r
+ var rechercheDomaine = this.regexDomain.exec(url);\r
+ if (rechercheDomaine && rechercheDomaine.length >= 2) {\r
+ versionShort = rechercheDomaine[1];\r
+ } else {\r
+ var protocolName = this.regexProtocolName.exec(url);\r
+ if (protocolName && protocolName.length >= 2) {\r
+ versionShort = protocolName[1];\r
+ }\r
+ }\r
+ }\r
+ \r
+ return [versionShort ? versionShort : "url", estUneImage];\r
+ };\r
+ \r
+euphorik.Formatter.prototype.supprimerSmiles = function(m) {\r
+ objectEach(this.smiles, function(name, smiles) {\r
+ for (var i = 0; i < smiles.length; i++) {\r
+ m = m.replace(smiles[i], "");\r
+ }\r
+ });\r
+ return m;\r
+};\r
+\r
+/**\r
+ * Traite les nick et messages à être affiché dans le titre d'une image visualisé avec lightbox.\r
+ * Supprime les smiles pour pas qu'ils puissent être remplacés par la fonction 'processSmiles'.\r
+ * TODO : trouver un moyen pour que les smiles puissent être conservés\r
+ */\r
+euphorik.Formatter.prototype.traiterPourFenetreLightBox = function(M, urlCourante) {\r
+ var thisFormatter = this;\r
+ var traitementUrl = function(url) {\r
+ return "[" + thisFormatter.getShort(url)[0] + (urlCourante === url ? "*" : "") + "]";\r
+ };\r
+ \r
+ return this.remplacerBalisesHTML(this.supprimerSmiles(M)).replace(this.regexUrl, traitementUrl);\r
+};\r
// You should have received a copy of the GNU General Public License\r
// along with Euphorik. If not, see <http://www.gnu.org/licenses/>.\r
\r
-euphorik.PageAbout = function(client, formater, util, communication) {\r
+euphorik.PageAbout = function(client, formatter, util, communication) {\r
this.name = "about";\r
\r
this.client = client;\r
- this.formater = formater;\r
- this.util = util;
+ this.formatter = formatter;\r
+ this.util = util;\r
this.communication = communication;\r
};\r
\r
/*jslint laxbreak:true */
-euphorik.PageAdmin = function(client, formater, util, communication) {
+euphorik.PageAdmin = function(client, formatter, util, communication) {
this.name = "admin";
this.client = client;
- this.formater = formater;
+ this.formatter = formatter;
this.util = util;
this.communication = communication;
'</span>|';
ip.users.each(function(j, user) {
XHTML += (j > 0 ? ", " : "") +
- '<span class="nick">' + thisPageAdmin.formater.completeProcessing(user.nick) + '</span>' +
- (user.login === "" ? "" : '<span class="login">(' + thisPageAdmin.formater.completeProcessing(user.login) + ')</span>');
+ '<span class="nick">' + thisPageAdmin.formatter.completeProcessing(user.nick) + '</span>' +
+ (user.login === "" ? "" : '<span class="login">(' + thisPageAdmin.formatter.completeProcessing(user.login) + ')</span>');
});
XHTML += '<span class="deban">débannir</span></div>';
});
/*jslint laxbreak:true */
-euphorik.PageMinichat = function(client, formater, util, communication) {
+euphorik.PageMinichat = function(client, formatter, util, communication) {
this.name = "minichat";
this.client = client;
- this.formater = formater;
+ this.formatter = formatter;
this.util = util;
this.communication = communication;
- this.commandes = new euphorik.Commandes(this.client, this, this.util, this.formater);
+ this.commandes = new euphorik.Commandes(this.client, this, this.util, this.formatter);
// permet d'éviter d'envoyer plusieurs messages simultanément en pressant
// rapidement sur "enter" par exemple
$("#posterMessage input.nick").val(this.client.nick);
// cet appel ne doit pas être fait avant l'appel à 'charger'
- this.conversations = new euphorik.Conversations(this.client, this.formater, this.util, this.communication, this.fragment);
+ this.conversations = new euphorik.Conversations(this.client, this.formatter, this.util, this.communication, this.fragment);
this.chargerConversationsFragment();
// <smiles>
$("body").append('<div id="smiles"></div>');
// affichage des smiles
- $("#smiles").append(this.formater.getSmilesHTML()).children().each(
+ $("#smiles").append(this.formatter.getSmilesHTML()).children().each(
function(i) {
var opacityBase = $(this).css("opacity");
$(this).click(
function() {
- thisPage.util.replaceSelection($("form#posterMessage input.message")[0], thisPage.formater.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""));
+ thisPage.util.replaceSelection($("form#posterMessage input.message")[0], thisPage.formatter.smiles[$(this).attr("class")][0].source.replace(/\\/g, ""));
}
).hover(
function() { $(this).animate({opacity: 1}, 200); },
var nick = $("form#posterMessage input.nick").val();
// (un nick vide est autorisé)
- nick = this.formater.formatNick(nick);
+ nick = this.formatter.formatNick(nick);
if (nick === euphorik.conf.defaultNick) {
this.util.messageDialog("Choose a nickname");
// You should have received a copy of the GNU General Public License\r
// along with Euphorik. If not, see <http://www.gnu.org/licenses/>.\r
\r
-euphorik.PageProfile = function(client, formater, util) {\r
+euphorik.PageProfile = function(client, formatter, util) {\r
this.name = "profile";\r
\r
this.client = client;\r
- this.formater = formater;\r
+ this.formatter = formatter;\r
this.util = util;\r
};\r
\r
\r
$("form#profile button").click(\r
function() {\r
- thisPage.client.nick = thisPage.formater.formatNick($("form#profile input.nick").val());\r
+ thisPage.client.nick = thisPage.formatter.formatNick($("form#profile input.nick").val());\r
thisPage.client.email = $("form#profile input.email").val();\r
thisPage.client.chatOrder = $("form#profile select#chatOrder option:selected").attr("value");\r
thisPage.client.nickFormat = $("form#profile select#affichagePseudo option:selected").attr("value");\r
// You should have received a copy of the GNU General Public License\r
// along with Euphorik. If not, see <http://www.gnu.org/licenses/>.\r
\r
-euphorik.PageRegister = function(client, formater, util) {\r
+euphorik.PageRegister = function(client, formatter, util) {\r
this.name = "register";\r
\r
this.client = client;\r
- this.formater = formater;\r
+ this.formatter = formatter;\r
this.util = util;\r
};\r
\r
* - Print a message box to display some information for the user.\r
* - Set a tooltip for a HTML element.\r
* - Some text manipulation for input area.\r
- * @formater An object for string format\r
+ * @formatter An object for string format\r
*/\r
-euphorik.Util = function (formater) {\r
+euphorik.Util = function (formatter) {\r
$("#info .close").click(function() {\r
$("#info").slideUp(50);\r
});\r
\r
$("body").append('<div id="tooltipArrow"></div>').append('<div id="tooltipMessage"><p></p></div>');\r
\r
- this.formater = formater;\r
+ this.formatter = formatter;\r
this.bulleActive = true;\r
};\r
\r
* @message [String] The message.\r
* @type [euphorik.Util.messageType] The message type like 'information' or 'error'. Default is messageType.informatif.\r
* @buttons An object where the properties are the labels and the values are functions which will be executed when a button is clicked.\r
- * @format [bool] The message should be formated. (see 'formater.js')\r
+ * @format [bool] The message should be formated. (see 'formatter.js')\r
* @time The time while the message is displayed. -1 for infinity.\r
*/\r
euphorik.Util.prototype.messageDialog = function(message, type, buttons, format, time) {\r
var close = function() { $("#info").slideUp(100); };\r
close();\r
\r
- $("#info .message").html(!thisUtil.formater || !format ? message : thisUtil.formater.completeProcessing(message));\r
+ $("#info .message").html(!thisUtil.formatter || !format ? message : thisUtil.formatter.completeProcessing(message));\r
\r
switch(type) {\r
case euphorik.Util.messageType.informatif : $("#info #icone").attr("class", "information"); break;\r
% Ce module permet de gérer les données persistantes lié au site d'euphorik.ch.\r
% Il permet d'ajouter des message, de demande les messages sur une page donnée, etc..\r
% Ce module utilise une base mnesia.\r
-% @author G.Burri\r
\r
\r
-module(euphorik_bd).\r
+-author("Greg Burri <greg.burri@gmail.com>").\r
-export([\r
% texte :\r
get_texte/1,\r
% @author G.Burri\r
\r
-module(euphorik_bd_admin).\r
-\r
+-author("Greg Burri <greg.burri@gmail.com>").\r
-export([\r
version_bd/0,\r
create/0,\r
% along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
%
% Module with some useful stuffs.
-% @author G.Burri
-module(euphorik_common).
+-author("Greg Burri <greg.burri@gmail.com>").
-export([
ceiling/1,
delta_date_ms/2,
%\r
% Module tournant en background s'occupant periodiquement de certaines tâches :\r
% - rechargement des modules lors d'une mise en production\r
-% Date : 05.11.2007\r
-% @author G.Burri\r
\r
\r
-module(euphorik_daemon).\r
+-author("Greg Burri <greg.burri@gmail.com>").\r
-export([start/1, reload_euphorik/0, loop/0]).\r
-include("../include/euphorik_defines.hrl").\r
\r
\r
loop() ->\r
receive\r
- switch -> % permet de substituer le code du process par un nouveau code, voir reload_euphorik\r
+ switch -> % To reload a new code, see 'reload_euphorik/0'.\r
euphorik_daemon:loop()\r
end.\r
\r
% Ce module permet la gestion des conversations du minichat d'euphorik.\r
% Un message (enfant) peut répondre à des messages (ses parents).\r
% Un message (parent) peut avoir plusieurs réponses (enfants)\r
-% @author G.Burri\r
%\r
% Les conversation se compose d'une liste de tuple comprenant la conversation, du premier message de la conversation,\r
% et d'un booleen indiquant s'il y a encore des messages\r
\r
\r
-module(euphorik_minichat_conversation).\r
+-author("Greg Burri <greg.burri@gmail.com>").\r
-export([\r
conversations/4\r
]).\r
% @spec conversation([integer()], [integer()], [integer()]) -> {[int()], [int()]}\r
conversation(Conv, [M | Reste], X) ->\r
Est_deja_traite = any(fun(E) -> E =:= M end, Conv),\r
- if Est_deja_traite ->\r
+ if Est_deja_traite ->\r
conversation(Conv, Reste, X);\r
true ->\r
Enfants = euphorik_bd:enfants_id(M),\r
%\r
% Ce module gére les différents messages envoyés par le client (javascript) via AJAX.\r
% Les messages donnés ainsi que les réponses sont au format JSON.\r
-% @author G.Burri\r
\r
\r
-module(euphorik_protocole).\r
+-author("Greg Burri <greg.burri@gmail.com>").\r
-export([\r
register/2,\r
login/2,\r
\r
\r
% Une utilisateur s'enregistre avec un tuple {Login, Password}.\r
-register([{login, Login}, {password, Password}, {profile, Profile_json}], IP) ->\r
+register([{"login", Login}, {"password", Password}, {"profile", Profile_json}], IP) ->\r
Can_register = euphorik_bd:can_register(IP),\r
if Can_register ->\r
case euphorik_bd:user_by_login(Login) of\r
erreur_register_flood()\r
end;\r
% Enregistrement sans {Login, Password}\r
-register([{profile, Profile_json}], IP) ->\r
+register([{"profile", Profile_json}], IP) ->\r
Can_register = euphorik_bd:can_register(IP),\r
if Can_register ->\r
Profile = profile_from_json(Profile_json),\r
\r
\r
% Un utilisateur se logge (avec un couple {login, mot de passe})\r
-login([{login, Login}, {password, Password}], IP) ->\r
+login([{"login", Login}, {"password", Password}], IP) ->\r
case euphorik_bd:user_by_login_password(Login, Password) of\r
{ok, User} ->\r
loginUser(User, IP);\r
erreur(30)\r
end;\r
% Un utilisateur se logge (avec un cookie)\r
-login([{cookie, Cookie}], IP) ->\r
+login([{"cookie", Cookie}], IP) ->\r
case euphorik_bd:user_by_cookie(Cookie) of\r
{ok, User} ->\r
loginUser(User, IP);\r
% Modification du profile.\r
profile(\r
[\r
- {cookie, Cookie},\r
- {login, Login},\r
- {password, Password},\r
- {profile, Profile_json}\r
+ {"cookie", Cookie},\r
+ {"login", Login},\r
+ {"password", Password},\r
+ {"profile", Profile_json}\r
]\r
) ->\r
case profile_from_json(Profile_json) of\r
profile_from_json(\r
{struct,\r
[\r
- {nick, Pseudo},\r
- {email, Email},\r
- {css, Css},\r
- {chat_order, Chat_order_str},\r
- {nick_format, Nick_format_str},\r
- {view_times, View_times},\r
- {view_tooltips, View_tooltips},\r
- {conversations, {array, Conversations_json}},\r
- {ostentatious_master, Ostentatious_master_str}\r
+ {"nick", Pseudo},\r
+ {"email", Email},\r
+ {"css", Css},\r
+ {"chat_order", Chat_order_str},\r
+ {"nick_format", Nick_format_str},\r
+ {"view_times", View_times},\r
+ {"view_tooltips", View_tooltips},\r
+ {"conversations", {array, Conversations_json}},\r
+ {"ostentatious_master", Ostentatious_master_str}\r
]\r
}\r
) ->\r
% décomposition de la strucure JSON\r
Conversations = lists:foldr(\r
- fun({struct, [{root, Racine}, {minimized, Reduit}]}, A) ->\r
+ fun({struct, [{"root", Racine}, {"minimized", Reduit}]}, A) ->\r
% virage des messages qui n'existent pas\r
Message_exite = euphorik_bd:message_existe(Racine),\r
if Message_exite ->\r
\r
% Attend un événement pour la page "Chat"\r
% last_message id et cookie sont facultatifs\r
-wait_event([{page, "chat"} | Data]) ->\r
+wait_event([{"page", "chat"} | Data]) ->\r
% traitement des inputs\r
- Cookie = case lists:keysearch(cookie, 1, Data) of {value, {_, C}} -> C; _ -> inconnu end,\r
- Last_message_id = case lists:keysearch(last_message_id, 1, Data) of {value, {_, Id}} -> Id; _ -> 0 end,\r
- {value, {_, Message_count}} = lists:keysearch(message_count, 1, Data),\r
- Main_page = case lists:keysearch(main_page, 1, Data) of {value, {_, P}} -> P; _ -> 1 end,\r
- {value, {_, {array, Conversations_json}}} = lists:keysearch(conversations, 1, Data),\r
+ Cookie = case lists:keysearch("cookie", 1, Data) of {value, {_, C}} -> C; _ -> inconnu end,\r
+ Last_message_id = case lists:keysearch("last_message_id", 1, Data) of {value, {_, Id}} -> Id; _ -> 0 end,\r
+ {value, {_, Message_count}} = lists:keysearch("message_count", 1, Data),\r
+ Main_page = case lists:keysearch("main_page", 1, Data) of {value, {_, P}} -> P; _ -> 1 end,\r
+ {value, {_, {array, Conversations_json}}} = lists:keysearch("conversations", 1, Data),\r
Racines_conversations = lists:map(\r
- fun({struct, [{root, Racine}, {page, Page} | Reste]}) ->\r
- Last_mess_conv = case Reste of [{last_message_id, L}] -> L; _ -> 0 end,\r
+ fun({struct, [{"root", Racine}, {"page", Page} | Reste]}) ->\r
+ Last_mess_conv = case Reste of [{"last_message_id", L}] -> L; _ -> 0 end,\r
{Racine, Page, Last_mess_conv}\r
end,\r
Conversations_json\r
R\r
end;\r
% Attend un événement pour la page "Admin"\r
-wait_event([{page, "admin"}]) ->\r
+wait_event([{"page", "admin"}]) ->\r
case wait_event_page_admin() of\r
banned_ips_refresh ->\r
{struct,\r
[\r
- {reply, "banned_ips_refresh"}\r
+ {"reply", "banned_ips_refresh"}\r
]\r
};\r
_ ->\r
Conversations ->\r
% Accrochez-vous ca va siouxer ;).\r
{struct, [\r
- {reply, "new_messages"},\r
- {conversations, {array,\r
+ {"reply", "new_messages"},\r
+ {"conversations", {array,\r
lists:map(\r
fun({Racine, {Conv, Plus}}) ->\r
{struct, [\r
- {last_page, not Plus},\r
- {first, % le premier message de la conversation\r
+ {"last_page", not Plus},\r
+ {"first", % le premier message de la conversation\r
if Racine =:= undefined orelse Conv =:= [] ->\r
null;\r
true ->\r
% Answer_to est une liste d'id (int)\r
put_message(\r
[\r
- {cookie, Cookie},\r
- {nick, Nick},\r
- {content, Content},\r
- {answer_to, {array, Answer_to}}\r
+ {"cookie", Cookie},\r
+ {"nick", Nick},\r
+ {"content", Content},\r
+ {"answer_to", {array, Answer_to}}\r
]\r
) ->\r
case euphorik_bd:user_by_cookie(Cookie) of\r
% bannissement d'un utilisateur (son ip est bannie)\r
ban(\r
[\r
- {cookie, Cookie},\r
- {duration, Duration},\r
- {user_id, User_id},\r
- {reason, Reason}\r
+ {"cookie", Cookie},\r
+ {"duration", Duration},\r
+ {"user_id", User_id},\r
+ {"reason", Reason}\r
]) ->\r
% controle que l'utilisateur est un admin\r
case euphorik_bd:user_by_cookie(Cookie) of\r
% slapage d'un user (avertissement)\r
slap(\r
[\r
- {cookie, Cookie},\r
- {user_id, User_id},\r
- {reason, Reason}\r
+ {"cookie", Cookie},\r
+ {"user_id", User_id},\r
+ {"reason", Reason}\r
]) ->\r
% controle que l'utilisateur est un admin\r
case euphorik_bd:user_by_cookie(Cookie) of\r
\r
unban_ip(\r
[\r
- {cookie, Cookie},\r
- {ip, IP}\r
+ {"cookie", Cookie},\r
+ {"ip", IP}\r
]\r
) ->\r
case euphorik_bd:user_by_cookie(Cookie) of\r
\r
list_banned_ips(\r
[\r
- {cookie, Cookie}\r
+ {"cookie", Cookie}\r
]\r
) ->\r
case euphorik_bd:user_by_cookie(Cookie) of\r
{\r
struct,\r
[\r
- {reply, "list_banned_ips"},\r
- {list, {array, lists:map(\r
+ {"reply", "list_banned_ips"},\r
+ {"list", {array, lists:map(\r
fun({IP, T, Users}) ->\r
{struct,\r
[\r
- {ip, euphorik_common:serialize_ip(IP)},\r
- {remaining_time, format_minutes(T)},\r
- {users, {array, lists:map(\r
+ {"ip", euphorik_common:serialize_ip(IP)},\r
+ {"remaining_time", format_minutes(T)},\r
+ {"users", {array, lists:map(\r
fun({Pseudo, Login}) ->\r
{struct,\r
[\r
- {nick, Pseudo},\r
- {login, Login}\r
+ {"nick", Pseudo},\r
+ {"login", Login}\r
]\r
}\r
end,\r
erreur_json(Num, Mess) ->\r
{\r
struct, [\r
- {reply, "error"},\r
- {no, Num},\r
- {error_message, Mess}\r
+ {"reply", "error"},\r
+ {"no", Num},\r
+ {"error_message", Mess}\r
]\r
}.\r
\r
\r
\r
json_reponse_ok() ->\r
- {struct, [{reply, "ok"}]}.\r
+ {struct, [{"reply", "ok"}]}.\r
\r
\r
json_reponse_login_ok(#user{profile = Profile} = User) ->\r
{\r
struct, [\r
- {reply, "login"},\r
- {status, if (User#user.password =/= []) and (User#user.login =/= []) -> "auth_registered"; true -> "auth_not_registered" end},\r
- {cookie, User#user.cookie},\r
- {id, User#user.id},\r
- {login, User#user.login},\r
- {ek_master, User#user.ek_master},\r
- {profile, {struct,\r
+ {"reply", "login"},\r
+ {"status", if (User#user.password =/= []) and (User#user.login =/= []) -> "auth_registered"; true -> "auth_not_registered" end},\r
+ {"cookie", User#user.cookie},\r
+ {"id", User#user.id},\r
+ {"login", User#user.login},\r
+ {"ek_master", User#user.ek_master},\r
+ {"profile", {struct,\r
[\r
- {nick, Profile#profile.pseudo},\r
- {email, Profile#profile.email},\r
- {css, Profile#profile.css},\r
- {chat_order, atom_to_list(Profile#profile.chat_order)},\r
- {nick_format, atom_to_list(Profile#profile.nick_format)},\r
- {view_times, Profile#profile.view_times},\r
- {view_tooltips, Profile#profile.view_tooltips},\r
- {conversations, {array, lists:map(\r
+ {"nick", Profile#profile.pseudo},\r
+ {"email", Profile#profile.email},\r
+ {"css", Profile#profile.css},\r
+ {"chat_order", atom_to_list(Profile#profile.chat_order)},\r
+ {"nick_format", atom_to_list(Profile#profile.nick_format)},\r
+ {"view_times", Profile#profile.view_times},\r
+ {"view_tooltips", Profile#profile.view_tooltips},\r
+ {"conversations", {array, lists:map(\r
fun({Racine, Reduit}) ->\r
- {struct, [{root, Racine}, {minimized, Reduit}]}\r
+ {struct, [{"root", Racine}, {"minimized", Reduit}]}\r
end,\r
Profile#profile.conversations\r
)}},\r
- {ostentatious_master, atom_to_list(Profile#profile.ostentatious_master)}\r
+ {"ostentatious_master", atom_to_list(Profile#profile.ostentatious_master)}\r
]\r
}}\r
]\r
Est_une_reponse_a_user = User =/= inconnu andalso euphorik_bd:est_une_reponse_a_user(User#user.id, Mess#minichat.id),\r
{ok, #user{profile = Profile_mess} = User_mess } = euphorik_bd:user_by_id(Mess#minichat.auteur_id),\r
{struct, [\r
- {id, Mess#minichat.id},\r
- {user_id, User_mess#user.id},\r
- {date, case Mess#minichat.date of undefined -> "?"; _ -> format_date(Mess#minichat.date) end},\r
- {system, Mess#minichat.auteur_id =:= 0},\r
- {owner, Est_proprietaire},\r
- {answered, A_repondu_a_message},\r
- {is_a_reply, Est_une_reponse_a_user},\r
- {nick, Mess#minichat.pseudo},\r
- {login, User_mess#user.login},\r
- {content, Mess#minichat.contenu},\r
- {root, Mess#minichat.racine_id},\r
- {answer_to, {array, lists:map(\r
+ {"id", Mess#minichat.id},\r
+ {"user_id", User_mess#user.id},\r
+ {"date", case Mess#minichat.date of undefined -> "?"; _ -> format_date(Mess#minichat.date) end},\r
+ {"system", Mess#minichat.auteur_id =:= 0},\r
+ {"owner", Est_proprietaire},\r
+ {"answered", A_repondu_a_message},\r
+ {"is_a_reply", Est_une_reponse_a_user},\r
+ {"nick", Mess#minichat.pseudo},\r
+ {"login", User_mess#user.login},\r
+ {"content", Mess#minichat.contenu},\r
+ {"root", Mess#minichat.racine_id},\r
+ {"answer_to", {array, lists:map(\r
fun(Id_mess) ->\r
{ok, M} = euphorik_bd:message_by_id(Id_mess),\r
{ok, User_reponse} = euphorik_bd:user_by_mess(M#minichat.id),\r
- {struct, [{id, M#minichat.id}, {nick, M#minichat.pseudo}, {login, User_reponse#user.login}]}\r
+ {struct, [{"id", M#minichat.id}, {"nick", M#minichat.pseudo}, {"login", User_reponse#user.login}]}\r
end,\r
Repond_a\r
)}},\r
- {ek_master, User_mess#user.ek_master},\r
- {ostentatious_master, atom_to_list(Profile_mess#profile.ostentatious_master)}\r
+ {"ek_master", User_mess#user.ek_master},\r
+ {"ostentatious_master", atom_to_list(Profile_mess#profile.ostentatious_master)}\r
]}.\r
% This module responds to JSON requests via 'AJAX'.\r
% It's defined as an Yaws 'appmods' with the url '/request'.\r
% For instance in debug mode 'http://localhost:8090/request' will call the out/1 function.\r
-% @author G.Burri\r
\r
\r
-module(euphorik_requests).\r
+-author("Greg Burri <greg.burri@gmail.com>").\r
-export([out/1]).\r
-include_lib("yaws_api.hrl").\r
-include("../include/euphorik_defines.hrl").\r
end,\r
% active: to receive {tcp_closed, _} when the socket is closing.\r
% keepalive: avoid firewalls to cut the connection.\r
+\r
inet:setopts(A#arg.clisock, [{active, true}, {keepalive, true}]),\r
{value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)),\r
+\r
Ret = traiter_message(Contenu, IP),\r
{content, "application/json", Ret}.\r
\r
% Décode le message JSON.\r
traiter_message(Contenu, IP) ->\r
% extrait l'entête obligatoire des messages JSON\r
- {ok, {struct, [{header, {struct, [{action, Action}, {version, Version_client}]}} | Reste]}} = json:decode_string(Contenu),\r
- json:encode(\r
+ {ok, {struct, [{"header", {struct, [{"action", Action}, {"version", Version_client}]}} | Reste]}} = json2:decode_string(Contenu),\r
+\r
+ json2:encode(\r
if Version_client =:= ?VERSION_PROTOCOLE ->\r
traiter_action(Action, Reste, IP);\r
true ->\r
timer:sleep(100),\r
spawn(\r
fun() ->\r
- {A1, A2, A3} = now(),\r
+ {A1, A2, A3} = erlang:timestamp(),\r
random:seed(A1, A2, A3),\r
loop(Id, M)\r
end\r
-# Configuration pour euphorik.ch en mode de développement.
+# Configuration pour euphorik.ch en mode de d�veloppement.
logdir = /tmp
allowed_scripts = yaws
appmods = <request, euphorik_requests>
start_mod = euphorik_daemon
+ auth_log = true
# dir_listings = true
</server>
cache_refresh_secs = 0
-# it is possible to have yaws start additional
+# it is possible to have yaws start additional
# application specific code at startup
# runmod = my_app
log_resolve_hostname = false
-# fail completely or not if yaws fails
+# fail completely or not if yaws fails
# to bind a listen socket
fail_on_bind_err = true
# If HTTP auth is used, it is possible to have a specific
# auth log.
-auth_log = true
-# When we're running multiple yaws systems on the same
+# When we're running multiple yaws systems on the same
# host, we need to give each yaws system an individual
# name. Yaws will write a number of runtime files under
# /tmp/yaws/${id}
# This is often nice in testing environments but not
# acceptable in real live hosting scenarios
pick_first_virthost_on_nomatch = true
-
-# All unices are broken since it's not possible to bind to
-# a privileged port (< 1024) unless uid==0
-# There is a contrib in jungerl which makes it possible by means
-# of an external setuid root programm called fdsrv to listen to
-# to privileged port.
-# If we use this feature, it requires fdsrv to be properly installed.
-# Doesn't yet work with SSL.
-use_fdsrv = false