summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf.rb8
-rwxr-xr-xindex.cgi92
-rwxr-xr-xindex.css62
-rwxr-xr-xinfos.rb48
-rwxr-xr-xlatest.cgi124
-rwxr-xr-xmenu.rb36
-rwxr-xr-xproposer.cgi54
-rwxr-xr-xtop.cgi82
8 files changed, 506 insertions, 0 deletions
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 <<HTML_BDG
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+ <head>
+ <title>BDG — Blagues de Geek</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="content-language" content="fr" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
+ <meta http-equiv="Expires" content="0" />
+ <link rel="shortcut icon" href="favicon.ico" />
+ <link rel="stylesheet" media="screen" type="text/css" title="Design" href="index.css" />
+ </head>
+ <body>
+HTML_BDG
+
+require 'menu'
+puts menu_bdg(page,subpage)
+
+puts <<HTML_BDG
+ <table id="milieu">
+ <tr>
+ <td id="gauche"><h1><a href="./">Quelques blagues au hasard</a></h1>
+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 <<HTML_BDG
+
+ <div class="Blague#{parity}">
+ <div class="titre"><h3>\##{row[0]} - #{CGI::escapeHTML(row[1])} <span class="vote">( #{row[5]} / #{row[6]} )</span></h3></div>
+ <p class="contenu">#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"<br />")}</p><p class="by">post&eacute; par #{CGI::escapeHTML(row[2])} le #{row[4]}</p>
+ </div>
+
+HTML_BDG
+
+ end
+ }
+end
+
+require 'infos'
+puts infos_bdg()
+
+puts <<HTML_BDG
+ </tr>
+ </table>
+ </body>
+</html>
+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 <a class=\"emphase\" href=\"http://speeqe.piernov.org/room/bdg/\">bdg@salons.nutritive.org</a>."
+
+ html = <<HTML_BDG
+ </td>
+ <td id="td_droite">
+ <h1>Informations</h1>
+ <div id="droite">
+ <div id="pensee"><h2>Nouvelles</h2>
+ Il y a <a href="latest.cgi">#{new_bdg} nouvelle(s) blague(s) de geek</a> aujourd'hui.
+ <hr /><h2><a href="pensee.cgi">Pens&eacute;e geek du jour : </a></h2>
+ <h4>#{pensee}</h4></div>
+
+ <div class="Principe"><h2>Qu'est ce qu'une blague de geek ? </h2>
+ 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&ecirc;me temps comprennent.
+ </div>
+
+ <div class="Principe"><h2>Qu'est ce qu'une parole de geek ? </h2>
+ Il s'agit d'un bref instantan&eacute; d'une conversation &eacute;crite. Qu'elle soit geek ou non, elle doit toujours faire rire les geeks !
+ </div>
+
+ <div class="Principe"><h2>Qu'est ce qu'une insulte de geek ? </h2>
+ 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 &agrave; prendre avec beaucoup d'humour.
+ </div>
+
+
+ <!-- Piwik -->
+ <script type="text/javascript">
+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://piernov.org/piwik/" : "http://piernov.org/piwik/");
+ document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
+ </script><script type="text/javascript">
+ try {
+ var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 4);
+ piwikTracker.trackPageView();
+ piwikTracker.enableLinkTracking();
+ } catch( err ) {}
+ </script><noscript><p><img src="http://piernov.org/piwik/piwik.php?idsite=4" style="border:0" alt="" /></p></noscript>
+ <!-- End Piwik Tracking Code -->
+
+
+ </div>
+ </td>
+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 <<HTML_BDG
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+ <head>
+ <title>BDG — Blagues de Geek</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="content-language" content="fr" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
+ <meta http-equiv="Expires" content="0" />
+ <link rel="shortcut icon" href="favicon.ico" />
+ <link rel="stylesheet" media="screen" type="text/css" title="Design" href="index.css" />
+ </head>
+ <body>
+HTML_BDG
+
+require 'menu'
+puts menu_bdg(page,subpage)
+
+puts <<HTML_BDG
+ <table id="milieu">
+ <tr>
+ <td id="gauche"><h1><a href="random.cgi">Dernières blagues ajoutés</a></h1>
+ <div id="page">
+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 <<HTML_BDG
+
+ <a class="page" href="?page=1">1</a>
+
+HTML_BDG
+end
+until i == num_page
+ i = i+1
+ if i > (page+10) and num_page/2 > 10 then
+ puts <<HTML_BDG
+
+ <a class="page" href="?page=#{(num_page+page)/2}">#{(num_page+page)/2}</a>
+
+HTML_BDG
+ break
+ elsif i > 5 and page > 5 then
+ puts <<HTML_BDG
+
+ <a class="page" href="?page=#{i-4}">#{i-4}</a>
+
+HTML_BDG
+ elsif i < 11 and page <= 5
+ puts <<HTML_BDG
+
+ <a class="page" href="?page=#{i}">#{i}</a>
+
+HTML_BDG
+ end
+end
+if num_page > 10 then
+ puts <<HTML_BDG
+
+ <a class="page" href="?page=#{num_page}">#{num_page}</a>
+
+HTML_BDG
+end
+puts"
+ </div>"
+
+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 <<HTML_BDG
+
+ <div class="Blague#{parity}">
+ <div class="titre"><h3>\##{row[0]} - #{CGI::escapeHTML(row[1])} <span class="vote">( #{row[5]} / #{row[6]} )</span></h3></div>
+ <p class="contenu">#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"<br />")}</p><p class="by">post&eacute; par #{CGI::escapeHTML(row[2])} le #{row[4]}</p>
+ </div>
+HTML_BDG
+ end
+}
+
+require 'infos'
+puts infos_bdg()
+
+puts <<HTML_BDG
+ </tr>
+ </table>
+ </body>
+</html>
+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 = <<HTML_BDG
+ <div id="header">
+ <a href="./"><img src="banner.png" alt="Blagues de Geek" /></a>
+ </div>
+
+ <div id="search">
+ <form method="get" action="search.cgi">
+ <fieldset>
+ <input type="submit" value="&gt;&gt;" />
+ <input type="text" name="q" size="15" />
+ </fieldset>
+ </form>
+ </div>
+
+ <div id="menu">
+ <a href="/">Blagues</a> |
+ <a href="tests.cgi">Tests</a> |
+ <a href="pensee.cgi">Divers</a> |
+ <a href="proposer.cgi">Proposer</a> |
+ <a href="forum/">Forum</a> |
+ <a href="http://speeqe.piernov.org/room/bdg/">Salon de discussion</a>
+ </div>
+
+ <div id="menu_blagues">
+ <a href="./">Aléatoire</a> |
+ <a href="top.cgi">Top 10</a> |
+ <a href="top.cgi?order=worst">Worst</a> |
+ <a href="latest.cgi">Derniers ajouts</a>
+ </div>
+HTML_BDG
+
+ html = html.gsub(">#{emphase}</a>", " class=\"emphase\">#{emphase}</a>")
+ html = html.gsub(">#{emphase_blagues}</a>", " class=\"emphase\">#{emphase_blagues}</a>")
+ 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 <<HTML_BDG
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+ <head>
+ <title>BDG — Blagues de Geek</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="content-language" content="fr" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
+ <meta http-equiv="Expires" content="0" />
+ <link rel="shortcut icon" href="favicon.ico" />
+ <link rel="stylesheet" media="screen" type="text/css" title="Design" href="index.css" />
+ </head>
+ <body>
+HTML_BDG
+
+require 'menu'
+puts menu_bdg(page,subpage)
+
+
+puts <<HTML_BDG
+ <table id="milieu">
+ <tr>
+ <td id="gauche"><h1><a href="proposer.cgi">Proposer une BDG</a></h1>
+HTML_BDG
+
+require 'infos'
+puts infos_bdg()
+
+puts <<HTML_BDG
+ </tr>
+ </table>
+ </body>
+</html>
+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 <<HTML_BDG
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+ <head>
+ <title>BDG — Blagues de Geek</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="content-language" content="fr" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
+ <meta http-equiv="Expires" content="0" />
+ <link rel="shortcut icon" href="favicon.ico" />
+ <link rel="stylesheet" media="screen" type="text/css" title="Design" href="index.css" />
+ </head>
+ <body>
+HTML_BDG
+
+require 'menu'
+puts menu_bdg(page,subpage)
+
+puts <<HTML_BDG
+ <table id="milieu">
+ <tr>
+ <td id="gauche"><h1><a href="top.cgi?order=#{cgi['order']}">#{subpage}</a></h1>
+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 <<HTML_BDG
+
+ <div class="Blague#{parity}">
+ <div class="titre"><h3>\##{row[0]} - #{CGI::escapeHTML(row[1])} <span class="vote">( #{row[5]} / #{row[6]} )</span></h3></div>
+ <p class="contenu">#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"<br />")}</p><p class="by">post&eacute; par #{CGI::escapeHTML(row[2])} le #{row[4]}</p>
+ </div>
+
+
+HTML_BDG
+ end
+ end
+ }
+
+require 'infos'
+puts infos_bdg()
+
+puts <<HTML_BDG
+ </tr>
+ </table>
+ </body>
+</html>
+HTML_BDG