Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ui:, feeds, feeds_parse: unify & fix xml serialization

  • Loading branch information...
commit 2b9ded927d03fdcdd6f4297ebd8dad19ffa68c08 1 parent ec66433
@astro authored
View
5 apps/feeds/src/feeds_update.erl
@@ -5,7 +5,6 @@
-include_lib("model/include/model.hrl").
-define(INTERVAL, 600).
--define(DEFAULT_XMLNS, [{"http://www.w3.org/XML/1998/namespace", "xml"}]).
start_link() ->
{ok, spawn_link(fun update_loop/0)}.
@@ -55,7 +54,7 @@ update1(URL, Etag1, LastModified1) ->
feeds_parse:pick_items(RootEl),
io:format("Picked ~b items from feed ~s~n",
[length(Items1), URL]),
- FeedXml1 = exmpp_xml:node_to_binary(FeedEl, [], ?DEFAULT_XMLNS),
+ FeedXml1 = iolist_to_binary(feeds_parse:serialize(FeedEl)),
ChannelEl = feeds_parse:get_channel(FeedEl),
Title1 = feeds_parse:title(ChannelEl),
Homepage1 = feeds_parse:link(ChannelEl),
@@ -128,7 +127,7 @@ xml_to_feed_item(Feed, Xml) ->
Homepage = feeds_parse:item_link(Xml),
Payment = feeds_parse:item_payment(Xml),
Image = feeds_parse:item_image(Xml),
- XmlSerialized = exmpp_xml:node_to_binary(Xml, [], ?DEFAULT_XMLNS),
+ XmlSerialized = iolist_to_binary(feeds_parse:serialize(Xml)),
Enclosures = feeds_parse:item_enclosures(Xml),
if
is_binary(Id),
View
9 apps/shared/src/feeds_parse.erl
@@ -1,6 +1,7 @@
-module(feeds_parse).
--export([get_type/1, get_channel/1,
+-export([serialize/1,
+ get_type/1, get_channel/1,
title/1, link/1, image/1,
pick_items/1, merge_items/2,
item_id/1, item_title/1, item_enclosures/1,
@@ -11,6 +12,10 @@
-define(NS_ATOM, "http://www.w3.org/2005/Atom").
+-define(DEFAULT_XMLNS, [{"http://www.w3.org/XML/1998/namespace", "xml"}]).
+
+serialize(Xml) ->
+ exmpp_xml:node_to_binary(Xml, [], ?DEFAULT_XMLNS).
get_type(Xml) ->
case exmpp_xml:get_ns_as_list(Xml) of
@@ -100,7 +105,7 @@ pick_items(#xmlel{} = RootEl) ->
false
end, RootEl#xmlel.children),
{ok,
- RootEl#xmlel{children = lists:reverse(FeedChildren)},
+ RootEl#xmlel{children = FeedChildren},
lists:reverse(Entries)};
%% Assume RSS
View
2  apps/ui/src/ui_template.erl
@@ -431,7 +431,7 @@ export_feed(UserName, Slug) ->
end)
end, ItemXmls),
CompleteFeedEl = feeds_parse:merge_items(FeedEl, ItemEls),
- Body = exmpp_xml:document_to_iolist(CompleteFeedEl),
+ Body = feeds_parse:serialize(CompleteFeedEl),
{ok, Type,
[<<"<?xml version='1.0' encoding='UTF-8'?>\n">>,
Body]};
Please sign in to comment.
Something went wrong with that request. Please try again.