summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.servegame.org>2012-10-21 21:40:48 +0200
committerpiernov <piernov@piernov.servegame.org>2012-10-21 21:40:48 +0200
commit9e5495e169ef0cb888a91a1ead62bc81e1b2bdba (patch)
tree91d54cbf14deec05c027e9c204997b2c04185957
parent8a03b03fb21e168ace1c5424967d0e6ddbc6c7cc (diff)
downloadbdg-master.tar.gz
bdg-master.tar.bz2
bdg-master.tar.xz
bdg-master.zip
Correction encodage UTF-8, correction pageur + ajout champ séléction page latest.cgiHEADmaster
-rw-r--r--conf.rb2
-rwxr-xr-xheader.rb4
-rwxr-xr-xindex.cgi2
-rwxr-xr-xindex.css16
-rwxr-xr-xlatest.cgi26
5 files changed, 37 insertions, 13 deletions
diff --git a/conf.rb b/conf.rb
index f855594..e031265 100644
--- a/conf.rb
+++ b/conf.rb
@@ -5,4 +5,4 @@ MySQL = { "host" => "localhost",
}
$db = DBI.connect("DBI:Mysql:" + MySQL["db"] + ":" + MySQL["host"], MySQL["user"], MySQL["passwd"])
-
+$db.execute("SET NAMES 'utf8'")
diff --git a/header.rb b/header.rb
index 51c3a85..10095ce 100755
--- a/header.rb
+++ b/header.rb
@@ -9,7 +9,7 @@ def header_bdg()
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
- <title>BDG — Blagues de Geek</title>
+ <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" />
@@ -21,4 +21,4 @@ def header_bdg()
<body>
HTML_BDG
return html
-end \ No newline at end of file
+end
diff --git a/index.cgi b/index.cgi
index 177054f..8084011 100755
--- a/index.cgi
+++ b/index.cgi
@@ -36,7 +36,7 @@ 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|
+db.execute("SELECT id,titre,auteur,blague,DATE_FORMAT(date_post, '%e/%c/%Y'),voteplus,voteminus FROM blague WHERE ID=#{rand(total)+1}").each { |row|
if displayed["#{row[0]}"] == true
next
else
diff --git a/index.css b/index.css
index 84bc78c..c846d47 100755
--- a/index.css
+++ b/index.css
@@ -46,17 +46,27 @@ fieldset{border:none}
#search form input{ background:#EFEFEF;
color:#000000;
border: 0.1em solid #555555 }
+
+#pageq{ position: relative}
+
+#pageq form{ float :right;
+ margin: 0.8em 2em 0 0}
+
+#pageq 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}
+#page{border:0.1em solid #555555;background:#DDDDDD; padding: 0.5em 0 0.5em 11em; margin:2em; height:auto; width:auto}
+.page{border:0.1em solid #555555;background:#000000; color:#FFFFFF; padding:0.2em; font-size:1.3em}
.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
+.by{font-style:italic}
diff --git a/latest.cgi b/latest.cgi
index 30ee24a..18ba1e5 100755
--- a/latest.cgi
+++ b/latest.cgi
@@ -14,7 +14,7 @@ require 'header'
puts header_bdg()
cgi=$cgi
-if cgi['page'] =~ /\d*/
+if cgi['page'] =~ /\d+/
current_page = cgi['page'].to_i
else
current_page = 1
@@ -27,13 +27,27 @@ puts <<HTML_BDG
<table id="milieu">
<tr>
<td id="gauche"><h1><a href="latest.cgi">Dernières blagues ajoutés</a></h1>
- <div id="page">
+
+ <div id="pageq">
+ <form method="get" action="latest.cgi">
+ <fieldset>
+ <input type="submit" value="&gt;&gt;" />
+ <input type="text" name="page" size="15" />
+ </fieldset>
+ </form>
+ </div>
+ <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 = 0
+db.execute("SELECT count(id) FROM blague").each { |row| num_page = row[0].to_s.chop.to_i+1 }
+
+if current_page > num_page then
+ current_page = num_page
+end
+
-num_page = ((num_bdg+11)/10+1)
i = 0
if current_page > 5 then
i = current_page
@@ -77,7 +91,7 @@ puts"
</div>"
i = 0
-db.execute("SELECT * FROM blague WHERE id < ((SELECT id FROM blague ORDER BY id DESC LIMIT 1)-#{(current_page*10)-11}) ORDER BY id DESC LIMIT 10").each { |row|
+db.execute("SELECT * FROM blague WHERE id <= #{current_page-1}9 AND id >= #{current_page-1}0 ORDER BY id DESC LIMIT 10").each { |row|
unless row[1] == ""
if i.modulo(2) == 1
parity = " impair"