From 4f33923ff61a9b2eef3c1e2101c1d235e0776a66 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 6 Oct 2023 12:10:02 +0100 Subject: [PATCH] Render the changelog in the admin interface Make it easier for admins to read about new features that have been added to Alaveteli from within Alaveteli itself. --- Gemfile | 1 + Gemfile.lock | 2 ++ app/controllers/admin/changelog_controller.rb | 9 +++++++++ app/views/admin/changelog/index.html.erb | 17 +++++++++++++++++ app/views/layouts/admin.html.erb | 5 ++++- config/routes.rb | 6 ++++++ .../admin/changelog_controller_spec.rb | 15 +++++++++++++++ 7 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/changelog_controller.rb create mode 100644 app/views/admin/changelog/index.html.erb create mode 100644 spec/controllers/admin/changelog_controller_spec.rb diff --git a/Gemfile b/Gemfile index 104a6e8f43f..c808b66827d 100644 --- a/Gemfile +++ b/Gemfile @@ -114,6 +114,7 @@ gem 'recaptcha', '~> 5.15.0', require: 'recaptcha/rails' gem 'matrix', '~> 0.4.2' gem 'mini_magick', '~> 4.12.0' gem 'net-protocol', '~> 0.1.3' +gem 'redcarpet', '~> 3.6.0' gem 'redis', '~> 4.8.1' gem 'rolify', '~> 6.0.1' gem 'ruby-msg', '~> 1.5.0', git: 'https://github.com/mysociety/ruby-msg.git', branch: 'ascii-encoding' diff --git a/Gemfile.lock b/Gemfile.lock index e4fdcf8c60c..9671e813a26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -420,6 +420,7 @@ GEM rainbow (3.1.1) rake (13.0.6) recaptcha (5.15.0) + redcarpet (3.6.0) redis (4.8.1) redlock (1.3.2) redis (>= 3.0.0, < 6.0) @@ -627,6 +628,7 @@ DEPENDENCIES rails-controller-testing rails-i18n (~> 7.0.5) recaptcha (~> 5.15.0) + redcarpet (~> 3.6.0) redis (~> 4.8.1) rolify (~> 6.0.1) routing-filter (~> 0.7.0) diff --git a/app/controllers/admin/changelog_controller.rb b/app/controllers/admin/changelog_controller.rb new file mode 100644 index 00000000000..6a897f1f7e7 --- /dev/null +++ b/app/controllers/admin/changelog_controller.rb @@ -0,0 +1,9 @@ +# Controller to render the changelog notes in a more human-friendly way within +# the admin interface. +class Admin::ChangelogController < AdminController + def index + markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new) + text = File.read(Rails.root + 'doc/CHANGES.md') + @changelog = markdown.render(text).html_safe + end +end diff --git a/app/views/admin/changelog/index.html.erb b/app/views/admin/changelog/index.html.erb new file mode 100644 index 00000000000..4c57a74983e --- /dev/null +++ b/app/views/admin/changelog/index.html.erb @@ -0,0 +1,17 @@ +<% @title = 'Alaveteli Changelog' %> + +

<%= @title %>

+ +

+ The changelog documents the features and upgrade notes for each versioned + release of Alaveteli. Here you will see the changelog for the version of + Alaveteli you have installed. You can check GitHub for + newer releases of + Alaveteli and preview upcoming changes in the + + development version of the changelog. +

+ +
+ +<%= @changelog %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index a41cb0cc974..6b72ea103d7 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -44,13 +44,16 @@