shimmer 0.0.14 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shimmer/helpers/meta_helper.rb +32 -0
- data/lib/shimmer/railtie.rb +8 -0
- data/lib/shimmer/tasks/db.rake +9 -0
- data/lib/shimmer/tasks/s3.rake +46 -0
- data/lib/shimmer/utils/file_helper.rb +21 -3
- data/lib/shimmer/utils/meta.rb +30 -0
- data/lib/shimmer/utils/remote_navigation.rb +7 -3
- data/lib/shimmer/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef9968ad0ba48627fb9adb95ae2702575de2f9fa1b1e56ba3f30c9872d9cde38
|
4
|
+
data.tar.gz: c8bef4d12c776820c96e810a1e3ae1cb7c6717f029d5ac532b7fc05e595005d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c2dfb753bd6ac9afc4a4ba726c99a53a1dce6e1843c6b5bcdc320671ffcb2da0a8575ff357fd1294b3c25beed7a2026e144dffc0873a1a6ded6b78318ac737a
|
7
|
+
data.tar.gz: 9c00815fe851db16bd4ebf925d2ba2beb8b84c729351982f430721d6c7a395d21fd162add118a82a80df13ed8b97c67f76ac8177dadac29573c9e9604d8f9687
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shimmer
|
4
|
+
module MetaHelper
|
5
|
+
def meta
|
6
|
+
@meta ||= Meta.new.tap do |meta|
|
7
|
+
meta.canonical = url_for(only_path: false)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def title(value)
|
12
|
+
meta.title = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def description(value)
|
16
|
+
meta.description = value
|
17
|
+
end
|
18
|
+
|
19
|
+
def image(value)
|
20
|
+
meta.image = image_file_url(value, width: 1200)
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_meta
|
24
|
+
tags = meta.tags.map do |tag|
|
25
|
+
type = tag.delete(:type) || "meta"
|
26
|
+
value = tag.delete(:value)
|
27
|
+
content_tag(type, value, tag)
|
28
|
+
end
|
29
|
+
safe_join tags, "\n"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/shimmer/railtie.rb
CHANGED
@@ -8,3 +8,11 @@ module Shimmer
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
ActiveSupport.on_load(:action_view) do
|
13
|
+
Dir.glob("#{File.expand_path(__dir__)}/helpers/**/*.rb").each do |file|
|
14
|
+
load file
|
15
|
+
name = file.split("/").last.delete_suffix(".rb").classify
|
16
|
+
include "Shimmer::#{name}".constantize
|
17
|
+
end
|
18
|
+
end
|
data/lib/shimmer/tasks/db.rake
CHANGED
@@ -43,4 +43,13 @@ namespace :db do
|
|
43
43
|
|
44
44
|
desc "Download all app data, including assets"
|
45
45
|
task pull: [:pull_data, :pull_assets]
|
46
|
+
|
47
|
+
desc "Migrates if the database has any tables."
|
48
|
+
task migrate_if_tables: :environment do
|
49
|
+
if ActiveRecord::Base.connection.tables.any?
|
50
|
+
Rake::Task["db:migrate"].invoke
|
51
|
+
else
|
52
|
+
puts "No tables in database yet, skipping migration"
|
53
|
+
end
|
54
|
+
end
|
46
55
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :s3 do
|
4
|
+
desc "Creates a new S3 bucket and outputs or uploads the credentials."
|
5
|
+
task :create_bucket do
|
6
|
+
puts "Please enter the name for your new bucket"
|
7
|
+
name = $stdin.gets.strip
|
8
|
+
region = "eu-central-1"
|
9
|
+
sh "aws s3 mb s3://#{name} --region #{region}"
|
10
|
+
sh "aws iam create-user --user-name #{name}"
|
11
|
+
policy = <<~JSON
|
12
|
+
{
|
13
|
+
"Version": "2012-10-17",
|
14
|
+
"Statement": [
|
15
|
+
{
|
16
|
+
"Effect": "Allow",
|
17
|
+
"Action": [
|
18
|
+
"s3:CreateBucket",
|
19
|
+
"s3:DeleteObject",
|
20
|
+
"s3:Put*",
|
21
|
+
"s3:Get*",
|
22
|
+
"s3:List*"
|
23
|
+
],
|
24
|
+
"Resource": [
|
25
|
+
"arn:aws:s3:::#{name}",
|
26
|
+
"arn:aws:s3:::#{name}/*"
|
27
|
+
]
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
31
|
+
JSON
|
32
|
+
File.write("policy.json", policy)
|
33
|
+
sh "aws iam put-user-policy --user-name #{name} --policy-name #{name} --policy-document file://policy.json"
|
34
|
+
File.delete("policy.json")
|
35
|
+
content = JSON.parse `aws iam create-access-key --user-name #{name}`
|
36
|
+
id = content.dig("AccessKey", "AccessKeyId")
|
37
|
+
secret = content.dig("AccessKey", "SecretAccessKey")
|
38
|
+
puts "Credentials and bucket were generated. Automatically assign them to the associated Heroku project? This will override and delete all current keys on Heroku. (y/n)"
|
39
|
+
vars = {AWS_REGION: region, AWS_BUCKET: name, AWS_ACCESS_KEY_ID: id, AWS_SECRET_ACCESS_KEY: secret}
|
40
|
+
if $stdin.gets.strip == "y"
|
41
|
+
sh "heroku config:set #{vars.map { |k, v| "#{k}=#{v}" }.join(" ")}"
|
42
|
+
else
|
43
|
+
vars.each { |k, v| puts "#{k}=#{v}" }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Shimmer
|
4
4
|
module FileHelper
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
ActiveSupport.on_load(:action_view) do
|
9
|
+
include Shimmer::FileAdditions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module FileAdditions
|
5
15
|
def image_tag(source, **options)
|
6
16
|
return nil if source.blank?
|
7
17
|
|
@@ -9,19 +19,27 @@ module Shimmer
|
|
9
19
|
attachment = source
|
10
20
|
width = options[:width]
|
11
21
|
height = options[:height]
|
12
|
-
source =
|
22
|
+
source = image_file_path(source, width: width, height: height)
|
13
23
|
options[:loading] = :lazy
|
14
|
-
options[:srcset] = "#{source} 1x, #{
|
24
|
+
options[:srcset] = "#{source} 1x, #{image_file_path(attachment, width: width.to_i * 2, height: height ? height.to_i * 2 : nil)} 2x" if options[:width].present?
|
15
25
|
end
|
16
26
|
super source, options
|
17
27
|
end
|
18
28
|
|
29
|
+
def image_file_path(source, width: nil, height: nil)
|
30
|
+
image_file_proxy(source, width: width, height: height).path
|
31
|
+
end
|
32
|
+
|
19
33
|
def image_file_url(source, width: nil, height: nil)
|
34
|
+
image_file_proxy(source, width: width, height: height).url
|
35
|
+
end
|
36
|
+
|
37
|
+
def image_file_proxy(source, width: nil, height: nil)
|
20
38
|
return if source.blank?
|
21
39
|
return source if source.is_a?(String)
|
22
40
|
|
23
41
|
blob = source.try(:blob) || source
|
24
|
-
Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height)
|
42
|
+
Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height)
|
25
43
|
end
|
26
44
|
end
|
27
45
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shimmer
|
4
|
+
class Meta
|
5
|
+
class_attribute :app_name
|
6
|
+
attr_accessor :title, :description, :image, :canonical
|
7
|
+
|
8
|
+
def tags
|
9
|
+
tags = []
|
10
|
+
title = self.title.present? ? "#{self.title} | #{app_name}" : app_name
|
11
|
+
tags.push(type: :title, value: title)
|
12
|
+
tags.push(property: "og:title", content: title)
|
13
|
+
if description.present?
|
14
|
+
tags.push(name: :description, content: description)
|
15
|
+
tags.push(property: "og:description", content: description)
|
16
|
+
end
|
17
|
+
if image.present?
|
18
|
+
tags.push(property: "og:image", content: image)
|
19
|
+
end
|
20
|
+
if canonical.present?
|
21
|
+
tags.push(type: :link, rel: :canonical, href: canonical)
|
22
|
+
tags.push(property: "og:url", content: canonical)
|
23
|
+
end
|
24
|
+
tags.push(property: "og:type", content: :website)
|
25
|
+
tags.push(property: "og:locale", content: I18n.locale)
|
26
|
+
tags.push(name: "twitter:card", content: :summary_large_image)
|
27
|
+
tags
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -22,8 +22,12 @@ module Shimmer
|
|
22
22
|
end
|
23
23
|
|
24
24
|
helper_method :close_modal_path
|
25
|
-
def close_modal_path(id
|
26
|
-
|
25
|
+
def close_modal_path(id = nil)
|
26
|
+
if id.present?
|
27
|
+
"javascript:ui.modal.close(#{{id: id}.to_json})"
|
28
|
+
else
|
29
|
+
"javascript:ui.modal.close()"
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
helper_method :popover_path
|
@@ -87,7 +91,7 @@ module Shimmer
|
|
87
91
|
|
88
92
|
def close_modal(id = nil)
|
89
93
|
if id.present?
|
90
|
-
run_javascript "ui.modal.close(
|
94
|
+
run_javascript "ui.modal.close(#{{id: id}.to_json})"
|
91
95
|
else
|
92
96
|
run_javascript "ui.modal.close()"
|
93
97
|
end
|
data/lib/shimmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Ravens
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -145,16 +145,19 @@ files:
|
|
145
145
|
- lib/shimmer/auth/user.rb
|
146
146
|
- lib/shimmer/controllers/files_controller.rb
|
147
147
|
- lib/shimmer/controllers/sitemaps_controller.rb
|
148
|
+
- lib/shimmer/helpers/meta_helper.rb
|
148
149
|
- lib/shimmer/jobs/sitemap_job.rb
|
149
150
|
- lib/shimmer/middlewares/cloudflare.rb
|
150
151
|
- lib/shimmer/railtie.rb
|
151
152
|
- lib/shimmer/tasks/auth.rake
|
152
153
|
- lib/shimmer/tasks/db.rake
|
153
154
|
- lib/shimmer/tasks/lint.rake
|
155
|
+
- lib/shimmer/tasks/s3.rake
|
154
156
|
- lib/shimmer/utils/config.rb
|
155
157
|
- lib/shimmer/utils/file_helper.rb
|
156
158
|
- lib/shimmer/utils/file_proxy.rb
|
157
159
|
- lib/shimmer/utils/localizable.rb
|
160
|
+
- lib/shimmer/utils/meta.rb
|
158
161
|
- lib/shimmer/utils/remote_navigation.rb
|
159
162
|
- lib/shimmer/utils/sitemap_adapter.rb
|
160
163
|
- lib/shimmer/version.rb
|