diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2010-10-08 17:02:47 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2010-10-08 17:02:47 +0200 |
| commit | 10c6b1f0978710cf5a9f309b6fdcaef922f9b07f (patch) | |
| tree | 00679d479d9554f91f5d3beb4f4e709705ba55df /src/cgg.c | |
| parent | 5fc53d25a171fbd85ee09c9fc771580350d689c8 (diff) | |
| download | cataract-10c6b1f0978710cf5a9f309b6fdcaef922f9b07f.tar.xz | |
Add basic Atom feed writer
Diffstat (limited to 'src/cgg.c')
| -rw-r--r-- | src/cgg.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -34,6 +34,8 @@ #include "setup.h" #include "job-manager.h" #include "stats.h" +#include "atom-writer.h" +#include "gallery-utils.h" @@ -118,6 +120,7 @@ main (int argc, char* argv[]) TGallerySetup *setup; time_t time_start = time (NULL); time_t time_stop; + gchar *s; /* * this initialize the library and check potential ABI mismatches @@ -173,12 +176,42 @@ main (int argc, char* argv[]) printf ("Using setup file \"%s\"\n", setup->setup_xml_path); } + /* Setup feeds */ + news_feed = NULL; + if (setup->feed_enabled) { + news_feed = atom_writer_new (); + atom_writer_set_title (news_feed, setup->feed_title ? setup->feed_title : setup->site_title); + } + /* Start building the gallery tree */ setup->verbose = verbose; setup->update_mode = update; setup->override_nofullsize = fullsize; build_tree (setup, source_dir, dst_dir, NULL, -1, jobs); + /* Write feeds */ + if (news_feed) { + if (verbose) + printf ("Writing Atom feed: %s\n", setup->feed_filename); + if (setup->feed_base_url == NULL || strlen (setup->feed_base_url) == 0) + log_error ("Error: feed base URL not defined!\n"); + else + if (setup->feed_filename == NULL || strlen (setup->feed_filename) == 0) + log_error ("Error: feed file name not defined!\n"); + else { + atom_writer_set_base_url (news_feed, setup->feed_base_url); + s = g_build_filename (setup->feed_base_url, setup->feed_filename, NULL); + atom_writer_set_feed_url (news_feed, s); + g_free (s); + + s = g_strdup_printf ("%s/%s", dst_dir, setup->feed_filename); + atom_writer_write_to_file (news_feed, s, setup); + g_free (s); + } + atom_writer_free (news_feed); + } + + /* Write stats */ if (verbose) { time_stop = time (NULL); printf ("\nProcessed %d images in %d albums, elapsed time = %dm %ds\n", stats_images, stats_dirs, (int) ((time_stop - time_start) / 60), (int) ((time_stop - time_start) % 60)); @@ -189,7 +222,6 @@ main (int argc, char* argv[]) } - MagickWandTerminus(); /* Cleanup function for the XML library. */ |
