From 2969d7fe66dbfcf1ab092b970ec86c40fbace14d Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Sat, 29 Jun 2024 02:30:00 +0100 Subject: [PATCH] Move all TODOs and FIXMEs to GitHub issues --- priv/static/assets/js/arizona.js | 2 -- src/arizona_html.erl | 1 - src/arizona_js.erl | 1 - src/arizona_live_reload.erl | 1 - src/arizona_tpl_compile.erl | 20 -------------------- src/arizona_tpl_parse.erl | 3 --- src/arizona_tpl_scan.erl | 19 ------------------- src/arizona_websocket.erl | 1 - 8 files changed, 48 deletions(-) diff --git a/priv/static/assets/js/arizona.js b/priv/static/assets/js/arizona.js index 91ce226..cb3760d 100644 --- a/priv/static/assets/js/arizona.js +++ b/priv/static/assets/js/arizona.js @@ -35,11 +35,9 @@ globalThis["arizona"] = (() => { const subscribers = new Map(); const unsubscribers = new Map(); - // @todo Subscribe to global events. function subscribe(eventName, callback, opts = {}) { let eventSubs = subscribers.get(eventName); if (!eventSubs) eventSubs = new Map(); - // @todo Improve id. const id = Math.random(); eventSubs.set(id, { id, callback, opts }); subscribers.set(eventName, eventSubs); diff --git a/src/arizona_html.erl b/src/arizona_html.erl index b2a17c8..2b63013 100644 --- a/src/arizona_html.erl +++ b/src/arizona_html.erl @@ -31,7 +31,6 @@ HTML support. %% API funtions. %% -------------------------------------------------------------------- -% TODO: Do this really safe for HTML. safe(V) when is_binary(V) -> V; safe(V) when is_atom(V) -> diff --git a/src/arizona_js.erl b/src/arizona_js.erl index 8453962..c8662cc 100644 --- a/src/arizona_js.erl +++ b/src/arizona_js.erl @@ -42,7 +42,6 @@ send(Event, Payload) -> %% Internal funtions. %% -------------------------------------------------------------------- -% TODO: Real safe JS. safe(Term) -> iolist_to_binary(json:encode(Term)). diff --git a/src/arizona_live_reload.erl b/src/arizona_live_reload.erl index 9df8840..f2bbf07 100644 --- a/src/arizona_live_reload.erl +++ b/src/arizona_live_reload.erl @@ -97,7 +97,6 @@ handle_info({_Pid, {fs, file_event}, {File, Events}}, [modified, closed] -> {noreply, State#state{files = Files#{File => {erl, modified}}}}; _ -> - % TODO: Act on created, renamed, deleted. {noreply, State} end; _ -> diff --git a/src/arizona_tpl_compile.erl b/src/arizona_tpl_compile.erl index 44223ba..5efae6b 100644 --- a/src/arizona_tpl_compile.erl +++ b/src/arizona_tpl_compile.erl @@ -43,7 +43,6 @@ compile({Mod, Fun, Args}) when is_atom(Mod), is_atom(Fun) -> directives => #{stateful => true}, attrs => []}}], [], 0, #state{view = Mod}), {ok, Block}; -% TODO: Maybe require a module to be the view. compile(Tree) -> [{0, Block}] = compile(Tree, [], 0, #state{}), {ok, Block}. @@ -74,11 +73,6 @@ compile_tag(#{name := Name} = Tag, Txt, T, P, I, State) -> norm_tag_attrs(#{attrs := Attrs0, directives := Dirs}, Id, Target) -> maps:fold(fun (stateful, true, Attrs) -> - % TODO: Rename 'arz-id' to 'arz-sid' (statefull id), - % and provide a 'arz-tid' (tag id) to each tag. - % I think this can improve changes patch, - % because just the most close tag could be rendered - % instead of the entirely block/tree. [{<<"arz-id">>, {text, arz_id(Id)}} | Attrs]; (K, V, Attrs) -> case atom_to_binary(K, utf8) of @@ -123,8 +117,6 @@ do_compile_tag([K | T], Tag, TT, P, I, State, Acc) -> do_compile_tag(T, Tag, TT, P, I, State, [K, $\s | Acc]); % IMPORTANT: Text concat must be reviewed when :if and :for be implemented. % Cannot concat when this kind of directive is defined. -% TODO: There are more optimizations to do by concatenating tags. -% Nested blocks of blocks are not concatenated. do_compile_tag([], Tag, TT, P, I, State, Acc) -> case maps:get(void, Tag, false) of true -> @@ -245,7 +237,6 @@ block_struct(Block, P, I, State) -> {Mod, Fun} = block_mod_fun(Block, State), Tree = apply(Mod, Fun, [maps:get(args, Block, #{})]), Attrs = block_attrs(Block), - % TODO: Check this directives merge implementation. Directives = maps:get(directives, Block), AllDirectives = case find_first_tag(Tree) of {ok, Tag} -> @@ -257,8 +248,6 @@ block_struct(Block, P, I, State) -> AllAttrs = maps:merge(Attrs, maps:without(NonAttrs, Directives)), Id = id(P, I), Stateful = maps:get(stateful, Directives, false), - % TODO: Remove vars prop from expr tokens. - % They will live in the block props. Tokens = case Stateful of true -> compile(Tree, [I | P], 0, @@ -285,7 +274,6 @@ block_struct(Block, P, I, State) -> vars => vars_group(vars(ExprVars, Id)) }. -% TODO: Change to binary_to_existing_atom. block_mod_fun(#{name := Name}, State) -> case binary:split(Name, <<":">>) of [M, F] -> @@ -311,7 +299,6 @@ find_first_tag(_) -> is_tag(Name) -> not lists:member(Name, [<<"!DOCTYPE">>, <<"!doctype">>, <<"?xml">>]). -% TODO: Use binary_to_existing_atom. block_attrs(#{attrs := Attrs}) -> #{binary_to_atom(K, utf8) => V || {K, V} <- Attrs}. @@ -575,10 +562,6 @@ counter(Macros) -> {% and adds this to the blocks param in the state. }
- {% TODO: Find a better way to define default values } - {% in a pure Erlang implementation. } - {% Using try/catch by now for this. } - {% Should find a way to define a maps:get/3. } {try _@label catch _:_ -> <<"Count:">> end} {% NOTE: _@counter_count not wrapper by try/catch, } @@ -597,9 +580,6 @@ counter(Macros) -> {% It's filled with tokens when is not a void tag } {% and the content between `>...
mycontent
} - {% FIXME: This implementation wont work, because it } - {% needs to be compiled in tokens. } - {% The 'merl:tsubst' should be used to fix this. } {% {try _@content catch _:_ -> <<>> end} }
"""), diff --git a/src/arizona_tpl_parse.erl b/src/arizona_tpl_parse.erl index d96f860..fffb7f6 100644 --- a/src/arizona_tpl_parse.erl +++ b/src/arizona_tpl_parse.erl @@ -94,7 +94,6 @@ do_parse_tag([tag_close | T0], Props0, Macros) -> true -> Props = case OpenName =:= <<"head">> of true -> - % TODO: Do not reverse. lists:reverse(inject_js_scripts(lists:reverse(Props1))); false -> Props1 @@ -163,12 +162,10 @@ parse_attr(K, {expr, ExprStr}, Macros) -> parse_attr(K, {text, Text}, _Macros) -> do_parse_attr(K, {text, Text}). -% TODO: Directive keys to atom using binary_to_existing_atom. do_parse_attr(<<$:, K/binary>>, {text, <<$:, K/binary>>}) -> {directive, {binary_to_atom(K, utf8), true}}; do_parse_attr(<<$:, K/binary>>, V) -> {directive, {binary_to_atom(K, utf8), V}}; -% TODO: Comments support. do_parse_attr(<<$%, _K/binary>>, _V) -> error(not_supported_yet); do_parse_attr(K, V) -> diff --git a/src/arizona_tpl_scan.erl b/src/arizona_tpl_scan.erl index 4c49455..312325a 100644 --- a/src/arizona_tpl_scan.erl +++ b/src/arizona_tpl_scan.erl @@ -30,24 +30,7 @@ Template scanner. %% API funtions. %% -------------------------------------------------------------------- -% TODO: Implement the :case directive: -% """ -% {% The directive should be a valid Erlang syntax, like: } -% {:case _@foo of -% foo -> -% """ -% {% Expressions will be compiled into a tree... } -%
foo
-% """; -% Bar -> -% """ -% {% and should be able to eval variables. } -%
{Bar}
-% """ -% end} -% """. string(Str) when is_binary(Str) -> - % TODO: Location. {ok, scan(Str, Str, 0, 0), 1}; string(Str) when is_list(Str) -> string(iolist_to_binary(Str)). @@ -120,8 +103,6 @@ scan_tag_name(<<$>, Rest/binary>>, Str, Pos, Len) -> scan_tag_name(<>, Str, Pos, Len) when C =:= $\s; C =:= $\r; C =:= $\n -> Name = binary_part(Str, Pos, Len), - % FIXME: If closing_tag we should go to 'scan' - % instead of 'scan_attr_key'. [{tag_name, Name} | scan_attr_key(Rest, Str, Pos + Len + 1, 0)]; scan_tag_name(<<_, Rest/binary>>, Str, Pos, Len) -> scan_tag_name(Rest, Str, Pos, Len + 1). diff --git a/src/arizona_websocket.erl b/src/arizona_websocket.erl index 830b3c2..cf5934d 100644 --- a/src/arizona_websocket.erl +++ b/src/arizona_websocket.erl @@ -71,7 +71,6 @@ websocket_handle({text, Msg}, #{sockets := Sockets} = State) -> {Target, Event, Payload} = decode_msg(Msg), Socket0 = maps:get(Target, Sockets), View = maps:get(view, Socket0), - % TODO: {reply, Msg, Socket} {noreply, Socket1} = arizona_live_view:handle_event(View, Event, Payload, Socket0), Socket = case maps:get(changes, Socket1) of Changes when map_size(Changes) > 0 ->