hyde_admin 0.0.7 → 0.0.8

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: 8ef51602655e92300fd16efb61fc625738e962b8708146c702666fefe759d582
4
- data.tar.gz: 695738c9eb64ff85aaa643fb2b06ac8219d9ed1abec97cd9fc2ca7a4b99014f8
3
+ metadata.gz: efb3733133bc8adfcf1bfa8a365ef7a5e7d98b87f03f615b538ccc874ec76fa1
4
+ data.tar.gz: 38a47d3d53dd35bae51f7673c21bcb25b85bf1f18992f9305cad83486ed46205
5
5
  SHA512:
6
- metadata.gz: 1076b6a7a5cd25e24715a5bfc27f5cc7ddb2f2a88c3406d6ca2affeb45e391cab4e74f734ef0036a6c33ae1f2fa61e977b63e8446cd26139aacafabcacbbde7e
7
- data.tar.gz: 29719bfc0e10609a22b45590031c5e4fea57d9e190ba158a186d2fa523953d0c37df8e204ff8d846296b915fb108d9a0a7d61b0bb2ae8b9991dccc2175d0c519
6
+ metadata.gz: 32f1fa3002f7b43460f94ca833c56c4c0ea820f4db3c03552f28c042c89286a553a9b74baddb9f8ac4b38b03f0b0bcfc1aea1ec5221b9f114f88498efd87ea71
7
+ data.tar.gz: 83b5a59c1a4ca153b58cff1ae58459831e6d951d954a5382b0880c3773abce88c159eb9bfecea914120add871ce34828ff211b0ef5287e1b8bae53f9688a1749
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,7 @@
1
+ # 0.0.8
2
+
3
+ Resize image at upload with ImageProcessing (MiniMagick)
4
+
1
5
  # 0.0.7
2
6
 
3
7
  Post edit : bugfix, keep layout & format when we don't show input.
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
@@ -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>
@@ -25,21 +25,25 @@
25
25
  </script>
26
26
  </head>
27
27
  <body style="width:800px;" class="p-4">
28
- <h1><%= t.upload_image_form.capitalize %></h1>
28
+ <div class="container-fluid">
29
+ <div class="row">
30
+ <h1><%= t.upload_image_form.capitalize %></h1>
29
31
 
30
- <% if @filenames %>
31
- <%= t.pictures_has_been_uploaded.capitalize %> : <%= @filenames.join(', ') %>
32
- <% end %>
32
+ <% if @filenames %>
33
+ <%= t.pictures_has_been_uploaded.capitalize %> : <%= @filenames.join(', ') %>
34
+ <% end %>
33
35
 
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>
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>
42
44
 
43
- <button class="btn btn-secondary btn-return-to-editor fixed-bottom mb-4 ms-4"><%= t.quit.capitalize %></button>
45
+ <button class="btn btn-secondary btn-return-to-editor fixed-bottom mb-4 ms-4"><%= t.quit.capitalize %></button>
46
+ </div>
47
+ </div>
44
48
  </body>
45
49
  </html>
data/bin/hyde_admin.ru CHANGED
@@ -6,6 +6,7 @@ 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)
@@ -82,6 +83,26 @@ class Mid < Roda
82
83
  str.to_s.scan(/^\[?(.*?)\]?$/).flatten.first.split(',')
83
84
  end
84
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)
104
+ end
105
+
85
106
  FORMAT_DATE_FILENAME = '%Y-%m-%d'
86
107
  FORMAT_DATE_INPUT_FILENAME = '%Y-%m-%d %H:%M:%S %z'
87
108
 
@@ -156,6 +177,9 @@ class Mid < Roda
156
177
  File.open(File.join(@hyde_parameters['images_path'], filename), 'wb') do |f|
157
178
  f.write(file[:tempfile].read)
158
179
  end
180
+ if @hyde_parameters['resize_enable'] == 'true'
181
+ Mid.resize_image(File.join(@hyde_parameters['images_path'], filename), @hyde_parameters)
182
+ end
159
183
  end
160
184
  render("upload_image_form")
161
185
  end
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'
data/bin/i18n/en.yml CHANGED
@@ -100,4 +100,10 @@ quit: quit
100
100
  header_name: header name
101
101
  header_value: header value
102
102
  images: images
103
- load_images: load images
103
+ load_images: load images
104
+ resize_format: jpg
105
+ help_resize_format: jpg or png
106
+ resize_size: 1500x1000
107
+ help_resize_size: Downsize to fit to the specified size (resize preserve ratio), example 1500x1000
108
+ resize_enable: true
109
+ help_resize_enable: enable feature resize image at upload
data/bin/i18n/fr.yml CHANGED
@@ -100,4 +100,10 @@ quit: quitter
100
100
  header_name: nom d'entête
101
101
  header_value: valeur d'entête
102
102
  images: images
103
- load_images: charger images
103
+ load_images: charger images
104
+ resize_format: jpg
105
+ help_resize_format: jpg ou png
106
+ resize_size: 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: true
109
+ help_resize_enable: active la fonctionnalité de redimensionnement d'image à l'upload
data/hyde_admin.gemspec CHANGED
@@ -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.7"
2
+ VERSION = "0.0.8"
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.7
4
+ version: 0.0.8
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-25 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -80,6 +80,20 @@ 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:
@@ -88,6 +102,7 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - ".gitattributes"
105
+ - ".gitignore"
91
106
  - ".idea/.gitignore"
92
107
  - ".idea/hyde_admin.iml"
93
108
  - ".idea/misc.xml"