From 75bb13e531654a561dc7baa2f2bc594aa4a8fc52 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 29 May 2011 19:00:44 +0200 Subject: Introduce new theming system This extends current templating system to another dimension, bringing the possibility to have multiple themes generated at once. The purpose is to be able to switch between multiple designs, from PC to mobile, classic vs. flat view, slideshow, etc. For the moment, only the classic theme is available. Rules: * for switching between themes, place a link inside your template manually - it's not a cgg concern, only your theming infrastructure * don't forget to define different file names for index and album pages across different themes * it's recommended to keep default theme named as "index.*" to avoid showing directory listing on webserver Notes: * some TODOs will be fixed when we have new theme using these advanced features (e.g. pictures in album pages) * TODO: introduce tag/block conditional system, allow custom user defines for each theme/page * TODO: deprecate , and in favor of conditionals (these tags belong to theming) --- src/setup.h | 125 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 77 insertions(+), 48 deletions(-) (limited to 'src/setup.h') diff --git a/src/setup.h b/src/setup.h index 3bc3b3f..69e92b6 100644 --- a/src/setup.h +++ b/src/setup.h @@ -23,16 +23,16 @@ G_BEGIN_DECLS -/* Directory names */ -#define DEFAULT_THUMBNAIL_DIR "_thumb" -#define DEFAULT_IMG_BIG_DIR "_big" -#define DEFAULT_IMG_ORIG_DIR "_orig" -#define DEFAULT_THUMBNAIL_NAME_FORMAT "thn_%d_%s" +#define DEFAULT_INDEX_FILENAME "index.html" +#define THUMBNAIL_NAME_FORMAT "%.3d_%s" +#define TARGET_IMAGE_DIR_PREFIX "_" #define SETUP_XML "setup.xml" -#define DEFAULT_INDEX_FILENAME "index.html" +/* forward declaration */ +typedef struct TGalleryDesign TGalleryDesign; + typedef enum { THUMBNAIL_SQUARE_TYPE_NONE, THUMBNAIL_SQUARE_TYPE_SIMPLE @@ -43,67 +43,81 @@ typedef enum { typedef struct { gboolean verbose; gboolean update_mode; - gchar *real_templates_dir; - + gboolean override_nofullsize; gchar *setup_xml_path; - gchar *templates_path; - gchar *template_index; - gchar *template_album; - gchar *template_photo; - gchar **template_files; - gboolean support_files_use_common_root; - gchar *index_file_name; - gchar *thumbnail_dir; - gchar *img_big_dir; - gchar *img_orig_dir; - gchar *thumbnail_name_format; - ThumbnailSquareType squared_thumbnail_type; + TGalleryDesign *design; - gchar *footer; - gchar *meta_author; - gchar *meta_author_email; - gchar *meta_description; - gchar *meta_keywords; - gboolean use_title_as_meta; - - int thumbnail_quality; - unsigned long thumbnail_landscape_width; - unsigned long thumbnail_landscape_height; - unsigned long thumbnail_portrait_width; - unsigned long thumbnail_portrait_height; - unsigned long thumbnail_square_size; - - int preview_quality; - unsigned long preview_landscape_width; - unsigned long preview_landscape_height; - unsigned long preview_portrait_width; - unsigned long preview_portrait_height; + /* design section */ + gchar *design_setup_file; + gboolean supplemental_files_use_common_root; + /* images section */ gchar *border_style; - gboolean nofullsize; - gboolean override_nofullsize; - gboolean preload; gboolean use_iptc_exif; gboolean erase_exif_thumbnail; + gboolean nofullsize; + ThumbnailSquareType squared_thumbnail_type; + /* meta section */ + gchar *meta_author; + gchar *meta_author_email; + gchar *meta_description; + gchar *meta_keywords; + gboolean use_title_as_meta; gchar *site_title; gchar *add_copyright; + gchar *favicon_file; + gchar *favicon_type; + + /* navigation section */ gboolean use_inpage_links; gboolean show_go_up; gboolean show_exif_table; - gchar *favicon_file; - gchar *favicon_type; - + /* feed section */ gboolean feed_enabled; gchar *feed_filename; gchar *feed_title; gchar *feed_base_url; + + /* footer section */ + gchar *footer; } TGallerySetup; +typedef struct { + gchar *name; + int landscape_width; + int landscape_height; + int portrait_width; + int portrait_height; + int square_size; + int quality; + gboolean no_resize; +} TImageSize; + +typedef struct { + gboolean enabled; + gchar *index_template; + gchar *index_filename; + gchar *album_template; + gchar *album_filename; + gchar *album_image_size; + gchar *picture_template; + gchar *picture_filename; + gchar *picture_image_size; + gchar **supplemental_files; +} TGalleryDesignTheme; + +struct TGalleryDesign { + GList *image_sizes; + GList *themes; + gchar **supplemental_files; +}; + + /* * find_setup_xml: try to find setup.xml in standard paths @@ -115,16 +129,31 @@ TGallerySetup * find_setup_xml (); */ TGallerySetup * parse_setup_xml (const gchar *filename); +/* + * parse_design_setup_xml: XML parser for design.xml file + */ +TGalleryDesign * parse_design_setup_xml (const gchar *filename); + +/* + * validate_design_setup: validate design.xml file setup + */ +gboolean validate_design_setup (TGalleryDesign *design); + /* * free_setup_data: free allocated setup data */ void free_setup_data (TGallerySetup *setup); /* - * find_templates_directory: absolute/relative path checks, trying to find templates directory - * - returned string should be freed + * free_design_setup_data: free allocated design setup data + */ +void free_design_setup_data (TGalleryDesign *design); + +/* + * find_design_directory: try to find design templates directory + * - returned string should be freed */ -gchar * find_templates_directory (TGallerySetup *setup); +gchar * find_design_directory (TGallerySetup *setup); G_END_DECLS -- cgit v1.2.3