shimmer 0.0.13 → 0.0.16
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 +4 -4
- data/lib/shimmer/auth/apple_provider.rb +2 -2
- data/lib/shimmer/auth/google_provider.rb +1 -1
- 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/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: d82a8e015623e83b0381e182752ede22419e26c40b9a730536f6020793818b75
|
4
|
+
data.tar.gz: 00766a05189358517092bcbc6ef958d26acbfae14efb98b45f81c3b848cfaffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e72dcab3004ea3c720a1b7041ee0714e4beded68cfa8caa9f5a1213fbe3ece9cf82030437be32c1532c85c67e489b159fa39f13392664c9c5f3520f8ba67f6
|
7
|
+
data.tar.gz: e8e15ddcc1aedbad180f0b62dd11af6791d8ef35aa5139e7f0e7ffdead8551052f8ccbed36c143ae39868e44ca381ed27737e036d93dca8b9e5b8cffd125fae5
|
@@ -15,8 +15,8 @@ module Shimmer
|
|
15
15
|
form = {
|
16
16
|
grant_type: "authorization_code",
|
17
17
|
code: params[:code],
|
18
|
-
client_id:
|
19
|
-
client_secret:
|
18
|
+
client_id: Config.instance.apple_bundle_id!,
|
19
|
+
client_secret: Config.instance.apple_client_secret,
|
20
20
|
scope: "name email"
|
21
21
|
}
|
22
22
|
response = HTTParty.post("https://appleid.apple.com/auth/token", body: URI.encode_www_form(form), headers: headers)
|
@@ -8,7 +8,7 @@ module Shimmer
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def request_details(params)
|
11
|
-
payload = GoogleIDToken::Validator.new.check(params[:credential],
|
11
|
+
payload = GoogleIDToken::Validator.new.check(params[:credential], Config.instance.google_client_id!)
|
12
12
|
UserDetails.new token: payload["sub"], email: payload["email"], first_name: payload["given_name"].presence, last_name: payload["family_name"].presence
|
13
13
|
end
|
14
14
|
end
|
@@ -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
|
@@ -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.16
|
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
|