From 9e5495e169ef0cb888a91a1ead62bc81e1b2bdba Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 21 Oct 2012 21:40:48 +0200 Subject: Correction encodage UTF-8, correction pageur + ajout champ séléction page latest.cgi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf.rb | 2 +- header.rb | 4 ++-- index.cgi | 2 +- index.css | 16 +++++++++++++--- latest.cgi | 26 ++++++++++++++++++++------ 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() - BDG — Blagues de Geek + BDG — Blagues de Geek @@ -21,4 +21,4 @@ def header_bdg() 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 <

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 = 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"
" 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" -- cgit v1.2.3-54-g00ecf