Permalink
Browse files

Fixing the yaws-rss functionality. Adding configure parameter rss_dir…

…, defining the directory where to store the RSS database.

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@929 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
Tobbe Tornquist
Tobbe Tornquist committed Nov 25, 2005
1 parent 8861642 commit 8af1e9995ba634a7aa4d4246a1e7cd8c9ccbe433
Showing with 15 additions and 3 deletions.
  1. +3 −0 src/yaws_config.erl
  2. +12 −3 src/yaws_rss.erl
View
@@ -781,6 +781,9 @@ fload(FD, rss, GC, C, Cs, Lno, Chars) ->
["rss_id", '=', Value] -> % mandatory !!
put(rss_id, list_to_atom(Value)),
fload(FD, rss, GC, C, Cs, Lno+1, Next);
+ ["rss_dir", '=', Value] -> % mandatory !!
+ put(rss, [{db_dir, 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);
View
@@ -56,10 +56,10 @@ open(App) ->
open(App, []).
%%%
-%%% @spec open(App::atom(), Dir::string(), Opts::list()) ->
+%%% @spec open(App::atom(), Opts::list()) ->
%%% {ok, DB::db()} | {error, string()}
%%%
-%%% @doc Open a RSS database, located at <em>Dir</em>.
+%%% @doc Open a RSS database.
%%% Per default <em>dets</em> is used as database,
%%% but by using the <em>db_mod</em> option it is
%%% possible to use your own database.</br>
@@ -78,6 +78,10 @@ open(App) ->
%%% XML will thus be done. Also, the whole <em>Opts</em> will be
%%% passed un-interpreted to the other DB module.</dd>
%%%
+%%% <dt>{db_dir, Dir}</dt>
+%%% <dd>Specifies the directory where the database will be created.
+%%% Default is: /tmp</dd>
+%%%
%%% <dt>{expire, Expire}</dt>
%%% <dd>Specifies what method to use to expire items. Possible values
%%% are: <em>false</em>, <em>days</em>, meaning
@@ -267,7 +271,7 @@ terminate(_Reason, _State) ->
do_open_dir(State, App, Opts) ->
case get_db_mod(Opts, dets) of
dets ->
- File = yaws_config:yaws_dir() ++ "/" ++ a2l(?DB) ++ ".dets",
+ File = get_db_file(Opts),
Expire = get_expire(Opts, #s.expire),
Max = get_max(Opts, #s.max),
Days = get_days(Opts, #s.days),
@@ -294,6 +298,10 @@ do_open_dir(State, App, Opts) ->
{State, catch apply(DBmod, open, Opts)}
end.
+get_db_file(Opts) ->
+ Dir = get_db_dir(Opts, "/tmp"),
+ Dir ++ "/" ++ a2l(?DB) ++ ".dets".
+
init_counter(DB) ->
case dets:lookup(DB, counter) of
[] -> dets:insert(DB, {counter, 0}), 0;
@@ -430,6 +438,7 @@ add_zero(L) when list(L) -> L.
get_db_mod(Opts, Def) -> lkup(db_mod, Opts, Def).
+get_db_dir(Opts, Def) -> lkup(db_dir, Opts, Def).
get_expire(Opts, Def) -> lkup(expire, Opts, Def).
get_max(Opts, Def) -> lkup(max, Opts, Def).
get_days(Opts, Def) -> lkup(days, Opts, Def).

0 comments on commit 8af1e99

Please sign in to comment.