aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks-export.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-07-10 21:33:49 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-07-10 21:33:49 +0800
commitd446a326bb0243e014e3d4e8e6152b6a6f9b7e28 (patch)
treefccfd27fab44f27b2d8f24c53bac8ddcefcde398 /src/bookmarks/ephy-bookmarks-export.c
parent268d6be0929222404146c78a5656ee0739af262a (diff)
downloadgsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.gz
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.bz2
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.lz
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.xz
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.zst
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.zip
Some minor changes in rdf format (thanks to Edd Dumbill), and use
2003-07-10 Marco Pesenti Gritti <marco@it.gnome.org> * src/bookmarks/ephy-bookmarks-export.c: (add_topics_list), (ephy_bookmarks_export_rdf): Some minor changes in rdf format (thanks to Edd Dumbill), and use namespaces in the code. * src/bookmarks/ephy-bookmarks-import.c: (bookmark_add), (ephy_bookmarks_import_xbel), (parse_rdf_subjects), (parse_rdf_item), (ephy_bookmarks_import_rdf): * src/bookmarks/ephy-bookmarks-import.h: Add an rdf importer. * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_load), (ephy_bookmarks_save), (ephy_bookmarks_init), (ephy_bookmarks_finalize): Update db to 1.0, import bookmarks from the rdf first time. WARNING Backup your bookmarks.rdf file before using this and let me know if you get any problems. (esp if you had a < 0.7.3 epiphany version).
Diffstat (limited to 'src/bookmarks/ephy-bookmarks-export.c')
-rw-r--r--src/bookmarks/ephy-bookmarks-export.c81
1 files changed, 59 insertions, 22 deletions
diff --git a/src/bookmarks/ephy-bookmarks-export.c b/src/bookmarks/ephy-bookmarks-export.c
index 7ca93811e..7f026f3a1 100644
--- a/src/bookmarks/ephy-bookmarks-export.c
+++ b/src/bookmarks/ephy-bookmarks-export.c
@@ -17,6 +17,7 @@
*/
#include <libxml/tree.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include "ephy-bookmarks-export.h"
@@ -25,12 +26,12 @@
#include "ephy-debug.h"
static void
-add_topics_list (EphyNode *topics, EphyNode *bmk, xmlNodePtr parent)
+add_topics_list (EphyNode *topics, EphyNode *bmk,
+ xmlNodePtr parent, xmlNsPtr dc_ns)
{
GPtrArray *children;
int i;
GList *bmks = NULL, *l;
- xmlNodePtr xml_node;
children = ephy_node_get_children (topics);
for (i = 0; i < children->len; i++)
@@ -57,11 +58,12 @@ add_topics_list (EphyNode *topics, EphyNode *bmk, xmlNodePtr parent)
{
const char *name;
EphyNode *node = l->data;
+ xmlNodePtr item_node;
- xml_node = xmlNewChild (parent, NULL, "dc:subject", NULL);
name = ephy_node_get_property_string
(node, EPHY_NODE_KEYWORD_PROP_NAME);
- xmlNodeSetContent (xml_node, name);
+ item_node = xmlNewChild (parent, dc_ns, "subject", NULL);
+ xmlNodeSetContent (item_node, name);
}
g_list_free (bmks);
@@ -75,8 +77,9 @@ ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
EphyNode *topics;
xmlDocPtr doc;
xmlNodePtr root, xml_node, channel_node, channel_seq_node;
- char *uri;
+ xmlNsPtr ephy_ns, rdf_ns, dc_ns;
GPtrArray *children;
+ char *file_uri;
int i;
LOG ("Exporting to rdf")
@@ -86,14 +89,14 @@ ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
root = xmlNewDocNode (doc, NULL, "rdf:RDF", NULL);
xmlDocSetRootElement (doc, root);
- xmlSetProp (root, "xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
- xmlSetProp (root, "xmlns", "http://purl.org/rss/1.0/");
- xmlSetProp (root, "xmlns:dc", "http://purl.org/dc/elements/1.1/");
-
+ rdf_ns = xmlNewNs (root, "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
+ xmlNewNs (root, "http://purl.org/rss/1.0/", NULL);
+ dc_ns = xmlNewNs (root, "http://purl.org/dc/elements/1.1/", "dc");
+ ephy_ns = xmlNewNs (root, "http://gnome.org/ns/epiphany#", "ephy");
channel_node = xmlNewChild (root, NULL, "channel", NULL);
- uri = gnome_vfs_get_uri_from_local_path (filename);
- xmlSetProp (channel_node, "rdf:about", uri);
- g_free (uri);
+ file_uri = gnome_vfs_get_uri_from_local_path (filename);
+ xmlSetProp (channel_node, "rdf:about", file_uri);
+ g_free (file_uri);
xml_node = xmlNewChild (channel_node, NULL, "title", NULL);
xmlNodeSetContent (xml_node, "Epiphany bookmarks");
@@ -103,7 +106,7 @@ ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
xml_node = xmlNewChild (channel_node, NULL, "items", NULL);
- channel_seq_node = xmlNewChild (xml_node, NULL, "rdf:Seq", NULL);
+ channel_seq_node = xmlNewChild (xml_node, rdf_ns, "Seq", NULL);
bmks = ephy_bookmarks_get_bookmarks (bookmarks);
topics = ephy_bookmarks_get_keywords (bookmarks);
@@ -114,28 +117,62 @@ ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks,
EphyNode *kid;
const char *url, *title;
xmlNodePtr item_node;
+ xmlChar *encoded_link;
+ char *link = NULL;
+ gboolean smart_url;
kid = g_ptr_array_index (children, i);
-
+ smart_url = ephy_node_get_property_boolean
+ (kid, EPHY_NODE_BMK_PROP_HAS_SMART_ADDRESS);
url = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_LOCATION);
title = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_TITLE);
- item_node = xmlNewChild (channel_seq_node, NULL, "rdf:li", NULL);
- xmlSetProp (item_node, "rdf:about", url);
+ if (smart_url)
+ {
+ GnomeVFSURI *uri;
+
+ uri = gnome_vfs_uri_new (url);
+
+ if (uri)
+ {
+ link = g_strconcat (gnome_vfs_uri_get_scheme (uri),
+ "://",
+ gnome_vfs_uri_get_host_name (uri),
+ NULL);
+
+ gnome_vfs_uri_unref (uri);
+ }
+ }
+
+ if (link == NULL)
+ {
+ link = g_strdup (url);
+ }
+
+ encoded_link = xmlEncodeEntitiesReentrant (doc, link);
+
+ item_node = xmlNewChild (channel_seq_node, rdf_ns, "li", NULL);
+ xmlSetNsProp (item_node, rdf_ns, "about", link);
item_node = xmlNewChild (root, NULL, "item", NULL);
- xmlSetProp (item_node, "rdf:about", url);
+ xmlSetNsProp (item_node, rdf_ns, "about", link);
- xml_node = xmlNewChild (item_node, NULL, "title", NULL);
- xmlNodeSetContent (xml_node, title);
+ xml_node = xmlNewChild (item_node, NULL, "title", title);
+
+ xml_node = xmlNewChild (item_node, NULL, "link", encoded_link);
+
+ if (smart_url)
+ {
+ xml_node = xmlNewChild (item_node, ephy_ns, "smartlink", url);
+ }
- xml_node = xmlNewChild (item_node, NULL, "link", NULL);
- xmlNodeSetContent (xml_node, url);
+ add_topics_list (topics, kid, item_node, dc_ns);
- add_topics_list (topics, kid, item_node);
+ xmlFree (encoded_link);
+ g_free (link);
}
ephy_node_thaw (bmks);