Skip to content

Commit

Permalink
Move all TODOs and FIXMEs to GitHub issues
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Jun 29, 2024
1 parent 09436c3 commit 2969d7f
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 48 deletions.
2 changes: 0 additions & 2 deletions priv/static/assets/js/arizona.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/arizona_html.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
1 change: 0 additions & 1 deletion src/arizona_js.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ send(Event, Payload) ->
%% Internal funtions.
%% --------------------------------------------------------------------

% TODO: Real safe JS.
safe(Term) ->
iolist_to_binary(json:encode(Term)).

1 change: 0 additions & 1 deletion src/arizona_live_reload.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
_ ->
Expand Down
20 changes: 0 additions & 20 deletions src/arizona_tpl_compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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} ->
Expand All @@ -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,
Expand All @@ -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] ->
Expand All @@ -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}.

Expand Down Expand Up @@ -575,10 +562,6 @@ counter(Macros) ->
{% and adds this to the blocks param in the state. }
<div id={_@id} :stateful>
<span>
{% 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, }
Expand All @@ -597,9 +580,6 @@ counter(Macros) ->
{% It's filled with tokens when is not a void tag }
{% and the content between `>...</`, for example }
{% > <div>mycontent</div> }
{% 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} }
</div>
"""),
Expand Down
3 changes: 0 additions & 3 deletions src/arizona_tpl_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) ->
Expand Down
19 changes: 0 additions & 19 deletions src/arizona_tpl_scan.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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... }
% <div>foo</div>
% """;
% Bar ->
% """
% {% and should be able to eval variables. }
% <div>{Bar}</div>
% """
% 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)).
Expand Down Expand Up @@ -120,8 +103,6 @@ scan_tag_name(<<$>, Rest/binary>>, Str, Pos, Len) ->
scan_tag_name(<<C, Rest/binary>>, 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).
Expand Down
1 change: 0 additions & 1 deletion src/arizona_websocket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 2969d7f

Please sign in to comment.