robin_cms 0.1.5 → 0.1.6
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 +4 -4
- data/lib/robin_cms/cms.rb +3 -10
- data/lib/robin_cms/collection_library.rb +1 -1
- data/lib/robin_cms/configuration.rb +1 -1
- data/lib/robin_cms/data_library.rb +1 -1
- data/lib/robin_cms/item.rb +8 -7
- data/lib/robin_cms/library.rb +13 -24
- data/lib/robin_cms/version.rb +1 -1
- data/lib/robin_cms/views/field_label.erb +9 -0
- data/lib/robin_cms/views/hidden_field.erb +1 -1
- data/lib/robin_cms/views/image_field.erb +5 -6
- data/lib/robin_cms/views/input_field.erb +2 -5
- data/lib/robin_cms/views/library.erb +5 -5
- data/lib/robin_cms/views/library_actions.erb +1 -1
- data/lib/robin_cms/views/library_item.erb +1 -0
- data/lib/robin_cms/views/richtext_field.erb +2 -5
- data/lib/robin_cms/views/select_field.erb +3 -6
- data/lib/robin_cms/views/stylesheet.css.erb +6 -10
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a9634aa2592fdf851123491cc53c9b1b347b6e6ca3f7f37d4adbd9e0fb494c7
|
|
4
|
+
data.tar.gz: 3885036d121802207eb4ae9cf80c372211ee199f60fa30c7e11f5b916af5c570
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f38e98b366edb3294b56e2b97c80819149163020d41dd565e893ec3d4d8c84f2332f108de62858a9d55bf135176bf8f042ee28980bd1eb6f6d6ddaf7d330f210
|
|
7
|
+
data.tar.gz: 29d90d7896c8366dbe5373bdd89193d4dcd336577cd8c517d2b5b5082b1aa65ffef18c0b733b5387bb9bf53405c8fcf77b8afdb700e1a682c98bc37ae1c51540
|
data/lib/robin_cms/cms.rb
CHANGED
|
@@ -18,25 +18,18 @@ module RobinCMS
|
|
|
18
18
|
set :session_secret, ENV.fetch("SESSION_SECRET", SecureRandom.hex(64))
|
|
19
19
|
|
|
20
20
|
before do
|
|
21
|
-
if %w[/login /logout].include?(request.path_info)
|
|
22
|
-
pass
|
|
23
|
-
end
|
|
21
|
+
pass if %w[/login /logout].include?(request.path_info)
|
|
24
22
|
|
|
25
23
|
redirect to("/login") unless session[:auth_user]
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
before /\/libraries\/(.*).*/ do
|
|
29
27
|
kind = params[:captures].first.split("/").first
|
|
30
|
-
library_schema = @config.
|
|
28
|
+
library_schema = @config.get_schema(kind)
|
|
31
29
|
|
|
32
30
|
halt 404 unless library_schema
|
|
33
31
|
|
|
34
|
-
@library =
|
|
35
|
-
when "collection"
|
|
36
|
-
CollectionLibrary.new(library_schema)
|
|
37
|
-
when "data"
|
|
38
|
-
DataLibrary.new(library_schema)
|
|
39
|
-
end
|
|
32
|
+
@library = Library.new(library_schema)
|
|
40
33
|
end
|
|
41
34
|
|
|
42
35
|
after do
|
data/lib/robin_cms/item.rb
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module RobinCMS
|
|
4
4
|
class Item
|
|
5
|
-
attr_reader :id, :attributes
|
|
5
|
+
attr_reader :id, :attributes, :schema
|
|
6
6
|
|
|
7
7
|
DATETIME_FORMAT = "%Y-%m-%d"
|
|
8
8
|
|
|
9
9
|
# The keys which we don't want to serialize.
|
|
10
10
|
FRONTMATTER_IGNORE_KEYS = [:id, :content, :image, :captures].freeze
|
|
11
11
|
|
|
12
|
-
def initialize(id, attrs = {}, **
|
|
12
|
+
def initialize(id, attrs = {}, **schema)
|
|
13
13
|
if !attrs.empty? && !attrs.has_key?(:title)
|
|
14
14
|
raise TypeError, "Missing required field `title'"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
@id = id
|
|
18
|
-
@
|
|
18
|
+
@schema = schema
|
|
19
19
|
|
|
20
20
|
# Be sure to use the setter here so the keys get converted to symbols.
|
|
21
21
|
self.attributes = attrs
|
|
@@ -71,9 +71,9 @@ module RobinCMS
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def display_name
|
|
74
|
-
return @attributes[:title] unless @
|
|
74
|
+
return @attributes[:title] unless @schema[:display_name_pattern]
|
|
75
75
|
|
|
76
|
-
@
|
|
76
|
+
@schema[:display_name_pattern].clone.tap do |name|
|
|
77
77
|
@attributes.each { |key, value| name.gsub!(":#{key}", value) }
|
|
78
78
|
end
|
|
79
79
|
end
|
|
@@ -96,13 +96,14 @@ module RobinCMS
|
|
|
96
96
|
frontmatter.to_h.transform_keys(&:to_s)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
def field_value_or_default(
|
|
99
|
+
def field_value_or_default(field_id)
|
|
100
|
+
field = @schema[:fields].find { |f| f[:id] == field_id }
|
|
100
101
|
value = @attributes[field[:id].to_sym] || field[:default]
|
|
101
102
|
value.to_s
|
|
102
103
|
end
|
|
103
104
|
|
|
104
105
|
def can_delete?
|
|
105
|
-
@id && @
|
|
106
|
+
@id && @schema[:can_delete]
|
|
106
107
|
end
|
|
107
108
|
end
|
|
108
109
|
end
|
data/lib/robin_cms/library.rb
CHANGED
|
@@ -8,38 +8,27 @@ module RobinCMS
|
|
|
8
8
|
|
|
9
9
|
attr_reader :schema
|
|
10
10
|
|
|
11
|
+
def self.of_kind(kind, **opts)
|
|
12
|
+
config = Configuration.parse(**opts)
|
|
13
|
+
schema = config.get_schema(kind)
|
|
14
|
+
new(schema)
|
|
15
|
+
end
|
|
16
|
+
|
|
11
17
|
def initialize(schema)
|
|
12
18
|
@schema = schema.freeze
|
|
19
|
+
|
|
20
|
+
case schema[:type]
|
|
21
|
+
when "collection"
|
|
22
|
+
extend CollectionLibrary
|
|
23
|
+
when "data"
|
|
24
|
+
extend DataLibrary
|
|
25
|
+
end
|
|
13
26
|
end
|
|
14
27
|
|
|
15
28
|
def blank
|
|
16
29
|
Item.new(nil, **@schema)
|
|
17
30
|
end
|
|
18
31
|
|
|
19
|
-
def create(attributes)
|
|
20
|
-
raise NotImplementedError
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def find_one(id)
|
|
24
|
-
raise NotImplementedError
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def all
|
|
28
|
-
raise NotImplementedError
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Writes the specified item to disk.
|
|
32
|
-
#
|
|
33
|
-
# Returns the path where the item was written.
|
|
34
|
-
def write(item)
|
|
35
|
-
raise NotImplementedError
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Delete the item specified by +id+.
|
|
39
|
-
def delete(id)
|
|
40
|
-
raise NotImplementedError
|
|
41
|
-
end
|
|
42
|
-
|
|
43
32
|
def create_static(filename, tempfile)
|
|
44
33
|
path = File.join(@schema[:static_location], File.basename(make_slug(filename)))
|
|
45
34
|
FileUtils.mkdir_p(File.dirname(path))
|
data/lib/robin_cms/version.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
<% if field[:description] %>
|
|
3
|
-
<small><%= field[:description] %></small>
|
|
4
|
-
<% end %>
|
|
1
|
+
<%= erb :field_label, locals: { field: field } %>
|
|
5
2
|
<%#
|
|
6
3
|
There is a bug here where if you upload a different image with the
|
|
7
4
|
same name, it shows the old image due to caching. This is a very
|
|
8
5
|
low priority because a) the user should be naming things in a
|
|
9
6
|
reasonable way and b) you can always just do a hard refresh.
|
|
7
|
+
|
|
8
|
+
Also required does nothing here as we're not populating the field with any
|
|
9
|
+
initial values. This one probably needs to be fixed.
|
|
10
10
|
%>
|
|
11
11
|
<img
|
|
12
12
|
id="image-preview"
|
|
@@ -18,6 +18,5 @@
|
|
|
18
18
|
id="<%= safe_id('image', 'field') %>"
|
|
19
19
|
type="file"
|
|
20
20
|
name="image"
|
|
21
|
-
accept="image/png,
|
|
22
|
-
<% if field[:required] %>required<% end %>
|
|
21
|
+
accept="image/png,image/jpeg"
|
|
23
22
|
/>
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
<% if field[:description] %>
|
|
3
|
-
<small><%= field[:description] %></small>
|
|
4
|
-
<% end %>
|
|
1
|
+
<%= erb :field_label, locals: { field: field } %>
|
|
5
2
|
<input
|
|
6
3
|
id="<%= safe_id(field[:id], 'field') %>"
|
|
7
4
|
type="<%= field[:type] %>"
|
|
8
5
|
name="<%= field[:id] %>"
|
|
9
|
-
value="<%= @item.field_value_or_default(field) %>"
|
|
6
|
+
value="<%= @item.field_value_or_default(field[:id]) %>"
|
|
10
7
|
<% if field[:required] %>required<% end %>
|
|
11
8
|
<% if field[:readonly] %>readonly<% end %>
|
|
12
9
|
/>
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
<table>
|
|
29
29
|
<thead>
|
|
30
30
|
<tr>
|
|
31
|
-
<th
|
|
31
|
+
<th>Name</th>
|
|
32
32
|
<% if @library.drafts_enabled? %>
|
|
33
33
|
<th>Status</th>
|
|
34
34
|
<% end %>
|
|
35
|
-
<th>Created</th>
|
|
36
|
-
<th>Last updated</th>
|
|
35
|
+
<th class="date">Created</th>
|
|
36
|
+
<th class="date">Last updated</th>
|
|
37
37
|
</tr>
|
|
38
38
|
</thead>
|
|
39
39
|
<tbody>
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
</a>
|
|
54
54
|
</td>
|
|
55
55
|
<% end %>
|
|
56
|
-
<td>
|
|
56
|
+
<td class="date">
|
|
57
57
|
<a href='<%= url("/libraries/#{@library.kind}/item/#{item.id}") %>'>
|
|
58
58
|
<%= item.created_at.strftime("%b %d, %Y") %>
|
|
59
59
|
</a>
|
|
60
60
|
</td>
|
|
61
|
-
<td>
|
|
61
|
+
<td class="date">
|
|
62
62
|
<a href='<%= url("/libraries/#{@library.kind}/item/#{item.id}") %>'>
|
|
63
63
|
<%= item.updated_at.strftime("%b %d, %Y") %>
|
|
64
64
|
</a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<span class="controls">
|
|
2
2
|
<a href='<%= url("/libraries/#{@library.kind}") %>'>Back</a>
|
|
3
|
-
<button type="submit">Save</button>
|
|
3
|
+
<button form="<%= safe_id(@item.id, 'edit_item') %>" type="submit">Save</button>
|
|
4
4
|
<% if has_delete %>
|
|
5
5
|
<%= erb :delete_dialog %>
|
|
6
6
|
<% end %>
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
<link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.8/dist/trix.css">
|
|
2
2
|
<script type="text/javascript" src="https://unpkg.com/trix@2.0.8/dist/trix.umd.min.js"></script>
|
|
3
|
-
|
|
4
|
-
<% if field[:description] %>
|
|
5
|
-
<small><%= field[:description] %></small>
|
|
6
|
-
<% end %>
|
|
3
|
+
<%= erb :field_label, locals: { field: field } %>
|
|
7
4
|
<input
|
|
8
5
|
id="richtext-content"
|
|
9
6
|
type="hidden"
|
|
10
7
|
name="<%= field[:id] %>"
|
|
11
|
-
value="<%= @item.field_value_or_default(field) %>"
|
|
8
|
+
value="<%= @item.field_value_or_default(field[:id]) %>"
|
|
12
9
|
>
|
|
13
10
|
<trix-editor input="richtext-content"></trix-editor>
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
<% if field[:description] %>
|
|
3
|
-
<small><%= field[:description] %></small>
|
|
4
|
-
<% end %>
|
|
1
|
+
<%= erb :field_label, locals: { field: field } %>
|
|
5
2
|
<select
|
|
6
3
|
id="<%= safe_id(field[:id], 'field') %>"
|
|
7
4
|
name="<%= field[:id] %>"
|
|
8
|
-
value="<%= @item.field_value_or_default(field) %>"
|
|
5
|
+
value="<%= @item.field_value_or_default(field[:id]) %>"
|
|
9
6
|
>
|
|
10
7
|
<% for option in field[:options] %>
|
|
11
8
|
<option
|
|
@@ -15,7 +12,7 @@
|
|
|
15
12
|
selected
|
|
16
13
|
<% end %>
|
|
17
14
|
<% else %>
|
|
18
|
-
<% if option[:value].to_s == @item.field_value_or_default(field) %>
|
|
15
|
+
<% if option[:value].to_s == @item.field_value_or_default(field[:id]) %>
|
|
19
16
|
selected
|
|
20
17
|
<% end %>
|
|
21
18
|
<% end %>
|
|
@@ -77,11 +77,10 @@ th {
|
|
|
77
77
|
font-weight: 500;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
th,
|
|
81
|
-
td {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
text-overflow: ellipsis;
|
|
80
|
+
th.date,
|
|
81
|
+
td.date > * {
|
|
82
|
+
width: 7rem;
|
|
83
|
+
text-align: right;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
td a {
|
|
@@ -192,7 +191,8 @@ select {
|
|
|
192
191
|
|
|
193
192
|
input,
|
|
194
193
|
select,
|
|
195
|
-
trix-toolbar
|
|
194
|
+
trix-toolbar,
|
|
195
|
+
img#image-preview {
|
|
196
196
|
display: block;
|
|
197
197
|
margin-top: var(--padding-xs);
|
|
198
198
|
}
|
|
@@ -412,10 +412,6 @@ hr {
|
|
|
412
412
|
padding: 2rem;
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
.grow-column {
|
|
416
|
-
width: 100%;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
415
|
.image-preview {
|
|
420
416
|
width: 8rem;
|
|
421
417
|
height: 8rem;
|
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.
|
|
4
|
+
version: 0.1.6
|
|
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-
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bcrypt
|
|
@@ -94,6 +94,7 @@ files:
|
|
|
94
94
|
- lib/robin_cms/views/change_password.erb
|
|
95
95
|
- lib/robin_cms/views/delete_dialog.erb
|
|
96
96
|
- lib/robin_cms/views/error.erb
|
|
97
|
+
- lib/robin_cms/views/field_label.erb
|
|
97
98
|
- lib/robin_cms/views/filter_form.erb
|
|
98
99
|
- lib/robin_cms/views/flash.erb
|
|
99
100
|
- lib/robin_cms/views/hidden_field.erb
|