simplec 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/app/assets/javascripts/simplec/summernote-config.js +1 -0
- data/app/constraints/simplec/subdomains.rb +14 -8
- data/app/controllers/simplec/embedded_images_controller.rb +7 -0
- data/app/models/simplec/embedded_image.rb +3 -1
- data/config/routes.rb +1 -0
- data/db/migrate/20170809210304_create_simplec_embedded_images.rb +1 -1
- data/lib/simplec/embedded_image_actions.rb +21 -20
- data/lib/simplec/version.rb +1 -1
- data/lib/simplec.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd4562c8c0bbab684b813215b25a37647dbbd134
|
4
|
+
data.tar.gz: 924e595fdddaf414fcbd91a33b0a5008e7913864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49b55b0d7c216b7e35a5cec8f8c2e99086077dfd43ad5f27d9da0e6de3446b62e51a06013b2fc707554a5888cfcb3b69cfa5947d51f73a9e7718775a18f9c8a5
|
7
|
+
data.tar.gz: 6ce855a1ca1486f9e302dab3bf1b8c69cc8137c85cefd84daf1e14794658f35bd5a41f4f427d3031820d49e205833ddeb84c0fe9335460ba202630fa5c7ca7f3
|
data/README.md
CHANGED
@@ -244,10 +244,11 @@ See this page for a good cheat sheet: http://markevans.github.io/dragonfly/image
|
|
244
244
|
|
245
245
|
1. TODOS:
|
246
246
|
|
247
|
-
- Embedded image id (integer -> uuid)
|
248
|
-
|
249
247
|
- Check doc view helpers
|
250
248
|
|
249
|
+
- Add config options for uuid vs integer ids, maybe check if page is using
|
250
|
+
uuid/id if table exists to determine going forward. Add note in README
|
251
|
+
|
251
252
|
- Throw clear warning when creating a page without a type
|
252
253
|
|
253
254
|
- Document `lib/simplec/controller_extensions.rb`
|
@@ -260,6 +261,8 @@ See this page for a good cheat sheet: http://markevans.github.io/dragonfly/image
|
|
260
261
|
|
261
262
|
- rewrite beginning part of usage
|
262
263
|
|
264
|
+
- utilize thread local variable for found subdomain in #subdomain
|
265
|
+
|
263
266
|
- simplec_path/simplec_url caching
|
264
267
|
|
265
268
|
1. Installer `rails generater simplec:install`
|
@@ -1,23 +1,29 @@
|
|
1
1
|
module Simplec
|
2
2
|
class Subdomains
|
3
|
-
|
3
|
+
def self.matches?(request)
|
4
|
+
simplec = request.headers['HTTP_X_ENGINE'] == 'simplec'
|
4
5
|
present = request.subdomain.present?
|
5
|
-
|
6
|
-
|
6
|
+
not_admin = request.subdomain != 'admin'
|
7
|
+
subdomain = Simplec::Subdomain.find_by(name: request.subdomain)
|
7
8
|
|
8
|
-
|
9
|
+
match = simplec || (present && not_admin && subdomain)
|
9
10
|
|
10
11
|
if match
|
11
12
|
Thread.current[:simplec_subdomain] = subdomain
|
13
|
+
Rails.logger.info <<-LOG
|
14
|
+
Simplec request received.
|
15
|
+
ActionDispatch::Request#original_url: #{request.original_url}
|
16
|
+
Simplec Engine: #{not_admin}
|
17
|
+
LOG
|
12
18
|
else
|
13
|
-
Rails.logger.info <<-LOG
|
19
|
+
Rails.logger.info <<-LOG
|
14
20
|
Simplec Subdomain '#{request.subdomain}' was not found.
|
15
21
|
ActionDispatch::Request#original_url: #{request.original_url}
|
16
22
|
'admin' subdomain bypass: #{!not_admin}
|
17
|
-
LOG
|
23
|
+
LOG
|
18
24
|
end
|
19
25
|
|
20
|
-
|
21
|
-
|
26
|
+
match
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Simplec
|
2
2
|
class EmbeddedImage < ApplicationRecord
|
3
3
|
belongs_to :embeddable,
|
4
|
-
polymorphic: true
|
4
|
+
polymorphic: true,
|
5
|
+
optional: true
|
5
6
|
|
6
7
|
dragonfly_accessor :asset
|
7
8
|
|
@@ -10,6 +11,7 @@ module Simplec
|
|
10
11
|
return self.asset.url unless persisted?
|
11
12
|
self.asset.url(ei: Base64.urlsafe_encode64(self.id.to_s))
|
12
13
|
end
|
14
|
+
alias_method :asset_url, :url
|
13
15
|
|
14
16
|
end
|
15
17
|
end
|
data/config/routes.rb
CHANGED
@@ -2,7 +2,7 @@ class CreateSimplecEmbeddedImages < ActiveRecord::Migration[5.0]
|
|
2
2
|
def change
|
3
3
|
create_table :simplec_embedded_images, id: :uuid, default: 'gen_random_uuid()' do |t|
|
4
4
|
t.string :embeddable_type
|
5
|
-
t.
|
5
|
+
t.uuid :embeddable_id
|
6
6
|
t.string :asset_uid
|
7
7
|
t.string :asset_name
|
8
8
|
|
@@ -4,28 +4,29 @@ module Simplec
|
|
4
4
|
|
5
5
|
module InstanceMethods
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
7
|
+
def create
|
8
|
+
@embedded_image = EmbeddedImage.new(embedded_image_params)
|
9
|
+
if @embedded_image.save
|
10
|
+
respond_to do |format|
|
11
|
+
format.json {
|
12
|
+
render status: 201, location: @embedded_image.url,
|
13
|
+
json: @embedded_image.slice(:id, :asset_name, :asset_url)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
else
|
17
|
+
respond_to do |format|
|
18
|
+
format.json {
|
19
|
+
render status: 422, json: @embedded_image.errors
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
+
private
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def embedded_image_params
|
28
|
+
params.permit(:asset_url, :asset_name)
|
29
|
+
end
|
29
30
|
|
30
31
|
end
|
31
32
|
|
data/lib/simplec/version.rb
CHANGED
data/lib/simplec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Smith
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- app/assets/stylesheets/simplec/summernote.scss
|
116
116
|
- app/constraints/simplec/subdomains.rb
|
117
117
|
- app/controllers/simplec/application_controller.rb
|
118
|
+
- app/controllers/simplec/embedded_images_controller.rb
|
118
119
|
- app/controllers/simplec/pages_controller.rb
|
119
120
|
- app/helpers/simplec/application_helper.rb
|
120
121
|
- app/jobs/simplec/application_job.rb
|