shipnotes 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +265 -0
- data/app/controllers/shipnotes/releases_controller.rb +61 -0
- data/app/helpers/shipnotes/releases_helper.rb +38 -0
- data/app/views/layouts/shipnotes/application.html.erb +24 -0
- data/app/views/shipnotes/releases/index.atom.builder +20 -0
- data/app/views/shipnotes/releases/index.html.erb +51 -0
- data/config/routes.rb +7 -0
- data/exe/shipnotes +7 -0
- data/lib/shipnotes/check.rb +218 -0
- data/lib/shipnotes/cli.rb +312 -0
- data/lib/shipnotes/config.rb +278 -0
- data/lib/shipnotes/differs/json_schema.rb +45 -0
- data/lib/shipnotes/differs/mcp_tools.rb +50 -0
- data/lib/shipnotes/differs/openapi.rb +55 -0
- data/lib/shipnotes/differs.rb +33 -0
- data/lib/shipnotes/engine.rb +44 -0
- data/lib/shipnotes/engine_configuration.rb +21 -0
- data/lib/shipnotes/entry.rb +18 -0
- data/lib/shipnotes/entry_writer.rb +116 -0
- data/lib/shipnotes/field.rb +55 -0
- data/lib/shipnotes/finding.rb +7 -0
- data/lib/shipnotes/git_diff.rb +65 -0
- data/lib/shipnotes/github_labels.rb +28 -0
- data/lib/shipnotes/init.rb +69 -0
- data/lib/shipnotes/publication.rb +46 -0
- data/lib/shipnotes/release.rb +32 -0
- data/lib/shipnotes/releaser.rb +128 -0
- data/lib/shipnotes/renderer.rb +92 -0
- data/lib/shipnotes/repository.rb +100 -0
- data/lib/shipnotes/schema.rb +82 -0
- data/lib/shipnotes/semver.rb +83 -0
- data/lib/shipnotes/source.rb +47 -0
- data/lib/shipnotes/surface.rb +32 -0
- data/lib/shipnotes/templates/changelog.md.erb +11 -0
- data/lib/shipnotes/templates/release_notes.md.erb +1 -0
- data/lib/shipnotes/version.rb +5 -0
- data/lib/shipnotes/version_bump.rb +34 -0
- data/lib/shipnotes/version_targets.rb +70 -0
- data/lib/shipnotes/yaml_file.rb +22 -0
- data/lib/shipnotes.rb +52 -0
- metadata +91 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 545848bc2d7da041eb9bb331bfbe6a46c83d42fdf84d3ef37e3928fe480951b5
|
|
4
|
+
data.tar.gz: 7ae94275ae822a82c7b8530ac28bfc495a9a8cacb02d34ed0d4c93b1eb3d60b7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8a78137088ee886a0ba2a9bb28c7b0c18ad671312dfbfa87761cf0a1a24c900307947635f4203db44dbb004bfb6e66996261218365aaf41059722f5e0c8185bc
|
|
7
|
+
data.tar.gz: bd8b841e6dd19c3f1c4e403d915b74ddd6340174564f34d0e050a9ec61af4c44444a2a6714d3358131097954d422e707bf5fe386ee77de187d7e605bdbb3e34a
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-12-01
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- First release: changelog entries as files, a CI check, computed versions, contract diffs and a Rails engine
|
|
8
|
+
|
|
9
|
+
Extracted from a production Rails app. Commands: init, new, status, lint, check, release, render, notes, current, next. Includes OpenAPI (oasdiff) and MCP tool-catalog breaking-change checks and a mountable engine with HTML, JSON and Atom.
|
|
10
|
+
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TechWright Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Shipnotes
|
|
2
|
+
|
|
3
|
+
Shipnotes keeps your changelog as one small YAML file per change, the same way changesets, changie and towncrier do. It adds three things those tools leave to you:
|
|
4
|
+
|
|
5
|
+
- **A pull request check that knows what needs an entry.** You map paths to *surfaces* (your app, your API, your MCP tools). The check reads the diff and fails when a change to a surface has no entry for that surface.
|
|
6
|
+
- **Versions that only move through a release.** `shipnotes release` computes the next semantic version from the entries and writes it to your version files. The check rejects a version edited by hand, and it re-verifies a release pull request against what `release` would have written.
|
|
7
|
+
- **Breaking-change detection for contracts.** When an OpenAPI document or an MCP tool catalog changes in a breaking way, the check requires an entry that bumps the major version.
|
|
8
|
+
|
|
9
|
+
It also renders `CHANGELOG.md`, prints release notes for GitHub releases, and ships an optional Rails engine that publishes the changelog as HTML, JSON and Atom.
|
|
10
|
+
|
|
11
|
+
The core uses only the Ruby standard library. It does not need Rails, a database or `bundle install` to run in CI.
|
|
12
|
+
|
|
13
|
+
**Documentation:** https://techwright-lab.github.io/shipnotes/ ([changelog](https://techwright-lab.github.io/shipnotes/changelog/))
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
# Gemfile
|
|
19
|
+
gem "shipnotes", group: :development
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Use the default group instead if you mount the Rails engine. Requires Ruby 3.2 or later.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bundle install
|
|
26
|
+
bundle exec shipnotes init # or: shipnotes init --rails, shipnotes init --version-file lib/my_gem/version.rb
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`init` writes `.shipnotes.yml`, `changelog/unreleased/` and `changelog/releases/`.
|
|
30
|
+
|
|
31
|
+
## Everyday use
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
shipnotes new # asks for each field on a terminal
|
|
35
|
+
shipnotes new --title "Search your sites" --kind added --body "A search box on every page."
|
|
36
|
+
shipnotes status # unreleased entries, their bump, the next version
|
|
37
|
+
shipnotes lint # validate every entry and release file
|
|
38
|
+
shipnotes check origin/main # what CI runs
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
An entry is one file in `changelog/unreleased/`. Its file name is its id.
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
# changelog/unreleased/search-your-sites.yml
|
|
45
|
+
title: Search your sites
|
|
46
|
+
kind: added
|
|
47
|
+
body: A search box on every page.
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Releasing
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
shipnotes release --dry-run # show the version, the files it writes and the entries it moves
|
|
54
|
+
shipnotes release # write changelog/releases/<id>.yml, bump version files, render CHANGELOG.md
|
|
55
|
+
shipnotes release --version 2.0.0-rc.1 # choose the version yourself (pre-releases included)
|
|
56
|
+
shipnotes notes 1.4.0 # Markdown for one release, for `gh release create --notes-file`
|
|
57
|
+
shipnotes current # the current version
|
|
58
|
+
shipnotes next # the version the unreleased entries lead to
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`release` moves every unreleased entry into one release file and deletes the entry files. Open the result as its own pull request. The check verifies it:
|
|
62
|
+
|
|
63
|
+
- it adds exactly one release file;
|
|
64
|
+
- the release holds exactly the entries it deletes;
|
|
65
|
+
- the version is the one the entries require (or a valid `--version` choice);
|
|
66
|
+
- every version file agrees;
|
|
67
|
+
- it changes nothing else.
|
|
68
|
+
|
|
69
|
+
The first release may keep the version that is already in your version file (`shipnotes release --version 0.1.0`). After that, each release must be newer than the last.
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
Everything lives in `.shipnotes.yml`. Every key is optional. This example shows the whole surface area:
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
directory: changelog # entries in changelog/unreleased, releases in changelog/releases
|
|
77
|
+
|
|
78
|
+
# The entry schema. Types: string, text, enum, list, date, boolean.
|
|
79
|
+
fields:
|
|
80
|
+
title: { type: string, required: true, description: One line that names the change }
|
|
81
|
+
kind: { type: enum, required: true, values: [added, improved, fixed, deprecated, removed, security] }
|
|
82
|
+
compatibility: { type: enum, required: true, values: [additive, compatible_fix, breaking, none] }
|
|
83
|
+
audience: { type: enum, values: [public, internal], default: public }
|
|
84
|
+
what: { type: text }
|
|
85
|
+
action: { type: string }
|
|
86
|
+
sunset: { type: date }
|
|
87
|
+
flag: { type: string }
|
|
88
|
+
|
|
89
|
+
# Conditional requirements. `when` matches when a field has one of the values.
|
|
90
|
+
rules:
|
|
91
|
+
- when: { kind: deprecated }
|
|
92
|
+
require: [sunset]
|
|
93
|
+
- when: { compatibility: breaking }
|
|
94
|
+
require: [action]
|
|
95
|
+
reject: { action: [none] }
|
|
96
|
+
message: a breaking change needs a real action for integrators # optional
|
|
97
|
+
|
|
98
|
+
# Path globs that make a change need an entry. Entries then carry a required
|
|
99
|
+
# `surfaces` list. A glob ending in /** matches everything below it.
|
|
100
|
+
surfaces:
|
|
101
|
+
app:
|
|
102
|
+
title: Product updates
|
|
103
|
+
paths: [app/views/**, app/javascript/**, config/routes.rb]
|
|
104
|
+
exclude: [app/views/admin/**]
|
|
105
|
+
api:
|
|
106
|
+
title: API changes
|
|
107
|
+
contract: { file: openapi.json, differ: openapi } # breaking changes need a major entry
|
|
108
|
+
mcp:
|
|
109
|
+
contract: { file: contract/mcp_tools.json, differ: mcp_tools }
|
|
110
|
+
|
|
111
|
+
# Regexes on changed lines that need an entry, for example a new feature flag.
|
|
112
|
+
triggers:
|
|
113
|
+
- name: feature flag
|
|
114
|
+
pattern: 'Flipper\.enabled\?\('
|
|
115
|
+
paths: [app, config]
|
|
116
|
+
surface: app # optional; without it any entry satisfies the trigger
|
|
117
|
+
|
|
118
|
+
check:
|
|
119
|
+
require_entry: auto # auto (surfaces if any, else always), always, surfaces
|
|
120
|
+
ignore: [test/**, "**/*.md"] # with `always`: changes only here need no entry ("*.md" is the root only)
|
|
121
|
+
|
|
122
|
+
versioning:
|
|
123
|
+
scheme: semver # or none
|
|
124
|
+
release_id: version # version (1.4.0.yml) or date (2026.12.01.1.yml, for apps)
|
|
125
|
+
initial: 0.0.0 # the starting version when there is no release and no version file
|
|
126
|
+
bump:
|
|
127
|
+
field: compatibility # which field decides the bump
|
|
128
|
+
levels: { breaking: major, additive: minor, compatible_fix: patch }
|
|
129
|
+
surfaces: [api, mcp] # optional: only entries on these surfaces bump the version
|
|
130
|
+
files: # written by `release`, checked by `check`
|
|
131
|
+
- { path: lib/my_gem/version.rb, pattern: 'VERSION = "(?<version>[^"]+)"' }
|
|
132
|
+
- { path: package.json, json: version }
|
|
133
|
+
- { path: openapi.json, json: info.version }
|
|
134
|
+
|
|
135
|
+
render:
|
|
136
|
+
output: CHANGELOG.md # null to skip writing a file
|
|
137
|
+
template: config/changelog.md.erb # optional ERB template
|
|
138
|
+
title: Changelog
|
|
139
|
+
group_by: kind # headings follow the enum's order
|
|
140
|
+
headings: { improved: Changed } # rename a heading
|
|
141
|
+
details: [what, action] # fields shown under each entry title
|
|
142
|
+
|
|
143
|
+
publication:
|
|
144
|
+
audience_field: audience # only these values are published
|
|
145
|
+
public_values: [public]
|
|
146
|
+
flag_field: flag # entries behind an off flag show as "coming soon" in the engine
|
|
147
|
+
|
|
148
|
+
require: [lib/shipnotes/differs.rb] # Ruby files that define custom differs
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The default configuration is Keep a Changelog: `title`, `kind` (added, changed, deprecated, removed, fixed, security) and `body`. `removed` bumps major, `added`, `changed` and `deprecated` bump minor, `fixed` and `security` bump patch.
|
|
152
|
+
|
|
153
|
+
Every entry may also set `bump: major | minor | patch | none` to override the computed bump.
|
|
154
|
+
|
|
155
|
+
## CI
|
|
156
|
+
|
|
157
|
+
GitHub Actions:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
changelog:
|
|
161
|
+
if: github.event_name == 'pull_request'
|
|
162
|
+
runs-on: ubuntu-latest
|
|
163
|
+
permissions: { contents: read, pull-requests: read }
|
|
164
|
+
steps:
|
|
165
|
+
- uses: actions/checkout@v4
|
|
166
|
+
with: { fetch-depth: 0 }
|
|
167
|
+
- uses: ruby/setup-ruby@v1
|
|
168
|
+
with: { bundler-cache: true }
|
|
169
|
+
- env:
|
|
170
|
+
GH_TOKEN: ${{ github.token }}
|
|
171
|
+
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
172
|
+
OASDIFF: /usr/local/bin/oasdiff # only for an openapi contract
|
|
173
|
+
run: bundle exec shipnotes check "origin/${{ github.base_ref }}" --skip-label no-changelog
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- `--skip-label no-changelog` reads the pull request's labels with the GitHub CLI. With the label set, the entry rule is skipped. The schema, version and breaking-change checks still run.
|
|
177
|
+
- `--skip-entry` does the same without a label, for local runs.
|
|
178
|
+
- The `openapi` differ runs [oasdiff](https://github.com/oasdiff/oasdiff). Pass `--oasdiff PATH`, set `OASDIFF`, or put it on `PATH`. Without it the REST diff is skipped with a note.
|
|
179
|
+
|
|
180
|
+
## Custom differs
|
|
181
|
+
|
|
182
|
+
A differ is any object with `call(base_text, head_text, options)` that returns `Shipnotes::Finding` values. Raise `Shipnotes::Differs::Skipped` when it cannot run.
|
|
183
|
+
|
|
184
|
+
```ruby
|
|
185
|
+
# lib/shipnotes/differs.rb, listed under `require:`
|
|
186
|
+
class GraphqlDiffer
|
|
187
|
+
def self.call(base, head, _options)
|
|
188
|
+
removed = types(base) - types(head)
|
|
189
|
+
removed.map { |name| Shipnotes::Finding.new(subject: name, breaking: true, internal: false, message: "type removed") }
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def self.types(schema) = schema.scan(/^type (\w+)/).flatten
|
|
193
|
+
end
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
surfaces:
|
|
198
|
+
graphql:
|
|
199
|
+
contract: { file: schema.graphql, differ: GraphqlDiffer }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Rails engine
|
|
203
|
+
|
|
204
|
+
```ruby
|
|
205
|
+
# config/routes.rb
|
|
206
|
+
mount Shipnotes::Engine, at: "/changelog"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
| Path | Shows |
|
|
210
|
+
|---|---|
|
|
211
|
+
| `/changelog` | every public entry, newest release first |
|
|
212
|
+
| `/changelog/<surface>` | one surface |
|
|
213
|
+
| `/changelog/all.json`, `/changelog/<surface>.json` | JSON with entry status |
|
|
214
|
+
| `/changelog/all.atom`, `/changelog/<surface>.atom` | Atom feed |
|
|
215
|
+
| `?page=2`, `?entry=<id>` | a page, or the page that holds an entry |
|
|
216
|
+
|
|
217
|
+
```ruby
|
|
218
|
+
# config/initializers/shipnotes.rb
|
|
219
|
+
Shipnotes.configure do |config|
|
|
220
|
+
config.title = "What's new"
|
|
221
|
+
config.description = "Product updates and fixes."
|
|
222
|
+
config.per_page = 10
|
|
223
|
+
config.layout = "application" # default: a small standalone layout
|
|
224
|
+
config.parent_controller = "PublicController" # default: ActionController::Base
|
|
225
|
+
config.flag_enabled = ->(flag) { Flipper.enabled?(flag) }
|
|
226
|
+
config.root = Rails.root # where .shipnotes.yml lives
|
|
227
|
+
config.cache = nil # nil: cache when the app eager-loads
|
|
228
|
+
end
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Override any view by adding the same path to your app, for example `app/views/shipnotes/releases/index.html.erb`. The helpers `shipnotes_groups`, `shipnotes_details`, `shipnotes_entry_url` and `shipnotes_publication` are available there.
|
|
232
|
+
|
|
233
|
+
To build your own page instead, read the data directly:
|
|
234
|
+
|
|
235
|
+
```ruby
|
|
236
|
+
config = Shipnotes::Config.load(Rails.root)
|
|
237
|
+
Shipnotes::Publication.new(config, flag_enabled: ->(flag) { Flipper.enabled?(flag) }).releases(surface: "app")
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Compared with other tools
|
|
241
|
+
|
|
242
|
+
| | Shipnotes | changesets | changie | towncrier |
|
|
243
|
+
|---|---|---|---|---|
|
|
244
|
+
| One file per change | yes | yes | yes | yes |
|
|
245
|
+
| Custom fields and rules | yes | no | yes | no |
|
|
246
|
+
| Bump computed from entries | yes | yes | yes | no |
|
|
247
|
+
| Check knows which paths need an entry | yes | no | no | no |
|
|
248
|
+
| Release PR verified in CI | yes | no | no | no |
|
|
249
|
+
| OpenAPI / MCP breaking-change gate | yes | no | no | no |
|
|
250
|
+
| Rails engine with HTML, JSON, Atom | yes | no | no | no |
|
|
251
|
+
| Monorepo packages | no | yes | yes | no |
|
|
252
|
+
|
|
253
|
+
## Development
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
bundle install
|
|
257
|
+
bundle exec rake test
|
|
258
|
+
bundle exec rubocop
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Shipnotes uses itself. A pull request that changes `lib/`, `app/`, `config/` or `exe/` needs an entry in `changelog/unreleased/`.
|
|
262
|
+
|
|
263
|
+
## License
|
|
264
|
+
|
|
265
|
+
MIT. See `LICENSE.txt`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Shipnotes
|
|
4
|
+
class ReleasesController < Shipnotes.configuration.parent_controller.constantize
|
|
5
|
+
PAGE = /\A[1-9]\d{0,8}\z/
|
|
6
|
+
|
|
7
|
+
layout -> { Shipnotes.configuration.layout }
|
|
8
|
+
helper Shipnotes::ReleasesHelper
|
|
9
|
+
helper_method :shipnotes_settings, :shipnotes_config, :shipnotes_publication
|
|
10
|
+
|
|
11
|
+
def index
|
|
12
|
+
@surface = params[:surface] && shipnotes_config.surface(params[:surface])
|
|
13
|
+
return head(:not_found) if params[:surface] && @surface.nil?
|
|
14
|
+
|
|
15
|
+
releases = shipnotes_publication.releases(surface: @surface&.key)
|
|
16
|
+
@page = selected_page(releases)
|
|
17
|
+
@total_pages = [ (releases.size.to_f / per_page).ceil, 1 ].max
|
|
18
|
+
return head(:not_found) if @page.nil? || @page > @total_pages
|
|
19
|
+
|
|
20
|
+
@releases = releases.slice((@page - 1) * per_page, per_page) || []
|
|
21
|
+
respond_to do |format|
|
|
22
|
+
format.html
|
|
23
|
+
format.atom
|
|
24
|
+
format.json { render json: json_payload }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def shipnotes_settings = Shipnotes.configuration
|
|
31
|
+
def shipnotes_config = @shipnotes_config ||= Shipnotes::Engine.project_config
|
|
32
|
+
def shipnotes_publication = @shipnotes_publication ||= Shipnotes::Engine.publication(shipnotes_config)
|
|
33
|
+
def per_page = [ shipnotes_settings.per_page.to_i, 1 ].max
|
|
34
|
+
|
|
35
|
+
# ?entry=<id> opens the page that holds that entry, so a shared link
|
|
36
|
+
# keeps working after newer releases push it off the first page.
|
|
37
|
+
def selected_page(releases)
|
|
38
|
+
if params[:entry].is_a?(String)
|
|
39
|
+
index = releases.index { |release| release.includes_entry?(params[:entry]) }
|
|
40
|
+
return index && index / per_page + 1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
value = params.fetch(:page, "1")
|
|
44
|
+
value.is_a?(String) && value.match?(PAGE) ? value.to_i : nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def json_payload
|
|
48
|
+
{
|
|
49
|
+
title: @surface&.title || shipnotes_settings.title,
|
|
50
|
+
surface: @surface&.key,
|
|
51
|
+
page: @page,
|
|
52
|
+
total_pages: @total_pages,
|
|
53
|
+
releases: @releases.map do |release|
|
|
54
|
+
release.to_h.except("entries").merge(
|
|
55
|
+
"entries" => release.entries.map { |entry| entry.to_h.merge("status" => shipnotes_publication.status(entry)) }
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Shipnotes
|
|
4
|
+
module ReleasesHelper
|
|
5
|
+
def shipnotes_groups(entries) = shipnotes_view.groups(entries)
|
|
6
|
+
|
|
7
|
+
# Pairs of [label, text]; the label is nil when only one detail field is shown.
|
|
8
|
+
def shipnotes_details(entry)
|
|
9
|
+
names = shipnotes_config.render.details
|
|
10
|
+
names.filter_map do |name|
|
|
11
|
+
text = entry[name].to_s
|
|
12
|
+
next if text.strip.empty?
|
|
13
|
+
|
|
14
|
+
[ names.size > 1 ? name.tr("_", " ").capitalize : nil, text ]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def shipnotes_release_title(release) = release.version || release.id
|
|
19
|
+
|
|
20
|
+
def shipnotes_page_path(page)
|
|
21
|
+
query = page > 1 ? { page: page } : {}
|
|
22
|
+
@surface ? surface_releases_path(@surface.key, query) : (page > 1 ? all_releases_path(query) : root_path)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def shipnotes_feed_url
|
|
26
|
+
@surface ? surface_releases_url(@surface.key, format: :atom) : all_releases_url(format: :atom)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def shipnotes_entry_url(entry)
|
|
30
|
+
base = @surface ? surface_releases_url(@surface.key, entry: entry.id) : all_releases_url(entry: entry.id)
|
|
31
|
+
"#{base}#change-#{entry.id}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def shipnotes_view = @shipnotes_view ||= Shipnotes::Renderer::View.new(config: shipnotes_config)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title><%= content_for?(:title) ? yield(:title) : shipnotes_settings.title %></title>
|
|
7
|
+
<%= auto_discovery_link_tag(:atom, shipnotes_feed_url, title: shipnotes_settings.title) %>
|
|
8
|
+
<style>
|
|
9
|
+
:root { color-scheme: light dark; --shipnotes-muted: #6b7280; --shipnotes-accent: #2563eb; }
|
|
10
|
+
body { font: 16px/1.6 system-ui, sans-serif; margin: 0; }
|
|
11
|
+
.shipnotes { max-width: 46rem; margin: 0 auto; padding: 3rem 1.25rem; }
|
|
12
|
+
.shipnotes-nav { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .9rem; }
|
|
13
|
+
.shipnotes-nav a[aria-current] { font-weight: 600; }
|
|
14
|
+
.shipnotes-release { border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent); margin-top: 2.5rem; padding-top: 1.5rem; }
|
|
15
|
+
.shipnotes-release time, .shipnotes-muted { color: var(--shipnotes-muted); font-size: .9rem; }
|
|
16
|
+
.shipnotes-entry h4 { margin: 1rem 0 .25rem; }
|
|
17
|
+
.shipnotes-badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid currentColor; margin-left: .5rem; }
|
|
18
|
+
a { color: var(--shipnotes-accent); }
|
|
19
|
+
</style>
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<main class="shipnotes"><%= yield %></main>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
entries = @releases.flat_map { |release| release.entries.map { |entry| [ release, entry ] } }
|
|
4
|
+
updated = @releases.first ? Time.utc(*@releases.first.date.split("-").map(&:to_i)) : Time.at(0).utc
|
|
5
|
+
|
|
6
|
+
atom_feed(root_url: (@surface ? surface_releases_url(@surface.key) : root_url), id: "tag:#{request.host},2005:#{request.path}") do |feed|
|
|
7
|
+
feed.title(@surface&.title || shipnotes_settings.title)
|
|
8
|
+
feed.updated(updated)
|
|
9
|
+
|
|
10
|
+
entries.each do |release, entry|
|
|
11
|
+
published = Time.utc(*release.date.split("-").map(&:to_i))
|
|
12
|
+
feed.entry(entry, id: "tag:#{request.host},2005:#{request.path}/#{entry.id}", url: shipnotes_entry_url(entry),
|
|
13
|
+
published: published, updated: published) do |item|
|
|
14
|
+
item.title(entry.title)
|
|
15
|
+
body = shipnotes_details(entry).map { |label, text| label ? "#{label}: #{text}" : text }.join("\n\n")
|
|
16
|
+
item.content(simple_format(body), type: "html")
|
|
17
|
+
item.author { |author| author.name(shipnotes_settings.title) }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<% heading = @surface&.title || shipnotes_settings.title %>
|
|
2
|
+
<% content_for(:title, heading) %>
|
|
3
|
+
<header class="shipnotes-header">
|
|
4
|
+
<h1><%= heading %></h1>
|
|
5
|
+
<% description = @surface&.description || shipnotes_settings.description %>
|
|
6
|
+
<% if description.present? %><p class="shipnotes-muted"><%= description %></p><% end %>
|
|
7
|
+
<nav class="shipnotes-nav" aria-label="Changelog sections">
|
|
8
|
+
<% if shipnotes_config.surfaces? %>
|
|
9
|
+
<%= link_to "All changes", root_path, "aria-current": (@surface ? nil : "page") %>
|
|
10
|
+
<% shipnotes_config.surfaces.each_value do |surface| %>
|
|
11
|
+
<%= link_to surface.title, surface_releases_path(surface.key), "aria-current": (@surface&.key == surface.key ? "page" : nil) %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<%= link_to "Atom feed", shipnotes_feed_url %>
|
|
15
|
+
</nav>
|
|
16
|
+
</header>
|
|
17
|
+
|
|
18
|
+
<% if @releases.empty? %>
|
|
19
|
+
<p class="shipnotes-muted">Nothing has been released yet.</p>
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<% @releases.each do |release| %>
|
|
23
|
+
<section class="shipnotes-release" id="release-<%= release.id %>">
|
|
24
|
+
<h2><%= shipnotes_release_title(release) %> <time datetime="<%= release.date %>"><%= Date.iso8601(release.date).strftime("%B %-d, %Y") %></time></h2>
|
|
25
|
+
<% shipnotes_groups(release.entries).each do |group, entries| %>
|
|
26
|
+
<% if group %><h3><%= group %></h3><% end %>
|
|
27
|
+
<% entries.each do |entry| %>
|
|
28
|
+
<article class="shipnotes-entry" id="change-<%= entry.id %>">
|
|
29
|
+
<h4>
|
|
30
|
+
<%= entry.title %>
|
|
31
|
+
<% if shipnotes_publication.status(entry) == "pending" %><span class="shipnotes-badge">Coming soon</span><% end %>
|
|
32
|
+
</h4>
|
|
33
|
+
<% shipnotes_details(entry).each do |label, text| %>
|
|
34
|
+
<div class="shipnotes-detail">
|
|
35
|
+
<% if label %><strong><%= label %>:</strong><% end %>
|
|
36
|
+
<%= simple_format(text) %>
|
|
37
|
+
</div>
|
|
38
|
+
<% end %>
|
|
39
|
+
</article>
|
|
40
|
+
<% end %>
|
|
41
|
+
<% end %>
|
|
42
|
+
</section>
|
|
43
|
+
<% end %>
|
|
44
|
+
|
|
45
|
+
<% if @total_pages > 1 %>
|
|
46
|
+
<nav class="shipnotes-nav shipnotes-pagination" aria-label="Pages">
|
|
47
|
+
<% if @page > 1 %><%= link_to "Newer", shipnotes_page_path(@page - 1), rel: "prev" %><% end %>
|
|
48
|
+
<span class="shipnotes-muted">Page <%= @page %> of <%= @total_pages %></span>
|
|
49
|
+
<% if @page < @total_pages %><%= link_to "Older", shipnotes_page_path(@page + 1), rel: "next" %><% end %>
|
|
50
|
+
</nav>
|
|
51
|
+
<% end %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Shipnotes::Engine.routes.draw do
|
|
4
|
+
root to: "releases#index"
|
|
5
|
+
get "all(.:format)", to: "releases#index", as: :all_releases
|
|
6
|
+
get ":surface(.:format)", to: "releases#index", as: :surface_releases, constraints: { surface: /[a-z0-9][a-z0-9_-]*/ }
|
|
7
|
+
end
|