From 7fac0f20beffe1a1b99351893add73d5eef33f2c Mon Sep 17 00:00:00 2001 From: piernov Date: Thu, 7 Mar 2013 00:08:36 +0100 Subject: Importation initiale du projet --- 404.rb | 20 ++++++++ RuDynFrame.sql | 29 ++++++++++++ comments.rb | 36 +++++++++++++++ conf.rb | 14 ++++++ footer.rb | 21 +++++++++ header.rb | 66 +++++++++++++++++++++++++++ index.cgi | 71 ++++++++++++++++++++++++++++ menu.rb | 80 ++++++++++++++++++++++++++++++++ proposer.cgi | 70 ++++++++++++++++++++++++++++ styles/msie.css | 10 ++++ styles/msie6.css | 77 +++++++++++++++++++++++++++++++ styles/nohtml5.css | 5 ++ styles/style.css | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++ styles/xhtml.xsl | 6 +++ 14 files changed, 637 insertions(+) create mode 100755 404.rb create mode 100755 RuDynFrame.sql create mode 100755 comments.rb create mode 100755 conf.rb create mode 100755 footer.rb create mode 100755 header.rb create mode 100755 index.cgi create mode 100755 menu.rb create mode 100755 proposer.cgi create mode 100644 styles/msie.css create mode 100644 styles/msie6.css create mode 100644 styles/nohtml5.css create mode 100755 styles/style.css create mode 100644 styles/xhtml.xsl diff --git a/404.rb b/404.rb new file mode 100755 index 0000000..0ef4065 --- /dev/null +++ b/404.rb @@ -0,0 +1,20 @@ +# encoding: utf-8 +def error404_tpe(page_actuelle,dest_page) + + puts < + + + Erreur 404 : Page introuvable - #{$Titre} + + + +

404 Not Found - Redirection

+

Page introuvable

+ + +HTML_TPE + +end diff --git a/RuDynFrame.sql b/RuDynFrame.sql new file mode 100755 index 0000000..512c598 --- /dev/null +++ b/RuDynFrame.sql @@ -0,0 +1,29 @@ +CREATE TABLE IF NOT EXISTS `commentaires` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_page` int(11) NOT NULL, + `auteur` varchar(64) NOT NULL, + `email` varchar(128) DEFAULT NULL, + `texte` text NOT NULL, + `date` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; + +CREATE TABLE IF NOT EXISTS `en_attente` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_page` int(11) NOT NULL, + `auteur` varchar(64) NOT NULL, + `email` varchar(128) DEFAULT NULL, + `texte` text NOT NULL, + `date` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; + +CREATE TABLE IF NOT EXISTS `pages` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `titre` varchar(128) NOT NULL, + `entree` varchar(24) NOT NULL, + `sous_menu` int(11) NOT NULL DEFAULT '0', + `contenu` text NOT NULL, + `derniere_maj` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; diff --git a/comments.rb b/comments.rb new file mode 100755 index 0000000..e58d681 --- /dev/null +++ b/comments.rb @@ -0,0 +1,36 @@ +# encoding: utf-8 +def comments_tpe(cgi,id,page,div_width) + html = < +
+

Commentaires

+
+HTML_TPE + $db.execute("SELECT auteur, texte, DATE_FORMAT(date, '%W %e %M %Y à %k:%i') as date FROM commentaires WHERE id_page=#{id}").each { |row| + html = html + < + #{row["texte"]} +
De #{row["auteur"]} le #{row["date"]}
+ +HTML_TPE + } + html.force_encoding('utf-8') + page.force_encoding('utf-8') + html = html +< +

+ :
+ :
+ :
+

+

+
+ +

+ + + +HTML_TPE + return html +end diff --git a/conf.rb b/conf.rb new file mode 100755 index 0000000..1d84cee --- /dev/null +++ b/conf.rb @@ -0,0 +1,14 @@ +# encoding: utf-8 +MySQL = { "host" => "localhost", + "db" => "RuDynFrame", + "user" => "RuDynFrame", + "passwd" => "RuDynFrame" + } + +$RepBase = "" +$Titre = "RuDynFrame" +$Commentaires = true + +$db = DBI.connect("DBI:Mysql:" + MySQL["db"] + ":" + MySQL["host"], MySQL["user"], MySQL["passwd"]) +$db.execute("SET NAMES 'utf8'") +$db.execute("SET lc_time_names = 'fr_FR'") diff --git a/footer.rb b/footer.rb new file mode 100755 index 0000000..c9e6172 --- /dev/null +++ b/footer.rb @@ -0,0 +1,21 @@ +# encoding: utf-8 +def footer_tpe(derniere_maj, derniere_maj_form) + derniere_maj_form.force_encoding('utf-8') + html = < +HTML_TPE + if derniere_maj and derniere_maj_form + html = html + <Dernière édition le #{derniere_maj_form}.
+HTML_TPE + end + html = html + <RuDynFrame.
+ Cette œuvre est mise à disposition selon les termes de la Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 3.0 France.
+ Licence Creative Commons + + + +HTML_TPE + return html +end diff --git a/header.rb b/header.rb new file mode 100755 index 0000000..89d61aa --- /dev/null +++ b/header.rb @@ -0,0 +1,66 @@ +# encoding: utf-8 +def header_tpe() + cgi = CGI.new + html = "" + if ENV['HTTP_ACCEPT'] and ENV['HTTP_ACCEPT']["application/xhtml+xml"] + html = html + < + +HTML_TPE + if ENV["HTTP_USER_AGENT"] and ENV["HTTP_USER_AGENT"]["MSIE"] + html = html + "" + end + ENV["HTTP_USER_AGENT"] =~ /Firefox\/(\d+)/ + if $1.to_i < 4 + html = html + "" + end + html = html + < + + +HTML_TPE + + else + html = html + < + + + + + +HTML_TPE + if ENV["HTTP_USER_AGENT"] =~ /MSIE [0-7]/ + html = html + < + + +HTML_TPE + end + + end + + html = html + < + #{$Titre}$titre$ + + + + +
+ +

#{$Titre}

+
+HTML_TPE + + return html, cgi +end diff --git a/index.cgi b/index.cgi new file mode 100755 index 0000000..0d02331 --- /dev/null +++ b/index.cgi @@ -0,0 +1,71 @@ +#!/usr/bin/env ruby1.9.1 +# encoding: utf-8 + +require 'rubygems' +require 'dbi' +require 'cgi' + +require './conf' +db=$db + +require './header' +header, cgi = header_tpe() + +if cgi['id'] =~ /^\d+$/ + id = cgi['id'].to_i +else + id = 10 +end + +entree = cgi['entree'].split("/") + +if cgi['entree'] != "" + page_actuelle = entree +else + page_actuelle = id +end + +require './menu' +menu, longueur_max, id, cur_page = menu_tpe(page_actuelle) +if id == 0 or (not page_actuelle.is_a?(Integer) and cur_page != cgi['entree']) + require './404' + puts error404_tpe(page_actuelle,cur_page) + exit 0 +end + +titre = "Pas de titre" +contenu = "Pas de contenu" +derniere_maj = "" +derniere_maj_form = "" + +db.execute("SELECT titre, entree, contenu, derniere_maj, DATE_FORMAT(derniere_maj, '%W %e %M %Y à %k:%i') as derniere_maj_form FROM pages WHERE id=#{id}").each { |row| titre, entree, contenu, derniere_maj, derniere_maj_form = row} + +header["$titre$"] = " - " + titre + +puts header + +menu["$width$"] = (0.66*longueur_max).to_s() +div_width = (0.66*longueur_max+3).to_s() + +puts menu + +if ENV["HTTP_USER_AGENT"] =~ /MSIE [0-7]/ + contenu = contenu.gsub(".svg", ".png") +end + +puts < +
+

#{titre}

+
+ #{contenu} + +HTML_TPE + +if $Commentaires + require './comments' + puts comments_tpe(cgi,id,cur_page,div_width) +end + +require './footer' +puts footer_tpe(derniere_maj, derniere_maj_form) diff --git a/menu.rb b/menu.rb new file mode 100755 index 0000000..6471254 --- /dev/null +++ b/menu.rb @@ -0,0 +1,80 @@ +# encoding: utf-8 +def menu_tpe(page_actuelle) + + html = < + +HTML_TPE + dans_sous_menu = 0 + dans_bon_sous_menu = 0 + lien = "" + cur_page = "" + if page_actuelle.is_a?(Integer) + id = page_actuelle + else + id = 0 + end + longueur_max = 0 + $db.execute("SELECT id, entree, sous_menu FROM pages ORDER BY id").each { |entree| + entree["entree"].force_encoding('utf-8') + longueur = entree["entree"].length + entree["sous_menu"]*3 + + if longueur > longueur_max + longueur_max = longueur + end + + if entree["sous_menu"] < dans_sous_menu + lien = lien.rpartition('/')[0] + html = html + " \n"*(dans_sous_menu-entree["sous_menu"]) + end + + if entree["sous_menu"] > dans_sous_menu + html = html + "
    \n" + else + lien = lien.rpartition('/')[0] + end + + if lien != "" + lien = lien + "/" + entree["entree"] + else + lien = entree["entree"] + end + + if page_actuelle.is_a?(Integer) + if entree["id"] == page_actuelle + cur_page = lien + html = html + "
  • #{entree["entree"]}
  • \n" + else + html = html + "
  • #{entree["entree"]}
  • \n" + end + else + + if entree["sous_menu"] < dans_bon_sous_menu + dans_bon_sous_menu = entree["sous_menu"] + end + + if page_actuelle[entree["sous_menu"]] == entree["entree"] and entree["sous_menu"] == dans_bon_sous_menu + dans_bon_sous_menu = entree["sous_menu"]+1 + id = entree["id"] + end + + if entree["entree"] == page_actuelle[entree["sous_menu"]] + cur_page = lien + html = html + "
  • #{entree["entree"]}
  • \n" + else + html = html + "
  • #{entree["entree"]}
  • \n" + end + end + dans_sous_menu = entree["sous_menu"] + } + until dans_sous_menu == 0 + html = html + "
\n" + dans_sous_menu -= 1 + end + + html = html + < + +HTML_TPE + return html, longueur_max, id, cur_page +end diff --git a/proposer.cgi b/proposer.cgi new file mode 100755 index 0000000..e7821a7 --- /dev/null +++ b/proposer.cgi @@ -0,0 +1,70 @@ +#!/usr/bin/env ruby1.9.1 +# encoding: utf-8 + +require 'rubygems' +require 'dbi' +require 'cgi' + +require './conf' +db=$db + +require './header' +header, cgi = header_tpe() + +pseudo=CGI.escapeHTML(cgi['pseudo']) or "Pseudo" +email=CGI.escapeHTML(cgi['email']) or "E-mail" +page=CGI.escapeHTML(cgi['page']) or "Inconnue" +texte=CGI.escapeHTML(cgi['texte']) or "" + +if page =~ /^\d+$/ + id = page.to_i + page_actuelle = id +elsif page != "" + entree = page.split("/") + page_actuelle = entree +else + id = 0 + page_actuelle = 0 +end + +require './menu' +menu, longueur_max, id, page = menu_tpe(page_actuelle) + +titre = "Pas de titre" +contenu = "Pas de contenu" +derniere_maj = "" +derniere_maj_form = "" + +db.execute("SELECT titre, entree, contenu, derniere_maj, DATE_FORMAT(derniere_maj, '%W %e %M %Y à %k:%i') as derniere_maj_form FROM pages WHERE id=#{id}").each { |row| titre, entree, contenu, derniere_maj, derniere_maj_form = row} + +header["$titre$"] = " - " + titre + +puts header + +menu["$width$"] = (0.64*longueur_max).to_s() +div_width = (0.64*longueur_max+3).to_s() + +puts menu + +if pseudo != "" and email != "" and id > 0 and page.split("/").last == entree and texte != "" then +puts < +
+

Commentaires

+
+
+Pseudo : #{pseudo}
+E-Mail : #{email}
+Page : #{page}
+Texte : #{texte}
+
+ +HTML_TPE +texte.gsub!("\n", "
") +db.do("INSERT INTO en_attente (id_page, auteur, email, texte, date) VALUES(?, ?, ?, ?, NOW())", id, pseudo, email, texte) +else +puts "Erreur lors de l'envoi du commentaire." +end + +require './footer' +puts footer_tpe(derniere_maj, derniere_maj_form) diff --git a/styles/msie.css b/styles/msie.css new file mode 100644 index 0000000..409e8a0 --- /dev/null +++ b/styles/msie.css @@ -0,0 +1,10 @@ +menu { + font-size: 1.0em +} + +menu li { + font-size: 0.5em +} +menu li a, menu li a:visited { + font-size: 2.0em +} diff --git a/styles/msie6.css b/styles/msie6.css new file mode 100644 index 0000000..753643b --- /dev/null +++ b/styles/msie6.css @@ -0,0 +1,77 @@ +body header { + margin-left: 20em; +} + +body header h1 { + text-align: left; + margin-top: 0.5em; +} + +body header a { + float: right; + font-family: Monospace; + font-size: 1.4em; + background-color: #DDDDFF; + margin: 0em; + border-style: solid; + border-width: 0 0 1px 1px; + border-color: black; + border-radius: 0 0 0 1em; + padding: 0.5em; +} + +menu a { + font-size: 0.8em; +} + +menu li { + list-style-type: none; +} + +menu ul li { + list-style-type: square; +} + +body article { + background-color: #DDDDFF; + border: 1px solid; + border-radius: 1em; + padding: 0 1em 1em 1em; +} + +body article header { + margin-left: 0; +} + +body > article > table { + border: 1px solid black; + border-collapse: collapse; +} + +body article table tr th { + border: 1px solid black; + background-color: silver; +} + +body article table tr td { + border: 1px solid black; +} + +body article ul li { + margin-bottom: 1em; +} + +body article footer { + text-align: left; +} + +body section header { + margin-left: 0; +} + +body footer { + color: grey; + text-align: center; + font-size: 0.75em; + margin-top: 1em; +} diff --git a/styles/nohtml5.css b/styles/nohtml5.css new file mode 100644 index 0000000..21c18df --- /dev/null +++ b/styles/nohtml5.css @@ -0,0 +1,5 @@ +/* Make HTML 5 elements display block-level for consistent styling */ +header, nav, article, section, footer, address { + display: block; +} + diff --git a/styles/style.css b/styles/style.css new file mode 100755 index 0000000..01d59d8 --- /dev/null +++ b/styles/style.css @@ -0,0 +1,132 @@ +body { + background-color: #EDEDFF; + font-family: Sans-Serif; + margin-top: 0; + margin-right: 0; +} + +a { + text-decoration: none; + color: blue; +} + +a:visited { + color: blue; +} + +a:hover { + color: #5555DD; +} + +a img { + border: none; +} + +body > header { + margin-left: 20em; +} + +body > header > h1 { + text-align: left; + display:inline-block; +} + +body > header > a { + float: right; + font-family: Monospace; + font-size: 1.4em; + background-color: #DDDDFF; + margin: 0em; + border-style: solid; + border-width: 0 0 1px 1px; + border-color: black; + border-radius: 0 0 0 1em; + padding: 0.5em 0.5em 1em 1em; + +} + +menu { + font-family: Monospace; + font-size: 1.2em; + background-color: #DDDDFF; + margin: 0em; + border: 1px solid; + border-radius: 1em; + float:left; + padding: 1em; +} + +menu > li { + list-style-type: none; +} + +menu > ul > li { + list-style-type: square; +} + +.emphase, .emphase:visited { + color:#D53030 +} + +.emphase:hover { + color:#F55050 +} + +body > article { + background-color: #DDDDFF; + border: 1px solid; + border-radius: 1em; + padding: 0 1em 1em 1em; +} + +body > article > ul > li { + margin-bottom: 1em; +} + +body > article > table { + border: 1px solid black; + border-collapse: collapse; +} + +body > article > table > tr > th { + border: 1px solid black; + background-color: silver; +} + +body > article > table > tr > td { + border: 1px solid black; +} + +body > footer { + color: grey; + text-align: center; + font-size: 0.75em; + margin-top: 1em; +} + +#comments { + background-color: #DDDDFF; + border: 1px solid; + border-radius: 1em; + padding: 1em; + margin-top: 1em; +} + +.comments { + background-color: #DDDDFF; + border: 1px solid; + border-radius: 1em; + padding: 1em; + margin-top: 1em; +} + +.comments footer { + color: #444444; + font-size: 0.75em; + margin: 1em 0 0 2em; +} + +textarea { + width: 100%; + overflow: auto; +} diff --git a/styles/xhtml.xsl b/styles/xhtml.xsl new file mode 100644 index 0000000..9f28863 --- /dev/null +++ b/styles/xhtml.xsl @@ -0,0 +1,6 @@ + + + -- cgit v1.2.3-70-g09d2