summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2011-09-18 22:09:06 -0400
committerShaun McCance <shaunm@gnome.org>2011-09-18 22:09:46 -0400
commit41a613acfce5d6a35513d38fa4e58e2fbd472c24 (patch)
tree61b76dd19857390db743a08e64e3690b8b9e23e7
parent06a5df121bb99e3e81fe618fc9a18ed8740f8fd9 (diff)
downloadyelp-41a613acfce5d6a35513d38fa4e58e2fbd472c24.tar.gz
libyelp: Fixed resolving of HTML and TXT documents
-rw-r--r--libyelp/yelp-document.c2
-rw-r--r--libyelp/yelp-simple-document.c24
2 files changed, 23 insertions, 3 deletions
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c
index 3fcedd1f..d6c0ff7b 100644
--- a/libyelp/yelp-document.c
+++ b/libyelp/yelp-document.c
@@ -181,8 +181,10 @@ yelp_document_get_for_uri (YelpUri *uri)
* holding the file, to allow a directory of HTML files to act
* as a single document. So we cache these by a fuller URI.
*/
+ docuri = yelp_uri_get_document_uri (uri);
page_id = yelp_uri_get_page_id (uri);
tmp = g_strconcat (docuri, "/", page_id, NULL);
+ g_free (docuri);
g_free (page_id);
docuri = tmp;
break;
diff --git a/libyelp/yelp-simple-document.c b/libyelp/yelp-simple-document.c
index 8f2dadc9..28dd31b7 100644
--- a/libyelp/yelp-simple-document.c
+++ b/libyelp/yelp-simple-document.c
@@ -44,6 +44,7 @@ struct _Request {
struct _YelpSimpleDocumentPriv {
GFile *file;
GInputStream *stream;
+ gchar *page_id;
gchar *contents;
gssize contents_len;
@@ -158,6 +159,7 @@ yelp_simple_document_finalize (GObject *object)
g_free (document->priv->contents);
g_free (document->priv->mime_type);
+ g_free (document->priv->page_id);
G_OBJECT_CLASS (yelp_simple_document_parent_class)->finalize (object);
}
@@ -175,6 +177,7 @@ yelp_simple_document_new (YelpUri *uri)
g_free (doc_uri);
document->priv->file = yelp_uri_get_file (uri);
+ document->priv->page_id = yelp_uri_get_page_id (uri);
return (YelpDocument *) document;
}
@@ -294,15 +297,30 @@ file_info_cb (GFile *file,
document->priv->mime_type = g_strdup (type);
g_object_unref (info);
- if (g_str_equal (document->priv->mime_type, "text/plain")) {
- gchar *basename = g_file_get_basename (document->priv->file);
+ if (document->priv->page_id) {
+ yelp_document_set_page_id (YELP_DOCUMENT (document),
+ document->priv->page_id,
+ document->priv->page_id);
+ yelp_document_set_page_id (YELP_DOCUMENT (document),
+ "//index",
+ document->priv->page_id);
+ yelp_document_set_page_id (YELP_DOCUMENT (document),
+ NULL,
+ document->priv->page_id);
+ }
+ else {
yelp_document_set_page_id (YELP_DOCUMENT (document), "//index", "//index");
yelp_document_set_page_id (YELP_DOCUMENT (document), NULL, "//index");
+ }
+
+ if (g_str_equal (document->priv->mime_type, "text/plain")) {
+ gchar *basename = g_file_get_basename (document->priv->file);
yelp_document_set_page_title (YELP_DOCUMENT (document), "//index", basename);
- yelp_document_set_page_icon (YELP_DOCUMENT (document), "//index", "text-x-generic");
g_free (basename);
}
+ yelp_document_set_page_icon (YELP_DOCUMENT (document), "//index", "yelp-page-symbolic");
+
g_file_read_async (document->priv->file,
G_PRIORITY_DEFAULT,
NULL,