summaryrefslogtreecommitdiff
path: root/src/setup.h
blob: faf02f6308f22b42ff6467ce9437a0a1bbefa688 (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*   Cataract - Static web photo gallery generator
 *   Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef __CGG__SETUP_H__
#define __CGG__SETUP_H__

#include <glib.h>

G_BEGIN_DECLS


#define DEFAULT_INDEX_FILENAME "index.html"
#define THUMBNAIL_NAME_FORMAT "%.3d_%s"
#define TARGET_IMAGE_DIR_PREFIX "_"

#define SETUP_XML "setup.xml"
#define SETUP_V2_XML "setup2.xml"
#define SETUP_NATIVE_VERSION 200  /*  2.0  */


/*  forward declaration  */
typedef struct TGalleryDesign TGalleryDesign;

/*  Global gallery setup  */
typedef struct {
  gboolean verbose;
  gboolean update_mode;
  gboolean strip_unused_tags;
  gboolean warn_resize;
  gchar *setup_xml_path;
  gint version;

  TGalleryDesign *design;

  /*  design section  */
  gchar *design_setup_file;
  gboolean supplemental_files_use_common_root;

  /*  images section  */
  gboolean preload;
  gboolean use_iptc_exif;
  gboolean erase_exif_thumbnail;
  gboolean strip_xmp;
  gboolean write_supplied_exif;
  gboolean autorotate;

  /*  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 *meta_artist_name;
  gchar *favicon_file;
  gchar *favicon_type;

  /*  navigation section  */
  gboolean use_inpage_links;

  /*  feed section  */
  gboolean feed_enabled;
  gchar *feed_filename;
  gchar *feed_title;

  /*  location section  */
  gchar *location_base_url;
  gchar *location_local_path;

  /*  footer section  */
  gchar *footer;
} TGallerySetup;

typedef enum {
  CROP_STYLE_NORMAL = 0,
  CROP_STYLE_SQUARED,
  CROP_STYLE_FIXED
} TCropStyle;

typedef struct {
  gchar *name;
  gchar *tagname;
  gboolean is_thumbnail;
  int landscape_width;
  int landscape_height;
  int portrait_width;
  int portrait_height;
  int square_size;
  int crop_width;
  int crop_height;
  int quality;
  gboolean no_resize;
  gchar *fallback_size;
  TCropStyle thumb_crop_style;
} TImageSize;

typedef struct {
  gboolean enabled;
  gchar *index_template;
  gchar *index_filename;
  gchar *index_thumb_size;
  gchar *index_protected_thumbnail;
  gchar *album_template;
  gchar *album_filename;
  gchar *album_image_size;
  gchar *album_thumb_size;
  gchar *picture_template;
  gchar *picture_filename;
  gchar *picture_image_size;
  gchar **supplemental_files;
  GHashTable *defines;
} TGalleryDesignTheme;

struct TGalleryDesign {
  gint version;
  GList *image_sizes;
  GList *themes;
  gchar **supplemental_files;
};


#define SETUP_IS_LEGACY(s) (s->version <  SETUP_NATIVE_VERSION)
#define SETUP_IS_NATIVE(s) (s->version == SETUP_NATIVE_VERSION)
#define SETUP_IS_NEWER(s)  (s->version >  SETUP_NATIVE_VERSION)

/*
 *   find_setup_xml: try to find setup.xml in standard paths
 */
TGallerySetup * find_setup_xml ();

/*
 *   parse_setup_xml: XML parser for setup.xml file
 */
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);

/*
 *   makeup_legacy_design: create design using legacy setup.xml file
 */
TGalleryDesign * makeup_legacy_design (const gchar *filename);

/*
 *   lookup_image_size_for_name: looks up an image size record for given image size name
 */
TImageSize * lookup_image_size_for_name (TGallerySetup *setup, const gchar *name);

/*
 *   validate_design_setup: validate design.xml file setup
 */
gboolean validate_design_setup (TGallerySetup *setup);

/*
 *   free_setup_data: free allocated setup data
 */
void free_setup_data (TGallerySetup *setup);

/*
 *   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_design_directory (TGallerySetup *setup);


G_END_DECLS

#endif /* __CGG__SETUP_H__ */