Photo gallery images are now automatically generated at default res and quality.
This commit is contained in:
parent
aaa78c5888
commit
97c4afdda9
14
src/main.c
14
src/main.c
@ -365,6 +365,9 @@ void photo_handler( struct gallery_info* gallery,
|
|||||||
|
|
||||||
/* Are we asked to show the original image? */
|
/* Are we asked to show the original image? */
|
||||||
int original = hdf_get_int_value( cgi->hdf, "Query.original", 0 );
|
int original = hdf_get_int_value( cgi->hdf, "Query.original", 0 );
|
||||||
|
|
||||||
|
/* Are we generating the gallery? */
|
||||||
|
int generate = hdf_get_int_value( cgi->hdf, "Query.generate", 0 );
|
||||||
|
|
||||||
int default_width = photo->default_dims.width;
|
int default_width = photo->default_dims.width;
|
||||||
int default_height = photo->default_dims.height;
|
int default_height = photo->default_dims.height;
|
||||||
@ -404,10 +407,12 @@ void photo_handler( struct gallery_info* gallery,
|
|||||||
"at %fdeg rotation and %d quality\n",
|
"at %fdeg rotation and %d quality\n",
|
||||||
width, height, rotation, quality);
|
width, height, rotation, quality);
|
||||||
|
|
||||||
/* Request image of the specified size */
|
/* Request image of the specified size
|
||||||
|
* If we're generating the gallery, we do not resize _yet_.
|
||||||
|
*/
|
||||||
struct dimensions dims;
|
struct dimensions dims;
|
||||||
char* resized;
|
char* resized;
|
||||||
if ( original )
|
if ( original || generate )
|
||||||
resized = construct_path( "s/s", gallery->gallery_name,
|
resized = construct_path( "s/s", gallery->gallery_name,
|
||||||
photo_name );
|
photo_name );
|
||||||
else
|
else
|
||||||
@ -481,7 +486,10 @@ void photo_handler( struct gallery_info* gallery,
|
|||||||
hdf_set_value( cgi->hdf, "photo.next", photo_name );
|
hdf_set_value( cgi->hdf, "photo.next", photo_name );
|
||||||
|
|
||||||
/* Render the page and display it */
|
/* Render the page and display it */
|
||||||
write_template( "photo.cs" );
|
if ( generate )
|
||||||
|
write_template( "generator.cs" );
|
||||||
|
else
|
||||||
|
write_template( "photo.cs" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_template( const char* template_name ) {
|
void write_template( const char* template_name ) {
|
||||||
|
69
templates/generator.cs
Normal file
69
templates/generator.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?cs def:html_head() ?>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>Image: <?cs var:html_strip(photo.annotation) ?> (<?cs var:photo.name ?>)</title>
|
||||||
|
<script lang="type/javascript">
|
||||||
|
function getData() {
|
||||||
|
var data = {
|
||||||
|
CGI: {
|
||||||
|
ScriptName: '<?cs var:js_escape(CGI.ScriptName) ?>'
|
||||||
|
},
|
||||||
|
gallery: {
|
||||||
|
name: '<?cs var:js_escape(gallery.name) ?>',
|
||||||
|
title: '<?cs var:js_escape(gallery.title) ?>',
|
||||||
|
desc: '<?cs var:js_escape(gallery.desc) ?>',
|
||||||
|
first: '<?cs var:js_escape(gallery.first) ?>',
|
||||||
|
last: '<?cs var:js_escape(gallery.last) ?>'
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
width: <?cs var:settings.width ?>,
|
||||||
|
height: <?cs var:settings.height ?>,
|
||||||
|
quality: <?cs var:settings.quality ?>,
|
||||||
|
rotation: <?cs var:settings.rotation ?>-0
|
||||||
|
},
|
||||||
|
photo: {
|
||||||
|
origwidth: <?cs var:photo.origwidth ?>,
|
||||||
|
origheight: <?cs var:photo.origheight ?>,
|
||||||
|
width: <?cs var:photo.width ?>,
|
||||||
|
height: <?cs var:photo.height ?>,
|
||||||
|
annotation: "<?cs var:js_escape(photo.annotation) ?>",
|
||||||
|
thumbnail: "<?cs var:js_escape(photo.thumbnails) ?>",
|
||||||
|
resized: "<?cs var:js_escape(photo.resized) ?>",
|
||||||
|
name: "<?cs var:js_escape(photo.name) ?>",
|
||||||
|
previous: "<?cs var:js_escape(photo.previous) ?>",
|
||||||
|
next: "<?cs var:js_escape(photo.next) ?>",
|
||||||
|
zoom: Math.round( 100*(<?cs var:photo.width ?>) /
|
||||||
|
<?cs var:photo.origwidth ?>)/100
|
||||||
|
}};
|
||||||
|
if ( document.data )
|
||||||
|
data = document.data;
|
||||||
|
else
|
||||||
|
document.data = data;
|
||||||
|
return( data );
|
||||||
|
}
|
||||||
|
|
||||||
|
function advance() {
|
||||||
|
var nexturl = '<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.next ?>?generate=1';
|
||||||
|
if ( nexturl != window.location.href )
|
||||||
|
window.location.href = nexturl;
|
||||||
|
else
|
||||||
|
window.location.href = '<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script lang="text/javascript" src="<?cs var:uri
|
||||||
|
?>/templates/lib.js"></script>
|
||||||
|
<script lang="text/javascript" src="<?cs var:uri
|
||||||
|
?>/templates/wheellib.js"></script>
|
||||||
|
<?cs /def ?>
|
||||||
|
|
||||||
|
<?cs def:html_body() ?>
|
||||||
|
<h3>Thumbnail</h3>
|
||||||
|
<p align="center"><img alt="" src="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.name ?>?width=100&height=100&quality=25&redirect=1" /></p>
|
||||||
|
<h3>Scaled Image</h3>
|
||||||
|
<p align="center"><img alt="" src="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.name ?>?redirect=1" /></p>
|
||||||
|
<?cs /def ?>
|
||||||
|
|
||||||
|
<?cs set:template.bodyargs = 'onload="advance();"' ?>
|
@ -5,7 +5,7 @@ body {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<title>Image: <?cs var:html_strip(photo.annotation) ?> (<?cs var:photo.name ?>)</title>
|
<title>Image: <?cs var:html_strip(photo.annotation) ?> (<?cs var:photo.name ?>)</title>
|
||||||
<script lang="tyoe/javascript">
|
<script lang="type/javascript">
|
||||||
function getData() {
|
function getData() {
|
||||||
var data = {
|
var data = {
|
||||||
CGI: {
|
CGI: {
|
||||||
|
Loading…
Reference in New Issue
Block a user