Skip to content

Commit

Permalink
Merge remote-tracking branch 'orgin/master' into zynamo
Browse files Browse the repository at this point in the history
Conflicts:
	.gitmodules
	modules/mod_base/dispatch/dispatch
	modules/mod_base/resources/resource_api.erl
	priv/sites/zotonic_status/dispatch/dispatch
	priv/sites/zotonic_status/lib/css/zp-project.css
	priv/sites/zotonic_status/modules/mod_zotonic_status_vcs/mod_zotonic_status_vcs.erl
	priv/sites/zotonic_status/templates/_menu.tpl
	priv/sites/zotonic_status/templates/base.tpl
	priv/sites/zotonic_status/templates/stats.tpl
	src/zotonic_sup.erl
  • Loading branch information
Arjan Scherpenisse committed Jan 25, 2012
2 parents 9c54dc7 + 698a43a commit 1d00e7b
Show file tree
Hide file tree
Showing 145 changed files with 4,100 additions and 459 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Daniel Hedlund <daniel@digitree.org>
Dmitrii Dimandt <dmitriid@gmail.com>
Elise Lambert <lambert_elise@hotmail.com>
Evren Kutar <furiston@gmail.com>
François Cardinaux <fcardinaux@gmail.com>
Igor Goryachev <igor@goryachev.org>
Jason Tanner <jt4websites@googlemail.com>
Jim Geovedi (xyn on github)
Expand Down
2 changes: 2 additions & 0 deletions TRANSLATORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
es - Juan Jose Comellas <juanjo@comellas.org>
ee - Taavi Talvik <taavi@uninet.ee>
fr - Michael Connors <michael@bring42.net>
nl - Arjan Scherpenisse <arjan@scherpenisse.net>
tr - furiston <furiston@gmail.com>
pl - Piotr Meyer <aniou@smutek.pl>
ru - Konstantin Nikiforov <helllamer@gmail.com>
9 changes: 4 additions & 5 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ popd


pushd .
cd .\deps\webmachine
cd .\deps\webzmachine
@echo on
@echo '------------------------------'
@echo 'make webmachine'
@echo 'make webzmachine'
@echo '------------------------------'
@echo off
%erl% -noinput +B -eval "case make:all() of up_to_date -> halt(0); error -> halt(1) end."
copy src\*.app ebin
popd

pushd .
cd .\deps\erlang-oauth
cd .\modules\mod_oauth\deps\erlang-oauth
@echo on
@echo '------------------------------'
@echo 'make erlang-oauth'
Expand All @@ -43,7 +43,6 @@ IF NOT EXIST ebin (
)
copy src\oauth.app ebin
%erl% -make

popd

pushd .
Expand All @@ -67,7 +66,7 @@ popd
@echo '------------------------------'
%erlc% -o src/erlydtl src/erlydtl/erlydtl_parser.yrl

%erl% -pa ebin ./erlang-oauth/ebin ./mochiweb/ebin ./webmachine/ebin -noinput +B -eval "case make:all() of up_to_date -> halt(0);error -> halt(1) end."
%erl% -pa ebin ./deps/mochiweb/ebin ./deps/webzmachine/ebin ./modules/mod_oauth/deps/erlang-oauth/ebin -noinput +B -eval "case make:all() of up_to_date -> halt(0);error -> halt(1) end."

copy src\zotonic.app ebin

12 changes: 10 additions & 2 deletions deps/mochiweb/src/mochiweb_html.erl
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ tokenize(B, S=#decoder{offset=O}) ->
tokenize_comment(B, ?ADV_COL(S, 4));
<<_:O/binary, "<!DOCTYPE", _/binary>> ->
tokenize_doctype(B, ?ADV_COL(S, 10));
<<_:O/binary, "<!doctype", _/binary>> ->
tokenize_doctype(B, ?ADV_COL(S, 10));
<<_:O/binary, "<![CDATA[", _/binary>> ->
tokenize_cdata(B, ?ADV_COL(S, 9));
<<_:O/binary, "<?php", _/binary>> ->
Expand Down Expand Up @@ -510,8 +512,6 @@ tokenize_quoted_attr_value(B, S=#decoder{offset=O}, Acc, Q) ->
tokenize_quoted_attr_value(B, S1, [Data|Acc], Q);
<<_:O/binary, Q, _/binary>> ->
{ iolist_to_binary(lists:reverse(Acc)), ?INC_COL(S) };
<<_:O/binary, $\n, _/binary>> ->
{ iolist_to_binary(lists:reverse(Acc)), ?INC_LINE(S) };
<<_:O/binary, C, _/binary>> ->
tokenize_quoted_attr_value(B, ?INC_COL(S), [C|Acc], Q)
end.
Expand Down Expand Up @@ -1252,6 +1252,14 @@ parse_quoted_attr_test() ->
{ <<"img">>, [ { <<"src">>, <<"/images/icon>.png">> } ], [] }
]},
mochiweb_html:parse(D2)),

%% Quoted attributes can contain whitespace and newlines
D3 = <<"<html><a href=\"#\" onclick=\"javascript: test(1,\ntrue);\"></html>">>,
?assertEqual(
{<<"html">>,[],[
{ <<"a">>, [ { <<"href">>, <<"#">> }, {<<"onclick">>, <<"javascript: test(1,\ntrue);">>} ], [] }
]},
mochiweb_html:parse(D3)),
ok.

parse_missing_attr_name_test() ->
Expand Down
2 changes: 2 additions & 0 deletions include/zotonic.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

-include("zotonic_notifications.hrl").

-include("zotonic_events.hrl").

-include_lib("deps/webzmachine/include/wm_reqdata.hrl").

%% @doc The request context, session information and other
Expand Down
46 changes: 46 additions & 0 deletions include/zotonic_events.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%% @author Maas-Maarten Zeeman <mmzeeman@xs4all.nl>
%% @copyright 2012 Maas-Maarten Zeeman
%% @doc Events used in Zotonic core

%% Copyright 2012 Maas-Maarten Zeeman
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.


%% @doc Postback event received from browser.
%%
-record(postback, {message, trigger, target}).

%% @doc Submit event received from browser.
%%
-record(submit, {message, form, target}).

%% The record of the postback_notify event is defined in zotonic_notifications.hrl

%% Drag and drop events. They are received in a normal postback event by scomp_base_droppable.
%% The are emitted as separate event.
%%

%% @doc Drag event.
-record(drag, {drag, drop}).

%% @doc Drop event.
-record(drop, {drag, drop}).

%% Sort event. It is received in a normal postback event by scomp_base_sorter.
%%

%% @doc Sort event.
-record(sort, {items, drop}).


5 changes: 3 additions & 2 deletions include/zotonic_notifications.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@


%% @doc Handle a javascript notification from the postback handler. The 'message' is the z_msg argument of
%% the request. (first)
%% the request. (first), 'trigger' the id of the element which triggered the postback, and 'target' the
%% id of the element which should receive possible updates. Note: postback_notify is also used as an event.
%% Return either 'undefined' or a #context with the result of the postback
-record(postback_notify, {message}).
-record(postback_notify, {message, trigger, target}).

%% @doc Notification to signal an inserted comment. (notify)
%% 'comment_id' is the id of the inserted comment, 'id' is the id of the resource commented on.
Expand Down
8 changes: 4 additions & 4 deletions modules/mod_admin/actions/action_admin_admin_tasks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ render_action(TriggerId, TargetId, Args, Context) ->
{PostbackMsgJS, Context}.

%% @doc Flush the caches of all sites.
event({postback, {admin_tasks, [{task, "flush"}]}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={admin_tasks, [{task, "flush"}]}}, Context) ->
do(fun z:flush/0, "Caches have been flushed.", Context);

%% @doc Reset templates.
event({postback, {admin_tasks, [{task, "templates_reset"}]}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={admin_tasks, [{task, "templates_reset"}]}}, Context) ->
do(fun() -> z_template:reset(Context) end, "Templates will be recompiled.", Context);


%% @doc Pivot everything
event({postback, {admin_tasks, [{task, "pivot_all"}]}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={admin_tasks, [{task, "pivot_all"}]}}, Context) ->
do(fun() -> z_pivot_rsc:queue_all(Context) end,
"The search index is rebuilding. Depending on the database size, this can take a long time.", Context);

%% @doc Renumber the category tree
event({postback, {admin_tasks, [{task, "renumber_categories"}]}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={admin_tasks, [{task, "renumber_categories"}]}}, Context) ->
do(fun() -> m_category:renumber(Context) end,
"The category tree is rebuilding. This can take a long time.", Context).

Expand Down
2 changes: 1 addition & 1 deletion modules/mod_admin/actions/action_admin_delete_media.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Delete a media. After the deletion the user is redirected, and/or some items on the page are faded out.
%% @spec event(Event, Context1) -> Context2
event({postback, {delete_media, Id, OnSuccess}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={delete_media, Id, OnSuccess}}, Context) ->
case z_acl:rsc_deletable(Id, Context) of
true ->
ok = m_media:delete(Id, Context),
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_admin/actions/action_admin_delete_rsc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Delete a resource. After the deletion the user is redirected, and/or some items on the page are faded out.
%% @spec event(Event, Context1) -> Context2
event({postback, {delete_rsc, Id, OnSuccess}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={delete_rsc, Id, OnSuccess}}, Context) ->
case z_acl:rsc_deletable(Id, Context) of
true ->
ok = m_rsc:delete(Id, Context),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Fill the dialog with the delete confirmation template. The next step will ask to delete the media
%% @spec event(Event, Context1) -> Context2
event({postback, {delete_media_dialog, Id, OnSuccess}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={delete_media_dialog, Id, OnSuccess}}, Context) ->
case z_acl:rsc_deletable(Id, Context) of
true ->
Vars = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Fill the dialog with the delete confirmation template. The next step will ask to delete the resource
%% @spec event(Event, Context1) -> Context2
event({postback, {delete_rsc_dialog, Id, OnSuccess}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={delete_rsc_dialog, Id, OnSuccess}}, Context) ->
case z_acl:rsc_deletable(Id, Context) of
true ->
Vars = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Fill the dialog with the duplicate page form. The form will be posted back to this module.
%% @spec event(Event, Context1) -> Context2
event({postback, {duplicate_rsc_dialog, Id}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={duplicate_rsc_dialog, Id}}, Context) ->
Vars = [
{delegate, atom_to_list(?MODULE)},
{id, Id}
],
z_render:dialog("Duplicate page.", "_action_dialog_duplicate_rsc.tpl", Vars, Context);


event({submit, {duplicate_page, ActionProps}, _TriggerId, _TargetId}, Context) ->
event(#submit{message={duplicate_page, ActionProps}}, Context) ->
Id = proplists:get_value(id, ActionProps),
Title = z_context:get_q("new_rsc_title", Context),
IsPublished = z_context:get_q("is_published", Context),
Expand Down
4 changes: 2 additions & 2 deletions modules/mod_admin/actions/action_admin_dialog_edit_basics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Fill the dialog with the edit basics form. The form will be posted back to this module.
%% @spec event(Event, Context1) -> Context2
event({postback, {edit_basics, RscId, EdgeId, Template, Actions}, _TriggerId, TargetId}, Context) ->
event(#postback{message={edit_basics, RscId, EdgeId, Template, Actions}, target=TargetId}, Context) ->
ObjectId = case RscId of
undefined ->
{_, _, OId} = m_edge:get_triple(EdgeId, Context),
Expand All @@ -60,7 +60,7 @@ event({postback, {edit_basics, RscId, EdgeId, Template, Actions}, _TriggerId, Ta
z_render:dialog("Edit " ++ Title, "_action_dialog_edit_basics.tpl", Vars, Context);

%% @doc Save the thing and close the dialog.
event({submit, {rsc_edit_basics, Args}, _TriggerId, _TargetId}, Context) ->
event(#submit{message={rsc_edit_basics, Args}}, Context) ->
{id, Id} = proplists:lookup(id, Args),
{edge_id, EdgeId} = proplists:lookup(edge_id, Args),
Actions = proplists:get_value(actions, Args, []),
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_admin/actions/action_admin_dialog_link.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Unlink the edge, on success show an undo message in the element with id "unlink-message"
%% @spec event(Event, Context1) -> Context2
event({postback, {dialog_link, SubjectId, Predicate, ElementId, EdgeTemplate, Actions}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={dialog_link, SubjectId, Predicate, ElementId, EdgeTemplate, Actions}}, Context) ->
Pred = m_predicate:get(Predicate, Context),
Title = ["Add a connection: ", ?__(proplists:get_value(title, Pred), Context)],
PredCat = case m_predicate:object_category(Predicate, Context) of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Fill the dialog with the new page form. The form will be posted back to this module.
%% @spec event(Event, Context1) -> Context2
event({postback, {media_upload_dialog, Title, Id, SubjectId, Predicate, Stay, Actions}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={media_upload_dialog, Title, Id, SubjectId, Predicate, Stay, Actions}}, Context) ->
Vars = [
{delegate, atom_to_list(?MODULE)},
{id, Id },
Expand All @@ -56,7 +56,7 @@ event({postback, {media_upload_dialog, Title, Id, SubjectId, Predicate, Stay, Ac
z_render:dialog(DTitle, "_action_dialog_media_upload.tpl", Vars, Context);


event({submit, {media_upload, EventProps}, _TriggerId, _TargetId}, Context) ->
event(#submit{message={media_upload, EventProps}}, Context) ->
File = z_context:get_q_validated("upload_file", Context),
ContextUpload = case File of
#upload{filename=OriginalFilename, tmpfile=TmpFile} ->
Expand All @@ -80,7 +80,7 @@ event({submit, {media_upload, EventProps}, _TriggerId, _TargetId}, Context) ->
z_render:wire({dialog_close, []}, ContextUpload);


event({submit, {media_url, EventProps}, _TriggerId, _TargetId}, Context) ->
event(#submit{message={media_url, EventProps}}, Context) ->
Url = z_context:get_q("url", Context),
Props = case proplists:get_value(id, EventProps) of
undefined ->
Expand Down
4 changes: 2 additions & 2 deletions modules/mod_admin/actions/action_admin_dialog_new_rsc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Fill the dialog with the new page form. The form will be posted back to this module.
%% @spec event(Event, Context1) -> Context2
event({postback, {new_rsc_dialog, Title, Cat, NoCatSelect, Redirect, SubjectId, Predicate, EdgeTemplate, Actions}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={new_rsc_dialog, Title, Cat, NoCatSelect, Redirect, SubjectId, Predicate, EdgeTemplate, Actions}}, Context) ->
CatName = case Cat of
undefined -> "page";
_ -> z_convert:to_list(?__(m_rsc:p(Cat, title, Context), Context))
Expand All @@ -69,7 +69,7 @@ event({postback, {new_rsc_dialog, Title, Cat, NoCatSelect, Redirect, SubjectId,
z_render:dialog("Make a new "++CatName++".", "_action_dialog_new_rsc.tpl", Vars, Context);


event({submit, {new_page, Args}, _TriggerId, _TargetId}, Context) ->
event(#submit{message={new_page, Args}}, Context) ->
Title = z_context:get_q("new_rsc_title", Context),
CatId = list_to_integer(z_context:get_q("category_id", Context)),
IsPublished = z_context:get_q("is_published", Context),
Expand Down
4 changes: 2 additions & 2 deletions modules/mod_admin/actions/action_admin_link.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Unlink the edge, on success show an undo message in the element with id "unlink-message"
%% @spec event(Event, Context1) -> Context2
event({postback, {link, SubjectId, Predicate, ObjectId, ElementId, EdgeTemplate, Action}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={link, SubjectId, Predicate, ObjectId, ElementId, EdgeTemplate, Action}}, Context) ->
do_link(SubjectId, Predicate, ObjectId, ElementId, EdgeTemplate, Action, Context).


Expand Down Expand Up @@ -73,4 +73,4 @@ do_link(SubjectId, Predicate, ObjectId, ElementId, EdgeTemplate, Action, Context
false ->
z_render:growl_error("Sorry, you have no permission to add the connection.", Context)
end.


4 changes: 2 additions & 2 deletions modules/mod_admin/actions/action_admin_unlink.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Unlink the edge, on success show an undo message in the element with id "undo-message"
%% @spec event(Event, Context1) -> Context2
event({postback, {unlink, EdgeId, SubjectId, Predicate, ObjectId, Hide, UndoMessageId, EdgeTemplate, Action, UndoAction}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={unlink, EdgeId, SubjectId, Predicate, ObjectId, Hide, UndoMessageId, EdgeTemplate, Action, UndoAction}}, Context) ->
case z_acl:rsc_editable(SubjectId, Context) of
true ->
{SubjectId, Predicate1, ObjectId1} = case EdgeId of
Expand All @@ -69,4 +69,4 @@ event({postback, {unlink, EdgeId, SubjectId, Predicate, ObjectId, Hide, UndoMess
false ->
z_render:growl_error("Sorry, you have no permission to edit this page.", Context)
end.


2 changes: 1 addition & 1 deletion modules/mod_admin/actions/action_admin_zmedia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ render_action(TriggerId, TargetId, Args, Context) ->

%% @doc Unlink the edge, on success show an undo message in the element with id "unlink-message"
%% @spec event(Event, Context1) -> Context2
event({postback, {zmedia_choose, Args}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={zmedia_choose, Args}}, Context) ->
z_render:dialog("Add/edit media", "_action_dialog_zmedia_choose.tpl", Args, Context).

%z_render:wire([{growl, [{text, "Yay."}]}], Context).
Expand Down
4 changes: 2 additions & 2 deletions modules/mod_admin/actions/action_admin_zmedia_choose.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ render_action(TriggerId, TargetId, Args, Context) ->


%% @spec event(Event, Context1) -> Context2
event({postback, {zmedia_choose, []}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={zmedia_choose, []}}, Context) ->
?DEBUG(z_context:get("media_id", Context)),
Args = [{id, z_context:get("media_id", Context)}],
z_render:wire({zmedia_has_chosen, Args}, Context);

%% @spec event(Event, Context1) -> Context2
event({postback, {zmedia_choose, Args}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={zmedia_choose, Args}}, Context) ->
z_render:wire({zmedia_has_chosen, Args}, Context).


Expand Down
8 changes: 4 additions & 4 deletions modules/mod_admin/resources/resource_admin_edit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ensure_id(Context) ->


%% @doc Handle the submit of the resource edit form
event({submit, rscform, _FormId, _TargetId}, Context) ->
event(#submit{message=rscform}, Context) ->
Post = z_context:get_q_all_noz(Context),
Props = filter_props(Post),
Id = z_convert:to_integer(proplists:get_value("id", Props)),
Expand Down Expand Up @@ -116,21 +116,21 @@ event({submit, rscform, _FormId, _TargetId}, Context) ->
z_render:growl_error("Something went wrong. Sorry.", Context)
end;

event({postback, {reload_media, Opts}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={reload_media, Opts}}, Context) ->
RscId = proplists:get_value(rsc_id, Opts),
DivId = proplists:get_value(div_id, Opts),
{Html, Context1} = z_template:render_to_iolist({cat, "_edit_media.tpl"}, [{id,RscId},{div_id,DivId}], Context),
z_render:update(DivId, Html, Context1);

event({sort, Sorted, {dragdrop, {object_sorter, Props}, _, _}}, Context) ->
event(#sort{items=Sorted, drop={dragdrop, {object_sorter, Props}, _, _}}, Context) ->
RscId = proplists:get_value(id, Props),
Predicate = proplists:get_value(predicate, Props),
EdgeIds = [ EdgeId || {dragdrop, EdgeId, _, _ElementId} <- Sorted ],
m_edge:update_sequence_edge_ids(RscId, Predicate, EdgeIds, Context),
Context;

%% Previewing the results of a query in the admin edit
event({postback, {query_preview, Opts}, _TriggerId, _TargetId}, Context) ->
event(#postback{message={query_preview, Opts}}, Context) ->
DivId = proplists:get_value(div_id, Opts),
try
Q = search_query:parse_query_text(z_context:get_q("triggervalue", Context)),
Expand Down
Loading

0 comments on commit 1d00e7b

Please sign in to comment.