\n",
- albumdesc,
- imglist[x].filename,
+ (albumdesc == NULL) ? "Untitled album" : albumdesc,
+ imglist[x].filename,
+ enc,
+ /* relative or absolute CSS path? */
+ (css[0] == '/') ? "" : "../",
+ css,
imglist[x].filename,
imglist[x].filename,
imglist[x].scalewidth,
@@ -204,7 +211,8 @@
* Returns the number of thumbnail index pages created.
*/
int
-create_thumbindex(char *dir, struct imginfo *imglist, int imgcount)
+create_thumbindex(char *dir, struct imginfo *imglist, int imgcount,
+ char *enc, char *css)
{
char *desc, final[MAXPATHLEN], tmp[MAXPATHLEN];
int pages, offset, x, y;
@@ -242,12 +250,20 @@
}
fprintf(html, "\n\n%s / %d\n"
+ "\n"
"\n"
+ "href=\"%s%s\" />\n"
"\n\n"
"%s / %d\n"
"\n\n"
- "\n", desc, offset, desc, offset);
+ "\n",
+ desc, offset,
+ enc,
+ /* relative or absolute CSS path? */
+ (css[0] == '/') ? "" : "../",
+ css,
+ desc, offset);
/*
* Generate "previous pictures" link depending on current
diff -Naur swiggle-0.4.orig/swiggle.c swiggle-0.4/swiggle.c
--- swiggle-0.4.orig/swiggle.c 2007-01-14 13:03:36.000000000 +0100
+++ swiggle-0.4/swiggle.c 2008-11-30 11:10:40.527211846 +0100
@@ -50,6 +50,13 @@
#ifdef AIX
#include
#endif
+
+#ifdef __linux__
+#define _GNU_SOURCE
+#include
+#define NO_D_TYPE
+#endif
+
#include
#include
@@ -65,6 +72,8 @@
char *defaultdesc = "my webgallery";
char generated[1024];
char *progname = "";
+char *defaultenc = "ISO-8859-1";
+char *defaultcss = "swiggle.css";
int cols = 5;
int rows = 3;
int scaleheight = 480;
@@ -115,7 +124,7 @@
progname = argv[0];
sort_func = sort_by_filename;
- while ((i = getopt(argc, argv, "c:d:h:H:r:s:flov")) != -1) {
+ while ((i = getopt(argc, argv, "c:d:h:H:r:s:e:C:flov")) != -1) {
switch (i) {
case 'c':
cols = (int) strtol(optarg, &eptr, 10);
@@ -165,6 +174,24 @@
usage();
}
break;
+ case 'e': /* encoding */
+ if (strlen(optarg) == 0)
+ {
+ fprintf(stderr, "%s: refusing to set empty "
+ "encoding.\n", progname);
+ usage();
+ }
+ defaultenc = optarg;
+ break;
+ case 'C': /* CSS path */
+ if (strlen(optarg) == 0)
+ {
+ fprintf(stderr, "%s: refusing to set empty "
+ "CSS path.\n", progname);
+ usage();
+ }
+ defaultcss = optarg;
+ break;
case 'f':
force = 1;
break;
@@ -222,12 +249,15 @@
fprintf(html, "\n"
"\n"
"%s\n"
+ "\n"
"\n"
+ "href=\"%s\" />\n"
"\n"
"\n"
"%s\n"
- "\n", defaultdesc, defaultdesc);
+ "\n",
+ defaultdesc, defaultenc, defaultcss, defaultdesc);
/*
* Open the directory given on the command line and descend into
@@ -244,6 +274,48 @@
/* Read in the directory contents and sort by filename. */
while ((dent = readdir(topdir)) != NULL) {
+ struct stat sbuf;
+
+ if (sprintf(buf, "%s/%s", argv[0], dent->d_name) < 0)
+ {
+ fprintf(stderr, "%s: sprintf failed: %s\n",
+ progname, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ if (stat((const char *) buf, &sbuf) == -1)
+ {
+ fprintf(stderr, "%s: stat on %s failed: %s\n",
+ progname, buf, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Only continue if the current entry is a directory.
+ */
+ if (!S_ISDIR(sbuf.st_mode))
+ {
+ continue;
+ }
+
+ /*
+ * Skip revision control directories.
+ */
+ if (strcmp(dent->d_name, ".svn") == 0 ||
+ strcmp(dent->d_name, "CVS") == 0)
+ {
+ continue;
+ }
+
+ /*
+ * Skip referential directories as well.
+ */
+ if (strcmp(dent->d_name, ".") == 0 ||
+ strcmp(dent->d_name, "..") == 0)
+ {
+ continue;
+ }
+
albums = realloc(albums, (albumcount+1)* sizeof(struct dirent));
if (albums == NULL) {
fprintf(stderr, "%s: can't realloc: %s\n", progname,
@@ -379,8 +451,9 @@
/* Sort the list according to desired sorting function. */
qsort(imglist, imgcount, sizeof(struct imginfo), sort_func);
- create_html(dir, imglist, imgcount);
- x = create_thumbindex(dir, imglist, imgcount);
+ create_html(dir, imglist, imgcount, defaultenc, defaultcss);
+ x = create_thumbindex(dir, imglist, imgcount,
+ defaultenc, defaultcss);
printf("%d thumbnail index pages created.\n", x);
}
@@ -1089,6 +1162,10 @@
"if not provided in\n");
fprintf(stderr, " '.description' files (default: '%s')\n",
defaultdesc);
+ fprintf(stderr, " -e ... document encoding (default: '%s')\n",
+ defaultenc);
+ fprintf(stderr, " -C ... CSS path (default: '%s')\n",
+ defaultcss);
fprintf(stderr, " -v ... show version info\n\n");
exit(EXIT_FAILURE);
}
diff -Naur swiggle-0.4.orig/swiggle.h swiggle-0.4/swiggle.h
--- swiggle-0.4.orig/swiggle.h 2006-11-12 22:41:46.000000000 +0100
+++ swiggle-0.4/swiggle.h 2008-11-30 11:05:30.911663889 +0100
@@ -71,8 +71,8 @@
char *desc;
};
-void create_html(char *, struct imginfo *, int);
-int create_thumbindex(char *, struct imginfo *, int);
+void create_html(char *, struct imginfo *, int, char *, char *);
+int create_thumbindex(char *, struct imginfo *, int, char *, char *);
int resize_bicubic(struct jpeg_decompress_struct *,
struct jpeg_compress_struct *, const unsigned char *, unsigned char **);
| | |