diff --git a/apps/zotonic_core/src/support/z_lib_include.erl b/apps/zotonic_core/src/support/z_lib_include.erl
index 47fe9f7778..003b4e0bb6 100644
--- a/apps/zotonic_core/src/support/z_lib_include.erl
+++ b/apps/zotonic_core/src/support/z_lib_include.erl
@@ -40,10 +40,10 @@ tag(Files, Context) ->
%% @doc Generate the link and/or script tags for the given files.
tag(Files, Args, Context) ->
- case m_config:get_value(mod_development, libsep, Context) of
- Empty when Empty == []; Empty == <<>>; Empty == undefined ->
+ case m_config:get_boolean(mod_development, libsep, Context) of
+ false ->
tag1(Files, Args, Context);
- _Other ->
+ true ->
lists:foldr(fun(F, [Css,Js]) ->
[C,J] = tag1([F], Args, Context),
[[C|Css], [J|Js]]
@@ -65,10 +65,12 @@ url(Files, Args, Context) ->
url_for(_F, [], _Ext, _Args, _Context) -> [];
url_for(F, P, Ext, Args, Context) ->
- [z_dispatcher:url_for(lib(Context), url_for_args(F, P, Ext, Args, Context), Context)].
+ [z_dispatcher:url_for(lib(Args, Context), url_for_args(F, P, Ext, Args, Context), Context)].
-lib(Context) ->
- case z_convert:to_bool(m_site:get(minification_enabled, Context)) of
+lib(Args, Context) ->
+ case z_convert:to_bool( proplists:get_value(minify, Args, false))
+ orelse m_config:get_boolean(site, minification_enabled, Context)
+ of
true -> lib_min;
false -> lib
end.
@@ -95,16 +97,60 @@ link_element(Css, CssPath, Args, Context) ->
undefined -> [];
TitleValue -> [<<" title=\"">>, TitleValue, $"]
end,
- MediaAttr = [<<" media=\"">>, proplists:get_value(media, Args, "all"), $"],
- RelAttr = [<<" rel=\"">>, proplists:get_value(rel, Args, "stylesheet"), $"],
- CssUrl = z_dispatcher:url_for(lib(Context), url_for_args(Css, CssPath, <<".css">>, Args, Context), Context),
- iolist_to_binary([<<">, CssUrl, <<"\" type=\"text/css\"">>, MediaAttr, TitleAttr, RelAttr, $/, $>]).
+ Media = proplists:get_value(media, Args, <<"all">>),
+ Rel = proplists:get_value(rel, Args, <<"stylesheet">>),
+ CssUrl = z_dispatcher:url_for(
+ lib(Args, Context),
+ url_for_args(Css, CssPath, <<".css">>, Args, Context),
+ Context),
+ case z_convert:to_bool( proplists:get_value(async, Args, false)) of
+ true ->
+ iolist_to_binary([
+ <<">, CssUrl, <<"\" type=\"text/css\"">>,
+ TitleAttr,
+ <<" media=\"none\"">>,
+ <<" onload=\"if(media!='">>, Media, <<"')media='">>, Media, <<"'\"">>,
+ <<" rel=\"">>, Rel, $",
+ <<">">>,
+ <<"">>
+
+ ]);
+ false ->
+ iolist_to_binary([
+ <<">, CssUrl, <<"\" type=\"text/css\"">>,
+ TitleAttr,
+ <<" media=\"">>, Media, $",
+ <<" rel=\"">>, Rel, $",
+ <<">">>
+ ])
+ end.
script_element(_Js, [], _Args, _Context) ->
[];
script_element(Js, JsPath, Args, Context) ->
- JsUrl = z_dispatcher:url_for(lib(Context), url_for_args(Js, JsPath, <<".js">>, Args, Context), Context),
- iolist_to_binary([<<"">>]).
+ JsUrl = z_dispatcher:url_for(
+ lib(Args, Context),
+ url_for_args(Js, JsPath, <<".js">>, Args, Context),
+ Context),
+ AsyncAttr = case z_convert:to_bool( proplists:get_value(async, Args, false)) of
+ true ->
+ <<" async ">>;
+ false ->
+ <<>>
+ end,
+ iolist_to_binary([
+ <<"">>
+ ]).
url_for_args(Files, JoinedPath, Extension, Args, Context) ->
AbsUrlArg = case proplists:get_value(absolute_url, Args, false) of
diff --git a/apps/zotonic_mod_base/priv/lib/js/apps/z.widgetmanager.js b/apps/zotonic_mod_base/priv/lib/js/apps/z.widgetmanager.js
index 7abdd870f3..8436c073a2 100644
--- a/apps/zotonic_mod_base/priv/lib/js/apps/z.widgetmanager.js
+++ b/apps/zotonic_mod_base/priv/lib/js/apps/z.widgetmanager.js
@@ -190,4 +190,20 @@ limitations under the License.
return this;
};
+ // Make jQuery UI optional
+ if (typeof $.ui === 'undefined') {
+ $.ui = {
+ dialog: {}
+ };
+ }
+
+ if (typeof $.widget !== 'function')
+ {
+ $.widget = function( widgetName ) {
+ let name = widgetName.replace(/^ui\./, '');
+ $.ui[name] = {
+ };
+ }
+ }
+
})(jQuery);
diff --git a/apps/zotonic_mod_translation/priv/lib-src/Makefile b/apps/zotonic_mod_translation/priv/lib-src/Makefile
new file mode 100644
index 0000000000..4b72e7efe5
--- /dev/null
+++ b/apps/zotonic_mod_translation/priv/lib-src/Makefile
@@ -0,0 +1,3 @@
+
+../lib/css/mod_translation.css: mod_translation.less
+ lessc --include-path="../../../zotonic_mod_admin/priv/lib-src/zotonic-admin/less/" mod_translation.less ../lib/css/mod_translation.css
diff --git a/apps/zotonic_mod_translation/priv/lib/less/mod_translation.less b/apps/zotonic_mod_translation/priv/lib-src/mod_translation.less
similarity index 97%
rename from apps/zotonic_mod_translation/priv/lib/less/mod_translation.less
rename to apps/zotonic_mod_translation/priv/lib-src/mod_translation.less
index dfb7e745e2..0ebd47a804 100644
--- a/apps/zotonic_mod_translation/priv/lib/less/mod_translation.less
+++ b/apps/zotonic_mod_translation/priv/lib-src/mod_translation.less
@@ -1,4 +1,4 @@
-@import (reference) "../../../../zotonic_mod_admin/priv/lib/less/variables.less";
+@import (reference) "variables.less";
.dropdown-menu {
&.mod_translation_menu-has-icons {
diff --git a/apps/zotonic_mod_translation/priv/lib/less/config b/apps/zotonic_mod_translation/priv/lib/less/config
deleted file mode 100644
index 0b4a8ace50..0000000000
--- a/apps/zotonic_mod_translation/priv/lib/less/config
+++ /dev/null
@@ -1,8 +0,0 @@
-%% Less config for Zotonic's file watcher
-%% Params 'from' and 'to' are mandatory.
-%% Path values are local to this config file.
-[
- {from, "mod_translation.less"},
- {to, "../css/mod_translation.css"},
- {params, "--include-path='../../../../zotonic_mod_admin/priv/lib/less'"}
-].
diff --git a/apps/zotonic_mod_translation/priv/lib/less/less_to_css b/apps/zotonic_mod_translation/priv/lib/less/less_to_css
deleted file mode 100755
index 52a0241371..0000000000
--- a/apps/zotonic_mod_translation/priv/lib/less/less_to_css
+++ /dev/null
@@ -1 +0,0 @@
-lessc --include-path="../../../../zotonic_mod_admin/priv/lib/less" mod_translation.less ../css/mod_translation.css
diff --git a/doc/ref/tags/tag_lib.rst b/doc/ref/tags/tag_lib.rst
index 2b2ea111bb..f1c8fe3213 100644
--- a/doc/ref/tags/tag_lib.rst
+++ b/doc/ref/tags/tag_lib.rst
@@ -29,13 +29,23 @@ Will output::
The number at the end is the Unix modification time of the most recently changed file.
-The `lib` tag supports optional arguments to control the resulting html tag:
+The `lib` tag supports optional arguments to control the resulting html tag. The arguments are supplied
+after the list of files::
+
+ {% lib
+ "css/not-so-important-styles.css"
+ minify
+ async
+ %}
+
+
+Accepted arguments are:
+-----------------+-------------+---------------------------------------------------------+
|Option |Default |Description |
+=================+=============+=========================================================+
|absolute_url |false |If true, prefix the generated URL with |
-| | |"http://{hostname}/". |
+| | |"https://{hostname}/". |
+-----------------+-------------+---------------------------------------------------------+
|title | |Specify a value for the title attribute of the link tag. |
+-----------------+-------------+---------------------------------------------------------+
@@ -43,5 +53,10 @@ The `lib` tag supports optional arguments to control the resulting html tag:
+-----------------+-------------+---------------------------------------------------------+
|rel |"stylesheet" |Specify value for the rel attribute of the link tag. |
+-----------------+-------------+---------------------------------------------------------+
+|minify | |Force minification use as ``{% lib ... minify %}`` |
++-----------------+-------------+---------------------------------------------------------+
+|async | |Load css or javascript asynchronously, use as |
+| | | ``{% lib ... async %}`` |
++-----------------+-------------+---------------------------------------------------------+
.. seealso:: :ref:`mod_development`.