hyde_admin 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e0533768c2271c1429d64400e80f166bac017b9efa08f658f4212d6505197de
4
- data.tar.gz: 2a972b4b4dad61f61795f9e818bc739dcaba4525137f668396d819e2c86372db
3
+ metadata.gz: 8ef51602655e92300fd16efb61fc625738e962b8708146c702666fefe759d582
4
+ data.tar.gz: 695738c9eb64ff85aaa643fb2b06ac8219d9ed1abec97cd9fc2ca7a4b99014f8
5
5
  SHA512:
6
- metadata.gz: a4d6e2a1095f6eebd9491903d441b02e157141f0174b19aa7514ec3b061a606873f8118fd37b3d76aab7f5fc2bb6637979c758213d37b3f941b4df49c640f13c
7
- data.tar.gz: 2a56bcbed352601a821fe2d382183bc2c1f01787fa553ff52fd1a6c1a9620b7f49f99ab9320583b720ede03d731c49561ccb79b56ed20ead3a7e1bb2b45cdcb7
6
+ metadata.gz: 1076b6a7a5cd25e24715a5bfc27f5cc7ddb2f2a88c3406d6ca2affeb45e391cab4e74f734ef0036a6c33ae1f2fa61e977b63e8446cd26139aacafabcacbbde7e
7
+ data.tar.gz: 29719bfc0e10609a22b45590031c5e4fea57d9e190ba158a186d2fa523953d0c37df8e204ff8d846296b915fb108d9a0a7d61b0bb2ae8b9991dccc2175d0c519
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # 0.0.7
2
+
3
+ Post edit : bugfix, keep layout & format when we don't show input.
4
+ CodeMirror editor : form-control style
5
+ Locales shows possible value for config.
6
+
7
+ # 0.0.6
8
+
9
+ Form upload image + style images selector
10
+ Menu follows workflow
11
+ Configuration remove beforeSend
12
+ Rsync params
13
+ Publish only for drafts
14
+
15
+ # 0.0.5
16
+
17
+ Sometimes no tags
18
+
1
19
  # 0.0.4
2
20
 
3
21
  Correct images selector
@@ -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,16 +79,15 @@
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 %>
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 %>
85
85
  </a>
86
86
  </li>
87
- <li class="nav-item"></li>
88
87
  <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 %>
88
+ <a class="nav-link active" aria-current="page" href="/deploy" id="btn-deploy">
89
+ <span data-feather="home" class="fas fa-cloud-upload-alt"></span>
90
+ <%= EscapeUtils.escape_html t.deploy.capitalize %>
92
91
  </a>
93
92
  </li>
94
93
  </ul>
@@ -124,43 +123,45 @@
124
123
  <div class="modal-dialog" role="document">
125
124
  <div class="modal-content">
126
125
  <div class="modal-header">
127
- <h5 class="modal-title">Images</h5>
126
+ <h5 class="modal-title"><%= t.images.capitalize %></h5>
128
127
  <!--
129
128
  <button type="button" class="btn btn-default close" data-dismiss="modal" aria-label="Close">
130
129
  <span aria-hidden="true">&times;</span>
131
130
  </button>
132
131
  -->
132
+ <button type="button" class="btn btn-outline-secondary btn-sm load-image">
133
+ <%= t.load_images.capitalize %>
134
+ </button>
133
135
  </div>
134
136
  <div class="modal-body">
135
137
  <div>
136
138
  <div class="image-selector-search d-block" data-page="0">
137
139
  <form action="" class="form-inline">
138
140
  <div class="form-group mb-2">
139
- <label for="inputPassword2" class="sr-only"><%= EscapeUtils.escape_html t.sort_by_date %></label>
140
141
  <label>
141
- <input class="form-check-input" type="radio" name="sort_date" value="asc"> <%= EscapeUtils.escape_html t.older %>
142
+ <input class="form-check-input" type="radio" name="sort_date" value="asc"> <%= EscapeUtils.escape_html t.newer.capitalize %>
142
143
  </label>
143
144
  &nbsp;&nbsp;&nbsp;
144
145
  <label>
145
- <input class="form-check-input" type="radio" name="sort_date" value="desc"> <%= EscapeUtils.escape_html t.newer %>
146
+ <input class="form-check-input" type="radio" name="sort_date" value="desc" checked> <%= EscapeUtils.escape_html t.older.capitalize %>
146
147
  </label>
147
148
  </div>
148
149
  <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...">
150
+ <label for="inputFilename" class="sr-only"><%= EscapeUtils.escape_html t.filename.capitalize %></label>
151
+ <input type="text" class="form-control" name="filename" id="inputFilename" placeholder="<%= EscapeUtils.escape_html t.filename_placeholder.capitalize %>">
151
152
  </div>
152
- <button type="submit" class="btn btn-primary image-selector-search-submit d-block mb-2"><%= EscapeUtils.escape_html t.search %></button>
153
+ <button type="submit" class="btn btn-primary image-selector-search-submit d-block mb-2"><%= EscapeUtils.escape_html t.search.capitalize %></button>
153
154
  </form>
154
155
  </div>
155
156
  <div class="image-selector-content">
156
- <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb') %>
157
+ <% path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb') %>
157
158
  <%= ERB.new(File.read(path)).result(binding) %>
158
159
  </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">
160
+ <div class="image-selector-page text-center">
161
+ <a href="#" title="<%= EscapeUtils.escape_html t.previous_images %>" class="btn btn-secondary image-selector-page-prev px-4">
161
162
  <i class="fas fa-chevron-left"></i>
162
163
  </a>
163
- <a href="#" title="<%= EscapeUtils.escape_html t.next_images %>"class="btn btn-secondary image-selector-page-next">
164
+ <a href="#" title="<%= EscapeUtils.escape_html t.next_images %>" class="btn btn-secondary image-selector-page-next px-4">
164
165
  <i class="fas fa-chevron-right"></i>
165
166
  </a>
166
167
  </div>
@@ -213,6 +214,13 @@
213
214
  search(1);
214
215
  return false;
215
216
  });
217
+ $(document).on('click', '.load-image', function(){
218
+ 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");
219
+ return false;
220
+ });
221
+ function reload_image(){
222
+ $('.load-image').click();
223
+ }
216
224
  </script>
217
225
  <script src="/fslightbox/fslightbox.js"></script>
218
226
  </body>
@@ -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,45 @@
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
+ <h1><%= t.upload_image_form.capitalize %></h1>
29
+
30
+ <% if @filenames %>
31
+ <%= t.pictures_has_been_uploaded.capitalize %> : <%= @filenames.join(', ') %>
32
+ <% end %>
33
+
34
+ <form enctype="multipart/form-data" method="post" action="/upload_image" class="row g-3">
35
+ <div class="col-10">
36
+ <input type="file" name="files[]" multiple class="form-control">
37
+ </div>
38
+ <div class="col-2">
39
+ <button class="btn btn-primary"><%= t.upload.capitalize %></button>
40
+ </div>
41
+ </form>
42
+
43
+ <button class="btn btn-secondary btn-return-to-editor fixed-bottom mb-4 ms-4"><%= t.quit.capitalize %></button>
44
+ </body>
45
+ </html>
data/bin/hyde_admin.ru CHANGED
@@ -9,8 +9,11 @@ require 'escape_utils'
9
9
  require_relative '../lib/hyde_admin/version'
10
10
 
11
11
  # TODO détecter format nouveau post (pour codemirror)
12
+ # Serve
13
+
14
+ class Mid < Roda
15
+ plugin :middleware
12
16
 
13
- class App < Roda
14
17
  YML_FILE_NAME = "hyde_admin.yml"
15
18
 
16
19
  plugin :render,
@@ -56,7 +59,7 @@ class App < Roda
56
59
  end
57
60
 
58
61
  def self.extract_header(str)
59
- headers = App.extract_header_str(str).to_s.split("\n")
62
+ headers = Mid.extract_header_str(str).to_s.split("\n")
60
63
  headers = headers.select{ |header| !header.empty? }.map{ |header| header.scan(/([a-zA-Z0-9]*): (.*)/).flatten }.select{ |header| !header.empty? }
61
64
  hsh_headers = {}
62
65
  if !headers.flatten.empty?
@@ -114,12 +117,13 @@ class App < Roda
114
117
  end
115
118
 
116
119
  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']}`
120
+ `#{@hyde_parameters['rsync_fullpath']} -avzr #{Dir.pwd}/_site/ #{@hyde_parameters['deploy_dest_user']}@#{@hyde_parameters['deploy_dest_address']}:#{@hyde_parameters['deploy_dest_path']}`
118
121
  r.redirect "/dashboard"
119
122
  end
120
123
 
121
124
  r.post "configuration" do
122
125
  r.params.each_pair do |k,v|
126
+ next if k.to_s == "beforeSend"
123
127
  @hyde_parameters[k] = v
124
128
  end
125
129
  File.open(File.join(Dir.pwd, YML_FILE_NAME),"w+") do |f|
@@ -136,6 +140,26 @@ class App < Roda
136
140
  view("dashboard")
137
141
  end
138
142
 
143
+ r.on "upload_image_form" do
144
+ render("upload_image_form")
145
+ end
146
+
147
+ r.post "upload_image" do
148
+ files = [r.params['files']].flatten # 1 or more files
149
+ @filenames = []
150
+ files.each do |file|
151
+ filename = file[:filename]
152
+ while File.exist?(File.join(@hyde_parameters['images_path'], filename))
153
+ filename = "#{File.basename(filename, File.extname(filename))}_#{File.extname(filename)}"
154
+ end
155
+ @filenames << filename
156
+ File.open(File.join(@hyde_parameters['images_path'], filename), 'wb') do |f|
157
+ f.write(file[:tempfile].read)
158
+ end
159
+ end
160
+ render("upload_image_form")
161
+ end
162
+
139
163
  r.on "files" do
140
164
  @dir_path = r.params['dir_path'] || Dir.pwd
141
165
 
@@ -150,6 +174,7 @@ class App < Roda
150
174
  r.post "create" do
151
175
  files = [r.params['files']].flatten # 1 or more files
152
176
  files.each do |file|
177
+ # TODO rename file if exist
153
178
  File.open(File.join(@dir_path, file[:filename]), 'wb') do |f|
154
179
  f.write(file[:tempfile].read)
155
180
  end
@@ -176,8 +201,8 @@ class App < Roda
176
201
  r.get "edit" do
177
202
  @file = r.params['file']
178
203
  @content = File.read(@file)
179
- @header = App.extract_header_str(@content)
180
- @content = App.remove_header(@content)
204
+ @header = Mid.extract_header_str(@content)
205
+ @content = Mid.remove_header(@content)
181
206
  @has_header = (!@header.nil? && !@header.empty?)
182
207
  @has_editor = ['.html','.md'].include?(File.extname(@file))
183
208
  view("files/edit")
@@ -219,7 +244,7 @@ class App < Roda
219
244
  path = r.params['path']
220
245
  title = r.params['title']
221
246
  I18n.config.available_locales = :en
222
- new_path = path.gsub(REGEXP_EXTRACT_DATE_TITLE_FROM_FILENAME, "\\1#{App.transliterate_title_for_url(title)}\\3")
247
+ new_path = path.gsub(REGEXP_EXTRACT_DATE_TITLE_FROM_FILENAME, "\\1#{Mid.transliterate_title_for_url(title)}\\3")
223
248
  response.write(new_path)
224
249
  end
225
250
  r.post "update_date_today" do
@@ -242,7 +267,7 @@ class App < Roda
242
267
  all_images = all_images.reverse if sort_date == 'asc'
243
268
  @images = all_images[start_elts, nb_elements_per_page]
244
269
 
245
- path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb')
270
+ path = File.join(Pathname.new(Mid.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb')
246
271
  data = ERB.new(File.read(path)).result(binding)
247
272
 
248
273
  response.write(data)
@@ -286,7 +311,7 @@ class App < Roda
286
311
  @file = r.params['file']
287
312
 
288
313
  content_file = File.read(@file)
289
- @headers = App.extract_header(content_file)
314
+ @headers = Mid.extract_header(content_file)
290
315
  @content = File.read(@file).gsub(/---(.*?)---/m, "")
291
316
 
292
317
  # for page
@@ -316,7 +341,7 @@ class App < Roda
316
341
  #$stderr.puts "---->"
317
342
 
318
343
  if @new_file.nil? || @new_file.empty?
319
- filename = App.urlize(@date, @title, (@type_file != 'pages'))
344
+ filename = Mid.urlize(@date, @title, (@type_file != 'pages'))
320
345
  @new_file = File.join(Dir.pwd,"_#{@type_file}", "#{filename}.#{@format}")
321
346
  end
322
347
 
@@ -358,4 +383,11 @@ class App < Roda
358
383
  end
359
384
  end
360
385
 
386
+ # https://roda.jeremyevans.net/rdoc/classes/Roda/RodaPlugins/Middleware.html
387
+ class App < Roda
388
+ use Mid
389
+ use Rack::Static, :urls => [''], root: Dir.pwd # allow to match all files in Dir.pwd
390
+ end
391
+
361
392
  run App.freeze.app
393
+
@@ -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,11 @@ 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
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,12 @@ 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
@@ -1,3 +1,3 @@
1
1
  module HydeAdmin
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
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.5
4
+ version: 0.0.7
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-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -107,6 +107,7 @@ files:
107
107
  - bin/admin_views/partials/images_page.html.erb
108
108
  - bin/admin_views/posts/edit.erb
109
109
  - bin/admin_views/posts/listing.erb
110
+ - bin/admin_views/upload_image_form.erb
110
111
  - bin/fslightbox/fslightbox.js
111
112
  - bin/hyde_admin
112
113
  - bin/hyde_admin.ru