Skip to content

Commit

Permalink
Fixing the yaws-rss functionality. Adding configure parameter rss_dir…
Browse files Browse the repository at this point in the history
…, 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 committed Nov 25, 2005
1 parent 8861642 commit 8af1e99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/yaws_config.erl
Expand Up @@ -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);
Expand Down
15 changes: 12 additions & 3 deletions src/yaws_rss.erl
Expand Up @@ -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>
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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;
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 8af1e99

Please sign in to comment.