Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

core: move skeleton modules and menu to site config.

  • Loading branch information...
commit b8898062050fd305771b0fb09f4b528cc46c9dda 1 parent 24898c9
@kaos kaos authored
View
10 doc/manuals/site-anatomy.rst
@@ -86,7 +86,15 @@ The following options can be configured:
``{skeleton, blog}``
Set by the ``zotonic addsite`` command, this settings tells Zotonic
which skeleton site to use.
-
+
+``{install_menu, [<menu-item>...]}``
+ Creates the initial main menu when installing mod_menu. A `menu-item`
+ is a erlang tuple with a resource id and a list of child menu-items,
+ if any: ``{rsc_name, []}``.
+
+``{install_modules, [<modules>...]}``
+ List all modules that should be enabled when installing the site data.
+
Database connection options
...........................
View
111 priv/skel/blog/config.in
@@ -1,39 +1,76 @@
-% Zotonic site configuration for %%SITE%%.
+%% Zotonic site configuration for %%SITE%%.
[
- % This site is enabled or not.
- {enabled, true},
-
- % Hostname on which this site runs
- {hostname, "%%SITE%%:8000"},
-
- % Aliases which should redirect to the primary hostname
- %{hostalias, "www.example.com"},
- %{hostalias, "example.com"},
-
- % PostgreSQL database connection
- {dbhost, "%%DBHOST%%"},
- {dbport, %%DBPORT%%},
- {dbuser, "%%DBUSER%%"},
- {dbpassword, "%%DBPASSWORD%%"},
- {dbdatabase, "%%DBDATABASE%%"},
- {dbschema, "%%DBSCHEMA%%"},
-
- % Depcache settings, maximum size in mbs
- {depcache_memory_max, 100},
-
- % Password for the 'admin' user.
- {admin_password, "%%ADMINPASSWORD%%"},
-
- % What skeleton site this site is based on; for installing the initial data.
- {skeleton, %%SKEL%%},
-
- %% Specific options
-
- %% Title of your site
- {title, <<"Your first blog">>},
- %% Subtitle
- {subtitle, <<"built with Zotonic, the Erlang CMS.">>},
-
- %% Page length
- {pagelen, 5}
+ %% This site is enabled or not.
+ {enabled, true},
+
+ %% Hostname on which this site runs
+ {hostname, "%%SITE%%:8000"},
+
+ %% Aliases which should redirect to the primary hostname
+ %%{hostalias, "www.example.com"},
+ %%{hostalias, "example.com"},
+
+ %% PostgreSQL database connection
+ {dbhost, "%%DBHOST%%"},
+ {
+ dbport, %%DBPORT%%
+ },
+ {dbuser, "%%DBUSER%%"},
+ {dbpassword, "%%DBPASSWORD%%"},
+ {dbdatabase, "%%DBDATABASE%%"},
+ {dbschema, "%%DBSCHEMA%%"},
+
+ %% Depcache settings, maximum size in mbs
+ {depcache_memory_max, 100},
+
+ %% Password for the 'admin' user.
+ {admin_password, "%%ADMINPASSWORD%%"},
+
+ %% What skeleton site this site is based on; for installing the initial data.
+ {
+ skeleton, %%SKEL%%
+ },
+ {install_menu, [{page_home, []}, {page_about, []}, {page_contact, []}]},
+ {install_modules,
+ [
+ mod_base,
+ mod_base_site,
+ mod_menu,
+ mod_oauth,
+ mod_search,
+ mod_oembed,
+ mod_atom_feed,
+ mod_translation,
+ mod_signal,
+ mod_logging,
+
+ mod_seo,
+ mod_seo_google,
+ mod_seo_sitemap,
+
+ mod_authentication,
+ mod_acl_adminonly,
+
+ mod_admin,
+ mod_admin_category,
+ mod_admin_config,
+ mod_admin_identity,
+ mod_admin_modules,
+ mod_admin_predicate,
+
+ mod_l10n,
+ mod_geomap,
+
+ mod_comment,
+ mod_bootstrap,
+ ]},
+ %% Specific options
+
+ %% Title of your site
+ {title, <<"Your first blog">>},
+ %% Subtitle
+ {subtitle, <<"built with Zotonic, the Erlang CMS.">>},
+
+ %% Page length
+ {pagelen, 5}
].
View
67 priv/skel/empty/config.in
@@ -1,29 +1,54 @@
-% Zotonic site configuration for %%SITE%%.
+%% Zotonic site configuration for %%SITE%%.
[
- % This site is enabled or not.
- {enabled, true},
+ %% This site is enabled or not.
+ {enabled, true},
- % Hostname on which this site runs
- {hostname, "%%SITE%%:8000"},
+ %% Hostname on which this site runs
+ {hostname, "%%SITE%%:8000"},
- % Aliases which should redirect to the primary hostname
- %{hostalias, "www.example.com"},
- %{hostalias, "example.com"},
+ %% Aliases which should redirect to the primary hostname
+ %%{hostalias, "www.example.com"},
+ %%{hostalias, "example.com"},
- % PostgreSQL database connection
- {dbhost, "%%DBHOST%%"},
- {dbport, %%DBPORT%%},
- {dbuser, "%%DBUSER%%"},
- {dbpassword, "%%DBPASSWORD%%"},
- {dbdatabase, "%%DBDATABASE%%"},
- {dbschema, "%%DBSCHEMA%%"},
+ %% PostgreSQL database connection
+ {dbhost, "%%DBHOST%%"},
+ {
+ dbport, %%DBPORT%%
+ },
+ {dbuser, "%%DBUSER%%"},
+ {dbpassword, "%%DBPASSWORD%%"},
+ {dbdatabase, "%%DBDATABASE%%"},
+ {dbschema, "%%DBSCHEMA%%"},
- % Depcache settings. The maximum size in Mbs
- {depcache_memory_max, 100},
+ %% Depcache settings. The maximum size in Mbs
+ {depcache_memory_max, 100},
- % Password for the 'admin' user.
- {admin_password, "%%ADMINPASSWORD%%"},
+ %% Password for the 'admin' user.
+ {admin_password, "%%ADMINPASSWORD%%"},
- % What skeleton site this site is based on; for installing the initial data.
- {skeleton, %%SKEL%%}
+ %% What skeleton site this site is based on; for installing the initial data.
+ {
+ skeleton, %%SKEL%%
+ },
+ %%{install_menu, []},
+ {install_modules,
+ [
+ mod_base,
+ mod_menu,
+ mod_oauth,
+ mod_search,
+ mod_oembed,
+ mod_signal,
+ mod_logging,
+
+ mod_authentication,
+ mod_acl_adminonly,
+
+ mod_admin,
+ mod_admin_category,
+ mod_admin_config,
+ mod_admin_identity,
+ mod_admin_modules,
+ mod_admin_predicate
+ ]}
].
View
72 priv/skel/nodb/config.in
@@ -1,37 +1,39 @@
-% Zotonic site configuration for %%SITE%%.
+%% Zotonic site configuration for %%SITE%%.
[
- % This site is enabled or not.
- {enabled, true},
-
- % Hostname on which this site runs
- {hostname, "%%SITE%%:8000"},
-
- % Aliases which should redirect to the primary hostname
- %{hostalias, "www.example.com"},
- %{hostalias, "example.com"},
-
- %% This site doesn't use a database connection
- {dbdatabase, none},
-
- %% Installed modules, defined here as there is no database connection
- {modules, [
- %%SITE%%,
- mod_base,
- mod_admin,
- mod_bootstrap,
- mod_zotonic_status_vcs,
- mod_zotonic_tracer
- ]},
-
- %% Default config keys
- {site, [{language, "en"}]},
-
- % Depcache settings. The maximum size in Mbs
- {depcache_memory_max, 100},
-
- % Password for the 'admin' user.
- {admin_password, "%%ADMINPASSWORD%%"},
-
- % What skeleton site this site is based on; for installing the initial data.
- {skeleton, %%SKEL%%}
+ %% This site is enabled or not.
+ {enabled, true},
+
+ %% Hostname on which this site runs
+ {hostname, "%%SITE%%:8000"},
+
+ %% Aliases which should redirect to the primary hostname
+ %%{hostalias, "www.example.com"},
+ %%{hostalias, "example.com"},
+
+ %% This site doesn't use a database connection
+ {dbdatabase, none},
+
+ %% Installed modules, defined here as there is no database connection
+ {modules, [
+ %%SITE%%,
+ mod_base,
+ mod_admin,
+ mod_bootstrap,
+ mod_zotonic_status_vcs,
+ mod_zotonic_tracer
+ ]},
+
+ %% Default config keys
+ {site, [{language, "en"}]},
+
+ %% Depcache settings. The maximum size in Mbs
+ {depcache_memory_max, 100},
+
+ %% Password for the 'admin' user.
+ {admin_password, "%%ADMINPASSWORD%%"},
+
+ %% What skeleton site this site is based on; for installing the initial data.
+ {
+ skeleton, %%SKEL%%
+ }
].
View
4 src/install/z_install.erl
@@ -58,11 +58,9 @@ pre_install(_, _) ->
%% @spec install(Host) -> ok
install(Host) ->
{ok, C} = pgsql_pool:get_connection(Host),
- Skeleton = proplists:get_value(skeleton, z_sites_manager:get_site_config(Host)),
-
ok = pgsql:with_transaction(C, fun (C2) ->
install_sql_list(C, model_pgsql()),
- z_install_data:install(Skeleton, Host, C2),
+ z_install_data:install(Host, C2),
ok
end
),
View
86 src/install/z_install_data.erl
@@ -23,7 +23,7 @@
%% interface functions
-export([
- install/3,
+ install/2,
install_category/1
]).
@@ -31,10 +31,10 @@
%% @doc Insert boot data into the database.
%% @spec install(Skeleton::atom(), Host::atom(), Connection) -> ok
-install(Skeleton, Host, C) ->
+install(Host, C) ->
?DEBUG({Host, "Install start."}),
ok = install_config(C),
- ok = install_modules(Skeleton, Host, C),
+ ok = install_modules(Host, C),
ok = install_category(C),
ok = install_rsc(C),
ok = install_identity(C),
@@ -52,81 +52,15 @@ install_config(_C) ->
%% pgsql:reset_id(C, "config"),
ok.
-
-install_modules(blog, Host, C) ->
- Modules =
- [
- "mod_base",
- "mod_base_site",
- "mod_menu",
- "mod_oauth",
- "mod_search",
- "mod_oembed",
- "mod_atom_feed",
- "mod_translation",
- "mod_signal",
- "mod_logging",
-
- "mod_seo",
- "mod_seo_google",
- "mod_seo_sitemap",
-
- "mod_authentication",
- "mod_acl_adminonly",
-
- "mod_admin",
- "mod_admin_category",
- "mod_admin_config",
- "mod_admin_identity",
- "mod_admin_modules",
- "mod_admin_predicate",
-
- "mod_l10n",
- "mod_geomap",
-
- "mod_comment",
- "mod_bootstrap",
-
- %% The site-specific site
- atom_to_list(Host)
- ],
- install_modules(Modules, C);
-install_modules(empty, Host, C) ->
- Modules =
- [
- "mod_base",
- "mod_menu",
- "mod_oauth",
- "mod_search",
- "mod_oembed",
- "mod_signal",
- "mod_logging",
-
- "mod_authentication",
- "mod_acl_adminonly",
-
- "mod_admin",
- "mod_admin_category",
- "mod_admin_config",
- "mod_admin_identity",
- "mod_admin_modules",
- "mod_admin_predicate",
-
- %% The site-specific site
- atom_to_list(Host)
- %% plus any from the site config
- |proplists:get_value(modules, z_sites_manager:get_site_config(Host), [])
- ],
- install_modules(Modules, C);
-install_modules(nodb, _, _) ->
- ok;
-install_modules(Err, Host, _) ->
- ?ERROR("~p: Invalid or missing skeleton: ~p.", [Host, Err]).
-
-install_modules(Modules, C) ->
+install_modules(Host, C) ->
?DEBUG("Inserting modules"),
+ Modules = [Host|proplists:get_value(install_modules, z_sites_manager:get_site_config(Host), [])],
[
- {ok, 1} = pgsql:equery(C, "insert into module (name, is_active) values ($1, true)", [M]) || M <- Modules
+ {ok, 1} = pgsql:equery(
+ C,
+ "insert into module (name, is_active) values ($1, true)",
+ [M])
+ || M <- Modules
],
ok.
View
15 src/install/z_install_defaultdata.erl
@@ -148,20 +148,11 @@ install(_, _) ->
%% @doc Retrieve the default menu structure for a given site. Used by mod_menu to create the menu.
default_menu(Context) ->
- case m_site:get(skeleton, Context) of
- empty ->
- m_site:get(default_menu, Context);
- Skeleton ->
- default_skeleton_menu(Skeleton)
+ case m_site:get(install_menu, Context) of
+ Menu when is_list(Menu) -> Menu;
+ _ -> []
end.
-default_skeleton_menu(blog) ->
- [{page_home, []}, {page_about, []}, {page_contact, []}];
-
-default_skeleton_menu(_) ->
- %% no/unknown skeleton = no default menu
- undefined.
-
%% @doc Helper function for getting an absolute path to a data file
%% that is part of the default data for a site skeleton.
Please sign in to comment.
Something went wrong with that request. Please try again.