Permalink
Browse files

Added RSS config parameters ro config parser and some more documentat…

…ion.

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@819 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent 2f8bae9 commit 30d242721c7b4333917bea705cf3c604ac955d10 Tobbe Tornquist committed Dec 19, 2004
Showing with 165 additions and 72 deletions.
  1. +37 −6 doc/README.rss
  2. +41 −1 src/yaws_config.erl
  3. +87 −65 src/yaws_rss.erl
View
@@ -1,5 +1,5 @@
-RSS Feed Interface
+RSS FEED INTERFACE
------------------
RSS is very cool! To see it in action look no further than Firebird 1.0.
@@ -13,7 +13,8 @@ The module yaws_rss.erl provides an RSS store/interface so that
you can RSS enable your application. More documentation can be
found in the yaws_rss.erl file (edoc).
-To setup an RSS feed
+
+TO CREATE AN RSS FEED
--------------------
Make sure your top page has the corresponding link information
@@ -52,7 +53,7 @@ rss.yaws
<erl>
out(A) ->
- case yaws_rss:retrieve(xml) of
+ case yaws_rss:retrieve(test, xml) of
{ok, Xml} ->
{html, [Xml]};
_ ->
@@ -69,15 +70,45 @@ To insert RSS items into the feed from your application, you
can write code like:
....
-yaws_rss:insert(xml,"Yaws now support RSS feeds.",
+yaws_rss:insert(test, xml, "Yaws now support RSS feeds.",
"http://www.blaha.org/latest_news.html",
"Yaws has now been extended to support....",
"Bill Smith").
....
-First comes a tag (which was used in rss.yaws when we retrieved
-the RSS content). Then follows a Title,Link,Description and Creator.
+First comes the application (RSSid) then a tag (these were used in
+rss.yaws when we retrieved the RSS content). Then follows the
+Title, Link, Description and Creator.
+
+The idea is that several independent application should be able
+to use the yaws_rss.erl API without affecting each other. Also,
+one application may have several RSS feeds (hence the Tag).
+
+
+
+HOW TO CONFIGURE RSS
+--------------------
+
+Inside a <server> block you specify the application you want
+to produce RSS content as:
+
+<rss>
+ rss_id = <application>
+</rss>
+
+This corresponds to the 'App' argument above and must be
+defined by the application in question. So, for example,
+the wikie application is using 'wiki' as rss_id.
+
+Other, non-mandatory, configuration parameters are (with
+explanation and default values):
+<rss>
+ rss_file = <filename> # filename of dets-DB (<yaws-dir>/yaws_rss.dets)
+ rss_expire = false | days # expire items, or not (false)
+ rss_rm_exp = <bool> # remove expired items (false)
+ rss_max = <integer> # max no.of items stored (infinite)
+</rss>
Good luck !
View
@@ -583,6 +583,11 @@ fload(FD, server, GC, C, Cs, Lno, Chars) ->
C2 = C#sconf{start_mod = list_to_atom(Module)},
fload(FD, server, GC, C2, Cs, Lno+1, Next);
+ ['<', "rss", '>'] ->
+ erase(rss_id),
+ put(rss, []),
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+
["allowed_scripts", '=' | Suffixes] ->
C2 = C#sconf{allowed_scripts =
lists:map(fun(X)->element(1,mime_types:t(X)) end,
@@ -707,6 +712,42 @@ fload(FD, ssl, GC, C, Cs, Lno, Chars) ->
{error, ?F("Unexpected input ~p at line ~w", [[H|T], Lno])}
end;
+fload(FD, rss, _GC, _C, _Cs, Lno, eof) ->
+ file:close(FD),
+ {error, ?F("Unexpected end of file at line ~w", [Lno])};
+
+fload(FD, rss, GC, C, Cs, Lno, Chars) ->
+ %?Debug("Chars: ~s", [Chars]),
+ Next = io:get_line(FD, ''),
+ case toks(Chars) of
+ [] ->
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ ['<', "/rss", '>'] ->
+ case get(rss_id) of
+ undefined ->
+ {error, ?F("No rss_id specified at line ~w", [Lno])};
+ RSSid ->
+ yaws_rss:open(RSSid, get(rss)),
+ fload(FD, server, GC, C, Cs, Lno+1, Next)
+ end;
+ ["rss_file", '=', Value] ->
+ put(rss, [{db_file, Value} | get(rss)]),
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ ["rss_expire", '=', Value] ->
+ put(rss, [{expire, Value} | get(rss)]),
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ ["rss_days", '=', Value] ->
+ put(rss, [{days, Value} | get(rss)]),
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ ["rss_rm_exp", '=', Value] ->
+ put(rss, [{rm_exp, Value} | get(rss)]),
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ ["rss_max", '=', Value] ->
+ put(rss, [{rm_max, Value} | get(rss)]),
+ fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ [H|T] ->
+ {error, ?F("Unexpected input ~p at line ~w", [[H|T], Lno])}
+ end;
fload(FD, opaque, _GC, _C, _Cs, Lno, eof) ->
file:close(FD),
@@ -728,7 +769,6 @@ fload(FD, opaque, GC, C, Cs, Lno, Chars) ->
end.
-
fload(FD, server_auth, _GC, _C, _Cs, Lno, eof, _Auth) ->
file:close(FD),
{error, ?F("Unexpected end of file at line ~w", [Lno])};
Oops, something went wrong.

0 comments on commit 30d2427

Please sign in to comment.