summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2013-03-07 00:08:36 +0100
committerpiernov <piernov@piernov.org>2013-03-07 00:08:36 +0100
commit7fac0f20beffe1a1b99351893add73d5eef33f2c (patch)
tree162c2ff1b2aa0709c2de26d0399106b1a5368708
downloadRuDynFrame-master.tar.gz
RuDynFrame-master.tar.bz2
RuDynFrame-master.tar.xz
RuDynFrame-master.zip
Importation initiale du projetHEADmaster
-rwxr-xr-x404.rb20
-rwxr-xr-xRuDynFrame.sql29
-rwxr-xr-xcomments.rb36
-rwxr-xr-xconf.rb14
-rwxr-xr-xfooter.rb21
-rwxr-xr-xheader.rb66
-rwxr-xr-xindex.cgi71
-rwxr-xr-xmenu.rb80
-rwxr-xr-xproposer.cgi70
-rw-r--r--styles/msie.css10
-rw-r--r--styles/msie6.css77
-rw-r--r--styles/nohtml5.css5
-rwxr-xr-xstyles/style.css132
-rw-r--r--styles/xhtml.xsl6
14 files changed, 637 insertions, 0 deletions
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 <<HTML_TPE
+Status: 404 Not Found
+
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Erreur 404 : Page introuvable - #{$Titre}</title>
+ <meta http-equiv="refresh" content="0;URL='#{$RepBase}/#{dest_page}'">
+ </head>
+ <body>
+ <h1>404 Not Found - Redirection</h1>
+ <h2>Page introuvable</h2>
+ </body>
+</html>
+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 = <<HTML_TPE
+ <section id="comments" style="margin-left:#{div_width}em">
+ <header>
+ <h3>Commentaires</h3>
+ </header>
+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 + <<HTML_TPE
+
+ <article class="comments">
+ #{row["texte"]}
+ <footer>De #{row["auteur"]} le #{row["date"]}</footer>
+ </article>
+HTML_TPE
+ }
+ html.force_encoding('utf-8')
+ page.force_encoding('utf-8')
+ html = html +<<HTML_TPE
+ <form method="post" action="#{$RepBase}/proposer.cgi" id="proposer" class="comments">
+ <p style="text-align:left">
+ <label for="page">Page</label> : <input type="text" name="page" id="page" value="#{page}" size="30" readonly="true" /><br />
+ <label for="pseudo">Pseudo</label> : <input type="text" name="pseudo" id="pseudo" placeholder="pseudo" size="32" maxlength="48" autofocus="autofocus" required="required" /><br />
+ <label for="email">Adresse e-mail</label> : <input type="email" name="email" id="email" placeholder="email" size="48" maxlength="92" required="required" /><br />
+ </p>
+ <p>
+ <label for="texte">Texte : </label><br />
+ <textarea name="texte" id="texte" rows="8" required="required">texte</textarea>
+ </p>
+ <input type="submit" value="Envoyer" />
+ </form>
+ </section>
+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
+ <footer>
+HTML_TPE
+ if derniere_maj and derniere_maj_form
+ html = html + <<HTML_TPE
+ <time datetime="#{derniere_maj}" pubdate="pubdate">Dernière édition le #{derniere_maj_form}.</time><br />
+HTML_TPE
+ end
+ html = html + <<HTML_TPE
+ Site web propulsé par <a href="http://piernov.org/git/RuDynFrame">RuDynFrame</a>.<br />
+ Cette œuvre est mise à disposition selon les termes de la <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/fr/">Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 3.0 France</a>.<br />
+ <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/fr/"><img alt="Licence Creative Commons" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/fr/80x15.png" /></a>
+ </footer>
+ </body>
+</html>
+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
+Vary: Accept
+Content-type: application/xhtml+xml
+
+<?xml version="1.0" encoding="UTF-8" ?>
+<?xml-stylesheet href="#{$RepBase}/styles/style.css"?>
+HTML_TPE
+ if ENV["HTTP_USER_AGENT"] and ENV["HTTP_USER_AGENT"]["MSIE"]
+ html = html + "<?xml-stylesheet href=\"#{$RepBase}/styles/msie.css\"?>"
+ end
+ ENV["HTTP_USER_AGENT"] =~ /Firefox\/(\d+)/
+ if $1.to_i < 4
+ html = html + "<?xml-stylesheet href=\"#{$RepBase}/styles/nohtml5.css\"?>"
+ end
+ html = html + <<HTML_TPE
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
+ <head>
+HTML_TPE
+
+ else
+ html = html + <<HTML_TPE
+Vary: Accept
+Content-type: application/xml
+
+<?xml version="1.0" encoding="UTF-8" ?>
+<?xml-stylesheet type="text/xsl" href="#{$RepBase}/styles/xhtml.xsl"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
+ <head>
+ <link rel="stylesheet" href="#{$RepBase}/styles/style.css" />
+HTML_TPE
+ if ENV["HTTP_USER_AGENT"] =~ /MSIE [0-7]/
+ html = html + <<HTML_TPE
+ <link rel="stylesheet" href="#{$RepBase}/styles/nohtml5.css" />
+ <link rel="stylesheet" href="#{$RepBase}/styles/msie6.css" />
+ <script>document.createElement("header");
+ document.createElement("nav");
+ document.createElement("article");
+ document.createElement("section");
+ document.createElement("footer");</script>
+HTML_TPE
+ end
+
+ end
+
+ html = html + <<HTML_TPE
+ <link rel="shortcut icon" type="image/x-icon" href="#{$RepBase}favicon.ico" />
+ <title>#{$Titre}$titre$</title>
+ <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
+ <meta http-equiv="Content-Language" content="fr" />
+ </head>
+ <body>
+ <header>
+<!-- <a href="#{$RepBase}/connexion.cgi">Connexion</a>-->
+ <h1>#{$Titre}</h1>
+ </header>
+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 <<HTML_TPE
+ <article style="margin-left:#{div_width}em">
+ <header>
+ <h1>#{titre}</h1>
+ </header>
+ #{contenu}
+ </article>
+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
+ <nav id="menubar">
+ <menu id="menu" style="width: $width$em">
+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 + " </ul>\n"*(dans_sous_menu-entree["sous_menu"])
+ end
+
+ if entree["sous_menu"] > dans_sous_menu
+ html = html + " <ul>\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 + " <li><a href=\"#{$RepBase}/#{lien}\" class=\"emphase\">#{entree["entree"]}</a></li>\n"
+ else
+ html = html + " <li><a href=\"#{$RepBase}/#{lien}\">#{entree["entree"]}</a></li>\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 + " <li><a href=\"#{$RepBase}/#{lien}\" class=\"emphase\">#{entree["entree"]}</a></li>\n"
+ else
+ html = html + " <li><a href=\"#{$RepBase}/#{lien}\">#{entree["entree"]}</a></li>\n"
+ end
+ end
+ dans_sous_menu = entree["sous_menu"]
+ }
+ until dans_sous_menu == 0
+ html = html + " </ul>\n"
+ dans_sous_menu -= 1
+ end
+
+ html = html + <<HTML_TPE
+ </menu>
+ </nav>
+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 <<HTML_TPE
+<section id="comments" style="margin-left:#{div_width}em">
+ <header>
+ <h3>Commentaires</h3>
+ </header>
+<pre>
+Pseudo : #{pseudo}
+E-Mail : #{email}
+Page : #{page}
+Texte : #{texte}
+</pre>
+</section>
+HTML_TPE
+texte.gsub!("\n", "<br />")
+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 @@
+<stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/XSL/Transform">
+ <template match="/">
+ <copy-of select="."/>
+ </template>
+</stylesheet>