hyde_admin 0.0.3 → 0.0.4

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: 1a05ad4bb0704e1175cd5ed0393ae09181a0241dd423add001cd7ef4cc365ed2
4
- data.tar.gz: 1db71be2ffc12226a0c10fb66751311e4bd6b8d795aa3bccf4dcc9da5993e557
3
+ metadata.gz: cb95670b96fd382d5e1f1ae437e50b055de1e1196192cb5438cb8a5b9da2a553
4
+ data.tar.gz: f2febcd67319f60a862b79e88e06290df9495dd2388d85900e38eb9486c76f50
5
5
  SHA512:
6
- metadata.gz: '0902597c60ffe712e999a065655ad6034f3d9e2b62f129b815e2139ef684d0f565f08d0fda4ad2f59b85a182da93f0d730dcfbad99128521befe593d266cd21e'
7
- data.tar.gz: 8926be4affe34325d115ccf1788609fc46a7770a770233944a425a2a054870b501861601eaf232ab73f2ac48741068b611ec59e3535035010513917b3c9d857d
6
+ metadata.gz: fb71c84a6420d278a484fb14a08ff24d155c926140838c243ba9fdd8df8d0495ed5d182fd12b58c9e5ab2981adbeaacb053e0f9e40f16f30ca812b564d7bde51
7
+ data.tar.gz: cac253c8000aa874cd925df410d3d4174032c573ffe3d359d7f09128d129be23e7a4d8b76c23354f3ef62b4074f6ae5df8af80b64ec133150228b715fab28f7f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.4
2
+
3
+ Correct images selector
4
+ Some refactoring
5
+ Escape translations
6
+
1
7
  # 0.0.3
2
8
 
3
9
  Bugfix (see commits)
data/TODO.md CHANGED
@@ -1 +1,3 @@
1
- Overview btn for posts/drafts/pages (save && rebuild && open in new tab)
1
+ Overview btn for posts/drafts/pages (save && rebuild && open in new tab)
2
+ See TINYmce for wysiwyg editor
3
+ Add defaults class for images injected by editor
@@ -35,7 +35,7 @@
35
35
  <li class="nav-item">
36
36
  <a class="nav-link active" aria-current="page" href="/<%= @hyde_parameters['site_index'] %>">
37
37
  <span data-feather="home" class="fas fa-eye"></span>
38
- <%= t.overview.capitalize %>
38
+ <%= EscapeUtils.escape_html t.overview.capitalize %>
39
39
  </a>
40
40
  </li>
41
41
  <li class="nav-item">
@@ -43,52 +43,52 @@
43
43
  <li class="nav-item">
44
44
  <a class="nav-link active" aria-current="page" href="/dashboard">
45
45
  <span data-feather="home" class="fas fa-tachometer-alt"></span>
46
- <%= t.dashboard.capitalize %>
46
+ <%= EscapeUtils.escape_html t.dashboard.capitalize %>
47
47
  </a>
48
48
  </li>
49
49
  <li class="nav-item">
50
50
  <a class="nav-link" href="/pages/index">
51
51
  <span data-feather="file" class="fas fa-file"></span>
52
- <%= t.pages.capitalize %>
52
+ <%= EscapeUtils.escape_html t.pages.capitalize %>
53
53
  </a>
54
54
  </li>
55
55
  <li class="nav-item">
56
56
  <a class="nav-link" href="/drafts/index">
57
57
  <span data-feather="shopping-cart" class="fas fa-file"></span>
58
- <%= t.drafts.capitalize %>
58
+ <%= EscapeUtils.escape_html t.drafts.capitalize %>
59
59
  </a>
60
60
  </li>
61
61
  <li class="nav-item">
62
62
  <a class="nav-link" href="/posts/index">
63
63
  <span data-feather="users" class="fas fa-file"></span>
64
- <%= t.posts.capitalize %>
64
+ <%= EscapeUtils.escape_html t.posts.capitalize %>
65
65
  </a>
66
66
  </li>
67
67
  <li class="nav-item"></li>
68
68
  <li class="nav-item">
69
69
  <a class="nav-link" href="/files/index">
70
70
  <span data-feather="users" class="fas fa-copy"></span>
71
- <%= t.files.capitalize %>
71
+ <%= EscapeUtils.escape_html t.files.capitalize %>
72
72
  </a>
73
73
  </li>
74
74
  <li class="nav-item"></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>
78
- <%= t.rebuild.capitalize %>
78
+ <%= EscapeUtils.escape_html t.rebuild.capitalize %>
79
79
  </a>
80
80
  </li>
81
81
  <li class="nav-item">
82
82
  <a class="nav-link active" aria-current="page" href="/deploy" id="btn-deploy">
83
83
  <span data-feather="home" class="fas fa-cloud-upload-alt"></span>
84
- <%= t.deploy.capitalize %>
84
+ <%= EscapeUtils.escape_html t.deploy.capitalize %>
85
85
  </a>
86
86
  </li>
87
87
  <li class="nav-item"></li>
88
88
  <li class="nav-item">
89
89
  <a class="nav-link" href="/configuration">
90
90
  <span data-feather="layers" class="fas fa-tools"></span>
91
- <%= t.configuration.capitalize %>
91
+ <%= EscapeUtils.escape_html t.configuration.capitalize %>
92
92
  </a>
93
93
  </li>
94
94
  </ul>
@@ -125,19 +125,46 @@
125
125
  <div class="modal-content">
126
126
  <div class="modal-header">
127
127
  <h5 class="modal-title">Images</h5>
128
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
128
+ <!--
129
+ <button type="button" class="btn btn-default close" data-dismiss="modal" aria-label="Close">
129
130
  <span aria-hidden="true">&times;</span>
130
131
  </button>
132
+ -->
131
133
  </div>
132
- <div class="modal-body modal-body-image">
133
- <% path_of_images = File.join(Dir.pwd, @hyde_parameters['images_path'], "**") %>
134
- <% $stderr.puts(path_of_images) %>
135
- <% Dir.glob(path_of_images)[(@page || 0) * 9, ((@page || 0) + 1) * 9 ].each do |img| %>
136
- <% img = img.gsub(Dir.pwd, "") %>
137
- <div class="image-element">
138
- <img src="<%= img %>" alt="<%= img %>">
134
+ <div class="modal-body">
135
+ <div>
136
+ <div class="image-selector-search d-block" data-page="0">
137
+ <form action="" class="form-inline">
138
+ <div class="form-group mb-2">
139
+ <label for="inputPassword2" class="sr-only"><%= EscapeUtils.escape_html t.sort_by_date %></label>
140
+ <label>
141
+ <input class="form-check-input" type="radio" name="sort_date" value="asc"> <%= EscapeUtils.escape_html t.older %>
142
+ </label>
143
+ &nbsp;&nbsp;&nbsp;
144
+ <label>
145
+ <input class="form-check-input" type="radio" name="sort_date" value="desc"> <%= EscapeUtils.escape_html t.newer %>
146
+ </label>
147
+ </div>
148
+ <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...">
151
+ </div>
152
+ <button type="submit" class="btn btn-primary image-selector-search-submit d-block mb-2"><%= EscapeUtils.escape_html t.search %></button>
153
+ </form>
139
154
  </div>
140
- <% end %>
155
+ <div class="image-selector-content">
156
+ <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb') %>
157
+ <%= ERB.new(File.read(path)).result(binding) %>
158
+ </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">
161
+ <i class="fas fa-chevron-left"></i>
162
+ </a>
163
+ <a href="#" title="<%= EscapeUtils.escape_html t.next_images %>"class="btn btn-secondary image-selector-page-next">
164
+ <i class="fas fa-chevron-right"></i>
165
+ </a>
166
+ </div>
167
+ </div>
141
168
  </div>
142
169
  </div>
143
170
  </div>
@@ -154,6 +181,38 @@
154
181
  });
155
182
  }
156
183
  <% end %>
184
+
185
+ function search(offset_page){
186
+ let sort_date = $('.image-selector-search input[name=sort_date]:checked').val();
187
+ let filename = $('.image-selector-search input[name=filename]').val();
188
+ let page = $('.image-selector-search').attr('data-page');
189
+ let new_page = parseInt(page) + offset_page;
190
+
191
+ if(new_page < 0){
192
+ new_page = 0;
193
+ }
194
+
195
+ $.post( "/ajax/images", { sort_date: sort_date, filename: filename, page: new_page })
196
+ .done(function( data ) {
197
+ $('.image-selector-content').html(data);
198
+ });
199
+
200
+ $('.image-selector-search').attr('data-page', new_page);
201
+ return false;
202
+ }
203
+
204
+ $(document).on('click', '.image-selector-search-submit', function(){
205
+ search(0);
206
+ return false;
207
+ });
208
+ $(document).on('click', '.image-selector-page-prev', function(){
209
+ search(-1);
210
+ return false;
211
+ });
212
+ $(document).on('click', '.image-selector-page-next', function(){
213
+ search(1);
214
+ return false;
215
+ });
157
216
  </script>
158
217
  <script src="/fslightbox/fslightbox.js"></script>
159
218
  </body>
@@ -1,13 +1,13 @@
1
- <h2><%= t.configuration.capitalize %></h2>
1
+ <h2><%= EscapeUtils.escape_html t.configuration.capitalize %></h2>
2
2
 
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"><%= t.send(setting).capitalize %></label>
6
+ <label for="i-<%= setting %>" class="form-label"><%= EscapeUtils.escape_html t.send(setting).capitalize %></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"><%= t.send("help_#{setting}").capitalize %></div>
8
+ <div id="i-<%= setting %>-help" class="form-text"><%= EscapeUtils.escape_html t.send("help_#{setting}").capitalize %></div>
9
9
  </div>
10
10
  <% end %>
11
- <button type="submit" class="btn btn-primary"><%= t.submit.capitalize %></button>
11
+ <button type="submit" class="btn btn-primary"><%= EscapeUtils.escape_html t.submit.capitalize %></button>
12
12
  </form>
13
13
 
@@ -1 +1 @@
1
- <h2><%= t.dashboard.capitalize %></h2>
1
+ <h2><%= EscapeUtils.escape_html t.dashboard.capitalize %></h2>
@@ -1,24 +1,24 @@
1
1
  <div class="codemirror-toolbar btn-toolbar" role="toolbar">
2
2
  <div class="btn-group mr-2" role="group" aria-label="Undo/redo">
3
- <button type="button" class="btn btn-light"><i class="fas fa-undo-alt" title="<%= t.editor_undo %>"></i></button>
4
- <button type="button" class="btn btn-light"><i class="fas fa-redo-alt" title="<%= t.editor_redo %>"></i></button>
3
+ <button type="button" class="btn btn-light"><i class="fas fa-undo-alt" title="<%= EscapeUtils.escape_html t.editor_undo %>"></i></button>
4
+ <button type="button" class="btn btn-light"><i class="fas fa-redo-alt" title="<%= EscapeUtils.escape_html t.editor_redo %>"></i></button>
5
5
  </div>
6
6
  <div class="btn-group mr-2" role="group" aria-label="Structural tags">
7
- <button type="button" class="btn btn-light"><i class="fas fa-file-image" title="<%= t.editor_file %>"></i></button>
8
- <button type="button" class="btn btn-light"><i class="fas fa-list cmt-replace" title="<%= t.editor_list %>"></i></button>
9
- <button type="button" class="btn btn-light"><i class="fas fa-list-ol cmt-replace" title="<%= t.editor_list_ol %>"></i></button>
10
- <button type="button" class="btn btn-light"><i class="fas fa-link cmt-replace" title="<%= t.editor_link %>"></i></button>
11
- <button type="button" class="btn btn-light"><i class="fas fa-quote-left cmt-replace" title="<%= t.editor_quote %>"></i></button>
7
+ <button type="button" class="btn btn-light"><i class="fas fa-file-image" title="<%= EscapeUtils.escape_html t.editor_file %>"></i></button>
8
+ <button type="button" class="btn btn-light"><i class="fas fa-list cmt-replace" title="<%= EscapeUtils.escape_html t.editor_list %>"></i></button>
9
+ <button type="button" class="btn btn-light"><i class="fas fa-list-ol cmt-replace" title="<%= EscapeUtils.escape_html t.editor_list_ol %>"></i></button>
10
+ <button type="button" class="btn btn-light"><i class="fas fa-link cmt-replace" title="<%= EscapeUtils.escape_html t.editor_link %>"></i></button>
11
+ <button type="button" class="btn btn-light"><i class="fas fa-quote-left cmt-replace" title="<%= EscapeUtils.escape_html t.editor_quote %>"></i></button>
12
12
  </div>
13
13
  <div class="btn-group mr-2" role="group" aria-label="Style tags">
14
- <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-1" title="<%= t.editor_title_h1 %>">1</i></button>
15
- <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-2" title="<%= t.editor_title_h2 %>">2</i></button>
16
- <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-3" title="<%= t.editor_title_h3 %>">3</i></button>
17
- <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-4" title="<%= t.editor_title_h4 %>">4</i></button>
18
- <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-5" title="<%= t.editor_title_h5 %>">5</i></button>
19
- <button type="button" class="btn btn-light"><i class="fas fa-underline cmt-replace" title="<%= t.editor_underline %>"></i></button>
20
- <button type="button" class="btn btn-light"><i class="fas fa-bold cmt-replace" title="<%= t.editor_bold %>"></i></button>
21
- <button type="button" class="btn btn-light"><i class="fas fa-italic cmt-replace" title="<%= t.editor_italic %>"></i></button>
22
- <button type="button" class="btn btn-light"><i class="fas fa-strikethrough cmt-replace" title="<%= t.editor_strikethrough %>"></i></button>
14
+ <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-1" title="<%= EscapeUtils.escape_html t.editor_title_h1 %>">1</i></button>
15
+ <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-2" title="<%= EscapeUtils.escape_html t.editor_title_h2 %>">2</i></button>
16
+ <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-3" title="<%= EscapeUtils.escape_html t.editor_title_h3 %>">3</i></button>
17
+ <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-4" title="<%= EscapeUtils.escape_html t.editor_title_h4 %>">4</i></button>
18
+ <button type="button" class="btn btn-light"><i class="fas fa-heading cmt-heading-5" title="<%= EscapeUtils.escape_html t.editor_title_h5 %>">5</i></button>
19
+ <button type="button" class="btn btn-light"><i class="fas fa-underline cmt-replace" title="<%= EscapeUtils.escape_html t.editor_underline %>"></i></button>
20
+ <button type="button" class="btn btn-light"><i class="fas fa-bold cmt-replace" title="<%= EscapeUtils.escape_html t.editor_bold %>"></i></button>
21
+ <button type="button" class="btn btn-light"><i class="fas fa-italic cmt-replace" title="<%= EscapeUtils.escape_html t.editor_italic %>"></i></button>
22
+ <button type="button" class="btn btn-light"><i class="fas fa-strikethrough cmt-replace" title="<%= EscapeUtils.escape_html t.editor_strikethrough %>"></i></button>
23
23
  </div>
24
24
  </div>
@@ -8,9 +8,9 @@ $(document).on('click', '.codemirror-toolbar .fa-file-image', function(){
8
8
  $('.modal-image').modal('show');
9
9
  });
10
10
  $(document).on('click', '.modal-image img', function(){
11
- let img_src = '<img src="' + $(this).attr('src') + '" alt="<%= t.default_alt_img %>" title="<%= t.default_title_img %>" />';
11
+ let img_src = '<img src="' + $(this).attr('src') + '" alt="<%= EscapeUtils.escape_html t.default_alt_img %>" title="<%= EscapeUtils.escape_html t.default_title_img %>" />';
12
12
  if(window.mode_markdown){
13
- img_src = '![<%= t.default_alt_img %>](' + $(this).attr('src') + ')';
13
+ img_src = '![<%= EscapeUtils.escape_html t.default_alt_img %>](' + $(this).attr('src') + ')';
14
14
  }
15
15
  window.myCodeMirror.replaceSelection(img_src);
16
16
  $('.modal-image').modal('hide');
@@ -1,30 +1,30 @@
1
- <h2><%= t.edit.capitalize %></h2>
1
+ <h2><%= EscapeUtils.escape_html t.edit.capitalize %></h2>
2
2
 
3
3
  <form action="/files/update?file=<%= @file %>" method="post">
4
4
  <% if @has_header %>
5
5
  <div class="mb-3">
6
- <label for="i-header" class="form-label"><%= t.header.capitalize %></label>
6
+ <label for="i-header" class="form-label"><%= EscapeUtils.escape_html t.header.capitalize %></label>
7
7
  <textarea class="form-control text-editor" id="i-header" rows="3" name="header" style="font-family: <%= (['.html', '.xml', '.yml', '.js', '.md'].include?(File.extname(@file)) ? 'monospace' : 'inherit') %>"><%= @header %></textarea>
8
8
  </div>
9
9
  <% end %>
10
10
  <div class="mb-3">
11
- <label for="i-content" class="form-label"><%= t.content.capitalize %>
11
+ <label for="i-content" class="form-label"><%= EscapeUtils.escape_html t.content.capitalize %>
12
12
  <% if ['.html','.md'].include?(File.extname(@file)) %>
13
13
  <a href="https://jekyllrb.com/docs/liquid/" class="text-secondary" target="_blank"><i class="fas fa-question-circle"></i></a>
14
14
  <% end %>
15
15
  </label>
16
16
 
17
17
  <% if @has_editor %>
18
- <% path = File.join(Pathname.new(File.dirname(__FILE__)).parent, 'editor_html.erb') %>
18
+ <% path = File.join(Pathname.new(App.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(File.dirname(__FILE__)).parent, 'editor_js.erb') %>
25
+ <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_js.erb') %>
26
26
  <%= ERB.new(File.read(path)).result(binding) %>
27
27
  </script>
28
28
  </div>
29
- <button type="submit" class="btn btn-primary"><%= t.submit.capitalize %></button>
29
+ <button type="submit" class="btn btn-primary"><%= EscapeUtils.escape_html t.submit.capitalize %></button>
30
30
  </form>
@@ -1,4 +1,4 @@
1
- <h2><%= t.files.capitalize %></h2>
1
+ <h2><%= EscapeUtils.escape_html t.files.capitalize %></h2>
2
2
 
3
3
  <div class="row g-3">
4
4
  <div class="col-auto">
@@ -8,7 +8,7 @@
8
8
  <input type="file" multiple name="files[]" class="form-control">
9
9
  </div>
10
10
  <div class="col-auto">
11
- <button type="submit" class="btn btn-outline-secondary"><i class="fa fa-plus" title="<%= t.create.capitalize %>"></i> <%= t.upload %></button>
11
+ <button type="submit" class="btn btn-outline-secondary"><i class="fa fa-plus" title="<%= EscapeUtils.escape_html t.create.capitalize %>"></i> <%= EscapeUtils.escape_html t.upload %></button>
12
12
  </div>
13
13
  </div>
14
14
  </form>
@@ -19,10 +19,10 @@
19
19
  <form method="post" action="/files/create_dir?dir_path=<%= @dir_path %>">
20
20
  <div class="row g-2 align-items-center">
21
21
  <div class="col-auto">
22
- <input type="text" name="directory_name" class="form-control" placeholder="<%= t.directory_input_placeholder %>">
22
+ <input type="text" name="directory_name" class="form-control" placeholder="<%= EscapeUtils.escape_html t.directory_input_placeholder %>">
23
23
  </div>
24
24
  <div class="col-auto">
25
- <button type="submit" class="btn btn-outline-secondary"><i class="fa fa-plus" title="<%= t.create.capitalize %>"></i> <%= t.create %></button>
25
+ <button type="submit" class="btn btn-outline-secondary"><i class="fa fa-plus" title="<%= EscapeUtils.escape_html t.create.capitalize %>"></i> <%= EscapeUtils.escape_html t.create %></button>
26
26
  </div>
27
27
  </div>
28
28
  </form>
@@ -33,10 +33,10 @@
33
33
  <form method="post" action="/files/create_file?dir_path=<%= @dir_path %>">
34
34
  <div class="row g-2 align-items-center">
35
35
  <div class="col-auto">
36
- <input type="text" name="file_name" class="form-control" placeholder="<%= t.file_input_placeholder %>">
36
+ <input type="text" name="file_name" class="form-control" placeholder="<%= EscapeUtils.escape_html t.file_input_placeholder %>">
37
37
  </div>
38
38
  <div class="col-auto">
39
- <button type="submit" class="btn btn-outline-secondary"><i class="fa fa-plus" title="<%= t.create.capitalize %>"></i> <%= t.create %></button>
39
+ <button type="submit" class="btn btn-outline-secondary"><i class="fa fa-plus" title="<%= EscapeUtils.escape_html t.create.capitalize %>"></i> <%= EscapeUtils.escape_html t.create %></button>
40
40
  </div>
41
41
  </div>
42
42
  </form>
@@ -49,20 +49,20 @@
49
49
  <table class="table table-striped table-sm">
50
50
  <tr>
51
51
  <th>
52
- <%= t.file.capitalize %>
52
+ <%= EscapeUtils.escape_html t.file.capitalize %>
53
53
  </th>
54
54
  <th class="text-center">
55
- <%= t.edit.capitalize %>
55
+ <%= EscapeUtils.escape_html t.edit.capitalize %>
56
56
  </th>
57
57
  <th class="text-center">
58
- <%= t.delete.capitalize %>
58
+ <%= EscapeUtils.escape_html t.delete.capitalize %>
59
59
  </th>
60
60
  </tr>
61
61
  <% if @parent_dir %>
62
62
  <tr>
63
63
  <td colspan="3">
64
64
  <i class="fas fa-folder"></i>
65
- <a href="/files/index?dir_path=<%= File.dirname(@dir_path) %>">[<%= t.parent_dir.capitalize %>]</a>
65
+ <a href="/files/index?dir_path=<%= File.dirname(@dir_path) %>">[<%= EscapeUtils.escape_html t.parent_dir.capitalize %>]</a>
66
66
  </td>
67
67
  </tr>
68
68
  <% end %>
@@ -95,13 +95,13 @@
95
95
  </td>
96
96
  <td class="text-center">
97
97
  <% if !File.directory?(f) %>
98
- <a href="/files/edit?file=<%= f %>&dir_path=<%= @dir_path %>" class="btn btn-default"><i class="fa fa-edit" title="<%= t.edit %>"></i></a>
98
+ <a href="/files/edit?file=<%= f %>&dir_path=<%= @dir_path %>" class="btn btn-default"><i class="fa fa-edit" title="<%= EscapeUtils.escape_html t.edit %>"></i></a>
99
99
  <% end %>
100
100
  </td>
101
101
  <td class="text-center">
102
- <form method="post" action="/files/delete?file=<%= f %>" class="inline form-confirm" data-confirm="<%= t.are_you_sure %>">
102
+ <form method="post" action="/files/delete?file=<%= f %>" class="inline form-confirm" data-confirm="<%= EscapeUtils.escape_html t.are_you_sure %>">
103
103
  <input name="path" type="hidden" value="<%= @dir_path %>">
104
- <button type="submit" class="btn btn-default"><i class="fa fa-trash" title="<%= t.delete %>"></i></button>
104
+ <button type="submit" class="btn btn-default"><i class="fa fa-trash" title="<%= EscapeUtils.escape_html t.delete %>"></i></button>
105
105
  </form>
106
106
  </td>
107
107
  </tr>
@@ -0,0 +1,4 @@
1
+ <div class="image-element">
2
+ <img src="<%= @img %>" alt="<%= @img %>">
3
+ <span class="font-size:8px;"><%= @img.split('/').last %></span>
4
+ </div>
@@ -0,0 +1,8 @@
1
+ <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'image_element.html.erb') %>
2
+ <% myerb = ERB.new(File.read(path), eoutvar: "@bidule") %>
3
+ <% # Why %= don't work !? Need to do a loop concat... %>
4
+ <% $stderr.puts @images %>
5
+ <% (@images || []).each do |img| %>
6
+ <% @img = img.gsub(Dir.pwd, "") %>
7
+ <%= myerb.result(binding) %>
8
+ <% end %>
@@ -1,49 +1,49 @@
1
- <h2><%= t.send(@type_file).capitalize %></h2>
1
+ <h2><%= EscapeUtils.escape_html t.send(@type_file).capitalize %></h2>
2
2
 
3
3
  <% file_params = (!@new_record ? "?file=#{@file}" : "") %>
4
4
 
5
5
  <form action="/<%= @type_file %><%= file_params %>" method="post">
6
6
  <% if !@new_record %>
7
7
  <div class="mb-3">
8
- <label for="i-path" class="form-label"><%= t.path.capitalize %></label>
8
+ <label for="i-path" class="form-label"><%= EscapeUtils.escape_html t.path.capitalize %></label>
9
9
  <div class="input-group">
10
- <input type="text" class="form-control" value="<%= @file %>" name="new_file" id="i-path">
11
10
  <span class="input-group-text">
12
- <i class="fas fa-calendar-alt" id="btn-date-path" title="<%= t.change_date_path %>"></i>
11
+ <i class="fas fa-calendar-alt" id="btn-date-path" title="<%= EscapeUtils.escape_html t.change_date_path %>"></i>
13
12
  </span>
14
13
  <span class="input-group-text">
15
- <i class="fas fa-sync-alt" id="btn-title-path" title="<%= t.change_title_path %>"></i>
14
+ <i class="fas fa-sync-alt" id="btn-title-path" title="<%= EscapeUtils.escape_html t.change_title_path %>"></i>
16
15
  </span>
16
+ <input type="text" class="form-control" value="<%= @file %>" name="new_file" id="i-path">
17
17
  </div>
18
- <div id="i-path-help" class="form-text"><%= t.help_path %></div>
18
+ <div id="i-path-help" class="form-text"><%= EscapeUtils.escape_html t.help_path %></div>
19
19
  </div>
20
20
  <% end %>
21
21
  <div class="mb-3">
22
- <label for="i-title" class="form-label"><%= t.title.capitalize %></label>
22
+ <label for="i-title" class="form-label"><%= EscapeUtils.escape_html t.title.capitalize %></label>
23
23
  <input type="text" value="<%= @headers.delete('title') %>" class="form-control" name="title" id="i-title">
24
24
  </div>
25
25
  <div class="mb-3">
26
- <label for="i-date" class="form-label"><%= t.date.capitalize %></label>
26
+ <label for="i-date" class="form-label"><%= EscapeUtils.escape_html t.date.capitalize %></label>
27
27
  <div class="input-group">
28
- <input type="text" value="<%= @headers.delete('date') || Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %>" class="form-control" name="date" id="i-date">
29
28
  <span class="input-group-text">
30
- <i class="fas fa-calendar-day" id="btn-date-today" title="<%= t.set_date_today %>"></i>
29
+ <i class="fas fa-calendar-day" id="btn-date-today" title="<%= EscapeUtils.escape_html t.set_date_today %>"></i>
31
30
  </span>
31
+ <input type="text" value="<%= @headers.delete('date') || Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %>" class="form-control" name="date" id="i-date">
32
32
  </div>
33
33
  </div>
34
34
  <div class="mb-3">
35
- <label for="i-tags" class="form-label"><%= t.tags.capitalize %></label>
36
- <input type="text" value="<%= @headers.delete('tags') %>" class="form-control" name="tags" id="i-tags">
37
- <div id="i-tags-help" class="form-text"><%= t.help_tags %></div>
35
+ <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
38
  </div>
39
39
  <div class="mb-3 form-check">
40
40
  <input type="checkbox" class="form-check-input" name="publish" value="publish" id="i-publish">
41
- <label class="form-check-label" for="i-publish"><%= t.publish.capitalize %></label>
41
+ <label class="form-check-label" for="i-publish"><%= EscapeUtils.escape_html t.publish.capitalize %></label>
42
42
  </div>
43
43
 
44
44
  <% if @hyde_parameters['display_layout'].to_s == 'true' %>
45
45
  <div class="mb-3">
46
- <label for="i-layout" class="form-label"><%= t.layout.capitalize %></label>
46
+ <label for="i-layout" class="form-label"><%= EscapeUtils.escape_html t.layout.capitalize %></label>
47
47
  <select class="form-select" aria-label="Choice layout" name="layout">
48
48
  <% Dir.glob(File.join(Dir.pwd, '_layouts', '*')).each do |f| %>
49
49
  <% layout = File.basename(f, File.extname(f)) %>
@@ -58,7 +58,7 @@
58
58
 
59
59
  <% if @hyde_parameters['display_format'].to_s == 'true' %>
60
60
  <div class="mb-3">
61
- <label for="i-format" class="form-label"><%= t.format.capitalize %></label>
61
+ <label for="i-format" class="form-label"><%= EscapeUtils.escape_html t.format.capitalize %></label>
62
62
  <select class="form-select" id="select-format" aria-label="Choice format" name="format">
63
63
  <% format = File.extname(@file) %>
64
64
  <% format = ".#{@hyde_parameters['default_format']}" if format.empty? %>
@@ -84,7 +84,7 @@
84
84
  </div>
85
85
  <% end %>
86
86
 
87
- <a href="#" class="btn btn-secondary mb-2" id="add-header"><i class="fas fa-plus"></i> <%= t.add_header.capitalize %></a>
87
+ <a href="#" class="btn btn-secondary mb-2" id="add-header"><i class="fas fa-plus"></i> <%= EscapeUtils.escape_html t.add_header.capitalize %></a>
88
88
  <div class="mb-3 custom-headers"></div>
89
89
 
90
90
  <div class="mb-3 template-header" style="display: none">
@@ -109,14 +109,14 @@
109
109
  </script>
110
110
 
111
111
  <div class="mb-3">
112
- <label for="i-content" class="form-label"><%= t.content.capitalize %> <a href="https://jekyllrb.com/docs/liquid/" class="text-secondary" target="_blank"><i class="fas fa-question-circle"></i></a></label>
112
+ <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
113
 
114
- <% path = File.join(Pathname.new(File.dirname(__FILE__)).parent, 'editor_html.erb') %>
114
+ <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_html.erb') %>
115
115
  <%= ERB.new(File.read(path)).result(binding) %>
116
116
 
117
117
  <textarea class="form-control text-editor" id="i-content" rows="3" name="content"><%= @content %></textarea>
118
118
  </div>
119
- <button type="submit" class="btn btn-primary"><%= t.submit.capitalize %></button>
119
+ <button type="submit" class="btn btn-primary"><%= EscapeUtils.escape_html t.submit.capitalize %></button>
120
120
  </form>
121
121
 
122
122
  <script type="text/javascript" charset="utf-8">
@@ -150,7 +150,7 @@
150
150
  return false;
151
151
  });
152
152
 
153
- <% path = File.join(Pathname.new(File.dirname(__FILE__)).parent, 'editor_js.erb') %>
153
+ <% path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'editor_js.erb') %>
154
154
  <%= ERB.new(File.read(path)).result(binding) %>
155
155
 
156
156
  </script>
@@ -1,16 +1,16 @@
1
- <h2><%= t.send(@type_file).capitalize %> &nbsp; <a href="/<%= @type_file %>/new" class="btn btn-secondary btn-sm"><i class="fas fa-plus"></i> <%= t.new.capitalize %></a></h2>
1
+ <h2><%= EscapeUtils.escape_html t.send(@type_file).capitalize %> &nbsp; <a href="/<%= @type_file %>/new" class="btn btn-secondary btn-sm"><i class="fas fa-plus"></i> <%= EscapeUtils.escape_html t.new.capitalize %></a></h2>
2
2
 
3
3
  <div class="table-responsive">
4
4
  <table class="table table-striped table-sm">
5
5
  <tr>
6
6
  <th>
7
- <%= t.file.capitalize %>
7
+ <%= EscapeUtils.escape_html t.file.capitalize %>
8
8
  </th>
9
9
  <th>
10
- <%= t.edit.capitalize %>
10
+ <%= EscapeUtils.escape_html t.edit.capitalize %>
11
11
  </th>
12
12
  <th>
13
- <%= t.delete.capitalize %>
13
+ <%= EscapeUtils.escape_html t.delete.capitalize %>
14
14
  </th>
15
15
  </tr>
16
16
  <% @files.each do |f| %>
@@ -19,12 +19,12 @@
19
19
  <%= f.gsub(File.join(Dir.pwd, ''),'') %>
20
20
  </td>
21
21
  <td>
22
- <a href="/<%= @type_file %>?file=<%= f %>" class="btn btn-default"><i class="fa fa-edit" title="<%= t.edit.capitalize %>"></i></a>
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>
23
23
  </td>
24
24
  <td>
25
- <form method="post" action="/<%= @type_file %>/delete" class="inline form-confirm" data-confirm="<%= t.are_you_sure %>">
25
+ <form method="post" action="/<%= @type_file %>/delete" class="inline form-confirm" data-confirm="<%= EscapeUtils.escape_html t.are_you_sure %>">
26
26
  <input type="hidden" name="file" value="<%= f %>">
27
- <button type="submit" class="btn btn-default"><i class="fa fa-trash" title="<%= t.delete.capitalize %>"></i></button>
27
+ <button type="submit" class="btn btn-default"><i class="fa fa-trash" title="<%= EscapeUtils.escape_html t.delete.capitalize %>"></i></button>
28
28
  </form>
29
29
  </td>
30
30
  </tr>
data/bin/hyde_admin.ru CHANGED
@@ -5,6 +5,7 @@ require 'yaml'
5
5
  require 'fileutils'
6
6
  require 'i18n'
7
7
  require 'date'
8
+ require 'escape_utils'
8
9
  require_relative '../lib/hyde_admin/version'
9
10
 
10
11
  # TODO détecter format nouveau post (pour codemirror)
@@ -70,6 +71,14 @@ class App < Roda
70
71
  str.gsub(/---(.*?)---/m, "")
71
72
  end
72
73
 
74
+ def self.gem_source_path
75
+ File.expand_path(File.dirname(__FILE__))
76
+ end
77
+
78
+ def self.extract_tags(str)
79
+ str.scan(/^\[?(.*?)\]?$/).flatten.first.split(',')
80
+ end
81
+
73
82
  FORMAT_DATE_FILENAME = '%Y-%m-%d'
74
83
  FORMAT_DATE_INPUT_FILENAME = '%Y-%m-%d %H:%M:%S %z'
75
84
 
@@ -217,6 +226,27 @@ class App < Roda
217
226
  date = Time.now.strftime(FORMAT_DATE_INPUT_FILENAME)
218
227
  response.write(date)
219
228
  end
229
+ r.post "images" do
230
+ nb_elements_per_page = 9
231
+
232
+ sort_date = r.params['sort_date']
233
+ filename = r.params['filename']
234
+ page = r.params['page'].to_i
235
+ start_elts = (page || 0) * nb_elements_per_page
236
+
237
+ search_filename = "*#{filename.strip}*"
238
+
239
+ path_of_images = File.join(Dir.pwd, @hyde_parameters['images_path'], search_filename)
240
+
241
+ all_images = Dir.glob(path_of_images).sort_by {|filename| File.mtime(filename) }
242
+ all_images = all_images.reverse if sort_date == 'asc'
243
+ @images = all_images[start_elts, nb_elements_per_page]
244
+
245
+ path = File.join(Pathname.new(App.gem_source_path), 'admin_views', 'partials', 'images_page.html.erb')
246
+ data = ERB.new(File.read(path)).result(binding)
247
+
248
+ response.write(data)
249
+ end
220
250
  end
221
251
 
222
252
  # Posts/pages/drafts
@@ -1,18 +1,31 @@
1
1
  /* modal pictures */
2
- .modal-body-image{
2
+ .image-selector-content{
3
3
  display: grid;
4
4
  grid-template-columns: 1fr 1fr 1fr;
5
5
  }
6
- .modal-body-image .image-element{
6
+ .image-selector-content .image-element{
7
7
  width: 150px;
8
8
  height: 150px;
9
9
  }
10
- .modal-body-image .image-element img{
10
+ .image-selector-content .image-element img{
11
11
  width: 100%;
12
12
  height: 100%;
13
13
  object-fit: contain;
14
14
  overflow: hidden;
15
15
  }
16
- .modal-body-image .image-element img:hover{
16
+ .image-selector-content .image-element img:hover{
17
17
  border:2px solid gray;
18
+ }
19
+
20
+ .image-element{
21
+ position: relative;
22
+ }
23
+
24
+ .image-element span{
25
+ position: absolute;
26
+ bottom:5px;
27
+ left:5px;
28
+ z-index: 10;
29
+ font-weight: bold;
30
+ text-shadow:white 0px 0px 3px, white 0px 0px 2px;
18
31
  }
data/bin/i18n/en.yml CHANGED
@@ -85,4 +85,11 @@ editor_italic: Italic
85
85
  editor_strikethrough: Strikethrough
86
86
  default_alt_img: Alt text
87
87
  default_title_img: Title text
88
- parent_dir: dossier parent
88
+ parent_dir: parent directory
89
+ sort_by_date: sort_by_date
90
+ older: older first
91
+ newer: newer first
92
+ previous_images: previous images
93
+ next_images: next images
94
+ search: search
95
+ filename: filename
data/bin/i18n/fr.yml CHANGED
@@ -85,4 +85,11 @@ editor_italic: Italique
85
85
  editor_strikethrough: Barré
86
86
  default_alt_img: Texte alternatif
87
87
  default_title_img: Titre image
88
- parent_dir: dossier parent
88
+ parent_dir: dossier parent
89
+ sort_by_date: tri par date
90
+ older: vieille d'abord
91
+ newer: récente d'abord
92
+ previous_images: images précédentes " lol
93
+ next_images: images suivantes
94
+ search: recherche
95
+ filename: nom de fichier
data/hyde_admin.gemspec CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency("roda", "~> 3.48.0")
29
29
  s.add_runtime_dependency("roda-i18n", "~> 0.4.0")
30
30
  s.add_runtime_dependency("roda-http-auth", "0.2.0")
31
+ s.add_runtime_dependency("escape_utils") # escape_javascript / escape_html
31
32
  #s.add_runtime_dependency("i18n", "~> 0.4.0") # I18n.transliterate (already required by jekyll)
32
33
  s.add_runtime_dependency('jekyll') # Because we call jekyll binary
33
34
  end
@@ -1,3 +1,3 @@
1
1
  module HydeAdmin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
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-13 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: escape_utils
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: jekyll
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +103,8 @@ files:
89
103
  - bin/admin_views/editor_js.erb
90
104
  - bin/admin_views/files/edit.erb
91
105
  - bin/admin_views/files/listing.erb
106
+ - bin/admin_views/partials/image_element.html.erb
107
+ - bin/admin_views/partials/images_page.html.erb
92
108
  - bin/admin_views/posts/edit.erb
93
109
  - bin/admin_views/posts/listing.erb
94
110
  - bin/fslightbox/fslightbox.js