~ubuntu-branches/ubuntu/vivid/liferea/vivid-proposed

« back to all changes in this revision

Viewing changes to src/htmlview.c

  • Committer: Package Import Robot
  • Author(s): Moray Allan, Bojo42, Rodrigo Gallardo, Moray Allan
  • Date: 2012-03-27 21:44:42 UTC
  • mfrom: (1.5.1)
  • mto: (3.3.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 122.
  • Revision ID: package-import@ubuntu.com-20120327214442-g0xfh714cdmsbnts
Tags: 1.8.3-0.1
[ Bojo42 ]
* Non-maintainer upload.
* New upstream release (Closes: #502307, #623619, #631778, #651913) 
* debian/patches:
  - drop libnotify0.7 as in upstream
  - debian-example-feeds: update, move planets from "News" to "Open Source"
  - www-browser: update due to new file location
  - libtool-dont-rearange-as-needed: rebase
* debian/control:
  - update Standards-Version
  - remove obsolete Build-Depends:
    - quilt not needed for "3.0 (quilt)" source format
    - libnm-glib-dev & libdbus-glib-1-dev: upstream switched to GDBus
    - liblua5.1-0-dev: LUA scripting support got dropped
  - new Build-Depends on libunique-dev, libjson-glib-dev & dh_autoreconf
  - update version dependencies
* debian/rules: run dh_autoreconf & update translations
* debian/liferea.install: nothing to ship from /usr/lib/liferea

[ Rodrigo Gallardo ]
* Lintian love:
  - debian/control: switch from Conflicts to Breaks
  - debian/rules: redo build targets

[ Moray Allan ]
* debian/copyright: update to include additional copyright owners.
* debian/patches/www-browser: also set default external browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @file htmlview.c  item view interface for HTML rendering
3
3
 * 
4
 
 * Copyright (C) 2006-2009 Lars Lindner <lars.lindner@gmail.com>
 
4
 * Copyright (C) 2006-2010 Lars Lindner <lars.lindner@gmail.com>
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
17
17
 * along with this program; if not, write to the Free Software
18
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 */
20
 
 
21
 
#ifdef HAVE_CONFIG_H
22
 
#  include <config.h>
23
 
#endif
24
20
 
25
21
#include <string.h>
 
22
#include <libxml/uri.h>
26
23
 
27
24
#include "common.h"
28
25
#include "debug.h"
31
28
#include "htmlview.h"
32
29
#include "item.h"
33
30
#include "itemlist.h"
34
 
#include "itemset.h"
35
31
#include "render.h"
36
32
#include "vfolder.h"
37
33
#include "ui/liferea_htmlview.h"
171
167
        }
172
168
}
173
169
 
174
 
// FIXME: bad naming -> unclear concept!
175
 
static xmlDocPtr
176
 
itemset_to_xml (nodePtr node) 
 
170
static const gchar *
 
171
htmlview_get_item_direction(itemPtr item)
177
172
{
178
 
        xmlDocPtr       doc;
179
 
        xmlNodePtr      itemSetNode;
180
 
        
181
 
        doc = xmlNewDoc ("1.0");
182
 
        itemSetNode = xmlNewDocNode (doc, NULL, "itemset", NULL);
183
 
        
184
 
        xmlDocSetRootElement (doc, itemSetNode);
185
 
        
186
 
        xmlNewTextChild (itemSetNode, NULL, "favicon", node_get_favicon_file (node));
187
 
        xmlNewTextChild (itemSetNode, NULL, "title", node_get_title (node));
188
 
 
189
 
        if (node->subscription) {
190
 
                if (subscription_get_source (node->subscription))
191
 
                        xmlNewTextChild (itemSetNode, NULL, "source", subscription_get_source (node->subscription));
192
 
                        
193
 
                if (subscription_get_homepage (node->subscription))
194
 
                        xmlNewTextChild (itemSetNode, NULL, "link", subscription_get_homepage (node->subscription));
195
 
        }
196
 
 
197
 
        return doc;
 
173
        if (item_get_title (item))
 
174
                return (common_get_text_direction (item_get_title (item)));
 
175
 
 
176
        if (item_get_description (item))
 
177
                return (common_get_text_direction (item_get_description (item)));
 
178
 
 
179
        /* what can we do? */
 
180
        return ("ltr");
198
181
}
199
182
 
200
183
static gchar *
203
186
                      gboolean summaryMode) 
204
187
{
205
188
        renderParamPtr  params;
206
 
        gchar           *output = NULL, *baseUrl;
 
189
        gchar           *output = NULL, *baseUrl = NULL;
207
190
        nodePtr         node;
208
 
        xmlDocPtr       doc;
 
191
        xmlDocPtr       doc;
 
192
        xmlNodePtr      xmlNode;
 
193
        const gchar     *text_direction = NULL;
209
194
 
210
195
        debug_enter ("htmlview_render_item");
211
196
 
212
197
        /* don't use node from htmlView_priv as this would be
213
198
           wrong for folders and other merged item sets */
214
199
        node = node_from_id (item->nodeId);
215
 
        baseUrl = common_uri_escape (node_get_base_url (node));
216
200
 
217
201
        /* do the XML serialization */
218
 
        doc = itemset_to_xml (node);
219
 
                        
 
202
        doc = xmlNewDoc ("1.0");
 
203
        xmlNode = xmlNewDocNode (doc, NULL, "itemset", NULL);
 
204
        xmlDocSetRootElement (doc, xmlNode);
 
205
                                
220
206
        item_to_xml(item, xmlDocGetRootElement (doc));
 
207
 
 
208
        text_direction = htmlview_get_item_direction (item);
221
209
                        
222
210
        if (IS_FEED (node)) {
223
211
                xmlNodePtr feed;
224
 
                feed = xmlNewChild(xmlDocGetRootElement(doc), NULL, "feed", NULL);
225
 
                feed_to_xml(node, feed);
 
212
                feed = xmlNewChild (xmlDocGetRootElement (doc), NULL, "feed", NULL);
 
213
                feed_to_xml (node, feed);
226
214
        }
227
215
        
228
216
        /* do the XSLT rendering */
229
217
        params = render_parameter_new ();
230
 
        render_parameter_add (params, "pixmapsDir='file://" PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "pixmaps" G_DIR_SEPARATOR_S "'");
231
 
        render_parameter_add (params, "baseUrl='%s'", baseUrl);
 
218
        
 
219
        if (NULL != node_get_base_url (node)) {
 
220
                baseUrl = common_uri_escape (node_get_base_url (node));
 
221
                render_parameter_add (params, "baseUrl='%s'", baseUrl);
 
222
        }
 
223
        
232
224
        render_parameter_add (params, "summary='%d'", summaryMode?1:0);
233
225
        render_parameter_add (params, "single='%d'", (viewMode == ITEMVIEW_SINGLE_ITEM)?1:0);
 
226
        render_parameter_add (params, "txtDirection='%s'", text_direction);
 
227
        render_parameter_add (params, "appDirection='%s'", common_get_app_direction ());
234
228
        output = render_xml (doc, "item", params);
235
229
        
236
230
        /* For debugging use: xmlSaveFormatFile("/tmp/test.xml", doc, 1); */
242
236
        return output;
243
237
}
244
238
 
245
 
extern htmlviewImplPtr htmlview_get_impl();
246
 
 
247
239
void 
248
240
htmlview_start_output (GString *buffer,
249
241
                       const gchar *base,