Skip to content

Commit

Permalink
Add instance-info CMS content
Browse files Browse the repository at this point in the history
This allows instance owners to provice some instance-specific information on
the main landing page.
  • Loading branch information
zonque committed Apr 14, 2024
1 parent a7bbc0d commit 4bf18d3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ The following keys are used in the project:
- `tos`: Terms of Service
- `privacy`: Data privacy policy
- `imprint`: Imprint
- `instance-info`: Information about the instance, displayed on the landing page

## Cleanup task

Expand Down
6 changes: 6 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
class HomeController < ApplicationController
def index
content = Content.for('instance-info', I18n.locale)
unless content.nil?
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {})
@instance_info_text = markdown.render(content.content)
@instance_info_title = content.title
end
end
end
6 changes: 6 additions & 0 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@
privacy_policy: link_to(t('privacy_policy'), privacy_path),
github_project: link_to('GitHub', 'https://github.com/HopHubProject')).each do |text|
%p= text.html_safe

-if @instance_info_text.present?
.col-12.col-lg-9
.shadow.p-3.mb-5.bg-body.rounded
%h1= @instance_info_title
= @instance_info_text.html_safe
4 changes: 4 additions & 0 deletions test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class HomeControllerTest < ActionDispatch::IntegrationTest
define_method("test_should_get_index_#{locale}") do
get root_url, params: { locale: locale }
assert_response :success

c = Content.for('instance-info', locale)
assert_match c.content, @response.body
assert_match c.title, @response.body
end

define_method("test_should_get_imprint_#{locale}") do
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/contents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ privacy_en:
locale: en
fallback: true
content: Privacy EN

instance_info_en:
name: instance-info
title: Instance Info
locale: en
fallback: true
content: Instance Info EN

0 comments on commit 4bf18d3

Please sign in to comment.