mobile_workflow 0.6.28 → 0.7.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 -0
- data/app/controllers/concerns/mobile_workflow/s3_storable.rb +1 -1
- data/app/controllers/mobile_workflow/sns_notifications_controller.rb +2 -9
- data/app/models/concerns/mobile_workflow/displayable.rb +10 -10
- data/lib/generators/mobile_workflow/install/install_generator.rb +1 -5
- data/lib/generators/mobile_workflow/install/templates/Gemfile.erb +3 -3
- data/lib/generators/mobile_workflow/install/templates/Procfile.dev +1 -1
- data/lib/generators/mobile_workflow/install/templates/seeds.rb.erb +2 -1
- data/lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb +1 -6
- data/lib/mobile_workflow/tasks/s3.rake +12 -0
- data/lib/mobile_workflow/tasks/{env_set.rake → set_env.rake} +13 -10
- data/lib/mobile_workflow/version.rb +2 -2
- metadata +6 -7
- data/lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_doorkeeper.rake +0 -5
- data/lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_s3.rake +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d460ed2222706c5a2084f87c0d0543e37ed05fdd77857e7e3e0d6929c93e4a5
|
4
|
+
data.tar.gz: 7d67f9e17223c4f72f3c0fb3386001ce5d22a4df631f2767eaa594ecd3827867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5108cd81390d9a8663a00c1656ee3de241aa72978168c9142adf2777459251f97c9e9896585c8cfed3eb4bbea356ea1520e2fa5c3fc2f0f6872be1607df4725f
|
7
|
+
data.tar.gz: c3d124f07540ca2ee3945b86cdb08a461d79d1b80d697ae669c1c724a5bcddcd68cd6600f1834c9646a4609829807e7d2320cf142ddfdfd7383d5c215bbef6ee
|
data/README.md
CHANGED
@@ -4,6 +4,11 @@ Short description and motivation.
|
|
4
4
|
## Usage
|
5
5
|
How to use my plugin.
|
6
6
|
|
7
|
+
## Uploads Design
|
8
|
+
This gem includes an engine to add and process S3 attachments. The design is as follows:
|
9
|
+
|
10
|
+
![Uploads Design](https://github.com/FutureWorkshops/mobile_workflow/blob/master/uploads_design.png?raw=true)
|
11
|
+
|
7
12
|
## Installation
|
8
13
|
Add this line to your application's Gemfile:
|
9
14
|
|
@@ -12,7 +12,7 @@ module MobileWorkflow
|
|
12
12
|
|
13
13
|
{
|
14
14
|
"identifier" => binary["identifier"],
|
15
|
-
"url" => presigned_url("#{object.class.name.underscore}/#{object.id}/#{object_attribute}.#{extension}"),
|
15
|
+
"url" => presigned_url("#{object.class.name.underscore}/#{object.id}/#{object_attribute}/#{SecureRandom.uuid}.#{extension}"),
|
16
16
|
"method" => "PUT"
|
17
17
|
}
|
18
18
|
end
|
@@ -56,10 +56,6 @@ module MobileWorkflow
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def attribute_name
|
59
|
-
file_name.split(".")[0] # remove the extension
|
60
|
-
end
|
61
|
-
|
62
|
-
def file_name
|
63
59
|
key_identifiers[2]
|
64
60
|
end
|
65
61
|
|
@@ -67,13 +63,10 @@ module MobileWorkflow
|
|
67
63
|
object_class_name, object_id, attribute_name = object_key.split("/")
|
68
64
|
return object_class_name, object_id, attribute_name
|
69
65
|
end
|
70
|
-
|
66
|
+
|
71
67
|
def object_key
|
72
|
-
@object_key ||= message['Records'][0]['s3']['object']['key']
|
73
|
-
end
|
74
|
-
|
75
|
-
def message
|
76
68
|
message = JSON.parse(message_body['Message'])
|
69
|
+
message['Records'][0]['s3']['object']['key']
|
77
70
|
end
|
78
71
|
|
79
72
|
def message_body
|
@@ -8,14 +8,14 @@ module MobileWorkflow
|
|
8
8
|
CONTENT_MODE_OPTIONS = [:scale_aspect_fill, :scale_aspect_fit]
|
9
9
|
QUESTION_STYLES = [:single_choice, :multiple_choice]
|
10
10
|
|
11
|
-
def mw_list_item(id: self.id, text:, detail_text: nil, sf_symbol_name: nil, image_attachment: nil)
|
12
|
-
mw_list_item = {id: id, text: text, detailText: detail_text, sfSymbolName: sf_symbol_name}
|
13
|
-
mw_list_item[:imageURL] = preview_url(image_attachment, options: { resize_to_fill: [
|
11
|
+
def mw_list_item(id: self.id, text:, detail_text: nil, sf_symbol_name: nil, material_icon_name: nil, image_attachment: nil)
|
12
|
+
mw_list_item = {id: id, text: text, detailText: detail_text, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}
|
13
|
+
mw_list_item[:imageURL] = preview_url(image_attachment, options: { resize_to_fill: [200, 200] }) if image_attachment
|
14
14
|
mw_list_item.compact
|
15
15
|
end
|
16
16
|
|
17
|
-
def mw_list_search_suggestion(id
|
18
|
-
{id: id, text: text, sectionName: section_name, sfSymbolName: sf_symbol_name}.compact
|
17
|
+
def mw_list_search_suggestion(id: self.id, text:, section_name:, sf_symbol_name: nil)
|
18
|
+
{id: id.to_s, text: text, sectionName: section_name, sfSymbolName: sf_symbol_name}.compact
|
19
19
|
end
|
20
20
|
|
21
21
|
def mw_map_item(id: self.id, text:, detail_text: nil, latitude:, longitude:)
|
@@ -30,7 +30,7 @@ module MobileWorkflow
|
|
30
30
|
{type: :text, label: label, text: text.to_s}.compact
|
31
31
|
end
|
32
32
|
|
33
|
-
def mw_display_image(attachment, content_mode: :scale_aspect_fill, options: { resize_to_fill: [
|
33
|
+
def mw_display_image(attachment, content_mode: :scale_aspect_fill, options: { resize_to_fill: [1200, 600] })
|
34
34
|
validate_content_mode!(content_mode)
|
35
35
|
|
36
36
|
{type: :image, contentMode: content_mode.to_s.camelize(:lower), previewURL: preview_url(attachment, options: options), url: attachment_url(attachment)}
|
@@ -73,7 +73,7 @@ module MobileWorkflow
|
|
73
73
|
|
74
74
|
def mw_display_system_url_button(label:, apple_system_url: nil, android_deep_link: nil, style: :primary, sf_symbol_name: nil, material_icon_name: nil)
|
75
75
|
validate_button_style!(style)
|
76
|
-
raise 'Invalid android_deep_link'
|
76
|
+
raise 'Invalid android_deep_link' if android_deep_link && !android_deep_link.start_with?('http')
|
77
77
|
|
78
78
|
{type: :button, label: label, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, style: style, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
|
79
79
|
end
|
@@ -110,12 +110,12 @@ module MobileWorkflow
|
|
110
110
|
{ id: id, text: text, type: :smallSection }
|
111
111
|
end
|
112
112
|
|
113
|
-
def mw_grid_item(id: self.id, text:, image_attachment: nil)
|
113
|
+
def mw_grid_item(id: self.id, text:, image_attachment: nil, options: { resize_to_fill: [1560, 877.5] })
|
114
114
|
raise 'Missing id' if id.nil?
|
115
115
|
raise 'Missing text' if text.nil?
|
116
116
|
|
117
117
|
item = { id: id, text: text, type: :item }
|
118
|
-
item[:imageURL] = preview_url(image_attachment, options:
|
118
|
+
item[:imageURL] = preview_url(image_attachment, options: options) if image_attachment
|
119
119
|
item
|
120
120
|
end
|
121
121
|
|
@@ -155,7 +155,7 @@ module MobileWorkflow
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def attachment_host
|
158
|
-
"https://#{ENV
|
158
|
+
"https://#{ENV.fetch('HEROKU_APP_NAME')}.herokuapp.com"
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -24,10 +24,6 @@ module MobileWorkflow
|
|
24
24
|
route "mount MobileWorkflow::Engine => '/'"
|
25
25
|
end
|
26
26
|
|
27
|
-
def copy_rake_tasks
|
28
|
-
copy_file("lib/tasks/mobile_workflow_doorkeeper.rake") if options[:doorkeeper_oauth]
|
29
|
-
end
|
30
|
-
|
31
27
|
def generate_doorkeeper
|
32
28
|
return unless options[:doorkeeper_oauth]
|
33
29
|
say "Generating Doorkeeper OAuth"
|
@@ -35,7 +31,7 @@ module MobileWorkflow
|
|
35
31
|
migration_template "create_users.rb", "db/migrate/create_users.rb"
|
36
32
|
|
37
33
|
generate 'doorkeeper:install'
|
38
|
-
gsub_file 'config/initializers/doorkeeper.rb', 'raise "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"', 'User.find_by_id(session
|
34
|
+
gsub_file 'config/initializers/doorkeeper.rb', 'raise "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"', 'User.find_by_id(session.delete(:user_id)) || redirect_to(new_session_url(return_to: request.fullpath))'
|
39
35
|
generate 'doorkeeper:migration'
|
40
36
|
generate 'doorkeeper:pkce'
|
41
37
|
template("user.rb.erb", "app/models/user.rb")
|
@@ -4,13 +4,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
4
4
|
ruby '<%= MobileWorkflow::RUBY_VERSION %>'
|
5
5
|
|
6
6
|
# Core Gems
|
7
|
-
gem 'rails', '
|
7
|
+
gem 'rails', '<%= MobileWorkflow::RAILS_VERSION %>'
|
8
8
|
gem 'puma', '~> 5.0'
|
9
9
|
gem 'sass-rails', '>= 6'
|
10
10
|
gem 'turbolinks', '~> 5'
|
11
11
|
|
12
12
|
# Mobile Workflow
|
13
|
-
gem 'mobile_workflow', '
|
13
|
+
gem 'mobile_workflow', '<%= MobileWorkflow::VERSION %>'
|
14
14
|
|
15
15
|
# Authorisation / Authentication
|
16
16
|
<%- if options[:doorkeeper_oauth] %>
|
@@ -32,7 +32,7 @@ gem 'aws-sdk-sns', '~> 1.23'
|
|
32
32
|
<%- end %>
|
33
33
|
|
34
34
|
# FFI for Mac M1
|
35
|
-
gem 'ffi',
|
35
|
+
gem 'ffi', '~> 1.15.1'
|
36
36
|
|
37
37
|
group :development do
|
38
38
|
gem 'web-console', '>= 3.3.0'
|
@@ -1 +1 @@
|
|
1
|
-
web:
|
1
|
+
web: bin/rails s -p $PORT
|
@@ -1,3 +1,4 @@
|
|
1
1
|
<%- if options[:doorkeeper_oauth] %>
|
2
|
-
|
2
|
+
# You can set the OAuth client ID and client secret in your ENV in order to avoid them being reset each time you reset the database.
|
3
|
+
Doorkeeper::Application.create! name: 'Main App', redirect_uri: 'mww://callback', scopes: 'public', uid: ENV['OAUTH_CLIENT_ID'], secret: ENV['OAUTH_CLIENT_SECRET']
|
3
4
|
<%- end %>
|
@@ -6,15 +6,10 @@ class SessionsController < ApplicationController
|
|
6
6
|
@user = User.find_by("LOWER(email)= ?", params[:email].downcase)
|
7
7
|
if @user && @user.authenticate(params[:password])
|
8
8
|
session[:user_id] = @user.id
|
9
|
-
redirect_to params[:return_to] || root_url
|
9
|
+
redirect_to params[:return_to] || root_url
|
10
10
|
else
|
11
11
|
flash[:warning] = "You have entered incorrect email and/or password."
|
12
12
|
render :new
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
|
-
def destroy
|
17
|
-
session.delete(:user_id)
|
18
|
-
redirect_to root_path
|
19
|
-
end
|
20
15
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
desc "Add S3 storage to a Heroku app"
|
2
|
+
namespace :mw do
|
3
|
+
task add_heroku_s3_storage: :environment do
|
4
|
+
require 'mobile_workflow/cli'
|
5
|
+
app_name = ENV['APP_NAME']
|
6
|
+
aws_region = ENV['AWS_REGION'] || 'us-east-1'
|
7
|
+
aws = MobileWorkflow::Cli::AwsBackend.new(app_name: app_name, region: aws_region)
|
8
|
+
heroku = MobileWorkflow::Cli::HerokuBackend.new(app_name: app_name)
|
9
|
+
aws.create
|
10
|
+
aws.create_topic_subscription(heroku.notifications_endpoint)
|
11
|
+
end
|
12
|
+
end
|
@@ -44,15 +44,18 @@ def env_set(path)
|
|
44
44
|
File.write(app_json_path, app_json.to_json)
|
45
45
|
end
|
46
46
|
|
47
|
-
namespace :
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
namespace :mw do
|
48
|
+
namespace :set_env do
|
49
|
+
desc 'Update Android app.json to use new env'
|
50
|
+
task :android do
|
51
|
+
env_set(File.join('app', 'src', 'main', 'res', 'raw', 'app.json'))
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
desc 'Update iOS app.json to use new env'
|
55
|
+
task :ios do
|
56
|
+
project_name = ENV["PROJECT_NAME"]
|
57
|
+
env_set(File.join(project_name, project_name, "Resources", "app.json"))
|
58
|
+
end
|
59
|
+
end
|
58
60
|
end
|
61
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobile_workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brooke-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.1.
|
19
|
+
version: 6.1.3.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.1.
|
26
|
+
version: 6.1.3.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,8 +116,6 @@ files:
|
|
116
116
|
- lib/generators/mobile_workflow/install/templates/app/views/layouts/application.html.erb
|
117
117
|
- lib/generators/mobile_workflow/install/templates/app/views/sessions/new.html.erb
|
118
118
|
- lib/generators/mobile_workflow/install/templates/create_users.rb
|
119
|
-
- lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_doorkeeper.rake
|
120
|
-
- lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_s3.rake
|
121
119
|
- lib/generators/mobile_workflow/install/templates/seeds.rb.erb
|
122
120
|
- lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
|
123
121
|
- lib/generators/mobile_workflow/install/templates/spec/factories/users.rb
|
@@ -138,7 +136,8 @@ files:
|
|
138
136
|
- lib/mobile_workflow/engine.rb
|
139
137
|
- lib/mobile_workflow/open_api_spec/parser.rb
|
140
138
|
- lib/mobile_workflow/railtie.rb
|
141
|
-
- lib/mobile_workflow/tasks/
|
139
|
+
- lib/mobile_workflow/tasks/s3.rake
|
140
|
+
- lib/mobile_workflow/tasks/set_env.rake
|
142
141
|
- lib/mobile_workflow/version.rb
|
143
142
|
homepage: https://github.com/futureworkshops/mobile_workflow
|
144
143
|
licenses:
|
@@ -1,9 +0,0 @@
|
|
1
|
-
desc "Add S3 storage to your environment"
|
2
|
-
task add_heroku_s3_storage: :environment do
|
3
|
-
require 'mobile_workflow/cli'
|
4
|
-
app_name = ENV['APP_NAME']
|
5
|
-
aws = MobileWorkflow::Cli::AwsBackend.new(app_name: app_name)
|
6
|
-
heroku = MobileWorkflow::Cli::HerokuBackend(app_name: app_name)
|
7
|
-
aws.create
|
8
|
-
aws.create_topic_subscription(heroku.notifications_endpoint)
|
9
|
-
end
|