Fix crash when feeds were not enabled
This commit is contained in:
parent
24eb944cbd
commit
6196309619
3 changed files with 21 additions and 6 deletions
|
@ -12,6 +12,7 @@ defmodule MebeWeb.ControllerUtils do
|
|||
@disqus_comments Application.get_env(:blog_config, :disqus_comments)
|
||||
@page_commenting Application.get_env(:blog_config, :page_commenting)
|
||||
@disqus_shortname Application.get_env(:blog_config, :disqus_shortname)
|
||||
@feeds_enabled Application.get_env(:blog_config, :enable_feeds)
|
||||
|
||||
@doc """
|
||||
Render a list of posts with the given template and params. The posts
|
||||
|
@ -36,5 +37,6 @@ defmodule MebeWeb.ControllerUtils do
|
|||
|> assign(:disqus_comments, @disqus_comments)
|
||||
|> assign(:page_commenting, @page_commenting)
|
||||
|> assign(:disqus_shortname, @disqus_shortname)
|
||||
|> assign(:feeds_enabled, @feeds_enabled)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
<title><%= title @conn %></title>
|
||||
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
|
||||
|
||||
<%= if @feeds_enabled do %>
|
||||
<%= if assigns[:page_type] == :tag do %>
|
||||
<link href="<%= @absolute_url %><%= feed_path @conn, :tag, @tag %>" rel="alternate" type="application/rss+xml" title="RSS feed for tag <%= @tag %>" />
|
||||
<% else %>
|
||||
<link href="<%= @absolute_url %><%= feed_path @conn, :index %>" rel="alternate" type="application/rss+xml" title="RSS feed" />
|
||||
<% end %>
|
||||
<% end %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -21,7 +23,7 @@
|
|||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a href="<%= @absolute_url %>" class="navbar-brand">
|
||||
<%= Application.get_env :blog_config, :blog_name %>
|
||||
<%= @blog_name %>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
@ -37,7 +39,7 @@
|
|||
<div class="footer row">
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<p>
|
||||
© <%= Application.get_env :blog_config, :blog_author %>
|
||||
© <%= @blog_author %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
|
|
|
@ -4,6 +4,8 @@ defmodule MebeWeb.LayoutView do
|
|||
@default_title Application.get_env(:blog_config, :blog_name)
|
||||
@extra_html Application.get_env(:blog_config, :extra_html)
|
||||
|
||||
@feeds_enabled Application.get_env(:blog_config, :enable_feeds)
|
||||
|
||||
@doc """
|
||||
Resolve title from the current assigns. Will use the current page's or post's title, if available.
|
||||
Otherwise will render default title.
|
||||
|
@ -25,6 +27,15 @@ defmodule MebeWeb.LayoutView do
|
|||
"""
|
||||
def extra_html(), do: @extra_html
|
||||
|
||||
if not @feeds_enabled do
|
||||
@doc """
|
||||
If feeds are not enabled, mock the feed_path functions so that compilation does not crash because
|
||||
of missing feed_path.
|
||||
"""
|
||||
def feed_path(_, _), do: nil
|
||||
def feed_path(_, _, _), do: nil
|
||||
end
|
||||
|
||||
@doc """
|
||||
Calculate time taken for request so far.
|
||||
"""
|
||||
|
|
Reference in a new issue