From 90459b2588102917548d6c06610e1dd82150ba91 Mon Sep 17 00:00:00 2001 From: Mikko Ahlroth Date: Tue, 29 Dec 2015 21:41:59 +0200 Subject: [PATCH] Add feature to use custom CSS if set in settings --- README.md | 2 +- config/config.exs.dist | 6 +++++- web/controllers/controller_utils.ex | 2 ++ web/templates/layout/app.html.eex | 9 ++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8013f9e..a892a70 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ The engine consists of two parts: * Disqus commenting * RSS feeds for all posts and for tags * Override templates by putting replacements into a directory +* Use custom style CSS by defining path in settings * Expect script for refreshing blog from the command line * Splitting of posts so that only the beginning will be shown in a list view or feed @@ -32,7 +33,6 @@ The engine consists of two parts: * Tests * User's guide * Sitemap -* Override styles more easily ## Licence diff --git a/config/config.exs.dist b/config/config.exs.dist index 68f4fce..b3cdba2 100644 --- a/config/config.exs.dist +++ b/config/config.exs.dist @@ -65,7 +65,11 @@ config :mebe_web, "FeedView" => false, "PageView" => false, "LayoutView" => false # Base layouts - } + }, + + use_default_style: true, # Use the default builtin style.css + custom_style_path: '/custom.css' # Path to custom style CSS, appended to absolute_url. Set to nil to disable + # Configures Elixir's Logger config :logger, :console, diff --git a/web/controllers/controller_utils.ex b/web/controllers/controller_utils.ex index e363e05..cd2bcf8 100644 --- a/web/controllers/controller_utils.ex +++ b/web/controllers/controller_utils.ex @@ -32,6 +32,8 @@ defmodule MebeWeb.ControllerUtils do |> assign(:disqus_shortname, Utils.get_conf(:disqus_shortname)) |> assign(:feeds_enabled, Utils.get_conf(:feeds_enabled)) |> assign(:force_read_more, Utils.get_conf(:force_read_more)) + |> assign(:use_default_style, Utils.get_conf(:use_default_style)) + |> assign(:custom_style_path, Utils.get_conf(:custom_style_path)) end @doc """ diff --git a/web/templates/layout/app.html.eex b/web/templates/layout/app.html.eex index 850c045..9423ae1 100644 --- a/web/templates/layout/app.html.eex +++ b/web/templates/layout/app.html.eex @@ -7,7 +7,14 @@ <%= title @conn %> - "> + + <%= if @use_default_style do %> + "> + <% end %> + + <%= if @custom_style_path != nil do %> + + <% end %> <%= if @feeds_enabled do %> <%= if assigns[:page_type] == :tag do %>