Browse Source

more work on tags

git-svn-id: http://erlydtl.googlecode.com/svn/trunk@16 a5195066-8e3e-0410-a82a-05b01b1b9875
rsaccon 17 years ago
parent
commit
5edc89b9c8

+ 25 - 0
priv/tags/flashvideo.html

@@ -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>

+ 1 - 0
src/erlydtl/erlydtl.app.src

@@ -6,6 +6,7 @@
     erlydtl_server,
     erlydtl_server,
     erlydtl_app,
     erlydtl_app,
     erlydtl_sup,
     erlydtl_sup,
+    erlydtl_deps,
     erlydtl_parser,
     erlydtl_parser,
     erlydtl_scanner,
     erlydtl_scanner,
     erlydtl_tools
     erlydtl_tools

+ 58 - 0
src/erlydtl/erlydtl_deps.erl

@@ -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
+%%====================================================================
+

+ 20 - 7
src/erlydtl/erlydtl_server.erl

@@ -258,9 +258,10 @@ transl(nil, [{var, Line, Val}], Out, Args, _) ->
             {regular, [{var, Line, Key} | Out], Args}
             {regular, [{var, Line, Key} | Out], Args}
     end;
     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, _) ->
 transl(nil, [Token], Out, Args, _) ->
     {regular, [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)
             transl(H, T, [{var, Line, Key} | Out], Args, DocRoot)
 	end;	 
 	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) ->      
     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]}) ->
 inplace_block({block, _Line , _Name, [nil, Str]}) ->
 	Str;
 	Str;
 inplace_block(Other) ->	
 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].

+ 7 - 3
tags/flashvideo.html

@@ -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 }}">
 <object id="{{ dom_id }}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{{ width }}" height="{{ height }}">
 	<param name="movie" value="{{ static }}/mediaplayer.swf">
 	<param name="movie" value="{{ static }}/mediaplayer.swf">
     <param name="allowfullscreen" value="true">
     <param name="allowfullscreen" value="true">
     <param name="menu" value="false">
     <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]>-->
     <!--[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="allowfullscreen" value="true">
     <param name="menu" value="false">
     <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]-->
     <!--<![endif]-->
     <h2>To view the Video:</h2>
     <h2>To view the Video:</h2>
     <p>
     <p>