What's new stays short as releases pile up

- Admin → About shows the running version's release notes, with a link
  to all releases.
- The What's new page keeps the running version (and any newer) open and
  folds each older release to one line, grouped by month: its version
  and a count of its changes, fixes and notes for administrators.
- CHANGELOG.md itself is unchanged and reads the same on GitHub; the
  app splits it into releases when shown (Changelog).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 13:38:45 -05:00
1 parent e4bc3a5b7b
commit e8b0cd030e
10 files changed
+218 -3

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
# The release notes (CHANGELOG.md) split into releases, so the app can show
# the running version's notes on their own and fold away older ones. The
# file stays one plain Markdown document (it reads the same on GitHub):
#
# # What's new
# intro...
# ## 2026.11.5
# ### Changes
# - ...
# ### Fixes
# - ...
class Changelog
PATH = Rails.root.join("CHANGELOG.md")
# The section headings counted in a release's one-line summary; items
# under any other heading (the first release's highlights) count as notes.
SECTIONS = { "Changes" => :changes, "Fixes" => :fixes, "For administrators" => :administrators }.freeze
Release = Data.define(:version, :markdown) do
def year = version.split(".")[0].to_i
def month = version.split(".")[1].to_i
def month_start = Date.new(year, month, 1)
def anchor = "v#{version.tr('.', '-')}"
# { changes: 4, fixes: 3 }: the top-level items under each heading.
def counts
counts = markdown.split(/^### /).drop(1).each_with_object(Hash.new(0)) do |section, tally|
heading, body = section.split("\n", 2)
tally[SECTIONS.fetch(heading.strip, :notes)] += body.to_s.scan(/^- /).size
end
(SECTIONS.values + [ :notes ]).filter_map { |key| [ key, counts[key] ] if counts[key].positive? }.to_h
end
end
def self.load = new(PATH.file? ? PATH.read : "")
attr_reader :title, :intro, :releases
def initialize(markdown)
head, *parts = markdown.split(/^## /)
@title = head[/\A# (.+)$/, 1] || "What's new"
@intro = head.sub(/\A# .+\n+/, "").strip
@releases = parts.filter_map do |part|
version, body = part.split("\n", 2)
version = version.strip
Release.new(version: version, markdown: body.to_s.strip) if version.match?(/\A\d{4}\.\d{1,2}\.\d+\z/)
end
end
def release(version) = releases.find { _1.version == version }
# Shown open: the running version and any newer (or the newest, when the
# running version has no notes, such as in development).
def open?(release, running:)
index = releases.index { _1.version == running } || 0
releases.index(release) <= index
end
end
+5 -1
View File
@@ -27,7 +27,11 @@ class HelpGuide
# Sanitized HTML. Links to other guide pages ("records.md#mistakes") go
# through `link` (slug, anchor) -> URL, or become plain text when nil.
def self.html(page, link:, title: true)
source = title ? page.markdown : page.markdown.sub(/\A# .+\n+/, "")
render(title ? page.markdown : page.markdown.sub(/\A# .+\n+/, ""), link: link)
end
# Any Markdown from the guide (or a part of it, such as one release of the changelog).
def self.render(source, link:)
html = Commonmarker.to_html(source, options: OPTIONS, plugins: { syntax_highlighter: nil })
html = Rails::HTML5::SafeListSanitizer.new.sanitize(html, tags: TAGS, attributes: ATTRIBUTES)
html.gsub(%r{<a href="([a-z-]+|README)\.md(?:#([a-z0-9-]+))?">(.*?)</a>}m) do