Permalink
Browse files

more work on tags

  • Loading branch information...
1 parent 8637d6f commit bda962a52041390032cac611af3a866d7d321414 @rsaccon rsaccon committed Dec 16, 2007
Showing with 111 additions and 10 deletions.
  1. +25 −0 priv/tags/flashvideo.html
  2. +1 −0 src/erlydtl/erlydtl.app.src
  3. +58 −0 src/erlydtl/erlydtl_deps.erl
  4. +20 −7 src/erlydtl/erlydtl_server.erl
  5. +7 −3 tags/flashvideo.html
View
@@ -0,0 +1,25 @@
+{# Embedding flash video
+
+ flashvideo(width, height, static, path_to_video, path_to_preview_image)
+#}
+<object id="{{ dom_id }}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{{ width }}" height="{{ height }}">
+ <param name="movie" value="{{ static }}/mediaplayer.swf">
+ <param name="allowfullscreen" value="true">
+ <param name="menu" value="false">
+ <param name="flashvars" value="file={{ path_to_video }}&image={{ path_to_preview_image }}">
+ <!--[if !IE]>-->
+ <object type="application/x-shockwave-flash" data="{{ static }}/mediaplayer.swf" width="800" height="620">
+ <param name="allowfullscreen" value="true">
+ <param name="menu" value="false">
+ <param name="flashvars" value="file={{ path_to_video }}&image={{ path_to_preview_image }}">
+ <!--<![endif]-->
+ <h2>To view the Video:</h2>
+ <p>
+ <a href="http://www.adobe.com/go/getflashplayer">
+ <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"alt="Get Adobe Flash player">
+ </a>
+ </p>
+ <!--[if !IE]>-->
+ </object>
+ <!--<![endif]-->
+</object>
@@ -6,6 +6,7 @@
erlydtl_server,
erlydtl_app,
erlydtl_sup,
+ erlydtl_deps,
erlydtl_parser,
erlydtl_scanner,
erlydtl_tools
@@ -0,0 +1,58 @@
+%%%-------------------------------------------------------------------
+%%% File: erlydtl_deps.erl
+%%% @author Roberto Saccon <rsaccon@gmail.com> [http://rsaccon.com]
+%%% @copyright 2007 Roberto Saccon
+%%% @doc
+%%% ErlyDTL helper module
+%%% @end
+%%%
+%%% The MIT License
+%%%
+%%% Copyright (c) 2007 Roberto Saccon
+%%%
+%%% Permission is hereby granted, free of charge, to any person obtaining a copy
+%%% of this software and associated documentation files (the "Software"), to deal
+%%% in the Software without restriction, including without limitation the rights
+%%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+%%% copies of the Software, and to permit persons to whom the Software is
+%%% furnished to do so, subject to the following conditions:
+%%%
+%%% The above copyright notice and this permission notice shall be included in
+%%% all copies or substantial portions of the Software.
+%%%
+%%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+%%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+%%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+%%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+%%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+%%% THE SOFTWARE.
+%%%
+%%% @since 2007-12-16 by Roberto Saccon
+%%%-------------------------------------------------------------------
+-module(erlydtl_deps).
+-author('rsaccon@gmail.com').
+
+%% API
+-export([get_base_dir/0, get_base_dir/1]).
+
+%%====================================================================
+%% API
+%%====================================================================
+%% @spec get_base_dir(Module) -> string()
+%% @doc Return the application directory for Module. It assumes Module is in
+%% a standard OTP layout application in the ebin or src directory.
+get_base_dir(Module) ->
+ {file, Here} = code:is_loaded(Module),
+ filename:dirname(filename:dirname(Here)).
+
+%% @spec get_base_dir() -> string()
+%% @doc Return the application directory for this application. Equivalent to
+%% get_base_dir(?MODULE).
+get_base_dir() ->
+ get_base_dir(?MODULE).
+
+%%====================================================================
+%% Internal functions
+%%====================================================================
+
@@ -258,9 +258,10 @@ transl(nil, [{var, Line, Val}], Out, Args, _) ->
{regular, [{var, Line, Key} | Out], Args}
end;
-transl(nil, [{tag, Line, _TagArgs}], Out, Args, _) ->
- %% TODO: call insert_ tag code
- {regular, [{string, Line, "not_fully_implemented_yet"} | Out], Args};
+transl(nil, [{tag, _Line, [TagName | TagArgs]}], Out, Args, _) ->
+ io:format("TRACE ~p:~p {TagName, TagArgs} ~p~n",[?MODULE, ?LINE, {TagName, TagArgs}]),
+ Out2 = load_tag(TagName, TagArgs, Out, default),
+ {regular, Out2, Args};
transl(nil, [Token], Out, Args, _) ->
{regular, [Token | Out], Args};
@@ -274,9 +275,10 @@ transl([H | T], [{var, Line, Val}], Out, Args, DocRoot) ->
transl(H, T, [{var, Line, Key} | Out], Args, DocRoot)
end;
-transl([H | T], [{tag, Line, _TagArgs}], Out, Args, DocRoot) ->
- %% TODO: call insert_tag code
- transl(H, T, [{string, Line, "not_fully_implemented_yet"} | Out], Args, DocRoot);
+transl([H | T], [{tag, _Line, [TagName | TagArgs]}], Out, Args, DocRoot) ->
+ io:format("TRACE ~p:~p {TagName, TagArgs} ~p~n",[?MODULE, ?LINE, {TagName, TagArgs}]),
+ Out2 = load_tag(TagName, TagArgs, Out, default),
+ transl(H, T, Out2, Args, DocRoot);
transl([H | T], [Token], Out, Args, DocRoot) ->
transl(H, T, [Token | Out], Args, DocRoot).
@@ -297,4 +299,15 @@ replace_block(Other, _What, Args) ->
inplace_block({block, _Line , _Name, [nil, Str]}) ->
Str;
inplace_block(Other) ->
- Other.
+ Other.
+
+load_tag(TagName, TagArgs, Acc, default) ->
+ case parse(filename:join([erlydtl_deps:get_base_dir(), "priv", "tags", TagName ++ ".html"])) of
+ {ok, ParentAst} ->
+ [H|T]=ParentAst,
+ {_, List, Args1} = transl(H, T, [], [], undefined),
+ io:format("TRACE loadtag: ~p:~p ~p~n",[?MODULE, ?LINE, {TagArgs, List, Args1}]);
+ {error, Msg} ->
+ io:format("TRACE ~p:~p ~p~n",[?MODULE, ?LINE, Msg])
+ end,
+ [{string, 666, "not_fully_implemented_yet3"} | Acc].
View
@@ -1,13 +1,17 @@
+{# Embedding flash video
+
+ flashvideo(width, height, static, path_to_video, path_to_preview_image)
+#}
<object id="{{ dom_id }}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{{ width }}" height="{{ height }}">
<param name="movie" value="{{ static }}/mediaplayer.swf">
<param name="allowfullscreen" value="true">
<param name="menu" value="false">
- <param name="flashvars" value="file={{ path_to_video }}&image={{path_to_preview_image}}">
+ <param name="flashvars" value="file={{ path_to_video }}&image={{ path_to_preview_image }}">
<!--[if !IE]>-->
- <object type="application/x-shockwave-flash" data="{{ path}}/mediaplayer.swf" width="800" height="620">
+ <object type="application/x-shockwave-flash" data="{{ static }}/mediaplayer.swf" width="800" height="620">
<param name="allowfullscreen" value="true">
<param name="menu" value="false">
- <param name="flashvars" value="file={{ path_to_video }}&image={{path_to_preview_image}}">
+ <param name="flashvars" value="file={{ path_to_video }}&image={{ path_to_preview_image }}">
<!--<![endif]-->
<h2>To view the Video:</h2>
<p>

0 comments on commit bda962a

Please sign in to comment.