Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all TODOs and FIXMEs to GitHub issues #124

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function subscribe(eventName, callback, opts = {}) {
let eventSubs = subscribers.get(eventName);
if (!eventSubs) eventSubs = new Map();
// @todo Improve id.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{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.
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
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.
Comment on lines -77 to -81
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[{<<"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.
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
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.
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
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.
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. }
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
{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. }
Comment on lines -600 to -602
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{% {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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#123 / 1

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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
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}
% """.
Comment on lines -33 to -48
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#17

string(Str) when is_binary(Str) ->
% TODO: Location.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#123 / 2

{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'.
Comment on lines -123 to -124
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[{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}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{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