hyde_admin 0.0.4 → 0.0.9

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: cb95670b96fd382d5e1f1ae437e50b055de1e1196192cb5438cb8a5b9da2a553
4
- data.tar.gz: f2febcd67319f60a862b79e88e06290df9495dd2388d85900e38eb9486c76f50
3
+ metadata.gz: 7b6c1b4aa57c65ae8ea48b7317b4d8c53b6dacc5162f9cf413b086213e8d16b9
4
+ data.tar.gz: e92ce331dd7fcb499084f1aff3dda0db7ac2093bb864c7a024068aa9ab29d0b1
5
5
  SHA512:
6
- metadata.gz: fb71c84a6420d278a484fb14a08ff24d155c926140838c243ba9fdd8df8d0495ed5d182fd12b58c9e5ab2981adbeaacb053e0f9e40f16f30ca812b564d7bde51
7
- data.tar.gz: cac253c8000aa874cd925df410d3d4174032c573ffe3d359d7f09128d129be23e7a4d8b76c23354f3ef62b4074f6ae5df8af80b64ec133150228b715fab28f7f
6
+ metadata.gz: 76426f6867cebd4884ab7cd5e589e3a72c0f14e7b8b5df64d16c3d98c08890c38d708cb4e55a840070604e957afcd6285818b82a7d0961375f17cf3ef5d000db
7
+ data.tar.gz: f94cb4bd9aa9d8337c5ebf7d86dc1e77ff257192bd724c84bb0fb2fd7190b9ffb2741e529d0c9ee4efe0d541f21630cba4685cefe4283df0d588252ee33854de
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/.idea/hyde_admin.iml CHANGED
@@ -12,7 +12,11 @@
12
12
  <orderEntry type="inheritedJdk" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, RVM: ruby-2.7.0) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.4, RVM: ruby-2.7.0) [gem]" level="application" />
15
16
  <orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.10, RVM: ruby-2.7.0) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="image_processing (v1.12.1, RVM: ruby-2.7.0) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="mini_magick (v4.11.0, RVM: ruby-2.7.0) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="ruby-vips (v2.0.17, RVM: ruby-2.7.0) [gem]" level="application" />
16
20
  </component>
17
21
  <component name="RModuleSettingsStorage">
18
22
  <LOAD_PATH number="0" />
data/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ # 0.0.9
2
+
3
+ Hide deploy button if 'deploy_dest_address' is empty.
4
+ hyde_admin_config allow you to install the latest default config file.
5
+
6
+ # 0.0.8
7
+
8
+ Resize image at upload with ImageProcessing (MiniMagick)
9
+
10
+ # 0.0.7
11
+
12
+ Post edit : bugfix, keep layout & format when we don't show input.
13
+ CodeMirror editor : form-control style
14
+ Locales shows possible value for config.
15
+
16
+ # 0.0.6
17
+
18
+ Form upload image + style images selector
19
+ Menu follows workflow
20
+ Configuration remove beforeSend
21
+ Rsync params
22
+ Publish only for drafts
23
+
24
+ # 0.0.5
25
+
26
+ Sometimes no tags
27
+
1
28
  # 0.0.4
2
29
 
3
30
  Correct images selector
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Hyde admin
2
+
3
+ Hyde_admin is a administration frontend for Jekyll (static site generator in Ruby).
4
+
1
5
  ## Getting Started with Hyde Admin
2
6
 
3
7
  Add
@@ -20,4 +24,10 @@ You can visit localhost:9292 !
20
24
  hyde_admin.yml is automatically generated in your jekyll directory.
21
25
  (you can change settings with hyde_admin ou directly)
22
26
 
23
- Hyde_admin allow ssh deployment.
27
+ Hyde_admin allow ssh deployment.
28
+
29
+ ## New version of hyde_admin ?
30
+
31
+ Just install the lastest config file (your config file will be renamed, and latest config file will be installed), run :
32
+
33
+ `hyde_admin_config`
@@ -32,12 +32,6 @@
32
32
  <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
33
33
  <div class="position-sticky pt-3">
34
34
  <ul class="nav flex-column">
35
- <li class="nav-item">
36
- <a class="nav-link active" aria-current="page" href="/<%= @hyde_parameters['site_index'] %>">
37
- <span data-feather="home" class="fas fa-eye"></span>
38
- <%= EscapeUtils.escape_html t.overview.capitalize %>
39
- </a>
40
- </li>
41
35
  <li class="nav-item">
42
36
  </li>
43
37
  <li class="nav-item">
@@ -64,14 +58,20 @@
64
58
  <%= EscapeUtils.escape_html t.posts.capitalize %>
65
59
  </a>
66
60
  </li>
67
- <li class="nav-item"></li>
68
61
  <li class="nav-item">
69
62
  <a class="nav-link" href="/files/index">
70
63
  <span data-feather="users" class="fas fa-copy"></span>
71
64
  <%= EscapeUtils.escape_html t.files.capitalize %>
72
65
  </a>
73
66
  </li>
74
- <li class="nav-item"></li>
67
+ <li></li>
68
+ <li class="nav-item mb-4 mt-4">
69
+ <a class="nav-link" href="/configuration">
70
+ <span data-feather="layers" class="fas fa-tools"></span>
71
+ <%= EscapeUtils.escape_html t.configuration.capitalize %>
72
+ </a>
73
+ </li>
74
+ <li></li>
75
75
  <li class="nav-item">
76
76
  <a class="nav-link active" aria-current="page" href="/rebuild" id="btn-rebuild">
77
77
  <span data-feather="home" class="fas fa-hammer"></span>
@@ -79,18 +79,19 @@
79
79
  </a>
80
80
  </li>
81
81
  <li class="nav-item">
82
- <a class="nav-link active" aria-current="page" href="/deploy" id="btn-deploy">
83
- <span data-feather="home" class="fas fa-cloud-upload-alt"></span>
84
- <%= EscapeUtils.escape_html t.deploy.capitalize %>
85
- </a>
86
- </li>
87
- <li class="nav-item"></li>
88
- <li class="nav-item">
89
- <a class="nav-link" href="/configuration">
90
- <span data-feather="layers" class="fas fa-tools"></span>
91
- <%= EscapeUtils.escape_html t.configuration.capitalize %>
82
+ <a class="nav-link active" aria-current="page" target="_blank" href="/<%= @hyde_parameters['site_index'] %>">
83
+ <span data-feather="home" class="fas fa-eye"></span>
84
+ <%= EscapeUtils.escape_html t.overview.capitalize %>
92
85
  </a>
93
86
  </li>
87
+ <% if !@hyde_parameters['deploy_dest_address'].blank? %>
88
+ <li class="nav-item">
89
+ <a class="nav-link active" aria-current="page" href="/deploy" id="btn-deploy">
90
+ <span data-feather="home" class="fas fa-cloud-upload-alt"></span>
91
+ <%= EscapeUtils.escape_html t.deploy.capitalize %>
92
+ </a>
93
+ </li>
94
+ <% end %>
94
95
  </ul>
95
96
  <p class="text-center text-muted"><br><br><em>Hyde Admin V.<%= HydeAdmin::VERSION %></em>&nbsp;&nbsp;&nbsp;<a href="https://github.com/rivsc/hyde_admin" class="link-secondary"><i class="fab fa-github"></i></a></p>
96
97
  </div>
@@ -124,43 +125,45 @@
124
125
  <div class="modal-dialog" role="document">
125
126
  <div class="modal-content">
126
127
  <div class="modal-header">
127
- <h5 class="modal-title">Images</h5>
128
+ <h5 class="modal-title"><%= t.images.capitalize %></h5>
128
129
  <!--
129
130
  <button type="button" class="btn btn-default close" data-dismiss="modal" aria-label="Close">
130
131
  <span aria-hidden="true">&times;</span>
131
132
  </button>
132
133
  -->
134
+ <button type="button" class="btn btn-outline-secondary btn-sm load-image">
135
+ <%= t.load_images.capitalize %>
136
+ </button>
133
137
  </div>
134
138
  <div class="modal-body">
135
139
  <div>
136
140
  <div class="image-selector-search d-block" data-page="0">
137
141
  <form action="" class="form-inline">
138
142
  <div class="form-group mb-2">
139
- <label for="inputPassword2" class="sr-only"><%= EscapeUtils.escape_html t.sort_by_date %></label>
140
143
  <label>
141
- <input class="form-check-input" type="radio" name="sort_date" value="asc"> <%= EscapeUtils.escape_html t.older %>
144
+ <input class="form-check-input" type="radio" name="sort_date" value="asc"> <%= EscapeUtils.escape_html t.newer.capitalize %>
142
145
  </label>
143
146
  &nbsp;&nbsp;&nbsp;
144
147
  <label>
145
- <input class="form-check-input" type="radio" name="sort_date" value="desc"> <%= EscapeUtils.escape_html t.newer %>
148
+ <input class="form-check-input" type="radio" name="sort_date" value="desc" checked> <%= EscapeUtils.escape_html t.older.capitalize %>
146
149
  </label>
147
150
  </div>
148
151
  <div class="form-group mb-2">
149
- <label for="inputFilename" class="sr-only"><%= EscapeUtils.escape_html t.filename %></label>
150
- <input type="text" class="form-control" name="filename" id="inputFilename" placeholder="Filename...">
152
+ <label for="inputFilename" class="sr-only"><%= EscapeUtils.escape_html t.filename.capitalize %></label>
153
+ <input type="text" class="form-control" name="filename" id="inputFilename" placeholder="<%= EscapeUtils.escape_html t.filename_placeholder.capitalize %>">
151
154
  </div>
152
- <button type="submit" class="btn btn-primary image-selector-search-submit d-block mb-2"><%= EscapeUtils.escape_html t.search %></button>
155
+ <button type="submit" class="btn btn-primary image-selector-search-submit d-block mb-2"><%= EscapeUtils.escape_html t.search.capitalize %></button>
153
156
  </form>
154
157
  </div>
155
158
  <div class="image-selector-content">
156
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb') %>
159
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb') %>
157
160
  <%= ERB.new(File.read(path)).result(binding) %>
158
161
  </div>
159
- <div class="image-selector-page">
160
- <a href="#" title="<%= EscapeUtils.escape_html t.previous_images %>" class="btn btn-secondary image-selector-page-prev">
162
+ <div class="image-selector-page text-center">
163
+ <a href="#" title="<%= EscapeUtils.escape_html t.previous_images %>" class="btn btn-secondary image-selector-page-prev px-4">
161
164
  <i class="fas fa-chevron-left"></i>
162
165
  </a>
163
- <a href="#" title="<%= EscapeUtils.escape_html t.next_images %>"class="btn btn-secondary image-selector-page-next">
166
+ <a href="#" title="<%= EscapeUtils.escape_html t.next_images %>" class="btn btn-secondary image-selector-page-next px-4">
164
167
  <i class="fas fa-chevron-right"></i>
165
168
  </a>
166
169
  </div>
@@ -213,6 +216,13 @@
213
216
  search(1);
214
217
  return false;
215
218
  });
219
+ $(document).on('click', '.load-image', function(){
220
+ var windowObjectReference = window.open("/upload_image_form", "update_image", "dialog=yes,menubar=no,location=no,resizable=no,scrollbars=yes,status=yes,outerWidth=800,innerHeight=300,width=800,height=300");
221
+ return false;
222
+ });
223
+ function reload_image(){
224
+ $('.load-image').click();
225
+ }
216
226
  </script>
217
227
  <script src="/fslightbox/fslightbox.js"></script>
218
228
  </body>
@@ -3,9 +3,9 @@
3
3
  <form action="/configuration" method="post">
4
4
  <% @hyde_parameters.each_pair do |setting, value| %>
5
5
  <div class="mb-3">
6
- <label for="i-<%= setting %>" class="form-label"><%= EscapeUtils.escape_html t.send(setting).capitalize %></label>
6
+ <label for="i-<%= setting %>" class="form-label"><%= (EscapeUtils.escape_html t.send(setting).capitalize rescue setting) %></label>
7
7
  <input type="text" class="form-control" value="<%= value %>" name="<%= setting %>" id="i-<%= setting %>">
8
- <div id="i-<%= setting %>-help" class="form-text"><%= EscapeUtils.escape_html t.send("help_#{setting}").capitalize %></div>
8
+ <div id="i-<%= setting %>-help" class="form-text"><%= (EscapeUtils.escape_html t.send("help_#{setting}").capitalize rescue '') %></div>
9
9
  </div>
10
10
  <% end %>
11
11
  <button type="submit" class="btn btn-primary"><%= EscapeUtils.escape_html t.submit.capitalize %></button>
@@ -15,14 +15,14 @@
15
15
  </label>
16
16
 
17
17
  <% if @has_editor %>
18
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_html.erb') %>
18
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'editor_html.erb') %>
19
19
  <%= ERB.new(File.read(path)).result(binding) %>
20
20
  <% end %>
21
21
 
22
22
  <textarea class="form-control text-editor" id="i-content" rows="3" name="content" style="font-family: <%= (['.html', '.xml', '.yml', '.js', '.md'].include?(File.extname(@file)) ? 'monospace' : 'inherit') %>"><%= @content %></textarea>
23
23
 
24
24
  <script type="text/javascript" charset="utf-8">
25
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_js.erb') %>
25
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'editor_js.erb') %>
26
26
  <%= ERB.new(File.read(path)).result(binding) %>
27
27
  </script>
28
28
  </div>
@@ -1,4 +1,4 @@
1
- <div class="image-element">
1
+ <div class="image-element mb-4">
2
2
  <img src="<%= @img %>" alt="<%= @img %>">
3
3
  <span class="font-size:8px;"><%= @img.split('/').last %></span>
4
4
  </div>
@@ -1,4 +1,4 @@
1
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'image_element.html.erb') %>
1
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'partials', 'image_element.html.erb') %>
2
2
  <% myerb = ERB.new(File.read(path), eoutvar: "@bidule") %>
3
3
  <% # Why %= don't work !? Need to do a loop concat... %>
4
4
  <% $stderr.puts @images %>
@@ -18,6 +18,7 @@
18
18
  <div id="i-path-help" class="form-text"><%= EscapeUtils.escape_html t.help_path %></div>
19
19
  </div>
20
20
  <% end %>
21
+
21
22
  <div class="mb-3">
22
23
  <label for="i-title" class="form-label"><%= EscapeUtils.escape_html t.title.capitalize %></label>
23
24
  <input type="text" value="<%= @headers.delete('title') %>" class="form-control" name="title" id="i-title">
@@ -33,49 +34,50 @@
33
34
  </div>
34
35
  <div class="mb-3">
35
36
  <label for="i-tags" class="form-label"><%= EscapeUtils.escape_html t.tags.capitalize %></label>
36
- <input type="text" value="<%= App.extract_tags(@headers.delete('tags')).join(',') %>" class="form-control" name="tags" id="i-tags">
37
- <div id="i-tags-help" class="form-text"><%= EscapeUtils.escape_html t.help_tags %></div>
38
- </div>
39
- <div class="mb-3 form-check">
40
- <input type="checkbox" class="form-check-input" name="publish" value="publish" id="i-publish">
41
- <label class="form-check-label" for="i-publish"><%= EscapeUtils.escape_html t.publish.capitalize %></label>
37
+ <input type="text" value="<%= Mid.extract_tags(@headers.delete('tags')).join(',') %>" class="form-control" name="tags" id="i-tags">
38
+ <div id="i-tags-help" class="form-text"><%= EscapeUtils.escape_html t.help_tags.capitalize %></div>
42
39
  </div>
43
40
 
41
+ <% if @type_file == 'drafts' %>
42
+ <div class="mb-3 form-check">
43
+ <input type="checkbox" class="form-check-input" name="publish" value="publish" id="i-publish">
44
+ <label class="form-check-label" for="i-publish"><%= EscapeUtils.escape_html t.publish.capitalize %></label>
45
+ </div>
46
+ <% end %>
47
+
48
+ <% selected_layout = @headers.delete('layout') %>
49
+ <% selected_layout = @hyde_parameters['default_layout'] if selected_layout.nil? || selected_layout.empty? %>
44
50
  <% if @hyde_parameters['display_layout'].to_s == 'true' %>
45
51
  <div class="mb-3">
46
52
  <label for="i-layout" class="form-label"><%= EscapeUtils.escape_html t.layout.capitalize %></label>
47
53
  <select class="form-select" aria-label="Choice layout" name="layout">
48
54
  <% Dir.glob(File.join(Dir.pwd, '_layouts', '*')).each do |f| %>
49
- <% layout = File.basename(f, File.extname(f)) %>
50
- <option <%= ((@headers['layout'] == f || (@headers['layout'].to_s.empty? && layout == @hyde_parameters['default_layout'])) ? 'selected' : '') %> value="<%= layout %>"><%= layout %></option>
55
+ <% layout_loop = File.basename(f, File.extname(f)) %>
56
+ <option <%= (layout_loop == selected_layout ? 'selected' : '') %> value="<%= layout_loop %>"><%= layout_loop %></option>
51
57
  <% end %>
52
58
  </select>
53
59
  </div>
54
- <% @headers.delete('layout') %>
55
60
  <% else %>
56
- <input type="hidden" name="layout" value="<%= @hyde_parameters['default_layout'] %>">
61
+ <input type="hidden" name="layout" value="<%= selected_layout %>">
57
62
  <% end %>
58
63
 
64
+ <% selected_format = File.extname(@file) %>
65
+ <% selected_format = ".#{@hyde_parameters['default_format']}" if selected_format.empty? %>
59
66
  <% if @hyde_parameters['display_format'].to_s == 'true' %>
60
67
  <div class="mb-3">
61
68
  <label for="i-format" class="form-label"><%= EscapeUtils.escape_html t.format.capitalize %></label>
62
69
  <select class="form-select" id="select-format" aria-label="Choice format" name="format">
63
- <% format = File.extname(@file) %>
64
- <% format = ".#{@hyde_parameters['default_format']}" if format.empty? %>
65
70
  <% { 'html' => 'html', 'markdown' => 'md' }.each do |k, v| %>
66
- <option <%= (format == ".#{v}" ? 'selected' : '') %> value="<%= v %>"><%= k %></option>
71
+ <option <%= (selected_format == ".#{v}" ? 'selected' : '') %> value="<%= v %>"><%= k %></option>
67
72
  <% end %>
68
73
  </select>
69
74
  </div>
70
- <script type="text/javascript" charset="utf-8">
71
- window.mode_markdown = '<%= format %>' === '.md';
72
- </script>
73
75
  <% else %>
74
- <input type="hidden" name="format" value="<%= @hyde_parameters['default_format'] %>">
75
- <script type="text/javascript" charset="utf-8">
76
- window.mode_markdown = '<%= @hyde_parameters['default_format'] %>' === 'md';
77
- </script>
76
+ <input type="hidden" name="format" value="<%= selected_format.gsub('.','') %>">
78
77
  <% end %>
78
+ <script type="text/javascript" charset="utf-8">
79
+ window.mode_markdown = '<%= selected_format %>' === '.md';
80
+ </script>
79
81
 
80
82
  <% @headers.each do |k,v| %>
81
83
  <div class="mb-3">
@@ -89,8 +91,8 @@
89
91
 
90
92
  <div class="mb-3 template-header" style="display: none">
91
93
  <div class="row">
92
- <div class="col-sm-4"><input type="text" class="col-sm-6 form-control header-name" name="" placeholder="header name"></div>
93
- <div class="col-sm-8"><input type="text" class="col-sm-6 form-control header-value" name="" placeholder="header value"></div>
94
+ <div class="col-sm-4"><input type="text" class="col-sm-6 form-control header-name" name="" placeholder="<%= EscapeUtils.escape_html t.header_name.capitalize %>"></div>
95
+ <div class="col-sm-8"><input type="text" class="col-sm-6 form-control header-value" name="" placeholder="<%= EscapeUtils.escape_html t.header_value.capitalize %>"></div>
94
96
  </div>
95
97
  </div>
96
98
 
@@ -111,7 +113,7 @@
111
113
  <div class="mb-3">
112
114
  <label for="i-content" class="form-label"><%= EscapeUtils.escape_html t.content.capitalize %> <a href="https://jekyllrb.com/docs/liquid/" class="text-secondary" target="_blank"><i class="fas fa-question-circle"></i></a></label>
113
115
 
114
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_html.erb') %>
116
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'editor_html.erb') %>
115
117
  <%= ERB.new(File.read(path)).result(binding) %>
116
118
 
117
119
  <textarea class="form-control text-editor" id="i-content" rows="3" name="content"><%= @content %></textarea>
@@ -150,7 +152,7 @@
150
152
  return false;
151
153
  });
152
154
 
153
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_js.erb') %>
155
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'editor_js.erb') %>
154
156
  <%= ERB.new(File.read(path)).result(binding) %>
155
157
 
156
158
  </script>
@@ -14,12 +14,15 @@
14
14
  </th>
15
15
  </tr>
16
16
  <% @files.each do |f| %>
17
+ <% edit_path = "/#{@type_file}?file=#{f}" %>
17
18
  <tr>
18
19
  <td>
19
- <%= f.gsub(File.join(Dir.pwd, ''),'') %>
20
+ <a href="<%= edit_path %>" class="link-dark">
21
+ <%= f.gsub(File.join(Dir.pwd, ''),'') %>
22
+ </a>
20
23
  </td>
21
24
  <td>
22
- <a href="/<%= @type_file %>?file=<%= f %>" class="btn btn-default"><i class="fa fa-edit" title="<%= EscapeUtils.escape_html t.edit.capitalize %>"></i></a>
25
+ <a href="<%= edit_path %>" class="btn btn-default"><i class="fa fa-edit" title="<%= EscapeUtils.escape_html t.edit.capitalize %>"></i></a>
23
26
  </td>
24
27
  <td>
25
28
  <form method="post" action="/<%= @type_file %>/delete" class="inline form-confirm" data-confirm="<%= EscapeUtils.escape_html t.are_you_sure %>">
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Hyde for Jekyll</title>
6
+
7
+ <meta name="description" content="Hyde for Jekyll">
8
+ <meta name="author" content="Sylvain Claudel (https://blog.rivsc.ovh)">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
+
11
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
12
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
13
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
14
+
15
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ $(function(){
19
+ $(document).on('click', '.btn-return-to-editor', function(){
20
+ //don't work
21
+ //window.opener.reload_image();
22
+ window.close();
23
+ });
24
+ });
25
+ </script>
26
+ </head>
27
+ <body style="width:800px;" class="p-4">
28
+ <div class="container-fluid">
29
+ <div class="row">
30
+ <h1><%= t.upload_image_form.capitalize %></h1>
31
+
32
+ <% if @filenames %>
33
+ <%= t.pictures_has_been_uploaded.capitalize %> : <%= @filenames.join(', ') %>
34
+ <% end %>
35
+
36
+ <form enctype="multipart/form-data" method="post" action="/upload_image" class="row g-3">
37
+ <div class="col-10">
38
+ <input type="file" name="files[]" multiple class="form-control">
39
+ </div>
40
+ <div class="col-2">
41
+ <button class="btn btn-primary"><%= t.upload.capitalize %></button>
42
+ </div>
43
+ </form>
44
+
45
+ <button class="btn btn-secondary btn-return-to-editor fixed-bottom mb-4 ms-4"><%= t.quit.capitalize %></button>
46
+ </div>
47
+ </div>
48
+ </body>
49
+ </html>
data/bin/hyde_admin.ru CHANGED
@@ -6,11 +6,15 @@ require 'fileutils'
6
6
  require 'i18n'
7
7
  require 'date'
8
8
  require 'escape_utils'
9
+ require 'image_processing/mini_magick'
9
10
  require_relative '../lib/hyde_admin/version'
10
11
 
11
12
  # TODO détecter format nouveau post (pour codemirror)
13
+ # Serve
14
+
15
+ class Mid < Roda
16
+ plugin :middleware
12
17
 
13
- class App < Roda
14
18
  YML_FILE_NAME = "hyde_admin.yml"
15
19
 
16
20
  plugin :render,
@@ -56,7 +60,7 @@ class App < Roda
56
60
  end
57
61
 
58
62
  def self.extract_header(str)
59
- headers = App.extract_header_str(str).to_s.split("\n")
63
+ headers = Mid.extract_header_str(str).to_s.split("\n")
60
64
  headers = headers.select{ |header| !header.empty? }.map{ |header| header.scan(/([a-zA-Z0-9]*): (.*)/).flatten }.select{ |header| !header.empty? }
61
65
  hsh_headers = {}
62
66
  if !headers.flatten.empty?
@@ -76,7 +80,27 @@ class App < Roda
76
80
  end
77
81
 
78
82
  def self.extract_tags(str)
79
- str.scan(/^\[?(.*?)\]?$/).flatten.first.split(',')
83
+ str.to_s.scan(/^\[?(.*?)\]?$/).flatten.first.split(',')
84
+ end
85
+
86
+ def self.resize_image(image_path,params)
87
+ dir = File.dirname(image_path)
88
+ basename = File.basename(image_path, File.extname(image_path))
89
+ while File.exist?("#{File.join(dir, "#{basename}_#{params['resize_size']}")}.#{params['resize_format']}")
90
+ basename += '_'
91
+ end
92
+ output_path = "#{File.join(dir, "#{basename}_#{params['resize_size']}")}.#{params['resize_format']}"
93
+
94
+ width,height = params['resize_size'].split("x")
95
+ ip = ImageProcessing::MiniMagick
96
+ .source(image_path)
97
+ .convert(params['resize_format'])
98
+ .resize_to_limit(width.to_i, height.to_i)
99
+ if params['resize_format'] == 'jpg'
100
+ ip = ip.saver(quality: 80, interlace: "Line")
101
+ end
102
+
103
+ ip.call(destination: output_path)
80
104
  end
81
105
 
82
106
  FORMAT_DATE_FILENAME = '%Y-%m-%d'
@@ -114,12 +138,13 @@ class App < Roda
114
138
  end
115
139
 
116
140
  r.on "deploy" do
117
- `#{@hyde_parameters['rsync_fullpath']} #{Dir.pwd}/_site/ #{@hyde_parameters['deploy_dest_user']}@#{@hyde_parameters['deploy_dest_address']}:#{@hyde_parameters['deploy_dest_path']}`
141
+ `#{@hyde_parameters['rsync_fullpath']} -avzr #{Dir.pwd}/_site/ #{@hyde_parameters['deploy_dest_user']}@#{@hyde_parameters['deploy_dest_address']}:#{@hyde_parameters['deploy_dest_path']}`
118
142
  r.redirect "/dashboard"
119
143
  end
120
144
 
121
145
  r.post "configuration" do
122
146
  r.params.each_pair do |k,v|
147
+ next if k.to_s == "beforeSend"
123
148
  @hyde_parameters[k] = v
124
149
  end
125
150
  File.open(File.join(Dir.pwd, YML_FILE_NAME),"w+") do |f|
@@ -136,6 +161,29 @@ class App < Roda
136
161
  view("dashboard")
137
162
  end
138
163
 
164
+ r.on "upload_image_form" do
165
+ render("upload_image_form")
166
+ end
167
+
168
+ r.post "upload_image" do
169
+ files = [r.params['files']].flatten # 1 or more files
170
+ @filenames = []
171
+ files.each do |file|
172
+ filename = file[:filename]
173
+ while File.exist?(File.join(@hyde_parameters['images_path'], filename))
174
+ filename = "#{File.basename(filename, File.extname(filename))}_#{File.extname(filename)}"
175
+ end
176
+ @filenames << filename
177
+ File.open(File.join(@hyde_parameters['images_path'], filename), 'wb') do |f|
178
+ f.write(file[:tempfile].read)
179
+ end
180
+ if @hyde_parameters['resize_enable'] == 'true'
181
+ Mid.resize_image(File.join(@hyde_parameters['images_path'], filename), @hyde_parameters)
182
+ end
183
+ end
184
+ render("upload_image_form")
185
+ end
186
+
139
187
  r.on "files" do
140
188
  @dir_path = r.params['dir_path'] || Dir.pwd
141
189
 
@@ -150,6 +198,7 @@ class App < Roda
150
198
  r.post "create" do
151
199
  files = [r.params['files']].flatten # 1 or more files
152
200
  files.each do |file|
201
+ # TODO rename file if exist
153
202
  File.open(File.join(@dir_path, file[:filename]), 'wb') do |f|
154
203
  f.write(file[:tempfile].read)
155
204
  end
@@ -176,8 +225,8 @@ class App < Roda
176
225
  r.get "edit" do
177
226
  @file = r.params['file']
178
227
  @content = File.read(@file)
179
- @header = App.extract_header_str(@content)
180
- @content = App.remove_header(@content)
228
+ @header = Mid.extract_header_str(@content)
229
+ @content = Mid.remove_header(@content)
181
230
  @has_header = (!@header.nil? && !@header.empty?)
182
231
  @has_editor = ['.html','.md'].include?(File.extname(@file))
183
232
  view("files/edit")
@@ -219,7 +268,7 @@ class App < Roda
219
268
  path = r.params['path']
220
269
  title = r.params['title']
221
270
  I18n.config.available_locales = :en
222
- new_path = path.gsub(REGEXP_EXTRACT_DATE_TITLE_FROM_FILENAME, "\\1#{App.transliterate_title_for_url(title)}\\3")
271
+ new_path = path.gsub(REGEXP_EXTRACT_DATE_TITLE_FROM_FILENAME, "\\1#{Mid.transliterate_title_for_url(title)}\\3")
223
272
  response.write(new_path)
224
273
  end
225
274
  r.post "update_date_today" do
@@ -242,7 +291,7 @@ class App < Roda
242
291
  all_images = all_images.reverse if sort_date == 'asc'
243
292
  @images = all_images[start_elts, nb_elements_per_page]
244
293
 
245
- path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb')
294
+ path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb')
246
295
  data = ERB.new(File.read(path)).result(binding)
247
296
 
248
297
  response.write(data)
@@ -286,7 +335,7 @@ class App < Roda
286
335
  @file = r.params['file']
287
336
 
288
337
  content_file = File.read(@file)
289
- @headers = App.extract_header(content_file)
338
+ @headers = Mid.extract_header(content_file)
290
339
  @content = File.read(@file).gsub(/---(.*?)---/m, "")
291
340
 
292
341
  # for page
@@ -316,7 +365,7 @@ class App < Roda
316
365
  #$stderr.puts "---->"
317
366
 
318
367
  if @new_file.nil? || @new_file.empty?
319
- filename = App.urlize(@date, @title, (@type_file != 'pages'))
368
+ filename = Mid.urlize(@date, @title, (@type_file != 'pages'))
320
369
  @new_file = File.join(Dir.pwd,"_#{@type_file}", "#{filename}.#{@format}")
321
370
  end
322
371
 
@@ -358,4 +407,11 @@ class App < Roda
358
407
  end
359
408
  end
360
409
 
410
+ # https://roda.jeremyevans.net/rdoc/classes/Roda/RodaPlugins/Middleware.html
411
+ class App < Roda
412
+ use Mid
413
+ use Rack::Static, :urls => [''], root: Dir.pwd # allow to match all files in Dir.pwd
414
+ end
415
+
361
416
  run App.freeze.app
417
+
data/bin/hyde_admin.yml CHANGED
@@ -6,10 +6,13 @@ deploy_dest_path: "/absolute/remote/path/mysite"
6
6
  rsync_fullpath: rsync
7
7
  site_index: index.html
8
8
  hyde_admin_language: en
9
- hyde_admin_auth: false
9
+ hyde_admin_auth: 'false'
10
10
  hyde_admin_user: admin
11
11
  hyde_admin_password: admin
12
12
  default_format: html
13
- display_layout: true
14
- display_format: true
15
- images_path: assets/images/
13
+ display_layout: 'true'
14
+ display_format: 'true'
15
+ images_path: assets/images/
16
+ resize_format: jpg
17
+ resize_size: 1500x1000
18
+ resize_enable: 'true'
@@ -0,0 +1,16 @@
1
+ #!/bin/env ruby
2
+
3
+ require 'fileutils'
4
+
5
+ local_config_file = File.join(Dir.pwd, 'hyde_admin.yml')
6
+ old_filename = "hyde_admin_old_#{Time.now.strftime('%Y_%m_%d')}.yml"
7
+
8
+ # Backup actual config file
9
+ if File.exist?(local_config_file)
10
+ FileUtils.mv(local_config_file, old_filename)
11
+ end
12
+
13
+ # Copy the default config file
14
+ FileUtils.copy(File.join(File.expand_path(File.dirname(__FILE__)), 'hyde_admin.yml'), local_config_file)
15
+
16
+ puts "#{local_config_file} copied, you can find your old config file here : #{old_filename} !"
@@ -12,6 +12,7 @@
12
12
  height: 100%;
13
13
  object-fit: contain;
14
14
  overflow: hidden;
15
+ border:2px solid white;
15
16
  }
16
17
  .image-selector-content .image-element img:hover{
17
18
  border:2px solid gray;
@@ -23,9 +24,14 @@
23
24
 
24
25
  .image-element span{
25
26
  position: absolute;
26
- bottom:5px;
27
+ bottom:0px;
27
28
  left:5px;
28
29
  z-index: 10;
29
30
  font-weight: bold;
30
- text-shadow:white 0px 0px 3px, white 0px 0px 2px;
31
+ margin-bottom: -20px;
32
+ }
33
+
34
+ .CodeMirror{
35
+ border: 1px solid #ced4da;
36
+ border-radius: 4px;
31
37
  }
data/bin/i18n/en.yml CHANGED
@@ -39,7 +39,7 @@ help_default_layout: default layout for jekyll posts/pages
39
39
  deploy_dest_user: deploy remote user
40
40
  help_deploy_dest_user: Ssh user for rsync
41
41
  deploy_dest_address: deploy remote domain
42
- help_deploy_dest_address: remote domain for ssh deployment
42
+ help_deploy_dest_address: remote domain for ssh deployment (example.com)
43
43
  deploy_dest_path: deploy remote path
44
44
  help_deploy_dest_path: remote path on disk for ssh deployment
45
45
  rsync_fullpath: rsync path
@@ -47,24 +47,24 @@ help_rsync_fullpath: if rsync is not in PATH, othervise just let 'rsync'
47
47
  site_index: index file name of site
48
48
  help_site_index: link to open when we click on overview
49
49
  hyde_admin_language: hyde admin language
50
- help_hyde_admin_language: To change hyde admin language interface
50
+ help_hyde_admin_language: To change hyde admin language interface (fr = french, en = english)
51
51
  set_date_today: set date at today
52
52
  change_date_path: update date in path
53
53
  change_title_path: update title in path
54
54
  directory_input_placeholder: directory name to create
55
55
  file_input_placeholder: file name to create
56
56
  hyde_admin_auth: enable BasicAuth
57
- help_hyde_admin_auth: enable BasicAuth
57
+ help_hyde_admin_auth: enable BasicAuth (true/false)
58
58
  hyde_admin_user: BasicAuth user
59
59
  help_hyde_admin_user: BasicAuth user
60
60
  hyde_admin_password: BasicAuth password
61
61
  help_hyde_admin_password: BasicAuth password
62
62
  default_format: default format
63
- help_default_format: default format
63
+ help_default_format: default format (html = html, md = markdown)
64
64
  display_layout: display the layout input on edit form
65
- help_display_layout: display the layout input on edit form
65
+ help_display_layout: display the layout input on edit form (true/false)
66
66
  display_format: display the format input on edit form
67
- help_display_format: display the format input on edit form
67
+ help_display_format: display the format input on edit form (true/false)
68
68
  images_path: pictures path
69
69
  help_images_path: relative local picture path
70
70
  editor_undo: Undo
@@ -93,3 +93,17 @@ previous_images: previous images
93
93
  next_images: next images
94
94
  search: search
95
95
  filename: filename
96
+ filename_placeholder: filename...
97
+ upload_image_form: upload image form
98
+ pictures_has_been_uploaded: pictures has been uploaded
99
+ quit: quit
100
+ header_name: header name
101
+ header_value: header value
102
+ images: images
103
+ load_images: load images
104
+ resize_format: jpg
105
+ help_resize_format: jpg or png
106
+ resize_size: "size to fit, example : 1500x1000"
107
+ help_resize_size: Downsize to fit to the specified size (resize preserve ratio), example 1500x1000
108
+ resize_enable: Enable resizing for images
109
+ help_resize_enable: enable feature resize image at upload
data/bin/i18n/fr.yml CHANGED
@@ -39,7 +39,7 @@ help_default_layout: présentation par défaut pour les posts et pages
39
39
  deploy_dest_user: Utilisateur pour déploiement
40
40
  help_deploy_dest_user: Utilisateur pour déploiement par ssh
41
41
  deploy_dest_address: Adresse pour déploiement
42
- help_deploy_dest_address: Domaine ou adresse IP pour déploiement à travers ssh
42
+ help_deploy_dest_address: Domaine ou adresse IP pour déploiement à travers ssh (example.com)
43
43
  deploy_dest_path: chemin distant pour déploiement
44
44
  help_deploy_dest_path: chemin distant pour déploiement du site
45
45
  rsync_fullpath: chemin rsync
@@ -47,24 +47,24 @@ help_rsync_fullpath: si rsync n'est pas dans le PATH, sinon laissez 'rsync'
47
47
  site_index: nom du fichier index pour le site
48
48
  help_site_index: Lien pour le lien aperçu, pensez à l'extention si nécessaire
49
49
  hyde_admin_language: hyde admin langue
50
- help_hyde_admin_language: Pour changer la langue d'interface de hyde admin
50
+ help_hyde_admin_language: Pour changer la langue d'interface de hyde admin (fr = français, en = anglais)
51
51
  set_date_today: mets la date du jour
52
52
  change_date_path: mets à jour la date dans le chemin de fichier
53
53
  change_title_path: mets à jour le titre dans le chemin de fichier
54
54
  directory_input_placeholder: nom du dossier à créer
55
55
  file_input_placeholder: nom du fichier à créer
56
56
  hyde_admin_auth: enable BasicAuth
57
- help_hyde_admin_auth: enable BasicAuth
57
+ help_hyde_admin_auth: enable BasicAuth (true/false)
58
58
  hyde_admin_user: BasicAuth user
59
59
  help_hyde_admin_user: BasicAuth user
60
60
  hyde_admin_password: BasicAuth password
61
61
  help_hyde_admin_password: BasicAuth password
62
62
  default_format: format par défaut
63
- help_default_format: format par défaut pour les posts
63
+ help_default_format: format par défaut pour les posts (html = html, md = markdown)
64
64
  display_layout: affiche le choix du layout sur le formulaire d'édition
65
- help_display_layout: affiche le choix du layout sur le formulaire d'édition
65
+ help_display_layout: affiche le choix du layout sur le formulaire d'édition (true/false)
66
66
  display_format: affiche le choix du format sur le formulaire d'édition
67
- help_display_format: affiche le choix du format sur le formulaire d'édition
67
+ help_display_format: affiche le choix du format sur le formulaire d'édition (true/false)
68
68
  images_path: chemin des images
69
69
  help_images_path: chemin local relatif des images
70
70
  editor_undo: Annuler
@@ -92,4 +92,18 @@ newer: récente d'abord
92
92
  previous_images: images précédentes " lol
93
93
  next_images: images suivantes
94
94
  search: recherche
95
- filename: nom de fichier
95
+ filename: nom de fichier
96
+ filename_placeholder: nom de fichier...
97
+ upload_image_form: formulaire d'upload d'image
98
+ pictures_has_been_uploaded: les images ont été uploadées
99
+ quit: quitter
100
+ header_name: nom d'entête
101
+ header_value: valeur d'entête
102
+ images: images
103
+ load_images: charger images
104
+ resize_format: jpg
105
+ help_resize_format: jpg ou png
106
+ resize_size: "Recadrer en (example : 1500x1000)"
107
+ help_resize_size: Réduit les image pour coller à la taille spécifiée (le redimensionnement préserve le ratio), exemple 1500x1000
108
+ resize_enable: activer redimensionnement
109
+ help_resize_enable: active la fonctionnalité de redimensionnement d'image à l'upload
data/hyde_admin.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  all_files = `git ls-files`.split("\n").reject{ |filepath| filepath.start_with? 'test/' }
12
12
  s.files = all_files
13
13
 
14
- s.executables = ['hyde_admin']
14
+ s.executables = ['hyde_admin','hyde_admin_config']
15
15
  s.bindir = "bin"
16
16
  s.require_paths = ["lib"]
17
17
 
@@ -31,4 +31,5 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency("escape_utils") # escape_javascript / escape_html
32
32
  #s.add_runtime_dependency("i18n", "~> 0.4.0") # I18n.transliterate (already required by jekyll)
33
33
  s.add_runtime_dependency('jekyll') # Because we call jekyll binary
34
+ s.add_runtime_dependency('image_processing') # JPEG quality
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module HydeAdmin
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyde_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Claudel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-21 00:00:00.000000000 Z
11
+ date: 2021-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -80,14 +80,30 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: image_processing
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: A Jekyll admin interface
84
98
  email: claudel.sylvain@gmail.com
85
99
  executables:
86
100
  - hyde_admin
101
+ - hyde_admin_config
87
102
  extensions: []
88
103
  extra_rdoc_files: []
89
104
  files:
90
105
  - ".gitattributes"
106
+ - ".gitignore"
91
107
  - ".idea/.gitignore"
92
108
  - ".idea/hyde_admin.iml"
93
109
  - ".idea/misc.xml"
@@ -107,10 +123,12 @@ files:
107
123
  - bin/admin_views/partials/images_page.html.erb
108
124
  - bin/admin_views/posts/edit.erb
109
125
  - bin/admin_views/posts/listing.erb
126
+ - bin/admin_views/upload_image_form.erb
110
127
  - bin/fslightbox/fslightbox.js
111
128
  - bin/hyde_admin
112
129
  - bin/hyde_admin.ru
113
130
  - bin/hyde_admin.yml
131
+ - bin/hyde_admin_config
114
132
  - bin/hyde_assets/hyde_admin.css
115
133
  - bin/hyde_assets/hyde_admin.js
116
134
  - bin/i18n/en.yml