robin_cms 0.1.5 → 0.1.7
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 +9 -15
- 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/helpers.rb +42 -5
- data/lib/robin_cms/item.rb +17 -8
- data/lib/robin_cms/library.rb +13 -24
- data/lib/robin_cms/version.rb +1 -1
- data/lib/robin_cms/views/change_password.erb +1 -1
- data/lib/robin_cms/views/delete_dialog.erb +1 -1
- data/lib/robin_cms/views/field_label.erb +9 -0
- data/lib/robin_cms/views/filter_form.erb +2 -2
- data/lib/robin_cms/views/hidden_field.erb +1 -1
- data/lib/robin_cms/views/image_field.erb +7 -8
- data/lib/robin_cms/views/input_field.erb +2 -5
- data/lib/robin_cms/views/layout.erb +22 -7
- data/lib/robin_cms/views/library.erb +14 -14
- data/lib/robin_cms/views/library_actions.erb +3 -5
- data/lib/robin_cms/views/library_item.erb +19 -16
- data/lib/robin_cms/views/nav.erb +2 -4
- data/lib/robin_cms/views/profile.erb +2 -2
- data/lib/robin_cms/views/richtext_field.erb +2 -5
- data/lib/robin_cms/views/select_field.erb +4 -13
- data/lib/robin_cms/views/stylesheet.css.erb +8 -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: 68c3b702cf90bbb615ebeea6303a3f12e4e5da64b3360b295a198b9347ea11bb
|
|
4
|
+
data.tar.gz: d266f45a2863ee190014bcd3174f0413fb70a5f745aaef74780f0a9ca7d6b3eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12d3f8064c84a26a3e3899ca964e411609ca03de3c193466aab157530d1022ffa0ae45237545260ad9a35377e07ff5cb09325c00c682cfd790247c1879b6dde4
|
|
7
|
+
data.tar.gz: d73739c5b1b1c83b4fc7f3d80363353318a0b69164fba07ad784a738d8e5c23c8cea6c73c1d55542279c6a38929dc65ffc673870669781cf9df2a631cb21bebd
|
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
|
|
@@ -44,7 +37,7 @@ module RobinCMS
|
|
|
44
37
|
end
|
|
45
38
|
|
|
46
39
|
get "/" do
|
|
47
|
-
redirect to(
|
|
40
|
+
redirect to(root_url)
|
|
48
41
|
end
|
|
49
42
|
|
|
50
43
|
get "/login" do
|
|
@@ -54,7 +47,7 @@ module RobinCMS
|
|
|
54
47
|
post "/login" do
|
|
55
48
|
authenticate!(params[:username], params[:password])
|
|
56
49
|
session[:auth_user] = params[:username]
|
|
57
|
-
redirect to(
|
|
50
|
+
redirect to(root_url)
|
|
58
51
|
rescue AuthenticationError
|
|
59
52
|
flash[:error] = "Incorrect username or password"
|
|
60
53
|
redirect to("/login")
|
|
@@ -162,13 +155,14 @@ module RobinCMS
|
|
|
162
155
|
end
|
|
163
156
|
|
|
164
157
|
post "/publish" do
|
|
165
|
-
|
|
158
|
+
system(@config[:build_command])
|
|
159
|
+
if $?.exitstatus == 0
|
|
166
160
|
flash[:success_dialog] = "Your site has been successfully published!"
|
|
167
161
|
else
|
|
168
|
-
flash[:
|
|
162
|
+
flash[:error_dialog] = "There was an error publishing the site."
|
|
169
163
|
end
|
|
170
164
|
|
|
171
|
-
redirect to(
|
|
165
|
+
redirect to(root_url)
|
|
172
166
|
end
|
|
173
167
|
|
|
174
168
|
not_found do
|
data/lib/robin_cms/helpers.rb
CHANGED
|
@@ -37,13 +37,50 @@ module RobinCMS
|
|
|
37
37
|
URI.decode_www_form(request.query_string).to_h
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
def root_url
|
|
41
|
+
url("/libraries/#{@config[:libraries].first[:id]}")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def profile_url
|
|
45
|
+
url("/profile")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def logout_url
|
|
49
|
+
url("/logout")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def change_password_url
|
|
53
|
+
url("/change-password")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def library_url(library)
|
|
57
|
+
url("/libraries/#{library[:id]}")
|
|
43
58
|
end
|
|
44
59
|
|
|
45
|
-
def
|
|
46
|
-
|
|
60
|
+
def library_item_url(library, item = nil)
|
|
61
|
+
if item
|
|
62
|
+
url("/libraries/#{library[:id]}/item/#{item.id}")
|
|
63
|
+
else
|
|
64
|
+
url("/libraries/#{library[:id]}/item")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def delete_library_item_url(library, item)
|
|
69
|
+
url("/libraries/#{library[:id]}/item/#{item.id}/delete")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def item_image_url(item)
|
|
73
|
+
url(item.image_src)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def publish_url
|
|
77
|
+
url("/publish")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def current_page?(library)
|
|
81
|
+
_, libraries, item = request.path_info.split("/")
|
|
82
|
+
current_page = item || libraries
|
|
83
|
+
library[:id].to_s == current_page
|
|
47
84
|
end
|
|
48
85
|
|
|
49
86
|
# For generating safe id's where the id needs to be based on user
|
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
|
-
FRONTMATTER_IGNORE_KEYS = [:id, :content, :image, :captures].freeze
|
|
10
|
+
FRONTMATTER_IGNORE_KEYS = [:id, :kind, :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,13 +71,21 @@ 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
|
|
80
80
|
|
|
81
|
+
def image_src
|
|
82
|
+
@attributes[:image_src]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def image_alt
|
|
86
|
+
@attributes[:image_alt]
|
|
87
|
+
end
|
|
88
|
+
|
|
81
89
|
# Get the frontmatter as a hash with stringified keys.
|
|
82
90
|
def frontmatter
|
|
83
91
|
frontmatter = @attributes.clone
|
|
@@ -96,13 +104,14 @@ module RobinCMS
|
|
|
96
104
|
frontmatter.to_h.transform_keys(&:to_s)
|
|
97
105
|
end
|
|
98
106
|
|
|
99
|
-
def field_value_or_default(
|
|
107
|
+
def field_value_or_default(field_id)
|
|
108
|
+
field = @schema[:fields].find { |f| f[:id] == field_id }
|
|
100
109
|
value = @attributes[field[:id].to_sym] || field[:default]
|
|
101
110
|
value.to_s
|
|
102
111
|
end
|
|
103
112
|
|
|
104
113
|
def can_delete?
|
|
105
|
-
@id && @
|
|
114
|
+
@id && @schema[:can_delete]
|
|
106
115
|
end
|
|
107
116
|
end
|
|
108
117
|
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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<button type="submit">Close</button>
|
|
10
10
|
</form>
|
|
11
11
|
<form
|
|
12
|
-
action=
|
|
12
|
+
action="<%= delete_library_item_url(@library, @item) %>"
|
|
13
13
|
method="post"
|
|
14
14
|
>
|
|
15
15
|
<button type="submit" class="--danger">Delete</button>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</select>
|
|
14
14
|
<% if @library.drafts_enabled? %>
|
|
15
15
|
<select id="published" name="published">
|
|
16
|
-
<% for option in PUBLISHED_OPTIONS%>
|
|
16
|
+
<% for option in PUBLISHED_OPTIONS %>
|
|
17
17
|
<option
|
|
18
18
|
value="<%= option[:value] %>"
|
|
19
19
|
<% if query_params["published"] == option[:value] %>
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
placeholder="Search <%= @library[:label].downcase %>..."
|
|
34
34
|
/>
|
|
35
35
|
<button type="submit">Apply</button>
|
|
36
|
-
<a href="
|
|
36
|
+
<a href="<%= library_url(@library) %>">Clear filters</a>
|
|
37
37
|
</form>
|
|
@@ -1,23 +1,22 @@
|
|
|
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"
|
|
13
13
|
class="image-preview"
|
|
14
|
-
src="<%=
|
|
15
|
-
alt="<%= @item.
|
|
14
|
+
src="<%= item_image_url(@item) %>"
|
|
15
|
+
alt="<%= @item.image_alt %>"
|
|
16
16
|
/>
|
|
17
17
|
<input
|
|
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
|
/>
|
|
@@ -9,23 +9,29 @@
|
|
|
9
9
|
<%= erb :"stylesheet.css" %>
|
|
10
10
|
</style>
|
|
11
11
|
</head>
|
|
12
|
-
<body
|
|
12
|
+
<body
|
|
13
|
+
<% if flash[:success_dialog] %>
|
|
14
|
+
onload="successdialog.showModal()"
|
|
15
|
+
<% elsif flash[:error_dialog] %>
|
|
16
|
+
onload="errordialog.showModal()"
|
|
17
|
+
<% end %>
|
|
18
|
+
>
|
|
13
19
|
<% if session[:auth_user] %>
|
|
14
20
|
<header id="site-header">
|
|
15
21
|
<span class="controls">
|
|
16
|
-
<h1><a href="
|
|
22
|
+
<h1><a href="<%= root_url %>"><%= @config[:title] %> admin</a></h1>
|
|
17
23
|
</span>
|
|
18
24
|
<span class="controls --gap-md">
|
|
19
25
|
<a href="<%= @config[:url] %>" target="_blank">
|
|
20
26
|
<%= @config[:url] %><%= erb :"new_tab.svg" %>
|
|
21
27
|
</a>
|
|
22
28
|
<% if @config[:build_command] %>
|
|
23
|
-
<form id="publish-form" action="
|
|
29
|
+
<form id="publish-form" action="<%= publish_url %>" method="post">
|
|
24
30
|
<button type="submit" form="publish-form">Publish site</button>
|
|
25
31
|
</form>
|
|
26
32
|
<% end %>
|
|
27
|
-
<a href=
|
|
28
|
-
<a href=
|
|
33
|
+
<a href="<%= profile_url %>">Account</a>
|
|
34
|
+
<a href="<%= logout_url %>">Log out</a>
|
|
29
35
|
</span>
|
|
30
36
|
</header>
|
|
31
37
|
<% end %>
|
|
@@ -44,8 +50,17 @@
|
|
|
44
50
|
<h2>Success!</h2>
|
|
45
51
|
<p><%= flash[:success_dialog] %></p>
|
|
46
52
|
<div class="controls">
|
|
47
|
-
<form id="dialog-close" method="dialog">
|
|
48
|
-
<button type="submit" form="dialog-close">Continue</button>
|
|
53
|
+
<form id="success-dialog-close" method="dialog">
|
|
54
|
+
<button type="submit" form="success-dialog-close">Continue</button>
|
|
55
|
+
</form>
|
|
56
|
+
</div>
|
|
57
|
+
</dialog>
|
|
58
|
+
<dialog id="errordialog" class="card">
|
|
59
|
+
<h2>Oops, something went wrong.</h2>
|
|
60
|
+
<p><%= flash[:error_dialog] %></p>
|
|
61
|
+
<div class="controls">
|
|
62
|
+
<form id="err-dialog-close" method="dialog">
|
|
63
|
+
<button type="submit" form="err-dialog-close">Continue</button>
|
|
49
64
|
</form>
|
|
50
65
|
</div>
|
|
51
66
|
</dialog>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<p><%= @library[:description] %></p>
|
|
7
7
|
<% end %>
|
|
8
8
|
<% if @library[:can_create] %>
|
|
9
|
-
<form action=
|
|
9
|
+
<form action="<%= library_item_url(@library) %>">
|
|
10
10
|
<button type="submit">
|
|
11
11
|
New <%= @library[:label_singular].downcase %>
|
|
12
12
|
</button>
|
|
@@ -20,46 +20,46 @@
|
|
|
20
20
|
<br />
|
|
21
21
|
<br />
|
|
22
22
|
<% if @library[:can_create] %>
|
|
23
|
-
Create a <a href=
|
|
24
|
-
or try <a href=
|
|
23
|
+
Create a <a href="<%= library_item_url(@library) %>">new <%= @library[:label_singular].downcase %></a>
|
|
24
|
+
or try <a href="<%= library_url(@library) %>">clearing</a> your search filters.
|
|
25
25
|
<% end %>
|
|
26
26
|
</div>
|
|
27
27
|
<% else %>
|
|
28
28
|
<table>
|
|
29
29
|
<thead>
|
|
30
30
|
<tr>
|
|
31
|
-
<th
|
|
31
|
+
<th>Name</th>
|
|
32
32
|
<% if @library.drafts_enabled? %>
|
|
33
|
-
<th>Status</th>
|
|
33
|
+
<th class="status">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>
|
|
40
40
|
<% for item in @items %>
|
|
41
41
|
<tr>
|
|
42
42
|
<td>
|
|
43
|
-
<a href=
|
|
43
|
+
<a href="<%= library_item_url(@library, item) %>">
|
|
44
44
|
<%= item.display_name %>
|
|
45
45
|
</a>
|
|
46
46
|
</td>
|
|
47
47
|
<% if @library.drafts_enabled? %>
|
|
48
48
|
<td>
|
|
49
|
-
<a href=
|
|
50
|
-
<span class="badge --<%= item.
|
|
49
|
+
<a href="<%= library_item_url(@library, item) %>">
|
|
50
|
+
<span class="badge --<%= item.published_label.downcase %>">
|
|
51
51
|
<%= item.published_label %>
|
|
52
52
|
</span>
|
|
53
53
|
</a>
|
|
54
54
|
</td>
|
|
55
55
|
<% end %>
|
|
56
|
-
<td>
|
|
57
|
-
<a href=
|
|
56
|
+
<td class="date">
|
|
57
|
+
<a href="<%= library_item_url(@library, item) %>">
|
|
58
58
|
<%= item.created_at.strftime("%b %d, %Y") %>
|
|
59
59
|
</a>
|
|
60
60
|
</td>
|
|
61
|
-
<td>
|
|
62
|
-
<a href=
|
|
61
|
+
<td class="date">
|
|
62
|
+
<a href="<%= library_item_url(@library, item) %>">
|
|
63
63
|
<%= item.updated_at.strftime("%b %d, %Y") %>
|
|
64
64
|
</a>
|
|
65
65
|
</td>
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
<span class="controls">
|
|
2
|
-
<a href=
|
|
3
|
-
<button type="submit">Save</button>
|
|
4
|
-
|
|
5
|
-
<%= erb :delete_dialog %>
|
|
6
|
-
<% end %>
|
|
2
|
+
<a href="<%= library_url(@library) %>">Back</a>
|
|
3
|
+
<button form="<%= safe_id(@item.id, 'edit_item') %>" type="submit">Save</button>
|
|
4
|
+
<%= erb :delete_dialog if has_delete %>
|
|
7
5
|
</span>
|
|
@@ -5,31 +5,34 @@
|
|
|
5
5
|
<%= erb :library_actions, locals: { has_delete: @item.can_delete? } %>
|
|
6
6
|
</header>
|
|
7
7
|
<form
|
|
8
|
+
id="<%= safe_id(@item.id, 'edit_item') %>"
|
|
8
9
|
class="card"
|
|
9
10
|
<% if @item.id %>
|
|
10
|
-
action=
|
|
11
|
+
action="<%= library_item_url(@library, @item) %>"
|
|
11
12
|
<% else %>
|
|
12
|
-
action=
|
|
13
|
+
action="<%= library_item_url(@library) %>"
|
|
13
14
|
<% end %>
|
|
14
15
|
method="post"
|
|
15
16
|
enctype="multipart/form-data"
|
|
16
17
|
>
|
|
17
18
|
<% @library.sorted_fields.each do |field| %>
|
|
18
19
|
<div class="field">
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
<%=
|
|
21
|
+
case field[:type]
|
|
22
|
+
when "text", "date", "number", "color", "email", "url"
|
|
23
|
+
erb :input_field, locals: { field: field }
|
|
24
|
+
when "hidden"
|
|
25
|
+
erb :hidden_field, locals: { field: field }
|
|
26
|
+
when "select"
|
|
27
|
+
erb :select_field, locals: { field: field }
|
|
28
|
+
when "image"
|
|
29
|
+
erb :image_field, locals: { field: field }
|
|
30
|
+
when "richtext"
|
|
31
|
+
erb :richtext_field, locals: { field: field }
|
|
32
|
+
else
|
|
33
|
+
""
|
|
34
|
+
end
|
|
35
|
+
%>
|
|
33
36
|
</div>
|
|
34
37
|
<% end %>
|
|
35
38
|
<%= erb :flash %>
|
data/lib/robin_cms/views/nav.erb
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
<nav id="site-nav">
|
|
2
2
|
<ul class="controls">
|
|
3
3
|
<% for library in @config[:libraries] %>
|
|
4
|
-
<li <% if current_page
|
|
5
|
-
<a href=
|
|
6
|
-
<%= library[:label] %>
|
|
7
|
-
</a>
|
|
4
|
+
<li <% if current_page?(library) %>class="current"<% end %>>
|
|
5
|
+
<a href="<%= library_url(library) %>"><%= library[:label] %></a>
|
|
8
6
|
</li>
|
|
9
7
|
<% end %>
|
|
10
8
|
</ul>
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<section class="card">
|
|
5
5
|
<p>You are currently logged in as <b><%= @username %></b>.</p>
|
|
6
6
|
<div class="controls --align-right">
|
|
7
|
-
<a href="
|
|
8
|
-
<form action="<%=
|
|
7
|
+
<a href="<%= root_url %>">Back</a>
|
|
8
|
+
<form action="<%= change_password_url %>">
|
|
9
9
|
<button type="submit">Change password</button>
|
|
10
10
|
</form>
|
|
11
11
|
</div>
|
|
@@ -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,23 +1,14 @@
|
|
|
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
|
|
12
9
|
value="<%= option[:value] %>"
|
|
13
|
-
<% if
|
|
14
|
-
|
|
15
|
-
selected
|
|
16
|
-
<% end %>
|
|
17
|
-
<% else %>
|
|
18
|
-
<% if option[:value].to_s == @item.field_value_or_default(field) %>
|
|
19
|
-
selected
|
|
20
|
-
<% end %>
|
|
10
|
+
<% if option[:value].to_s == @item.published?.to_s %>
|
|
11
|
+
selected
|
|
21
12
|
<% end %>
|
|
22
13
|
>
|
|
23
14
|
<%= option[:label] %>
|
|
@@ -77,11 +77,12 @@ th {
|
|
|
77
77
|
font-weight: 500;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
th,
|
|
81
|
-
td
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
th.date,
|
|
81
|
+
td.date > *,
|
|
82
|
+
th.status,
|
|
83
|
+
td.status > * {
|
|
84
|
+
width: 7rem;
|
|
85
|
+
text-align: right;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
td a {
|
|
@@ -192,7 +193,8 @@ select {
|
|
|
192
193
|
|
|
193
194
|
input,
|
|
194
195
|
select,
|
|
195
|
-
trix-toolbar
|
|
196
|
+
trix-toolbar,
|
|
197
|
+
img#image-preview {
|
|
196
198
|
display: block;
|
|
197
199
|
margin-top: var(--padding-xs);
|
|
198
200
|
}
|
|
@@ -412,10 +414,6 @@ hr {
|
|
|
412
414
|
padding: 2rem;
|
|
413
415
|
}
|
|
414
416
|
|
|
415
|
-
.grow-column {
|
|
416
|
-
width: 100%;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
417
|
.image-preview {
|
|
420
418
|
width: 8rem;
|
|
421
419
|
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.7
|
|
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-25 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
|