File: 0007_Add-support-for-online-renaming-of-images.patch

package info (click to toggle)
libapache-gallery-perl 1.0.2-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,260 kB
  • sloc: perl: 1,281; sh: 21; makefile: 13
file content (117 lines) | stat: -rw-r--r-- 5,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Origin: 213fb003270770c1dc5ac08c0005252f201400a1 Mon Sep 17 00:00:00 2001
From: Don Armstrong <don@donarmstrong.com>
Last-Update: 2017-11-02
Bug-Debian: https://bugs.debian.org/337012
Subject: Add support for online renaming of images using .file

---
 README                |  4 ++++
 debian/changelog      |  2 ++
 lib/Apache/Gallery.pm | 36 ++++++++++++++++++++++++++++++++----
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/README b/README
index 64361e8..3910f39 100644
--- a/README
+++ b/README
@@ -292,6 +292,10 @@ FEATURES
         of the folder, but can be changed by creating a file
         <directory>.folder with the visible name of the folder.
 
+        Similarly, the visible name of any file is by default identical to the
+        name of the file, but can be changed by creating a file <file>.file
+        with the visible name of the file.
+
         It is also possible to set GalleryCommentExifKey to the name of an
         EXIF field containing the comment, e.g. ImageDescription. The EXIF
         comment is overridden by the .comment file if it exists.
diff --git a/lib/Apache/Gallery.pm b/lib/Apache/Gallery.pm
index 88a03b4..3cb6e56 100644
--- a/lib/Apache/Gallery.pm
+++ b/lib/Apache/Gallery.pm
@@ -367,9 +367,14 @@ sub handler {
 						$filetype = "unknown";
 					}
 
-					# Debian bug #348724 <http://bugs.debian.org/348724>
+					# Debian bug #337012 <http://bugs.debian.org/337012>
 					# not images
 					my $filetitle = $file;
+					if (-e $thumbfilename . ".file") {
+						$filetitle = get_filecontent($thumbfilename . ".file");
+					}
+
+					# Debian bug #348724 <http://bugs.debian.org/348724>
 					$filetitle =~ s/_/ /g if $r->dir_config('GalleryUnderscoresToSpaces');
 
 					$tpl_vars{FILES} .=
@@ -397,9 +402,14 @@ sub handler {
 
 					my $rotate = readfile_getnum($r, $imageinfo, $thumbfilename.".rotate");
 
-					# Debian bug #348724 <http://bugs.debian.org/348724>
+					# Debian bug #337012 <http://bugs.debian.org/337012>
 					# HTML <img> tag, alt attribute
 					my $filetitle = $file;
+					if (-e $thumbfilename . ".file") {
+						$filetitle = get_filecontent($thumbfilename . ".file");
+					}
+
+					# Debian bug #348724 <http://bugs.debian.org/348724>
 					$filetitle =~ s/_/ /g if $r->dir_config('GalleryUnderscoresToSpaces');
 
 					my %file_vars = (FILEURL => uri_escape($fileurl, $escape_rule),
@@ -640,9 +650,14 @@ sub handler {
 					my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);	
 					my $imageinfo = get_imageinfo($r, $path.$prevpicture, $type, $orig_width, $orig_height);
 					my $cached = get_scaled_picture_name($path.$prevpicture, $thumbnailwidth, $thumbnailheight);
+					# Debian bug #337012 <http://bugs.debian.org/337012>
+					my $prevpicture_title = $prevpicture;
+					if (-e $path."/".$prevpicture . ".file") {
+						$prevpicture_title = get_filecontent($path."/".$prevpicture . ".file");
+					}
 					my %nav_vars;
 					$nav_vars{URL}       = uri_escape($prevpicture, $escape_rule);
-					$nav_vars{FILENAME}  = $prevpicture;
+					$nav_vars{FILENAME}  = $prevpicture_title;
 					$nav_vars{WIDTH}     = $width;
 					$nav_vars{PICTURE}   = uri_escape(".cache/$cached", $escape_rule);
 					$nav_vars{DIRECTION} = "&laquo; <u>p</u>rev";
@@ -663,9 +678,14 @@ sub handler {
 					my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);	
 					my $imageinfo = get_imageinfo($r, $path.$nextpicture, $type, $thumbnailwidth, $thumbnailheight);
 					my $cached = get_scaled_picture_name($path.$nextpicture, $thumbnailwidth, $thumbnailheight);
+					# Debian bug #337012 <http://bugs.debian.org/337012>
+					my $nextpicture_title = $nextpicture;
+					if (-e $path."/".$nextpicture . ".file") {
+						$nextpicture_title = get_filecontent($path."/".$nextpicture . ".file");
+					}
 					my %nav_vars;
 					$nav_vars{URL}       = uri_escape($nextpicture, $escape_rule);
-					$nav_vars{FILENAME}  = $nextpicture;
+					$nav_vars{FILENAME}  = $nextpicture_title;
 					$nav_vars{WIDTH}     = $width;
 					$nav_vars{PICTURE}   = uri_escape(".cache/$cached", $escape_rule);
 					$nav_vars{DIRECTION} = "<u>n</u>ext &raquo;";
@@ -1480,6 +1500,10 @@ sub generate_menu {
 	my $picturename;
 	if (-f $filename) {
 		$picturename = pop(@links);	
+		# Debian bug #337012 <http://bugs.debian.org/337012>
+		if (-e $filename . ".file") {
+			$picturename = get_filecontent($filename . ".file");
+		}
 	}
 
 	if ($r->uri eq $root_path) {
@@ -2015,6 +2039,10 @@ The visible name of the folder is by default identical to the name of
 the folder, but can be changed by creating a file <directory>.folder
 with the visible name of the folder.
 
+Similarly, the visible name of any file is by default identical to the
+name of the file, but can be changed by creating a file <file>.file
+with the visible name of the file.
+
 It is also possible to set GalleryCommentExifKey to the name of an EXIF
 field containing the comment, e.g. ImageDescription. The EXIF comment is
 overridden by the .comment file if it exists.