Mail Index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ApacheGallery] [PATCH] Admin interface all done :-P
Hi A::G users and develoopers,
Attached is a patch introducing a 'selection mode' in A::G. Whenever
in index-mode (showing thumbnails) you can click on the '[select]'
link and get a check-box alongside every picture. After checking the
pictures you want, press <enter> (saves us an ugly submit button) and
you get a plain text list of the filenames.
I believe most A::G users are familiar with mv and cp and some may
even have heard of for file in .....; do ...... :)
Of course this patch can (and should) be improved, but I personally do
not think a huge admin interface for moving, renaming, converting,
mailing pictures will look nice on A::G.
Please rid my perl of any pythonic twists that may have crept in...
Oh, and the patch is against the current svn version as of tonight
(rev 136 I think (first time using svn -- like it already :)).
- Peter
--
Peter Andreasen <pandr@xxxxxxxx> | http://pandr.dk | ln -s /dev/random ~/.plan
------ Fingerprint: 4311 664F 8034 EB15 C75B 30F0 9729 BCD9 0E11 4DA4 -------
Index: lib/Apache/Gallery.pm
===================================================================
--- lib/Apache/Gallery.pm (revision 136)
+++ lib/Apache/Gallery.pm (working copy)
@@ -54,8 +54,22 @@
return OK;
}
- my $apr = Apache::Request->instance($r, DISABLE_UPLOADS => 1, POST_MAX => 1024);
+ my $apr = Apache::Request->instance($r, DISABLE_UPLOADS => 1, POST_MAX => 10024);
+ # Handle selected images
+ if ($apr->param('selection')) {
+ my @selected = $apr->param('selection');
+ my $content = "@selected";
+ $r->content_type('text/html');
+ $r->header_out('Content-Length', length($content));
+ $r->send_http_header;
+ $r->print($content);
+ return OK;
+ }
+
+ # Selectmode providing checkboxes beside all thumbnails
+ my $select_mode = $apr->param('select');
+
# Let Apache serve icons and files from the cache without us
# modifying the request
if ($r->uri =~ m/^\/icons/i) {
@@ -118,6 +132,9 @@
}
$tpl->assign(MENU => generate_menu($r));
+
+ $tpl->assign(FORM_BEGIN => $select_mode?'<form method="post">':'');
+ $tpl->assign(FORM_END => $select_mode?'</form>':'');
# Read, sort, and filter files
my @files = grep { !/^\./ && -f "$filename/$_" } readdir (DIR);
@@ -224,6 +241,7 @@
$tpl->assign(SRC => uri_escape($uri."/.cache/$cached", $escape_rule));
$tpl->assign(HEIGHT => ($rotate ? $thumbnailwidth : $thumbnailheight));
$tpl->assign(WIDTH => ($rotate ? $thumbnailheight : $thumbnailwidth));
+ $tpl->assign(SELECT => $select_mode?'<input type="checkbox" name="selection" value="'.$file.'"> ':'');
$tpl->parse(FILES => '.picture');
@@ -983,6 +1001,9 @@
if (-f $filename) {
$menu .= $picturename;
}
+ else {
+ $menu .= "<a href=\"".uri_escape($menuurl, $escape_rule)."?select=1\">[select]</a> ";
+ }
return $menu;
}
Index: templates/index.tpl
===================================================================
--- templates/index.tpl (revision 136)
+++ templates/index.tpl (working copy)
@@ -2,6 +2,7 @@
<div id="menu">
$MENU
</div>
+ $FORM_BEGIN
<table>
<tr>
<td id="directory">
@@ -17,4 +18,5 @@
</td>
</tr>
</table>
+ $FORM_END
</div>
Index: templates/picture.tpl
===================================================================
--- templates/picture.tpl (revision 136)
+++ templates/picture.tpl (working copy)
@@ -1 +1 @@
- <a href="$FILEURL"><img alt="$FILE - $DATE" src="$SRC" width="$WIDTH" height="$HEIGHT"></a>
+ <a href="$FILEURL"><img alt="$FILE - $DATE" src="$SRC" width="$WIDTH" height="$HEIGHT"></a>$SELECT