neofiles 2.0.2 → 2.1.1
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 +5 -5
- data/README.md +11 -0
- data/app/controllers/neofiles/admin_controller.rb +2 -1
- data/app/models/neofiles/data_store/amazon_s3.rb +16 -7
- data/app/views/neofiles/admin/_file_compact.html.haml +11 -5
- data/lib/neofiles/engine.rb +2 -0
- data/lib/neofiles/version.rb +1 -1
- data/lib/neofiles.rb +13 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c990b0639f2c8783d0c511266ecc7bc5df9eaff856f171c08b33648a372ba8c0
|
4
|
+
data.tar.gz: 77177e83d421a156bf2e62e67ee408df101d3db971ce41df8b5053fa6a91a2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58b69ec97b11ef6957470b49e229c89af3c26c286bd9161daec5ee05e77d2067541de311dc09135be62b394f7772860868323f04e3b3d758bbbd81b18958d51
|
7
|
+
data.tar.gz: 3357f8319fa3db3df89ca947968c24a59cd74b1e4d03ea938b73369932617c6ab6881bb6c56ab90e68c3e1523bd73611ae4221dbde33084965fcecd4c8ec3604
|
data/README.md
CHANGED
@@ -403,6 +403,17 @@ config.neofiles.image_max_crop_height = 2000 # users can request resizing only u
|
|
403
403
|
config.neofiles.watermarker = ->(image, no_watermark: false, watermark_width:, watermark_height:) do
|
404
404
|
...
|
405
405
|
end
|
406
|
+
|
407
|
+
# picture when added is displayed on the right or left
|
408
|
+
# also affects the order of displaying pictures
|
409
|
+
config.neofiles.album_append_create_side = :left
|
410
|
+
|
411
|
+
# Amazon S3 settings
|
412
|
+
config.neofiles.amazon_s3_region = 'us-east'
|
413
|
+
config.neofiles.amazon_s3_api = 'KEY_ID'
|
414
|
+
config.neofiles.amazon_s3_secret = 'KEY_SECRET'
|
415
|
+
config.neofiles.amazon_s3_bucket = 'neofiles_prod'
|
416
|
+
config.neofiles.amazon_s3_endpoint = 'https://some-s3-provider.com' # optional
|
406
417
|
```
|
407
418
|
|
408
419
|
Roadmap, TODOs
|
@@ -107,7 +107,8 @@ class Neofiles::AdminController < ApplicationController
|
|
107
107
|
|
108
108
|
result = []
|
109
109
|
file_objects.each_with_index do |file, i|
|
110
|
-
|
110
|
+
append_create_position = Rails.application.config.neofiles.album_append_create_side == :left ? i == 0 : i == file_objects.count - 1
|
111
|
+
result << file_compact(data.merge(id: file.id, widget_id: "#{data[:widget_id]}_ap_#{i}", append_create: append_create_position && !old_file && data[:append_create] == '1' ? '1' : '0'))
|
111
112
|
end
|
112
113
|
|
113
114
|
if result.empty?
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# If you want to work with amazon s3 you need set values for the following parameters in your config file
|
3
3
|
# amazon_s3_region - the AWS region to connect to. The region is used to construct the client endpoint.
|
4
4
|
# amazon_s3_api, amazon_s3_secret - used to set credentials statically
|
5
|
+
# amazon_s3_endpoint - change if using another S3-compatible provider
|
5
6
|
# bucket_name - storage name in amazon_s3. Bucket must have a name that conforms to the naming requirements for non-US Standard regions.
|
6
7
|
# http://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html
|
7
8
|
# File will be named as id of the Neofiles::File object
|
@@ -81,15 +82,23 @@ class Neofiles::DataStore::AmazonS3
|
|
81
82
|
end
|
82
83
|
|
83
84
|
def client
|
84
|
-
@client ||= Aws::S3::Client.new(
|
85
|
-
region: Rails.application.config.neofiles.amazon_s3_region,
|
86
|
-
credentials: Aws::Credentials.new(
|
87
|
-
Rails.application.config.neofiles.amazon_s3_api,
|
88
|
-
Rails.application.config.neofiles.amazon_s3_secret
|
89
|
-
)
|
90
|
-
)
|
85
|
+
@client ||= Aws::S3::Client.new(client_params)
|
91
86
|
rescue Aws::S3::Errors::ServiceError
|
92
87
|
nil
|
93
88
|
end
|
94
89
|
|
90
|
+
def client_params
|
91
|
+
{
|
92
|
+
region: Rails.application.config.neofiles.amazon_s3_region,
|
93
|
+
credentials: Aws::Credentials.new(
|
94
|
+
Rails.application.config.neofiles.amazon_s3_api,
|
95
|
+
Rails.application.config.neofiles.amazon_s3_secret
|
96
|
+
)
|
97
|
+
}.tap do |result|
|
98
|
+
if Rails.application.config.neofiles.amazon_s3_endpoint
|
99
|
+
result[:endpoint] = Rails.application.config.neofiles.amazon_s3_endpoint
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
95
104
|
end
|
@@ -2,6 +2,11 @@
|
|
2
2
|
- desc = file.try(:description).try(:to_s).try!(:strip).try!(:truncate, 15).presence
|
3
3
|
- empty_desc = t 'neofiles.views.no_description'
|
4
4
|
|
5
|
+
- if Rails.application.config.neofiles.album_append_create_side == :left
|
6
|
+
- if append_create and file
|
7
|
+
= render partial: 'file_compact', locals: {file: nil, input_name: input_name, widget_id: widget_id + '_ap', clean_remove: clean_remove, append_create: true, error: nil, disabled: disabled, multiple: multiple, with_desc: with_desc, no_wm: no_wm}
|
8
|
+
|
9
|
+
|
5
10
|
- classes = []
|
6
11
|
- classes << 'neofiles-image-compact-empty' unless file
|
7
12
|
- classes << 'neofiles-image-compact-with-description' if file && with_desc
|
@@ -53,11 +58,11 @@
|
|
53
58
|
- popover_template = capture do
|
54
59
|
.popover.neofiles-image-compact-description-popover(role="tooltip")
|
55
60
|
.arrow
|
56
|
-
%h3.popover-title
|
57
|
-
.popover-content
|
61
|
+
%h3.popover-title.popover-header
|
62
|
+
.popover-content.popover-body
|
58
63
|
|
59
64
|
.neofiles-image-compact-description
|
60
|
-
%a.neofiles-image-compact-description-handle(href="#" data-empty=empty_desc data-toggle="popover" data-trigger="click" data-placement="bottom" data-html="true" data-animation="false" data-title="#{t 'neofiles.views.description'}" data-content=description_form data-template=popover_template){class: ('neofiles-image-compact-description-empty' unless desc)}= desc || empty_desc
|
65
|
+
%a.neofiles-image-compact-description-handle(href="#" data-empty=empty_desc data-toggle="popover" data-trigger="click" data-placement="bottom" data-html="true" data-animation="false" data-title="#{t 'neofiles.views.description'}" data-content="#{description_form}" data-template="#{popover_template}" data-container="##{widget_id}"){class: ('neofiles-image-compact-description-empty' unless desc)}= desc || empty_desc
|
61
66
|
|
62
67
|
%span.neofiles-image-compact-upload-icon
|
63
68
|
%i.icon-upload.glyphicon.glyphicon-upload
|
@@ -82,6 +87,7 @@
|
|
82
87
|
$("##{widget_id}").image();
|
83
88
|
});
|
84
89
|
|
85
|
-
- if
|
86
|
-
|
90
|
+
- if Rails.application.config.neofiles.album_append_create_side == :right
|
91
|
+
- if append_create && file
|
92
|
+
= render partial: 'file_compact', locals: {file: nil, input_name: input_name, widget_id: widget_id + '_ap', clean_remove: clean_remove, append_create: true, error: nil, disabled: disabled, multiple: multiple, with_desc: with_desc, no_wm: no_wm}
|
87
93
|
|
data/lib/neofiles/engine.rb
CHANGED
@@ -16,6 +16,8 @@ module Neofiles
|
|
16
16
|
config.neofiles.image_max_crop_width = 2000 # users can request resizing only up to this width
|
17
17
|
config.neofiles.image_max_crop_height = 2000 # users can request resizing only up to this height
|
18
18
|
|
19
|
+
config.neofiles.album_append_create_side = :right # picture when added is displayed on the right
|
20
|
+
|
19
21
|
# default storage
|
20
22
|
config.neofiles.write_data_stores = 'mongo'
|
21
23
|
config.neofiles.read_data_stores = 'mongo'
|
data/lib/neofiles/version.rb
CHANGED
data/lib/neofiles.rb
CHANGED
@@ -57,6 +57,19 @@ module Neofiles
|
|
57
57
|
# image fits into requested dimensions, no resizing will occur
|
58
58
|
return image_file_width, image_file_height if image_file_width <= width && image_file_height <= height
|
59
59
|
|
60
|
+
in_aspect = 1.0 * image_file_width / image_file_height
|
61
|
+
out_aspect = 1.0 * width / height
|
62
|
+
|
63
|
+
if in_aspect > out_aspect
|
64
|
+
# If image is more "flat", the output width will always be equal to the requested width,
|
65
|
+
# and the output height will be less than the requested height
|
66
|
+
height = nil
|
67
|
+
else
|
68
|
+
# If input image is more "stretched" vertically or its aspect ratio is equal to output aspect ratio,
|
69
|
+
# the output height will be equal to the requested height, and the output width will be less than or equal to the requested width
|
70
|
+
width = nil
|
71
|
+
end
|
72
|
+
|
60
73
|
AspectRatio.resize(image_file_width, image_file_height, width, height).map(&:to_i)
|
61
74
|
|
62
75
|
rescue
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neofiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konanykhin Ilya
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -155,7 +155,7 @@ homepage: http://neoweb.kz
|
|
155
155
|
licenses:
|
156
156
|
- MIT
|
157
157
|
metadata: {}
|
158
|
-
post_install_message:
|
158
|
+
post_install_message:
|
159
159
|
rdoc_options: []
|
160
160
|
require_paths:
|
161
161
|
- lib
|
@@ -170,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
|
174
|
-
|
175
|
-
signing_key:
|
173
|
+
rubygems_version: 3.0.9
|
174
|
+
signing_key:
|
176
175
|
specification_version: 4
|
177
176
|
summary: Serves and manages files & images.
|
178
177
|
test_files: []
|