robin_cms 0.1.1 → 0.1.2

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: 36e4c02115d1c4d3849376ff70e8c20fd0fb1e80c6ae806f4ae09a7a88e981bf
4
- data.tar.gz: f6a86d8721ee1180221c19f7480341accfc3cf5e191f1fde4eab4a7747c757ce
3
+ metadata.gz: 398d0d377f476c68de1e02e504cbe7353347e1f93835d3cce55811d7a90e82a3
4
+ data.tar.gz: 5b253a4f07db5e5282bf879695ec96ed51d28a2b8e667f1110213b45e0c63e98
5
5
  SHA512:
6
- metadata.gz: cefc9e3a84b3b19c786f2110e0baffe2ceafdea25e120320d3a0241ca4aa934775674df7157e0acb9a03dda831d5787516751ec59716ff39436e724e874a696f
7
- data.tar.gz: ca16243899f791e64780e268aea3a45c54e2f4d9e6dfd160b4ba07adaf5d25e79f6d3fd7404f42fd67f0b849725963f17e879db10c0ace46dba641d5e95d5f51
6
+ metadata.gz: b976e15a5ca7c7af3f44f8be1ee2df5f6ddfe766ddfedafeb6c17dd41c48dc449e13d819b0dcdac17c23263a04d9c3e7e99a1f3cc5b66d97b562c7fc8d77ecfb
7
+ data.tar.gz: 609ed3f32088e434615486ba25da6fdb199a074b0d628ee5e58f45b13f80151b7319437bad45538d636158e6b522701e3960663b2269db5f78ea3699e233ea07
data/README.md CHANGED
@@ -65,6 +65,63 @@ Just the usual incantation:
65
65
  gem install robin_cms
66
66
  ```
67
67
 
68
+ ## Configuring
69
+
70
+ You can define your content model in a `_cms.yml` file like this:
71
+
72
+ ```yml
73
+ url: https://example.com
74
+ title: Example
75
+ libraries:
76
+ - id: poem
77
+ type: collection
78
+ label: Poem
79
+ location: poems
80
+ filetype: html
81
+ fields:
82
+ - { label: Title, id: title, type: input }
83
+ - { label: Author, id: author_name, type: input }
84
+ - { label: Content, id: content, type: richtext }
85
+ - id: book
86
+ type: data
87
+ label: Book
88
+ location: books
89
+ filetype: yml
90
+ fields:
91
+ - { label: Title, id: title, type: input }
92
+ - { label: Author, id: author_name, type: input }
93
+ ```
94
+
95
+ The admin username and password needs to be set in a `.htpasswd` file in the
96
+ root directory of the project. Obviously make sure you `.gitignore` that file.
97
+ Also make sure your static site generator is ignoring it because you don't want
98
+ it in your public directory! Each line of the `.htpasswd` file should follow
99
+ the format `<username>:<password>`, but note that only a single
100
+ username/password is supported for now. The password needs to be encrypted with
101
+ bcrypt. You can do this in Ruby with the `bcrypt` gem:
102
+
103
+ ```sh
104
+ ruby -r bcrypt -e "puts BCrypt::Password.create('mypassword')"
105
+ ```
106
+
107
+ Another thing to note is that if no `.htpasswd` file is found, it will
108
+ automatically create one with username "admin" and password "admin". This lets
109
+ you play around with it locally without configuring a password. So make sure
110
+ you create a `.htpasswd` file before running it in production!
111
+
112
+ You'll also need to expose a `SESSION_SECRET` environment variable. If you
113
+ don't, it will create one for you, but it creates a new secret each time
114
+ the server starts, meaning you will have to log in again whenever you restart
115
+ the server. It is recommended to create one via Ruby's SecureRandom package.
116
+
117
+ ```sh
118
+ ruby -r securerandom -e "puts SecureRandom.hex(64)"
119
+ ```
120
+
121
+ See the [examples](./examples) folder for a full example. I haven't written any
122
+ documentation yet, but the example `_cms.yml` file is thoroughly commented to
123
+ explain each of the fields.
124
+
68
125
  ## Usage
69
126
 
70
127
  You have a few options for using this gem in your project. Firstly, you can use
@@ -107,60 +164,10 @@ end
107
164
  ```
108
165
 
109
166
  After running `bundle exec jekyll serve`, the CMS should be available on your
110
- website under `/admin`.
111
-
112
- ## Configuring
113
-
114
- You can define your content model in a `_cms.yml` file like this:
115
-
116
- ```yml
117
- libraries:
118
- - name: "poem"
119
- label: "Poem"
120
- location: "poems"
121
- filetype: "html"
122
- fields:
123
- - { label: "Title", name; "title", type: "input" }
124
- - { label: "Author", name; "author_name", type: "input" }
125
- - { label: "Content", name; "content", type: "richtext" }
126
- - name: "book"
127
- label: "Book"
128
- location: "books"
129
- filetype: "yml"
130
- fields:
131
- - { label: "Title", name; "title", type: "input" }
132
- - { label: "Author", name; "author_name", type: "input" }
133
- ```
134
-
135
- The admin username and password needs to be set in a `.htpasswd` file in the
136
- root directory of the project. Obviously make sure you `.gitignore` that file.
137
- Also make sure your static site generator is ignoring it because you don't want
138
- it in your public directory! Each line of the `.htpasswd` file should follow
139
- the format `<username>:<password>`, but note that only a single
140
- username/password is supported for now. The password needs to be encrypted with
141
- bcrypt. You can do this in Ruby with the `bcrypt` gem:
142
-
143
- ```sh
144
- ruby -r bcrypt -e "puts BCrypt::Password.create('mypassword')"
145
- ```
146
-
147
- Another thing to note is that if no `.htpasswd` file is found, it will
148
- automatically create one with username "admin" and password "admin". This lets
149
- you play around with it locally without configuring a password. So make sure
150
- you create a `.htpasswd` file before running it in production!
151
-
152
- You'll also need to expose a `SESSION_SECRET` environment variable. If you
153
- don't, it will create one for you, but it creates a new secret each time
154
- the server starts, meaning you will have to log in again whenever you restart
155
- the server. It is recommended to create one via Ruby's SecureRandom package.
156
-
157
- ```sh
158
- ruby -r securerandom -e "puts SecureRandom.hex(64)"
159
- ```
160
-
161
- See the [examples](./examples) folder for a full example. I haven't written any
162
- documentation yet, but the example `_cms.yml` file is thoroughly commented to
163
- explain each of the fields.
167
+ website under `/admin`. Note that if using it as a Jekyll plugin, you can put
168
+ your config in Jekyll's `_config.yml` file under the `cms` field. You also
169
+ don't need to specify the `url` and `title` fields, as these are taken from the
170
+ Jekyll config.
164
171
 
165
172
  ## Testing
166
173
 
@@ -68,8 +68,7 @@ module RobinCMS
68
68
  fm = frontmatter.to_h.transform_keys(&:to_s)
69
69
 
70
70
  items = if File.exist?(filepath)
71
- raw = File.read(filepath)
72
- YAML.load(raw)
71
+ YAML.load_file(filepath) || []
73
72
  else
74
73
  []
75
74
  end
@@ -7,10 +7,10 @@ module RobinCMS
7
7
  DATETIME_FORMAT = "%Y-%m-%d"
8
8
 
9
9
  # The keys which we don't want to serialize.
10
- SERIALIZE_IGNORE_KEYS = %i[id kind content image captures].freeze
10
+ SERIALIZE_IGNORE_KEYS = [:id, :kind, :content, :image, :captures].freeze
11
11
 
12
12
  def initialize(id, library, attrs = {})
13
- %i[id location filetype].each do |key|
13
+ [:id, :location, :filetype].each do |key|
14
14
  unless library.has_key?(key)
15
15
  raise TypeError, "Missing required field #{key}"
16
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RobinCMS
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robin_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aron Lebani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-10 00:00:00.000000000 Z
11
+ date: 2025-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt