summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog1
-rwxr-xr-xbin/dthumb9
-rwxr-xr-xlib/App/Dthumb.pm33
-rw-r--r--lib/App/Dthumb/Data.pm.PL14
-rw-r--r--share/html_start3
-rw-r--r--share/main.css11
6 files changed, 52 insertions, 19 deletions
diff --git a/Changelog b/Changelog
index a80e9c0..ea5e415 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ git HEAD
* Add progressbar, introduces new dependency Time::Progress
* Switch from lightbox to shadowbox <http://www.shadowbox-js.com/>
* Show filename in lightbox
+ * The HTML title is now configurable, it defaults to the current directory
dthumb 0.1 - Sun Feb 27 2011
diff --git a/bin/dthumb b/bin/dthumb
index dcf82cf..fa3f975 100755
--- a/bin/dthumb
+++ b/bin/dthumb
@@ -20,11 +20,12 @@ GetOptions(
$opt,
qw{
help|h
- size|d=i
- spacing|s=f
no-lightbox|L
no-names|n
quality|q=i
+ size|d=i
+ spacing|s=f
+ title|t=s
version|v
},
) or die("Please see perldoc -F $0\n");
@@ -114,6 +115,10 @@ no border at all, etc.
Defaults to 1.1
+=item B<-t>, B<--title> I<string>
+
+Set HTML document title. Defaults to the basename of the current directory
+
=item B<-q>, B<--quality> I<int>
Set thumbnail quality.
diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm
index 952eaaa..5cb8fa6 100755
--- a/lib/App/Dthumb.pm
+++ b/lib/App/Dthumb.pm
@@ -114,9 +114,10 @@ sub new {
my ($obj, $conf) = @_;
my $ref = {};
- $conf->{size} //= 200;
- $conf->{spacing} //= 1.1;
- $conf->{quality} //= 75;
+ $conf->{size} //= 200;
+ $conf->{spacing} //= 1.1;
+ $conf->{quality} //= 75;
+ $conf->{title} //= (split(qr{/}, cwd()))[-1];
$conf->{lightbox} = !$conf->{'no-lightbox'};
$conf->{names} = !$conf->{'no-names'};
@@ -124,14 +125,18 @@ sub new {
$ref->{data} = App::Dthumb::Data->new();
- $ref->{html} = $ref->{data}->get('html_start');
-
- $ref->{current_file_id} = 0;
+ $ref->{data}->set_vars(
+ title => $conf->{title},
+ width => $conf->{size} * $conf->{spacing} . 'px',
+ height => $conf->{size} * $conf->{spacing} . 'px',
+ );
$ref->{config}->{file_index} = 'index.xhtml';
$ref->{config}->{dir_thumbs} = '.thumbs';
$ref->{config}->{dir_data} = '.dthumb';
+ $ref->{html} = $ref->{data}->get('html_start');
+
return bless($ref, $obj);
}
@@ -230,8 +235,8 @@ sub create_files {
mkdir($datadir);
}
- for my $file (qw(close.png loading.gif next.png pause.png play.png
- previous.png shadowbox.css shadowbox.js)) {
+ for my $file (qw(close.png loading.gif main.css next.png pause.png
+ play.png previous.png shadowbox.css shadowbox.js)) {
open(my $fh, '>', "${datadir}/${file}");
print {$fh} $self->{data}->get($file);
close($fh);
@@ -284,14 +289,8 @@ sub create_thumbnail_html {
my $div_width = $self->{config}->{size} * $self->{config}->{spacing};
my $div_height = $div_width + ($self->{config}->{names} ? 10 : 0);
- $self->{html} .= sprintf(
- "<div style=\"%s; %s; %s; width: %dpx; height: %dpx\">\n",
- 'text-align: center',
- 'font-size: 80%',
- 'float: left',
- $div_width,
- $div_height,
- );
+ $self->{html} .= "<div class=\"image-container\">\n";
+
$self->{html} .= sprintf(
"\t<a rel=\"shadowbox[main]\" href=\"%s\" title=\"%s\">\n"
. "\t\t<img src=\"%s/%s\" alt=\"%s\" /></a>\n",
@@ -299,6 +298,7 @@ sub create_thumbnail_html {
$self->{config}->{dir_thumbs},
($file) x 2,
);
+
if ($self->{config}->{names}) {
$self->{html} .= sprintf(
"\t<br />\n"
@@ -307,6 +307,7 @@ sub create_thumbnail_html {
($file) x 2,
);
}
+
$self->{html} .= "</div>\n";
}
diff --git a/lib/App/Dthumb/Data.pm.PL b/lib/App/Dthumb/Data.pm.PL
index c1f1ed2..a686c6d 100644
--- a/lib/App/Dthumb/Data.pm.PL
+++ b/lib/App/Dthumb/Data.pm.PL
@@ -54,6 +54,11 @@ sub new {
return bless($ref, $obj);
}
+sub set_vars {
+ my ($self, %vars) = @_;
+ $self->{replace} = \%vars;
+}
+
sub get {
my ($self, $name) = @_;
my $data = $self->section_data($name);
@@ -65,6 +70,15 @@ sub get {
if ($name =~ qr{ \. (png | gif) $ }ox) {
return decode_base64(${$data});
}
+
+ while (my ($key, $value) = each %{$self->{replace}}) {
+ ${$data} =~ s{
+ ( \<\!-- | /\* )
+ \s+ \$ $key \s+
+ ( --\> | \*/ )
+ }{$value}gx;
+ }
+
return ${$data};
}
diff --git a/share/html_start b/share/html_start
index f628c2c..baf8167 100644
--- a/share/html_start
+++ b/share/html_start
@@ -2,8 +2,9 @@
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
- <title>dthumb</title>
+ <title><!-- $title --></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <link rel="stylesheet" type="text/css" href=".dthumb/main.css"/>
<link rel="stylesheet" type="text/css" href=".dthumb/shadowbox.css"/>
<script type="text/javascript" src=".dthumb/shadowbox.js"></script>
<script type="text/javascript">
diff --git a/share/main.css b/share/main.css
new file mode 100644
index 0000000..5554843
--- /dev/null
+++ b/share/main.css
@@ -0,0 +1,11 @@
+div.image-container {
+ text-align: center;
+ font-size: 80%;
+ float: left;
+ width: /* $width */;
+ height: /* $height */;
+}
+
+div.image-container a {
+ text-decoration: none;
+}