Template tweaks, more fixes.
This commit is contained in:
parent
bc791db732
commit
361b0b606d
6
Makefile
6
Makefile
@ -12,13 +12,17 @@ OBJS=obj/main.o obj/util.o obj/galleries.o obj/gallery.o obj/varray.o \
|
||||
$(CS_PATH)/lib/libneo_cgi.a $(CS_PATH)/lib/libneo_cs.a \
|
||||
$(CS_PATH)/lib/libneo_utl.a
|
||||
|
||||
VERSIONSTAMP=$(shell if [ -d .git ]; then git-describe; else cat version; fi)
|
||||
COMPILESTAMP=$(shell date "+%Y-%m-%d %H:%M:%S %z" )
|
||||
|
||||
gallery.cgi: $(OBJS)
|
||||
$(CC) -o $@ $(OBJS) $(LDFLAGS)
|
||||
obj:
|
||||
mkdir obj
|
||||
|
||||
obj/%.o: src/%.c include/%.h obj
|
||||
$(CC) -DCOMPILESTAMP='"$(shell date "+%Y-%m-%d %H:%M:%S %z" )"' \
|
||||
$(CC) -DCOMPILESTAMP='"$(COMPILESTAMP)"' \
|
||||
-DVERSIONSTAMP='"$(VERSIONSTAMP)"' \
|
||||
$(CFLAGS) -I include -o $@ -c $<
|
||||
|
||||
clean:
|
||||
|
@ -27,6 +27,16 @@ char* cstemp_dir;
|
||||
#define OUTPUT_JSON 1
|
||||
char output_mode = OUTPUT_HTML;
|
||||
|
||||
/* Default Photo settings */
|
||||
#define DEFAULT_WIDTH 720
|
||||
#define DEFAULT_HEIGHT 0
|
||||
#define DEFAULT_QUALITY 60
|
||||
#define DEFAULT_ROTATION "0.0"
|
||||
|
||||
/* Max size */
|
||||
#define MAX_WIDTH 2048
|
||||
#define MAX_HEIGHT 2048
|
||||
|
||||
/* Entry point into entire webapp */
|
||||
int main( int argc, char** argv );
|
||||
|
||||
|
33
src/main.c
33
src/main.c
@ -40,6 +40,12 @@ int main( int argc, char** argv ) {
|
||||
cgi_cs_init( cgi, &cstemp );
|
||||
|
||||
hdf_set_value( cgi->hdf, "uri", get_cgiuri() );
|
||||
#ifdef COMPILESTAMP
|
||||
hdf_set_value( cgi->hdf, "system.compiledate", COMPILESTAMP );
|
||||
#endif
|
||||
#ifdef VERSIONSTAMP
|
||||
hdf_set_value( cgi->hdf, "system.version", VERSIONSTAMP );
|
||||
#endif
|
||||
|
||||
/* Detect JSON mode */
|
||||
if ( argc > 1 )
|
||||
@ -245,13 +251,13 @@ void photo_handler( struct gallery_info* gallery,
|
||||
int original = hdf_get_int_value( cgi->hdf, "Query.original", 0 );
|
||||
|
||||
/* Pull the size/quality information out of the GET variables. */
|
||||
int width = hdf_get_int_value( cgi->hdf, "Query.width", 720 );
|
||||
int height = hdf_get_int_value( cgi->hdf, "Query.height", 0 );
|
||||
int quality = hdf_get_int_value( cgi->hdf, "Query.quality", 60 );
|
||||
int width = hdf_get_int_value( cgi->hdf, "Query.width", DEFAULT_WIDTH );
|
||||
int height = hdf_get_int_value( cgi->hdf, "Query.height", DEFAULT_HEIGHT );
|
||||
int quality = hdf_get_int_value( cgi->hdf, "Query.quality", DEFAULT_QUALITY );
|
||||
|
||||
/* MAX SIZE: Allow images no bigger than a 2048 pixel square */
|
||||
if ( width > 2048 ) width = 2048;
|
||||
if ( height > 2048 ) height = 2048;
|
||||
if ( width > MAX_WIDTH ) width = MAX_WIDTH;
|
||||
if ( height > MAX_HEIGHT ) height = MAX_HEIGHT;
|
||||
|
||||
/* Prevent nonsense values */
|
||||
if ( width < 0 ) width = 0;
|
||||
@ -262,7 +268,7 @@ void photo_handler( struct gallery_info* gallery,
|
||||
/* Since ClearSilver doesn't provide a 'get float', we have to get
|
||||
* string then call atof on it.
|
||||
*/
|
||||
char* rotation_str = hdf_get_value( cgi->hdf, "Query.rotation", "0" );
|
||||
char* rotation_str = hdf_get_value( cgi->hdf, "Query.rotation", DEFAULT_ROTATION );
|
||||
double rotation = atof( rotation_str );
|
||||
if ( ( rotation < -360.0 ) || ( rotation > 360.0 ) ) rotation = 0.0;
|
||||
|
||||
@ -301,10 +307,13 @@ void photo_handler( struct gallery_info* gallery,
|
||||
hdf_set_value( cgi->hdf, "gallery.last",
|
||||
gc->photos->string[ gc->photos->length - 1 ] );
|
||||
|
||||
/* Requested settings pass-thru */
|
||||
hdf_set_int_value( cgi->hdf, "settings.width", width );
|
||||
hdf_set_int_value( cgi->hdf, "settings.height", height );
|
||||
hdf_set_int_value( cgi->hdf, "settings.quality", quality );
|
||||
/* Requested settings pass-thru -- if differing from defaults */
|
||||
if ( width != DEFAULT_WIDTH )
|
||||
hdf_set_int_value( cgi->hdf, "settings.width", width );
|
||||
if ( height != DEFAULT_HEIGHT )
|
||||
hdf_set_int_value( cgi->hdf, "settings.height", height );
|
||||
if ( quality != DEFAULT_QUALITY )
|
||||
hdf_set_int_value( cgi->hdf, "settings.quality", quality );
|
||||
hdf_set_value( cgi->hdf, "settings.rotation", rotation_str );
|
||||
|
||||
hdf_set_int_value( cgi->hdf, "photo.origwidth",
|
||||
@ -325,12 +334,12 @@ void photo_handler( struct gallery_info* gallery,
|
||||
hdf_set_value( cgi->hdf, "photo.previous",
|
||||
photo->previous );
|
||||
else
|
||||
hdf_set_value( cgi->hdf, "photo.previous", "#" );
|
||||
hdf_set_value( cgi->hdf, "photo.previous", photo_name );
|
||||
if ( photo->next != NULL )
|
||||
hdf_set_value( cgi->hdf, "photo.next",
|
||||
photo->next );
|
||||
else
|
||||
hdf_set_value( cgi->hdf, "photo.next", "#" );
|
||||
hdf_set_value( cgi->hdf, "photo.next", photo_name );
|
||||
|
||||
/* Render the page and display it */
|
||||
write_template( "photo.cs" );
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?cs def:html_head() ?>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin-top: 240px;
|
||||
margin-top: 180px;
|
||||
}
|
||||
</style>
|
||||
<title>Gallery: <?cs var:gallery.title ?></title>
|
||||
@ -12,7 +12,7 @@ body {
|
||||
<td class="status"><a class="button"
|
||||
accesskey="i" href="<?cs var:CGI.ScriptName ?>"
|
||||
target="_top"><img alt="Index"
|
||||
src="/templates/images/top.png"
|
||||
src="<?cs var:uri ?>/templates/images/top.png"
|
||||
border="0" align="absmiddle" /></a></td>
|
||||
|
||||
</tr>
|
||||
|
@ -3,10 +3,21 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="/templates/style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="<?cs var:uri ?>/templates/style.css" type="text/css" />
|
||||
<?cs call:html_head() ?>
|
||||
</head>
|
||||
<body>
|
||||
<?cs call:html_body() ?>
|
||||
<hr />
|
||||
<p align="right">
|
||||
<address>Gallery at <?cs var:CGI.ServerName ?>
|
||||
<?cs if system.version ?>
|
||||
version <?cs var:system.version ?>
|
||||
<?cs /if ?>
|
||||
<?cs if system.compiledate ?>
|
||||
compiled <?cs var:system.compiledate ?>
|
||||
<?cs /if ?>
|
||||
</address>
|
||||
</a>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -9,10 +9,13 @@ body {
|
||||
<?cs def:html_body() ?>
|
||||
<table width="100%" class="controls">
|
||||
<tr>
|
||||
<td class="prevlink"><a class="button" accesskey="," href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.previous ?>"><img alt="<- Prev" src="/templates/images/back.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="status"><a class="button" accesskey="l" href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>" target="_top"><img alt="Album" src="/templates/images/up.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="status"><a class="button" accesskey="i" href="<?cs var:CGI.ScriptName ?>" target="_top"><img alt="Index" src="/templates/images/top.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="nextlink"><a class="button" accesskey="." href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.next ?>"><img alt="-> Next" src="/templates/images/forward.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="firstlink"><a class="button" accesskey="[" href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:gallery.first ?>"><img alt="|<- First" src="<?cs var:uri ?>/templates/images/start.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="prevlink"><a class="button" accesskey="," href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.previous ?>"><img alt="<- Prev" src="<?cs var:uri ?>/templates/images/back.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="status"><a class="button" accesskey="l" href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>" target="_top"><img alt="Album" src="<?cs var:uri ?>/templates/images/up.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="status"><a class="button" accesskey="a" href="#adjust" target="_top"><img alt="Adjust" src="<?cs var:uri ?>/templates/images/configure.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="status"><a class="button" accesskey="i" href="<?cs var:CGI.ScriptName ?>" target="_top"><img alt="Index" src="<?cs var:uri ?>/templates/images/top.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="nextlink"><a class="button" accesskey="." href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:photo.next ?>"><img alt="-> Next" src="<?cs var:uri ?>/templates/images/forward.png" border="0" align="absmiddle" /></a></td>
|
||||
<td class="lastlink"><a class="button" accesskey="]" href="<?cs var:CGI.ScriptName ?>/<?cs var:gallery.name ?>/<?cs var:gallery.last ?>"><img alt="->| Last" src="<?cs var:uri ?>/templates/images/finish.png" border="0" align="absmiddle" /></a></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
@ -27,12 +30,14 @@ body {
|
||||
lowsrc="<?cs var:uri ?>/<?cs var:photo.thumbnail ?>" /></p>
|
||||
<form>
|
||||
<p align="center">
|
||||
<a name="adjust">
|
||||
Resize: <input type="text" name="width" value="<?cs var:photo.width ?>" size="3" /> x
|
||||
<input type="text" name="height" value="<?cs var:photo.height ?>" size="3" />
|
||||
Rotation:
|
||||
<input type="text" name="rotation" value="0.000" size="3" />
|
||||
Quality: <input type="text" name="quality" value="60" size="3" /> (100% = PNG)
|
||||
<input type="submit" value="Go" />
|
||||
</a>
|
||||
</p>
|
||||
</form>
|
||||
<?cs /def ?>
|
||||
|
Loading…
Reference in New Issue
Block a user