From 2df4c55788261bf9efd40bc31047885683f948f6 Mon Sep 17 00:00:00 2001 From: piernov Date: Fri, 19 Oct 2012 19:16:23 +0200 Subject: Initialisation du dépôt. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf.rb | 8 ++++ index.cgi | 92 ++++++++++++++++++++++++++++++++++++++++++++ index.css | 62 ++++++++++++++++++++++++++++++ infos.rb | 48 +++++++++++++++++++++++ latest.cgi | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ menu.rb | 36 +++++++++++++++++ proposer.cgi | 54 ++++++++++++++++++++++++++ top.cgi | 82 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 506 insertions(+) create mode 100644 conf.rb create mode 100755 index.cgi create mode 100755 index.css create mode 100755 infos.rb create mode 100755 latest.cgi create mode 100755 menu.rb create mode 100755 proposer.cgi create mode 100755 top.cgi diff --git a/conf.rb b/conf.rb new file mode 100644 index 0000000..f855594 --- /dev/null +++ b/conf.rb @@ -0,0 +1,8 @@ +MySQL = { "host" => "localhost", + "db" => "bdg_dev", + "user" => "bdg_dev", + "passwd" => "bdg_dev" + } + +$db = DBI.connect("DBI:Mysql:" + MySQL["db"] + ":" + MySQL["host"], MySQL["user"], MySQL["passwd"]) + diff --git a/index.cgi b/index.cgi new file mode 100755 index 0000000..5cd81ac --- /dev/null +++ b/index.cgi @@ -0,0 +1,92 @@ +#!/usr/bin/ruby + +require 'rubygems' +require 'dbi' +require 'cgi' + +require 'conf' +db=$db + +page="Blagues" +subpage="Aléatoire" + +cgi = CGI.new +puts cgi.header + +puts < + + + + + BDG — Blagues de Geek + + + + + + + + + +HTML_BDG + +require 'menu' +puts menu_bdg(page,subpage) + +puts < + +

Quelques blagues au hasard

+HTML_BDG + +total = 0 +db.execute("SELECT COUNT(*) FROM blague").each { |row| total = row[0] } + +if total < 5 + count = total +else + count = 5 +end + +displayed = Hash.new() + +i = 0 +until i == count +db.execute("SELECT id,titre,auteur,blague,DATE_FORMAT(date_post, '%e/%c/%Y'),voteplus,votetotal FROM blague WHERE ID=#{rand(total)+1}").each { |row| + if displayed["#{row[0]}"] == true + next + else + displayed["#{row[0]}"] = true + end + + unless row[1] == "" + if i.modulo(2) == 1 + parity = " impair" + else + parity = "" + end + i += 1 + puts < +

\##{row[0]} - #{CGI::escapeHTML(row[1])} ( #{row[5]} / #{row[6]} )

+

#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"
")}

posté par #{CGI::escapeHTML(row[2])} le #{row[4]}

+ + +HTML_BDG + + end + } +end + +require 'infos' +puts infos_bdg() + +puts < + + + +HTML_BDG diff --git a/index.css b/index.css new file mode 100755 index 0000000..84bc78c --- /dev/null +++ b/index.css @@ -0,0 +1,62 @@ +body{ font-size:0.7em; + font-family:arial,tahoma,serif; + text-align: center } + +img{ border:none } + +a{ color:#1D1D1D; + text-decoration:none; + font-weight:bold } + +a:hover{color:#909090} + +fieldset{border:none} + +#header{ font-size:7em } + +#menu{ width:auto; + margin:0.5em; + margin-left:-0.6em; + margin-right:-0.6em; + padding:0.8em 0; + background:#DDDDDD; + border:0.15em solid #555555; + border-left: 0; + border-right:0} + +#menu_blagues{ width:auto; + margin:0.5em; + margin-left:-0.6em; + margin-right:-0.6em; + padding:0.8em; + padding-right:18em; + background:#DDDDDD; + border:0.15em solid #555555; + border-left: 0; + border-right:0} + +.emphase{color:#d53030} +.emphase:hover{color:#f55050} + +#search{ position: relative} + +#search form{ float :right; + margin: 0.8em } + +#search form input{ background:#EFEFEF; + color:#000000; + border: 0.1em solid #555555 } +#milieu{width:100%;margin:0 0%} +#gauche{width:55%} +#td_droite{vertical-align:top; } +#droite{padding:0 2em; border:0.1em solid #999999;background:#EEEEEE;text-align: justify} +#droite h2{text-align: center} +#pensee{border:0.1em solid #555555;background:#DDDDDD; padding:0 2em 0.8em; margin:2em} +#page{border:0.1em solid #555555;background:#DDDDDD; padding: 1em; margin:2em; height:auto; width:auto} +.page{border:0.1em solid #555555;background:#000000; color:#FFFFFF; padding:0.1em; margin:2; width:2em; height:2em} +.Principe{border:0.1em solid #555555;background:#DDDDDD; padding:0 2em 0.8em; margin:1em} +.titre{border:0.1em solid #555555; background:#DDDDDD} +.Blague{padding:1em 0.5em 0.5em; margin:0.5em 1em; border:0.1em solid #999999;background:#F9F9F9} +.impair {background:#E9E9E9} +.vote {font-size:0.7em; float:right; padding-right:2em; color:#770000} +.by{font-style:italic} \ No newline at end of file diff --git a/infos.rb b/infos.rb new file mode 100755 index 0000000..27acb18 --- /dev/null +++ b/infos.rb @@ -0,0 +1,48 @@ +def infos_bdg() + new_bdg = 0 + $db.execute("SELECT COUNT(*) FROM blague WHERE date_post = CURDATE()").each { |row| new_bdg = row[0] } + pensee="Rejoignez-nous sur notre salon Jabber à l'adresse bdg@salons.nutritive.org." + + html = < + +

Informations

+
+

Nouvelles

+ Il y a #{new_bdg} nouvelle(s) blague(s) de geek aujourd'hui. +

Pensée geek du jour :

+

#{pensee}

+ +

Qu'est ce qu'une blague de geek ?

+ C'est tout simplement une blague pour les 1337, une blague que personne d'autre que ceux qui savent lire en binaire, coder en hexa et manger de la pizza en même temps comprennent. +
+ +

Qu'est ce qu'une parole de geek ?

+ Il s'agit d'un bref instantané d'une conversation écrite. Qu'elle soit geek ou non, elle doit toujours faire rire les geeks ! +
+ +

Qu'est ce qu'une insulte de geek ?

+ Une insulte de geek est une courte phrase, parfois quelques mots seulements, qui peuvent blesser un geek au plus profond de son kernel. Le tout est à prendre avec beaucoup d'humour. +
+ + + + + + + +
+ +HTML_BDG + + return html +end diff --git a/latest.cgi b/latest.cgi new file mode 100755 index 0000000..22bb34a --- /dev/null +++ b/latest.cgi @@ -0,0 +1,124 @@ +#!/usr/bin/ruby + +require 'rubygems' +require 'dbi' +require 'cgi' + +require 'conf' +db=$db + +page="Blagues" +subpage="Derniers ajouts" + +cgi = CGI.new +puts cgi.header + +if cgi['page'] =~ /\d*/ + page = cgi['page'].to_i +else + page = 1 +end + +puts < + + + + + BDG — Blagues de Geek + + + + + + + + + +HTML_BDG + +require 'menu' +puts menu_bdg(page,subpage) + +puts < + +

Dernières blagues ajoutés

+
+HTML_BDG + +num_bdg = 0 +db.execute("SELECT count(id) FROM blague").each { |row| num_bdg = row[0].to_i } + +num_page = ((num_bdg+11)/10+1) +i = 0 +if page > 5 then + i = page + puts <1 + +HTML_BDG +end +until i == num_page + i = i+1 + if i > (page+10) and num_page/2 > 10 then + puts <#{(num_page+page)/2} + +HTML_BDG + break + elsif i > 5 and page > 5 then + puts <#{i-4} + +HTML_BDG + elsif i < 11 and page <= 5 + puts <#{i} + +HTML_BDG + end +end +if num_page > 10 then + puts <#{num_page} + +HTML_BDG +end +puts" +
" + +i = 0 +db.execute("SELECT * FROM blague WHERE id < ((SELECT id FROM blague ORDER BY id DESC LIMIT 1)-#{(page*10)-11}) ORDER BY id DESC LIMIT 10").each { |row| + unless row[1] == "" + if i.modulo(2) == 1 + parity = " impair" + else + parity = "" + end + i = i + 1 + puts < +

\##{row[0]} - #{CGI::escapeHTML(row[1])} ( #{row[5]} / #{row[6]} )

+

#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"
")}

posté par #{CGI::escapeHTML(row[2])} le #{row[4]}

+ +HTML_BDG + end +} + +require 'infos' +puts infos_bdg() + +puts < + + + +HTML_BDG diff --git a/menu.rb b/menu.rb new file mode 100755 index 0000000..23c89d9 --- /dev/null +++ b/menu.rb @@ -0,0 +1,36 @@ +def menu_bdg(emphase, emphase_blagues) + html = < + Blagues de Geek + + + + + + + +HTML_BDG + + html = html.gsub(">#{emphase}", " class=\"emphase\">#{emphase}") + html = html.gsub(">#{emphase_blagues}", " class=\"emphase\">#{emphase_blagues}") + return html +end diff --git a/proposer.cgi b/proposer.cgi new file mode 100755 index 0000000..417a950 --- /dev/null +++ b/proposer.cgi @@ -0,0 +1,54 @@ +#!/usr/bin/ruby + +require 'rubygems' +require 'dbi' +require 'cgi' + +require 'conf' +db=$db + +page="Proposer" +subpage="Proposer" + +cgi = CGI.new +puts cgi.header + +puts < + + + + + BDG — Blagues de Geek + + + + + + + + + +HTML_BDG + +require 'menu' +puts menu_bdg(page,subpage) + + +puts < + +

Proposer une BDG

+HTML_BDG + +require 'infos' +puts infos_bdg() + +puts < + + + +HTML_BDG + diff --git a/top.cgi b/top.cgi new file mode 100755 index 0000000..df6424f --- /dev/null +++ b/top.cgi @@ -0,0 +1,82 @@ +#!/usr/bin/ruby + +require 'rubygems' +require 'dbi' +require 'cgi' + +require 'conf' +db=$db + +order = "-" +page="Blagues" +subpage="Top 10" + +cgi = CGI.new + +if cgi['order'] == "worst" + order = "+" + subpage="Worst" +end + +puts cgi.header + +puts < + + + + + BDG — Blagues de Geek + + + + + + + + + +HTML_BDG + +require 'menu' +puts menu_bdg(page,subpage) + +puts < + +

#{subpage}

+HTML_BDG + +i = 0 +db.execute("SELECT * FROM blague").sort_by { |row| eval "#{order + "row" + '[5]'}" }.each { |row| + unless i == 10 + unless row[1] == "" + if i.modulo(2) == 1 + parity = " impair" + else + parity = "" + end + i += 1 + puts < +

\##{row[0]} - #{CGI::escapeHTML(row[1])} ( #{row[5]} / #{row[6]} )

+

#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"
")}

posté par #{CGI::escapeHTML(row[2])} le #{row[4]}

+ + + +HTML_BDG + end + end + } + +require 'infos' +puts infos_bdg() + +puts < + + + +HTML_BDG -- cgit v1.2.3-70-g09d2