Skip to content

Commit

Permalink
Custom HTML support (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstorm authored Jan 12, 2023
1 parent c20bb03 commit fe3522c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Admin
class SettingsController < Admin::ApplicationController

SETTING_KEYS = %w(blog_name blog_background_color admin_username admin_password site_favicon)
SETTING_KEYS = %w(blog_name blog_background_color blog_custom_html admin_username admin_password site_favicon)

def index
@title = "Settings"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/blog/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Blog
class ApplicationController < ::ApplicationController
META_KEYS = %w(blog_name blog_background_color)
META_KEYS = %w(blog_name blog_background_color blog_custom_html)

layout "blog"
before_action :set_meta_values
Expand Down
6 changes: 5 additions & 1 deletion app/views/admin/setting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@
</div>
<%= form.text_field :blog_background_color, class:"form-control", value:@settings[:blog_background_color], placeholder: "#ffffff" %>
</div>

<div class="flex flex-col space-y-2">
<%= form.label :blog_name, "Blog name" %>
<%= form.text_field :blog_name, class:"form-control", value:@settings[:blog_name], placeholder:@settings[:blog_name], required: true %>
</div>
<div class="flex flex-col space-y-2">
<%= form.label :blog_name, "Custom HTML" %>
<%= form.text_area :blog_custom_html, class:"form-control", value:@settings[:blog_custom_html], placeholder:@settings[:blog_custom_html], required: false %>
<p class="text-gray-500 text-xs">The custom HTML will be added to the bottom of your blog page's source code.</p>
</div>
<div class="flex flex-col space-y-2">
<%= form.label :admin_username, "Admin username" %>
<%= form.text_field :admin_username, class:"form-control", value:@settings[:admin_username], placeholder: "admin", required: true, disabled: @is_disable_update_admin %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/blog/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<footer>
<i>Powered by <a href="https://github.com/blackstorm/goose" target="_blank">Goose</a></i>
</footer>
9 changes: 6 additions & 3 deletions app/views/layouts/blog.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
<%= link_to @blog_mates[:blog_name], root_path %>
</h1>
<%= yield %>
<footer>
<i>Powered by <a href="https://github.com/blackstorm/goose" target="_blank">Goose</a></i>
</footer>
<% if @blog_mates[:blog_custom_html].nil? %>
<%= render "blog/footer" %>
<% else %>
<%= @blog_mates[:blog_custom_html] && @blog_mates[:blog_custom_html].html_safe %>
<%= render "blog/footer" %>
<% end %>
</body>
</html>

0 comments on commit fe3522c

Please sign in to comment.