Permalink
Browse files

Added a template delegate

  • Loading branch information...
1 parent bbdac53 commit 4140a7a9f0bcb5c876cb17ec3d737b47e03356d0 @ngerakines committed Jul 15, 2008
Showing with 22 additions and 6 deletions.
  1. +8 −0 README
  2. +2 −1 ebin/s3images.app
  3. +9 −3 src/s3images.erl
  4. +3 −2 src/s3images_ahandler.erl
View
@@ -57,6 +57,11 @@ The following configuration variables must be set in the ebin/s3images.app:
6. s3secret -- The secret token used in conjunction with the key.
7. reproxy -- Set to 'true' to send the 'X-REPROXY-URL' header.
8. create_sq -- Set to 'true' to create/upload 100x100 thumbnails
+9. delegate -- When this variable is set then the module this variable
+ points to is used for a number of delegated actions. Please refer to the
+ s3images_demo module for more information and documentation.
+10. template -- This variable points to a template module that is used in
+ place of the default s3imagestmpl_ahandler.et template.
BUILDING
@@ -89,6 +94,9 @@ CAVEATS / NOTES / KNOWN ISSUES
CHANGES
+2008-07-14 ngerakines
+ - Added a config option to point to a different template delegate.
+
2008-07-12 ngerakines
- Added a config option to direct the app to set the 'X-REPROXY-URL' header
instead of sending a redirect.
View
@@ -22,7 +22,8 @@
{s3secret, "secretabc789"},
{reproxy, true},
{create_sq, true},
- {delegate, s3images_demo}
+ {delegate, s3images_demo},
+ {template, s3imagestmpl_ahandler}
]},
{start_phases, [
{mnesia, []},
View
@@ -39,7 +39,8 @@
-module(s3images).
-behaviour(application).
--export([start/2, stop/1, start_phase/3, build_templates/0, env_key/1]).
+-export([start/2, stop/1, start_phase/3, build_templates/0]).
+-export([env_key/1, env_key/2]).
-include("s3images.hrl").
-include("s3.hrl").
@@ -76,5 +77,10 @@ build_templates() ->
end || F <- filelib:wildcard("templates/*.et")].
env_key(Key) ->
- {ok, Val} = application:get_env(s3images, Key),
- Val.
+ env_key(Key, <<"none">>).
+
+env_key(Key, Default) ->
+ case application:get_env(s3images, Key) of
+ {ok, Val} -> Val;
+ _ -> Default
+ end.
@@ -48,8 +48,9 @@ out(Arg) ->
%% @doc Provide a simple way to wrap request specific body inside of a
%% larger document.
wrap_body(Outer, {Inner, Args}) ->
- InnerBody = apply(s3imagestmpl_ahandler, Inner, [Args]),
- OuterBody = apply(s3imagestmpl_ahandler, Outer, [InnerBody]),
+ Tmpl = s3images:env_key(template, s3imagestmpl_ahandler),
+ InnerBody = apply(Tmpl, Inner, [Args]),
+ OuterBody = apply(Tmpl, Outer, [InnerBody]),
iolist_to_binary(OuterBody).
%% @spec handle_request(Request, Path, Arg) -> Response

0 comments on commit 4140a7a

Please sign in to comment.