patch de Guill ajoutant une vue en vignettes

This commit is contained in:
nojhan 2008-05-12 18:58:31 +00:00
commit bd9eb1f070
8 changed files with 214 additions and 0 deletions

View file

@ -9,3 +9,10 @@ P:Simon
E:contact@leblanc-simon.eu
D:2007-12
C:internationalisation, limitation items RSS, bugfixes
N:Guillaume Duhamel
P:Guill
E:guillaume.duhamel@gmail.com
D:2008-05
C:Galerie de vignettes

View file

@ -1,4 +1,5 @@
SVN :
* ajout d'une vue en vignettes
* possibilité d'ajouter des commentaires avec PunBB (http://www.punbb.org)
* légères modifications du template

View file

@ -87,6 +87,11 @@ class configuration
* HTML template to use
*/
var $template_html = 'template_default.html';
/**
* Number of thumbnails per gallery page
*/
var $thumbs_per_page = 5;
}
?>

120
gallery.php Normal file
View file

@ -0,0 +1,120 @@
<?php
/**
* Strip-It Gallery manager (based on RSS manager)
*
* @author Johann "nojhan" Dréo <nojhan@gmail.com>
* @license http://www.gnu.org/licenses/gpl.html GPL
* @copyright 2007 Johann Dréo
*
* @package stripit
*/
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd());
require_once 'strip_manager.php';
require_once 'configuration.php';
// hack for passing objects by values instead of reference under PHP5 (but not PHP4)
// damn clone keyword !
if (version_compare(phpversion(), '5.0') < 0) {
eval('function clone($object) {return $object;}');
}
/**
* Gallery manager
*/
class gallery_manager
{
/**
* Items list
* @var array
*/
var $items_list = array();
/**
* Configuration
* @var array
*/
var $general;
var $nav_base_url = "gallery.php?page=";
/**
* Constructor
*
* Use the {@link strip_manager} to do the stuff, and convert date from the iso8601 to RFC822 format.
*/
function gallery_manager() {
//$this->general = new configuration;
$sm = new strip_manager();
$this->general = $sm->general;
$this->lang = $sm->lang;
$sm->strips_list_get();
// limit the number of strips in Gallery
$limit = $this->general->thumbs_per_page;
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
$limit = $_GET['limit'];
if ($limit <= 0) {
$limit = $this->general->thumbs_per_page;
}
}
$lastpage = intval(($sm->strips_count - 1) / $limit);
if( !isset($_GET['page']) || $_GET['page'] == '' || !is_numeric($_GET['page']) ) {
$element_asked = 0;
} else {
$element_asked = $_GET['page'];
if ($element_asked < 0) {
$element_asked = 0;
}
if ($element_asked > $lastpage) {
$element_asked = $lastpage;
}
}
$start = $element_asked * $limit;
$end = $start + $limit;
if ($end > $sm->strips_count) {
$end = $sm->strips_count;
}
for( $i = $start; $i < $end; $i++ ) {
$sm->strip_info_get( $i );
$this->items_list[] = clone($sm); // hack for php4/5 compat
}
$this->nav_prev = $this->nav_base_url . ($element_asked - 1) . "&limit=$limit";
$this->nav_next = $this->nav_base_url . ($element_asked + 1) . "&limit=$limit";
$this->nav_last = $this->nav_base_url . $lastpage . "&limit=$limit";
$this->nav_first = $this->nav_base_url . "&limit=$limit";
}
/**
* Generate the Gallery output with the template engine.
*/
function generate() {
$sm = new strip_manager;
$output = new HTML_Template_Flexy($sm->options);
$output->compile('template_gallery_default.html');
$output->outputObject($this,$this->items_list);
}
}
/**
* Instanciation and output.
*/
$gallerym = new gallery_manager();
$gallerym->generate();
?>

View file

@ -80,6 +80,10 @@ class strip_manager
* URL of the displayed file
*/
var $img_src ='';
/**
* URL of the thumbnail
*/
var $thumbnail ='';
/**
* Title
*/
@ -260,6 +264,7 @@ class strip_manager
// change the extension for {@link $img_src}
$png = explode( '.', $file);
$this->img_src = $this->strips_path.'/'.$png[0].'.png';
$this->thumbnail = $this->strips_path.'/'.$png[0].'.thumb.png';
$this->source = $svg;

View file

@ -252,6 +252,19 @@ class Stripit:
if self.verbose:
print '\tok'
# generation de la miniature pour la galerie
if self.verbose:
print '\tCreating the thumbnail PNG from the SVG...',
sys.stdout.flush()
cmd = 'inkscape -z --export-width=345 --export-png %s.thumb.png %s.svg ' % (file_we,file_we)
cmd += options
os.popen( cmd )
if self.verbose:
print '\tok'
def xfind( self, tree, ns ):
# on ne veut passer qu'un liste d'élements

View file

@ -55,6 +55,11 @@ a:hover {
width:100%;
}
.stripbox {
border:1px solid black;
background-color:white;
}
#strip {
border:1px solid black;
background-color:white;

View file

@ -0,0 +1,58 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>{general.title} - {title}</title>
<meta http-equiv="Content-Type" content="text/HTML; charset=utf-8" />
<meta name=" robot" content="follow, index, all" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.php" />
<link rel="stylesheet" type="text/css" href="style_default.css" />
</head>
<body>
<div class="shadow_simple">
<div id="navbar">
<div id="site_title"><p id="site_head">{general.title}</p><p id="site_desc">{general.description}</p></div>
<div id="main"><a href="..">{lang.accueil}</a> <br/> <a id="feed" href="rss.php">{lang.rss}</a> <a id="feed" href="rss.php?limit=10">10</a> <br/><a href="mailto:{general.email}">{general.webmaster}</a></div>
<a id="navfirst" href="{nav_first}">{lang.premier}</a>
<a id="navprev" href="{nav_prev}">{lang.precedent}</a>
<a id="navnext" href="{nav_next}">{lang.suivant}</a>
<a id="navlast" href="{nav_last}">{lang.dernier}</a>
</div>
</div>
{foreach:items_list,id,strip}
<div class="centering">
<div class="shadow">
<a href="{general.url}/{strip.nav_base_url}{strip.current_id}"><img class="stripbox" src="{general.url}/{strip.thumbnail}" style="width:345px;"/></a>
</div>
</div>
{end:}
<div id="footbar">
<p id="forum"><a href="{general.forum}">{lang.forum}</a></p>
<p id="forum_comments">{comments:h}</p>
<p id="forum_post"><a href="{forum_post_url}">{lang.forum_new}</a></p>
<p id="shop_infos"><a href="{general.shop}">{lang.boutique} {general.title}</a> {lang.teeshirt}.</p>
{lang.see_also}
<ul id="linkbar">
{foreach:general.see_also,name,url}
<li><a href="{url}">{name}</a></li>
{end:}
</ul>
<p>{lang.propulse} <a href="http://stripit.sourceforge.net/">Strip-It</a>, {lang.descstrip} ({general.version}).</p>
</div>
</body>
</html>