From 10c6b1f0978710cf5a9f309b6fdcaef922f9b07f Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 8 Oct 2010 17:02:47 +0200 Subject: Add basic Atom feed writer --- src/atom-writer.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/atom-writer.h (limited to 'src/atom-writer.h') diff --git a/src/atom-writer.h b/src/atom-writer.h new file mode 100644 index 0000000..cf90001 --- /dev/null +++ b/src/atom-writer.h @@ -0,0 +1,70 @@ +/* Cataract - Static web photo gallery generator + * Copyright (C) 2010 Tomas Bzatek + * + * 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 __ATOM_WRITER_H__ +#define __ATOM_WRITER_H__ + +#include +#include "setup.h" + +/* + * Resources: + * http://tools.ietf.org/html/rfc4287 + * http://www.atomenabled.org/developers/syndication/ + * http://feedvalidator.org/ + * http://diveintomark.org/archives/2004/05/28/howto-atom-id + * + */ + + +typedef struct { + gchar *title; + gchar *base_url; + gchar *feed_url; + + GSList *items; +} TAtomFeed; + +typedef struct { + gchar *title; + gchar *path; /* relative path in the gallery structure */ + gchar *date; /* format ISO.8601.1988 yyyy-mm-ddThh:mm:ssZ or yyyy-mm-ddThh:mm:ss+hh:mm (timezone) */ + gchar *summary; /* escaped automatically */ + gchar *summary_type; /* valid values are "text", "html", "xhtml" */ +} TAtomFeedItem; + + +/* Global instances */ +TAtomFeed *news_feed; + + +TAtomFeed * atom_writer_new (); +void atom_writer_write_to_file (TAtomFeed *feed, const gchar *filename, TGallerySetup *setup); +void atom_writer_set_title (TAtomFeed *feed, const gchar *title); +void atom_writer_set_base_url (TAtomFeed *feed, const gchar *base_url); +void atom_writer_set_feed_url (TAtomFeed *feed, const gchar *feed_url); +void atom_writer_free (TAtomFeed *feed); /* will free data of all items */ + +TAtomFeedItem * atom_writer_add_item (TAtomFeed *feed); +void atom_feed_item_set_title (TAtomFeedItem *item, const gchar *title); +void atom_feed_item_set_path (TAtomFeedItem *item, const gchar *path); +void atom_feed_item_set_date (TAtomFeedItem *item, const gchar *date); +void atom_feed_item_set_summary (TAtomFeedItem *item, const gchar *summary); +void atom_feed_item_set_summary_type (TAtomFeedItem *item, const gchar *summary_type); + + +#endif /* __ATOM_WRITER_H__ */ -- cgit v1.2.3