andromeda_cms 0.4.2 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3e717009de7bff8e377893a2d94e810d58c3c26827124c63efefdb5e26871df
4
- data.tar.gz: d7516800193e99d6a1b67ddf781f6703ea56dad3a76e20ed6bc5adbaf1618b33
3
+ metadata.gz: 3e28cb7d39787447bf6360e6bfc15477843f77cdab11b1fad64b47cc17be65b2
4
+ data.tar.gz: bd742b08aaf8ddb578cbb3b0417433c6c399e74b99484bbbde059c76037e6704
5
5
  SHA512:
6
- metadata.gz: 5062e06b1700c44ebd3adcc4d440d6d929a6f38d593c73491a3d87f7161593e2776b8f9d50fd1ad37b2d6e4c87e15a288bd5d864d5b0961eed113e177c064479
7
- data.tar.gz: ebf5ff1699e815b80c540f41b897c0977197fa6a7e18089f42f0049800602178e3217f6f651e988b1f49b2b1dbcc16650e0dd904660ebe53ccf29a53e1d56030
6
+ metadata.gz: '09057949a55b6029eab67c488989e6a7f4cfd14d67468b7517a07b3eddfbcbd70a2bf1118c5daaaec7663a5a62387efefd0a560315bf640d869221976098f55c'
7
+ data.tar.gz: 8d92e0d40e78db9985dceb71ec227c89f02a7fc245102d32521bb6de2d243f375f591ddbbfbd52397d0c62371cb6bb0a9f84fbef22b0d10ed911bf98c7adc4a8
data/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.0] - 2026-10-08
9
+
10
+ ### Added
11
+
12
+ - `Entry.replace_entries(list)` swaps a collection's entries in tests without
13
+ depending on internal cache variables; `reload!` restores the real ones.
14
+
15
+ ### Fixed
16
+
17
+ - The gem now requires `json < 3`, so `bundle update` no longer pulls in a
18
+ version that breaks session cookie decryption on Rails 8.1. The `Gemfile`
19
+ pin from the README is no longer needed.
20
+
21
+ ## [0.5.0] - 2026-10-07
22
+
23
+ ### Changed
24
+
25
+ - `andromeda_content` now wraps the entry body in an `<andromeda-content>`
26
+ element, so the body can be targeted from CSS. Browsers treat an unknown
27
+ element as inline, so add `andromeda-content { display: block; }` to your
28
+ stylesheet. Markup that selected the body's direct children from the
29
+ parent element needs updating. Inside a component rendered during
30
+ `andromeda:build` the wrapper is left out, so an embedded entry is not
31
+ wrapped twice.
32
+
8
33
  ## [0.4.2] - 2026-09-30
9
34
 
10
35
  ### Fixed
@@ -141,6 +166,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
141
166
  - Generators: `andromeda:install`, `andromeda:collection`,
142
167
  `andromeda:component` and `andromeda:import_astro`.
143
168
 
169
+ [0.6.0]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.6.0
170
+ [0.5.0]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.5.0
144
171
  [0.4.2]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.4.2
145
172
  [0.4.1]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.4.1
146
173
  [0.4.0]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.4.0
data/README.md CHANGED
@@ -107,6 +107,10 @@ end
107
107
  </article>
108
108
  ```
109
109
 
110
+ `andromeda_content` wraps the body in an `<andromeda-content>` element. Browsers
111
+ treat it as inline by default, so add `andromeda-content { display: block; }`
112
+ to your stylesheet.
113
+
110
114
  From there it is your code. A typical next step is to make fields mandatory,
111
115
  add a draft flag, and add a table of contents:
112
116
 
@@ -303,16 +307,27 @@ bundle exec rake test:corpus # after test/fetch_corpus.sh: parse ~370 real Astr
303
307
  ## Troubleshooting
304
308
 
305
309
  **`ArgumentError: wrong number of arguments (given 2, expected 1)` from `JSON.parse`.**
306
- Not this gem: Rails 8.1 calls `JSON.parse` with a positional options hash, which
307
- version 3 of the `json` gem no longer accepts, and decrypting a session cookie
308
- hits that path — so pages fail only once a session exists. Pin the `json` gem
309
- until Rails ships a fix:
310
+ Not this gem's code: Rails 8.1 calls `JSON.parse` with a positional options hash,
311
+ which version 3 of the `json` gem no longer accepts, and decrypting a session
312
+ cookie hits that path, so pages fail only once a session exists. The gem
313
+ restricts `json` to `< 3` to avoid this. If you are on an older andromeda_cms,
314
+ pin it in your own `Gemfile` until Rails ships a fix:
310
315
 
311
316
  ```ruby
312
317
  # Gemfile
313
318
  gem "json", "~> 2.9"
314
319
  ```
315
320
 
321
+ ## Testing
322
+
323
+ To run model tests against entries that are not files under `app/content`,
324
+ swap them in with `replace_entries` and restore the real ones with `reload!`:
325
+
326
+ ```ruby
327
+ setup { Content::Post.replace_entries([Content::Post.new(id: "a", collection: :posts, data: { title: "A" }, body: "", file_path: "a.md", digest: "x")]) }
328
+ teardown { Content::Post.reload! }
329
+ ```
330
+
316
331
  ## Contributing
317
332
 
318
333
  Bug reports are welcome; patches are not. Andromeda is open source but not open
@@ -184,6 +184,22 @@ module Andromeda
184
184
  @entries_signature = nil
185
185
  end
186
186
 
187
+ # Swaps the collection's entries for `list`, so tests can run against
188
+ # entries that are not backed by files under `app/content`. The cache
189
+ # signature is set to match the current source files, so the next query
190
+ # keeps `list` instead of noticing a mismatch and re-reading the files;
191
+ # setting `@entries` alone leaves the signature nil and the swap is
192
+ # silently undone. A later source file change, or `reload!`, restores
193
+ # the real entries.
194
+ #
195
+ # @param list [Array<Andromeda::Entry>]
196
+ # @return [Array<Andromeda::Entry>]
197
+ def replace_entries(list)
198
+ @entries = list.to_a.dup
199
+ @entries_signature = production? ? nil : source_signature
200
+ @entries
201
+ end
202
+
187
203
  private
188
204
 
189
205
  # Production never touches source files: everything a query
@@ -5,7 +5,11 @@ module Andromeda
5
5
  # thin presentation layer over data the build already produced: no parsing
6
6
  # or rendering happens while serving a request.
7
7
  module Helpers
8
- # Outputs an entry's converted body. Marked html_safe because the build
8
+ # Outputs an entry's converted body, wrapped in `<andromeda-content>` so
9
+ # it can be targeted from CSS. Inside a component rendered at conversion
10
+ # time the wrapper is left out: the component's output is stored in the
11
+ # entry's html and wrapped once, when the page is served. Marked
12
+ # html_safe because the build
9
13
  # produced this markup from content the application's own authors wrote,
10
14
  # the same trust model Astro applies to `.md`/`.mdx` (see 13_security).
11
15
  # Inside a component rendered at conversion time the asset markers are
@@ -14,8 +18,9 @@ module Andromeda
14
18
  # @param entry [Andromeda::Entry]
15
19
  # @return [ActiveSupport::SafeBuffer]
16
20
  def andromeda_content(entry)
17
- html = Andromeda::BuildContext.converting? ? entry.html : Andromeda::Assets.resolve(entry.html)
18
- html.html_safe # rubocop:disable Rails/OutputSafety
21
+ return entry.html.html_safe if Andromeda::BuildContext.converting? # rubocop:disable Rails/OutputSafety
22
+
23
+ tag.send("andromeda-content", Andromeda::Assets.resolve(entry.html).html_safe) # rubocop:disable Rails/OutputSafety
19
24
  end
20
25
 
21
26
  # Inside a component partial rendered at conversion time, this returns
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Andromeda
4
- VERSION = "0.4.2"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andromeda_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LIMHAUS Inc.
@@ -65,6 +65,20 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '2.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: json
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '3'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '3'
68
82
  description: |
69
83
  Andromeda brings Astro's content collections to an ordinary Ruby on Rails
70
84
  app. Markdown and MDX files copied from an Astro project are validated