From f39b28682e1e41cd487a2268320552b687640adf Mon Sep 17 00:00:00 2001
From: Greg Burri <greg.burri@gmail.com>
Date: Wed, 9 Jul 2008 17:45:20 +0000
Subject: [PATCH] MOD restructuration des styles (pas fini)

---
 index.yaws                                | 30 +++++++++++++++---
 js/euphorik.js                            |  2 +-
 modules/erl/euphorik_bd_update.erl        | 22 ++++++++++---
 nbproject/project.properties              |  2 +-
 nbproject/project.xml                     |  2 +-
 {css => styles}/1/euphorik.css            | 16 +++++-----
 {css => styles}/1/pageAbout.css           |  0
 {css => styles}/1/pageAdmin.css           |  0
 {css => styles}/1/pageMinichat.css        | 38 +++++++++++------------
 {css => styles}/1/pageProfileRegister.css |  0
 {css => styles}/2/euphorik.css            | 12 +++----
 {css => styles}/2/pageAbout.css           |  0
 {css => styles}/2/pageAdmin.css           |  0
 {css => styles}/2/pageMinichat.css        |  4 +--
 {css => styles}/2/pageProfileRegister.css |  0
 {css => styles}/3/euphorik.css            |  0
 {css => styles}/3/pageMinichat.css        |  0
 {css => styles}/3/pageProfileRegister.css |  0
 {css => styles}/jquery.lightbox.css       |  0
 19 files changed, 81 insertions(+), 47 deletions(-)
 rename {css => styles}/1/euphorik.css (89%)
 rename {css => styles}/1/pageAbout.css (100%)
 rename {css => styles}/1/pageAdmin.css (100%)
 rename {css => styles}/1/pageMinichat.css (86%)
 rename {css => styles}/1/pageProfileRegister.css (100%)
 rename {css => styles}/2/euphorik.css (91%)
 rename {css => styles}/2/pageAbout.css (100%)
 rename {css => styles}/2/pageAdmin.css (100%)
 rename {css => styles}/2/pageMinichat.css (98%)
 rename {css => styles}/2/pageProfileRegister.css (100%)
 rename {css => styles}/3/euphorik.css (100%)
 rename {css => styles}/3/pageMinichat.css (100%)
 rename {css => styles}/3/pageProfileRegister.css (100%)
 rename {css => styles}/jquery.lightbox.css (100%)

diff --git a/index.yaws b/index.yaws
index d3ff0f8..c600fe9 100755
--- a/index.yaws
+++ b/index.yaws
@@ -9,7 +9,7 @@
       % prédéfinit la feuille de style
       out(A) -> 
          CSS = case euphorik_bd:css_from_user_cookie(yaws_api:find_cookie_val("cookie", A)) of
-            undefined -> "css/1/euphorik.css";
+            undefined -> "styles/1/euphorik.css";
             C -> C
          end,
          {ehtml, {link ,
@@ -37,7 +37,7 @@
    <body>
       <div id="container">
          <erl>
-            % permet de prédéfinir la "class" du logo pour un ekMaster..
+            % permet de prédéfinir la "class" du logo pour un ekMaster...
             out(A) -> 
                Est_ek_master = euphorik_bd:is_ek_master_from_cookie(yaws_api:find_cookie_val("cookie", A)),
                {ehtml, {'div', [{id, "logo"}] ++ if Est_ek_master -> [{class, "ekMaster"}]; true -> [] end}}.
@@ -47,11 +47,31 @@
          <ul id="menu">
             <li class="minichat">chat</li><li class="admin" style="display:none">admin</li><li class="profile"></li><li class="register">register</li><li class="logout">logout</li><li class="about">about</li>
          </ul>
-         <form action=""  id="formMenuCss">
+         <form action="" id="formMenuCss">
             <p>
                <select id="menuCss">
-                  <option value="1" selected="selected">Retro</option>
-                  <option value="2">Dark</option>
+                  <erl>
+                     % parse les styles disponible
+                     out(A) ->
+                        Stlyes_dir = A#arg.docroot ++ "/styles",
+                        {ok, Liste_dir} = file:list_dir(Stlyes_dir),
+                        {ehtml, 
+                           lists:foldr(
+                              fun(Dir, Acc) ->
+                                 case file:consult(Stlyes_dir ++ "/" ++ Dir ++ "/infos.txt") of
+                                    {ok, [{nom, Nom}]} ->
+                                       [{option, [{value, Dir}], Nom} | Acc];
+                                    _ -> 
+                                       Acc
+                                 end
+                              end,
+                              [],
+                              Liste_dir
+                           )
+                        }.
+                  </erl>
+                  <!-- option value="1" selected="selected">Retro</option>
+                  <option value="2">Dark</option -->
                </select>
             </p>
          </form> 
diff --git a/js/euphorik.js b/js/euphorik.js
index de64738..eb9741b 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -1209,7 +1209,7 @@ $(document).ready(
       // connexion vers le serveur (utilise un cookie qui traine)
       client.connexionCookie()
       
-      $("#menuCss").change(function(){ client.setCss("css/" + $("option:selected", this).attr("value") + "/euphorik.css")})
+      $("#menuCss").change(function(){ client.setCss("styles/" + $("option:selected", this).attr("value") + "/euphorik.css")})
 
       // FIXME : ne fonctionne pas sous opera
       // voir : http://dev.jquery.com/ticket/2892#preview
diff --git a/modules/erl/euphorik_bd_update.erl b/modules/erl/euphorik_bd_update.erl
index 1f04ab0..4c72284 100644
--- a/modules/erl/euphorik_bd_update.erl
+++ b/modules/erl/euphorik_bd_update.erl
@@ -24,6 +24,7 @@
 -export([
    version_bd/0,
    update/0,
+   backup/1,
    restore/1
 ]).
 -import(qlc, [e/2, q/1, cursor/2]).
@@ -78,7 +79,7 @@ patch(1) ->
    mnesia:transform_table(
       user,
       fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Nick_format, View_times, View_tooltips, Indice_flood, _Page_principale, Conversations, Ek_master, Last_ip}) ->
-            {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Nick_format, View_times, View_tooltips, light, reverse, Indice_flood, lists:map(fun({R, _}) -> {R, false} end, Conversations), Ek_master, Last_ip}
+            {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, patch1_transforme_css(Css), Nick_format, View_times, View_tooltips, light, reverse, Indice_flood, lists:map(fun({R, _}) -> {R, false} end, Conversations), Ek_master, Last_ip}
       end,
       record_info(fields, user),
       user
@@ -106,6 +107,14 @@ patch(1) ->
 %patch(2) ->
 
 
+% Prend un chemin vers la feuille de style de type "css/1/euphorik.css"
+% et renvoie "styles/1/euphorik.css"
+patch1_transforme_css(["css" | Reste]) ->
+   ["styles" | Reste];
+patch1_transforme_css(F) ->
+   F.
+
+   
 patch_1_traiter_message(M, Racine) ->
    % met à jour la racine de chaque message qui répond à M
    lists:foreach(
@@ -116,13 +125,18 @@ patch_1_traiter_message(M, Racine) ->
       euphorik_bd:enfants(M#minichat.id)
    ).
 
+% crée un backup dont le nom est fournit dans le repertoire backups qui se trouve dans le repertoire de la BD.
+backup(Nom) ->
+   mnesia:backup(mnesia:system_info(directory) ++ "/backups/" ++ Nom).
+   
 
 % Reviens à une version précédente de la base de données
 % (les données insérées durant les versions plus récentes sont perdues)
-restore(N) ->
-   mnesia:restore(fichier_backup(N), []).
+restore(N) when is_integer(N) ->
+   mnesia:restore(fichier_backup(N), [{default_op, recreate_tables}]);
+restore(Nom) when is_string(Nom) ->
 
 
-% Renvoie le fichier (avec le chemin) correspondant à la version Version.
+% Renvoie le fichier (avec le chemin) correspondant à la version Version, par exemple : "/var/euphorik/BD/backups/backup1"
 fichier_backup(Version) -> 
    mnesia:system_info(directory) ++ "/backups/backup" ++ integer_to_list(Version).
diff --git a/nbproject/project.properties b/nbproject/project.properties
index c61bcc0..f0548fd 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -3,9 +3,9 @@ file.reference.modules-include=modules/include
 javac.classpath=
 main.file=
 ruby.includejava=false
-src.css.dir=css
 src.doc.dir=doc
 src.js.dir=js
 src.modules.dir=modules
 src.pages.dir=pages
+src.styles.dir=styles
 src.tools.dir=tools
diff --git a/nbproject/project.xml b/nbproject/project.xml
index 55ee5ef..d8c477d 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -5,8 +5,8 @@
         <data xmlns="http://www.netbeans.org/ns/erlang-project/1">
             <name>euphorik</name>
             <source-roots>
-                <root id="src.css.dir" name="Css"/>
                 <root id="src.doc.dir" name="Documentation"/>
+                <root id="src.styles.dir" name="Styles"/>
                 <root id="src.pages.dir" name="Pages XHTML"/>
                 <root id="src.tools.dir" name="Tools"/>
                 <root id="src.js.dir" name="JS"/>
diff --git a/css/1/euphorik.css b/styles/1/euphorik.css
similarity index 89%
rename from css/1/euphorik.css
rename to styles/1/euphorik.css
index 25b51cf..0383346 100755
--- a/css/1/euphorik.css
+++ b/styles/1/euphorik.css
@@ -24,7 +24,7 @@ body {
 
 /***** Menu *****/
 ul#menu {
-	background-image: url(../../img/css1/logo_fond.png);
+	background-image: url(img/logo_fond.png);
 	height:129px;
 	width: 100%;
 	font-size: 11px;
@@ -47,7 +47,7 @@ ul#menu {
 }
 #menu li.courante {	
 	background-color: #ffffff;
-	background-image: url(../../img/css1/triangle.png);
+	background-image: url(img/triangle.png);
 	background-repeat: no-repeat;
 	background-position: center bottom
 }
@@ -101,14 +101,14 @@ ul#menu {
 }
 #logo {
 	z-index: 10;
-	background-image: url(../../img/css1/logo.png);
+	background-image: url(img/logo.png);
 	background-repeat: no-repeat;
 	width: 304px;
 	height: 129px;
 	position: absolute;
 }
 #logo.ekMaster {
-	background-image: url(../../img/css1/logo_ek_master.png);
+	background-image: url(img/logo_ek_master.png);
 }
 
 /***** Le pied de page *****/
@@ -181,22 +181,22 @@ div#info .boutons div:hover {
 	display: none
 }
 .flecheBulleHaut {
-	background-image: url(../../img/css1/fleche_bulle_haut.png);
+	background-image: url(img/fleche_bulle_haut.png);
 	width: 15px;
 	height: 8px;
 }
 .flecheBulleDroite {
-	background-image: url(../../img/css1/fleche_bulle_droite.png);
+	background-image: url(img/fleche_bulle_droite.png);
 	width: 8px;
 	height: 15px;
 }
 .flecheBulleBas {
-	background-image: url(../../img/css1/fleche_bulle_bas.png);
+	background-image: url(img/fleche_bulle_bas.png);
 	width: 15px;
 	height: 8px;
 }
 .flecheBulleGauche {
-	background-image: url(../../img/css1/fleche_bulle_gauche.png);
+	background-image: url(img/fleche_bulle_gauche.png);
 	width: 8px;
 	height: 15px;
 }
diff --git a/css/1/pageAbout.css b/styles/1/pageAbout.css
similarity index 100%
rename from css/1/pageAbout.css
rename to styles/1/pageAbout.css
diff --git a/css/1/pageAdmin.css b/styles/1/pageAdmin.css
similarity index 100%
rename from css/1/pageAdmin.css
rename to styles/1/pageAdmin.css
diff --git a/css/1/pageMinichat.css b/styles/1/pageMinichat.css
similarity index 86%
rename from css/1/pageMinichat.css
rename to styles/1/pageMinichat.css
index 946c06c..528d685 100755
--- a/css/1/pageMinichat.css
+++ b/styles/1/pageMinichat.css
@@ -91,7 +91,7 @@
 #page.minichat form#posterMessage .return {
 	height: 16px;
 	width: 32px;
-	background-image: url(../../img/css1/return.png);
+	background-image: url(img/return.png);
 	background-repeat: no-repeat;
 	background-position: 5px 2px;
 	vertical-align: top;
@@ -100,7 +100,7 @@
 #page.minichat form#posterMessage .smiles {
 	height: 16px;
 	width: 16px;
-	background-image: url(../../img/css2/bouton_smiles.png);
+	background-image: url(img/bouton_smiles.png);
 	background-repeat: no-repeat;
 	background-position: 2px 2px;
 	vertical-align: top;
@@ -160,11 +160,11 @@
 	float: right;
 	width: 13px;
 	height: 13px;
-	background-image: url(../../img/css1/reduire_conv.png);
+	background-image: url(img/reduire_conv.png);
 	cursor: pointer;
 }
 #page.minichat #conversations .titre .nav .reduire:hover {
-	background-image: url(../../img/css1/reduire_conv_hover.png);
+	background-image: url(img/reduire_conv_hover.png);
 }	
 
 #page.minichat #conversations .titre .nav .fermer {
@@ -173,11 +173,11 @@
 	float: right;
 	width: 13px;
 	height: 13px;
-	background-image: url(../../img/css1/fermer_conv.png);
+	background-image: url(img/fermer_conv.png);
 	cursor: pointer;
 }
 #page.minichat #conversations .titre .nav .fermer:hover {
-	background-image: url(../../img/css1/fermer_conv_hover.png);
+	background-image: url(img/fermer_conv_hover.png);
 }	
 #page.minichat #conversations .titre .nav .lien {
 	margin-top: 1px;
@@ -185,11 +185,11 @@
 	float: right;
 	width: 13px;
 	height: 13px;
-	background-image: url(../../img/css1/copier_conv.png);
+	background-image: url(img/copier_conv.png);
 	cursor: pointer;
 }
 #page.minichat #conversations .titre .nav .lien:hover {
-	background-image: url(../../img/css1/copier_conv_hover.png);
+	background-image: url(img/copier_conv_hover.png);
 }	
 #page.minichat #conversations .titre .nav .next,
 #page.minichat #conversations .titre .nav .prev {
@@ -234,21 +234,21 @@
 }
 #page.minichat div.message.reponse .delimitationEntete,
 #page.minichat div.message.reponse .repondA {
-	background-image: url(../../img/css1/fleche_reponse.png);
+	background-image: url(img/fleche_reponse.png);
 }
 #page.minichat div.message.repondu .entete {
 	background-color: #84196c
 }
 #page.minichat div.message.repondu .delimitationEntete,
 #page.minichat div.message.repondu .repondA {
-	background-image: url(../../img/css1/fleche_repondu.png);
+	background-image: url(img/fleche_repondu.png);
 }
 #page.minichat div.message.proprietaire .entete {
 	background-color: #31732f
 }
 #page.minichat div.message.proprietaire .delimitationEntete,
 #page.minichat div.message.proprietaire .repondA {
-	background-image: url(../../img/css1/fleche_proprietaire.png);
+	background-image: url(img/fleche_proprietaire.png);
 }
 #page.minichat div.message.repondEnEvidence {
 	background-color: #fce476
@@ -279,7 +279,7 @@
 	z-index: 20;
 	height: 18px;
 	width: 7px;
-	background-image: url(../../img/css1/fleche.png);
+	background-image: url(img/fleche.png);
 	display: block;
 	float: left;
 }
@@ -300,7 +300,7 @@
 #page.minichat div.message.ekMasterheavy .pseudo {
    color: #fcd82f;
    padding-left: 14px;
-   background: transparent url(../../img/css1/marque_ek.png) no-repeat scroll left center
+   background: transparent url(img/marque_ek.png) no-repeat scroll left center
 }
 
 #page.minichat div.message .pseudo .login {
@@ -316,14 +316,14 @@
 	background-color: #cb2626; 
 	color: #ffffff;
 	display: block;
-	background-image: url(../../img/css1/fleche.png);
+	background-image: url(img/fleche.png);
 	background-repeat: no-repeat;
 }
 #page.minichat .delimitationRepondA {
 	z-index: 20;
 	height: 18px;
 	width: 7px;
-	background-image: url(../../img/css1/fleche_reponda.png);
+	background-image: url(img/fleche_reponda.png);
 	display: block;
 	float: left;
 }
@@ -341,20 +341,20 @@
 	float: right;
 	width: 13px;
 	height: 13px;
-	background-image: url(../../img/css1/extraction.png);
+	background-image: url(img/extraction.png);
 	margin-top: 2px;
 }
 #page.minichat .extraire:hover {
-	background-image: url(../../img/css1/extraction_hover.png);
+	background-image: url(img/extraction_hover.png);
 }
 #page.minichat .extraireCompletement {
 	float: right;
 	width: 13px;
 	height: 13px;
-	background-image: url(../../img/css1/extraction_complete.png);
+	background-image: url(img/extraction_complete.png);
 	margin-top: 2px;
    margin-right: 2px;
 }
 #page.minichat .extraireCompletement:hover {
-	background-image: url(../../img/css1/extraction_complete_hover.png);
+	background-image: url(img/extraction_complete_hover.png);
 }
diff --git a/css/1/pageProfileRegister.css b/styles/1/pageProfileRegister.css
similarity index 100%
rename from css/1/pageProfileRegister.css
rename to styles/1/pageProfileRegister.css
diff --git a/css/2/euphorik.css b/styles/2/euphorik.css
similarity index 91%
rename from css/2/euphorik.css
rename to styles/2/euphorik.css
index 4ba9352..66029b5 100755
--- a/css/2/euphorik.css
+++ b/styles/2/euphorik.css
@@ -15,7 +15,7 @@ body {
    font-size: 12px;
    color: #EEEEEE;
    background-color: #DFDFDF;
-   background-image: url(../../img/css2/fond.png)
+   background-image: url(img/fond.png)
 }
 
 #container {
@@ -100,7 +100,7 @@ ul#menu {
 }
 #logo {
    z-index: 10;
-   background-image: url(../../img/css2/logo_2.png);
+   background-image: url(img/logo_2.png);
    width: 253px;
    height: 37px;
    position: absolute;
@@ -175,22 +175,22 @@ div#info .boutons div:hover {
 	display: none
 }
 .flecheBulleHaut {
-	background-image: url(../../img/css2/fleche_bulle_haut.png);
+	background-image: url(img/fleche_bulle_haut.png);
 	width: 15px;
 	height: 8px;
 }
 .flecheBulleDroite {
-	background-image: url(../../img/css2/fleche_bulle_droite.png);
+	background-image: url(img/fleche_bulle_droite.png);
 	width: 8px;
 	height: 15px;
 }
 .flecheBulleBas {
-	background-image: url(../../img/css2/fleche_bulle_bas.png);
+	background-image: url(img/fleche_bulle_bas.png);
 	width: 15px;
 	height: 8px;
 }
 .flecheBulleGauche {
-	background-image: url(../../img/css2/fleche_bulle_gauche.png);
+	background-image: url(img/fleche_bulle_gauche.png);
 	width: 8px;
 	height: 15px;
 }
diff --git a/css/2/pageAbout.css b/styles/2/pageAbout.css
similarity index 100%
rename from css/2/pageAbout.css
rename to styles/2/pageAbout.css
diff --git a/css/2/pageAdmin.css b/styles/2/pageAdmin.css
similarity index 100%
rename from css/2/pageAdmin.css
rename to styles/2/pageAdmin.css
diff --git a/css/2/pageMinichat.css b/styles/2/pageMinichat.css
similarity index 98%
rename from css/2/pageMinichat.css
rename to styles/2/pageMinichat.css
index bf27f96..7045ecd 100755
--- a/css/2/pageMinichat.css
+++ b/styles/2/pageMinichat.css
@@ -88,7 +88,7 @@
 #page.minichat form#posterMessage .return {
 	height: 16px;
 	width: 32px;
-	background-image: url(../../img/css2/return.png);
+	background-image: url(img/return.png);
 	background-repeat: no-repeat;
 	background-position: 5px 2px;
 	vertical-align: top;
@@ -97,7 +97,7 @@
 #page.minichat form#posterMessage .smiles {
 	height: 16px;
 	width: 16px;
-	background-image: url(../../img/css2/bouton_smiles.png);
+	background-image: url(img/bouton_smiles.png);
 	background-repeat: no-repeat;
 	background-position: 2px 2px;
 	vertical-align: top;
diff --git a/css/2/pageProfileRegister.css b/styles/2/pageProfileRegister.css
similarity index 100%
rename from css/2/pageProfileRegister.css
rename to styles/2/pageProfileRegister.css
diff --git a/css/3/euphorik.css b/styles/3/euphorik.css
similarity index 100%
rename from css/3/euphorik.css
rename to styles/3/euphorik.css
diff --git a/css/3/pageMinichat.css b/styles/3/pageMinichat.css
similarity index 100%
rename from css/3/pageMinichat.css
rename to styles/3/pageMinichat.css
diff --git a/css/3/pageProfileRegister.css b/styles/3/pageProfileRegister.css
similarity index 100%
rename from css/3/pageProfileRegister.css
rename to styles/3/pageProfileRegister.css
diff --git a/css/jquery.lightbox.css b/styles/jquery.lightbox.css
similarity index 100%
rename from css/jquery.lightbox.css
rename to styles/jquery.lightbox.css
-- 
2.49.0