glib-web 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d9c8901bfee8243bbc64b4693fbd3f3d2395ce3dacfdf394456204ec5c995c9
4
- data.tar.gz: 3c1fbb85bd85b9b2c58eabb5824cac8dbd94a0b97b815e01b442142ebcff9e80
3
+ metadata.gz: 483dc48299df91d5551fd4ce401fa1dd654e41ef210b6a7d0e4b04ea5e9c48a4
4
+ data.tar.gz: 2d7c3e9b6a3242099c19e20b110926badee014a6865d1f082f9aadf6bea5f80f
5
5
  SHA512:
6
- metadata.gz: 8531f46175119fbc397cda8ee0a7e7c4ad4cecad00a6935973a0d1d25a17b34a8a62680f06e45a099dde054816d6e60c3ed24597b5c2213bb41c1e3658c2a589
7
- data.tar.gz: 2b78a224ac48364902f42fbc24f6fcce9478e49665f86137aae30167a1d3892ccabab15ee40bfb3c129378956de037b55c20d8e5d9a2d26fc519fb84ad6a3290
6
+ metadata.gz: 540ee1e2e471fd0dfae4e5137a09088e668149cb71e03488c0e747b1ca998bab76b75e49703c12d8506cff4149b44f75197a2dd99eaba66d195a967508a982e4
7
+ data.tar.gz: f641a8945036d40bd336a89b70d41a69a8d26433dda816335c8e1c1f4c2578f3157b2315a63d6d3e021202f1e0bb8d2c86dab76781ee641e130f525488d965b3
@@ -1,4 +1,5 @@
1
- module Concerns::Application::Json::Libs
1
+ # TODO: Deprecate
2
+ module Application::Json::Libs
2
3
  extend ActiveSupport::Concern
3
4
 
4
5
  included do
@@ -27,7 +28,7 @@ module Concerns::Application::Json::Libs
27
28
  def json_ui_app_is_android?
28
29
  json_ui_app_device_os == 'android'
29
30
  end
30
-
31
+
31
32
  def json_ui_app_is_ios?
32
33
  json_ui_app_device_os == 'ios'
33
34
  end
@@ -41,9 +42,9 @@ module Concerns::Application::Json::Libs
41
42
  module ClassMethods
42
43
 
43
44
  def json_libs_init(options)
44
- include Concerns::Application::Json::Transformation
45
- include Concerns::Application::Json::Validation
46
- include Concerns::Application::Json::Ui
45
+ include Application::Json::Transformation
46
+ include Application::Json::Validation
47
+ include Application::Json::Ui
47
48
 
48
49
  before_action :__json_ui_start
49
50
 
@@ -54,7 +55,7 @@ module Concerns::Application::Json::Libs
54
55
  after_action :__json_transformation_commit
55
56
  after_action :__json_validate_perform
56
57
  end
57
-
58
+
58
59
  def json_libs_set_locale
59
60
  before_action do
60
61
  # Need to explicitly fallback to EN
@@ -63,7 +64,7 @@ module Concerns::Application::Json::Libs
63
64
  I18n.locale = :en
64
65
  end
65
66
  end
66
-
67
+
67
68
  def json_libs_force_json_ui
68
69
  before_action do
69
70
  if params[:_render] != 'v1'
@@ -72,17 +73,17 @@ module Concerns::Application::Json::Libs
72
73
  end
73
74
  end
74
75
 
75
- def json_libs_rescue_csrf
76
+ def json_libs_rescue_csrf
76
77
  rescue_from ActionController::InvalidAuthenticityToken do |exception|
77
78
  sign_out(:user)
78
79
 
79
80
  respond_to do |format|
80
81
  format.json do
81
- render json: {
82
- onResponse: {
82
+ render json: {
83
+ onResponse: {
83
84
  action: 'windows/open-v1',
84
85
  url: root_url
85
- }
86
+ }
86
87
  }
87
88
  end
88
89
  end
@@ -1,4 +1,4 @@
1
- module Concerns::Application::Json::Transformation
1
+ module Application::Json::Transformation
2
2
  def json_transformation_start
3
3
  if request.format == 'json'
4
4
  @__transformed_json ||= JSON.parse(response.body) rescue nil
@@ -1,10 +1,10 @@
1
- module Concerns::Application::Json::Ui
1
+ module Application::Json::Ui
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
5
  rescue_from ActionController::UnknownFormat do |exception|
6
6
  if json_ui_activated?
7
- # Tell `__json_ui_start()` to avoid rendering this page while still retaining the `_render` param
7
+ # Tell `__json_ui_start()` to avoid rendering this page while still retaining the `_render` param
8
8
  # so that the page remains linking to other json_ui pages.
9
9
  redirect_to url_for(format: nil, _skip_render: true)
10
10
  else
@@ -61,6 +61,6 @@ module Concerns::Application::Json::Ui
61
61
  def __json_ui_vue(hash, options)
62
62
  renderer_path = options[:renderer_path]
63
63
  @__json_ui_orig_page = response.body
64
- response.body = render_to_string(file: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
64
+ response.body = render_to_string(template: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
65
65
  end
66
66
  end
@@ -1,4 +1,4 @@
1
- module Concerns::Application::Json::Validation
1
+ module Application::Json::Validation
2
2
  def __json_validate_perform
3
3
  if Rails.env.development? && params[:_validate] == 'true'
4
4
  if (hash = json_transformation_start).is_a?(Hash)
@@ -0,0 +1,93 @@
1
+ module Glib::Json::Libs
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ extend ClassMethods
6
+
7
+ helper_method :json_ui_app_bundle_id, :json_ui_app_build_version, :json_ui_app_device_os
8
+ helper_method :json_ui_app_is_android?, :json_ui_app_is_ios?, :json_ui_app_is_web?
9
+ end
10
+
11
+ def json_ui_app_bundle_id
12
+ @json_ui_app_bundle_id ||= request.headers['JsonUiApp-Bundle-Id']
13
+ end
14
+
15
+ def json_ui_app_build_version
16
+ @json_ui_app_build_version ||= request.headers['JsonUiApp-Build-Version']
17
+ @json_ui_app_build_version = params[:build_version] if @json_ui_app_build_version.nil? && Rails.env.development? # For easy testing
18
+ @json_ui_app_build_version
19
+ end
20
+
21
+ def json_ui_app_device_os
22
+ @json_ui_app_device_os ||= request.headers['JsonUiApp-Device-Os']
23
+ @json_ui_app_device_os = params[:device_os] if @json_ui_app_device_os.nil? && Rails.env.development? # For easy testing
24
+ @json_ui_app_device_os || 'web'
25
+ end
26
+
27
+ def json_ui_app_is_android?
28
+ json_ui_app_device_os == 'android'
29
+ end
30
+
31
+ def json_ui_app_is_ios?
32
+ json_ui_app_device_os == 'ios'
33
+ end
34
+
35
+ def json_ui_app_is_web?
36
+ json_ui_app_device_os == 'web'
37
+ end
38
+
39
+
40
+
41
+ module ClassMethods
42
+
43
+ def json_libs_init(options)
44
+ include Glib::Json::Transformation
45
+ include Glib::Json::Validation
46
+ include Glib::Json::Ui
47
+
48
+ before_action :__json_ui_start
49
+
50
+ # Note that after_action gets executed in reverse
51
+ after_action do
52
+ __json_ui_commit(options)
53
+ end
54
+ after_action :__json_transformation_commit
55
+ after_action :__json_validate_perform
56
+ end
57
+
58
+ def json_libs_set_locale
59
+ before_action do
60
+ # Need to explicitly fallback to EN
61
+ I18n.locale = params[:_locale] || :en
62
+ rescue
63
+ I18n.locale = :en
64
+ end
65
+ end
66
+
67
+ def json_libs_force_json_ui
68
+ before_action do
69
+ if params[:_render] != 'v1'
70
+ redirect_to url_for(params.to_unsafe_h.merge(_render: 'v1'))
71
+ end
72
+ end
73
+ end
74
+
75
+ def json_libs_rescue_csrf
76
+ rescue_from ActionController::InvalidAuthenticityToken do |exception|
77
+ sign_out(:user)
78
+
79
+ respond_to do |format|
80
+ format.json do
81
+ render json: {
82
+ onResponse: {
83
+ action: 'windows/open-v1',
84
+ url: root_url
85
+ }
86
+ }
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,11 @@
1
+ module Glib::Json::Transformation
2
+ def json_transformation_start
3
+ if request.format == 'json'
4
+ @__transformed_json ||= JSON.parse(response.body) rescue nil
5
+ end
6
+ end
7
+
8
+ def __json_transformation_commit
9
+ response.body = @__transformed_json.to_json if @__transformed_json
10
+ end
11
+ end
@@ -0,0 +1,66 @@
1
+ module Glib::Json::Ui
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ rescue_from ActionController::UnknownFormat do |exception|
6
+ if json_ui_activated?
7
+ # Tell `__json_ui_start()` to avoid rendering this page while still retaining the `_render` param
8
+ # so that the page remains linking to other json_ui pages.
9
+ redirect_to url_for(format: nil, _skip_render: true)
10
+ else
11
+ raise exception
12
+ end
13
+ end
14
+ end
15
+
16
+ # Override
17
+ def form_authenticity_token
18
+ Rails.env.test? ? 'test_token' : super
19
+ end
20
+
21
+ # NOTE: Override default_url_options and call this method
22
+ def json_ui_url_options
23
+ options = {}
24
+ options[:_render] = params[:_render]
25
+ options[:_locale] = params[:_locale]
26
+ options[:format] = :json if request.format == :json
27
+ options
28
+ end
29
+
30
+ def json_ui_activated?
31
+ @__json_ui_activated
32
+ end
33
+
34
+ def __json_ui_start
35
+ @__json_ui_activated = false
36
+ @__json_ui_rendering = false
37
+ if params[:_render].present?
38
+ @__json_ui_activated = true
39
+ request.variant = :ui
40
+
41
+ if request.format.html? && params[:_skip_render] != 'true'
42
+ @__json_ui_rendering = true
43
+ request.format = 'json'
44
+ end
45
+ end
46
+ end
47
+
48
+ def __json_ui_commit(options)
49
+ if @__json_ui_rendering
50
+ if (hash = json_transformation_start).is_a?(Hash)
51
+ case params[:_render]
52
+ when 'v1'
53
+ __json_ui_vue(hash, options)
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def __json_ui_vue(hash, options)
62
+ renderer_path = options[:renderer_path]
63
+ @__json_ui_orig_page = response.body
64
+ response.body = render_to_string(template: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
65
+ end
66
+ end
@@ -0,0 +1,13 @@
1
+ module Glib::Json::Validation
2
+ def __json_validate_perform
3
+ if Rails.env.development? && params[:_validate] == 'true'
4
+ if (hash = json_transformation_start).is_a?(Hash)
5
+ json_validate = JSONValidate.new(hash)
6
+ response_message = json_validate.valid?
7
+ hash[:_json] = {
8
+ validationErrors: response_message
9
+ }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ module Glib
2
+ module DynamicTextsHelper
3
+ def dt(key, default_value = '', **args)
4
+ new_key = key
5
+ options = {
6
+ scope: args.fetch(:scope, 'itinerarybuilder'),
7
+ lang: args.fetch(:lang, 'en')
8
+ }
9
+
10
+ if key.starts_with?('.')
11
+ new_key = "#{controller_name}.#{action_name}#{key}"
12
+ end
13
+
14
+ content = Glib::Text.get_content(new_key, default_value, options: options)
15
+ content.gsub(/\{\{(\w+)\}\}/) { args.fetch($1.to_sym, "{{#{$1}}}") }
16
+ end
17
+ end
18
+ end
@@ -4,7 +4,7 @@ module Glib
4
4
  def method_missing m, *args
5
5
  add_singleton_element_v1 'action', m, *args
6
6
  end
7
-
7
+
8
8
  class Action < JsonUiElement
9
9
  def analytics(value)
10
10
  if value.is_a?(String)
@@ -43,31 +43,31 @@ module Glib
43
43
  string :message
44
44
  action :onClose
45
45
  end
46
-
46
+
47
47
  # class Confirm < Action
48
48
  # string :message
49
49
  # action :onConfirm
50
50
  # action :onCancel
51
51
  # end
52
-
52
+
53
53
  class Options < Action
54
54
  string :message
55
-
55
+
56
56
  def buttons(block)
57
57
  json.buttons do
58
58
  block.call page.menu_builder
59
59
  end
60
60
  end
61
61
  end
62
-
62
+
63
63
  class Open < Action
64
64
  string :url, cache: true
65
65
  end
66
-
66
+
67
67
  class Close < Action
68
68
  action :onClose
69
69
  end
70
-
70
+
71
71
  # TODO: Deprecate
72
72
  # Consider renaming to ShowSnackbar
73
73
  class Snackbar < Action
@@ -76,9 +76,17 @@ module Glib
76
76
  string :horizontalPosition
77
77
  singleton_array :styleClass, :styleClasses
78
78
  end
79
-
79
+
80
+ class Notification < Action
81
+ string :title
82
+ string :body
83
+ string :tag
84
+ int :timeout
85
+ action :onClick
86
+ end
87
+
80
88
  end
81
-
89
+
82
90
  module Snackbars
83
91
  class Alert < Action
84
92
  string :message
@@ -88,20 +96,20 @@ module Glib
88
96
  string :horizontalPosition
89
97
  singleton_array :styleClass, :styleClasses
90
98
  end
91
-
99
+
92
100
  # class Confirm < Action
93
101
  # string :message
94
102
  # action :onConfirm
95
103
  # action :onCancel
96
-
104
+
97
105
  # string :verticalPosition
98
106
  # string :horizontalPosition
99
107
  # singleton_array :styleClass, :styleClasses
100
108
  # end
101
-
109
+
102
110
  class Options < Action
103
111
  string :message
104
-
112
+
105
113
  string :verticalPosition
106
114
  string :horizontalPosition
107
115
  singleton_array :styleClass, :styleClasses
@@ -111,15 +119,15 @@ module Glib
111
119
  block.call page.menu_builder
112
120
  end
113
121
  end
114
-
122
+
115
123
  end
116
-
124
+
117
125
  end
118
126
 
119
127
  module Forms
120
128
  class Submit < Action
121
129
  end
122
-
130
+
123
131
  end
124
132
 
125
133
  module Windows
@@ -130,16 +138,16 @@ module Glib
130
138
  class CloseAll < Action
131
139
  action :onClose
132
140
  end
133
-
141
+
134
142
  class Open < Action
135
143
  string :url, cache: true
136
144
  action :onOpen
137
145
  end
138
-
146
+
139
147
  class OpenWeb < Action
140
148
  string :url
141
149
  end
142
-
150
+
143
151
  class Reload < Action
144
152
  string :url, cache: true
145
153
  end
@@ -151,16 +159,16 @@ module Glib
151
159
  string :token
152
160
  action :onSave
153
161
  end
154
-
162
+
155
163
  end
156
-
164
+
157
165
  # FUTURE
158
166
  module Data
159
167
  class SaveCsrfToken < Action
160
168
  string :token
161
169
  action :onSave
162
170
  end
163
-
171
+
164
172
  class Clear < Action
165
173
  end
166
174
  end
@@ -170,17 +178,17 @@ module Glib
170
178
  string :url, cache: true
171
179
  hash :formData
172
180
  end
173
-
181
+
174
182
  class Patch < Action
175
183
  string :url, cache: true
176
184
  hash :formData
177
185
  end
178
-
186
+
179
187
  class Delete < Action
180
188
  string :url, cache: true
181
189
  hash :formData
182
190
  end
183
-
191
+
184
192
  end
185
193
 
186
194
  ###
@@ -71,8 +71,9 @@ module Glib
71
71
 
72
72
  class P < AbstractText
73
73
  end
74
-
74
+
75
75
  class Label < AbstractText
76
+ string :format
76
77
  action :onClick
77
78
  end
78
79
 
@@ -86,7 +87,7 @@ module Glib
86
87
  string :url
87
88
  action :onClick
88
89
  end
89
-
90
+
90
91
  class Icon < View
91
92
  string :name
92
93
  action :onClick
@@ -96,7 +97,7 @@ module Glib
96
97
  # icon :icon
97
98
  # string :text
98
99
  # end
99
-
100
+
100
101
  class Button < View
101
102
  icon :icon, cache: true
102
103
  string :text, cache: true
@@ -121,7 +122,7 @@ module Glib
121
122
  int :zoom
122
123
  string :dataUrl
123
124
  end
124
-
125
+
125
126
  class Chip < View
126
127
  string :text
127
128
  end
@@ -129,10 +130,10 @@ module Glib
129
130
  class Calendar < View
130
131
  string :dataUrl
131
132
  end
132
-
133
+
133
134
  class TabBar < View
134
135
  color :color
135
-
136
+
136
137
  def tabButtons(block)
137
138
  json.tabButtons do
138
139
  block.call page.menu_builder
@@ -150,7 +151,7 @@ module Glib
150
151
  # end
151
152
  # end
152
153
  # end
153
-
154
+
154
155
  end
155
156
 
156
157
  end
@@ -0,0 +1,6 @@
1
+ module Glib
2
+ class DynamicTextRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ connects_to database: { writing: :dynamic_text, reading: :dynamic_text }
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ module Glib
2
+ class Text < Glib::DynamicTextRecord
3
+ validates :scope, presence: true
4
+ validates :lang, presence: true
5
+ validates :key, presence: true, uniqueness: { scope: [:scope, :lang] }
6
+ validates :content, presence: true
7
+
8
+ after_save :update_to_redis
9
+
10
+ def self.get_content(key, default_value, options:)
11
+ scope_key = "#{options[:scope]}.#{options[:lang]}.#{key}"
12
+
13
+ unless content = $dt_redis.get(scope_key)
14
+ if text = find_by(scope: options[:scope], lang: options[:lang], key: key)
15
+ update_content(scope_key, text.content)
16
+ content = text.content
17
+ else
18
+ create(scope: options[:scope], lang: options[:lang], key: key, content: default_value)
19
+ update_content(scope_key, default_value)
20
+ content = default_value
21
+ end
22
+ end
23
+
24
+ content
25
+ end
26
+
27
+ private
28
+ def self.update_content(scope_key, content)
29
+ $dt_redis.set(scope_key, content)
30
+ end
31
+
32
+ def update_to_redis
33
+ Glib::Text.update_content("#{scope}.#{lang}.#{key}", content)
34
+ end
35
+ end
36
+ end
@@ -2,11 +2,13 @@ json.title 'Notifications'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
5
-
5
+
6
6
  page.list firstSection: ->(section) do
7
7
  section.rows builder: ->(template) do
8
8
  template.thumbnail title: 'Send Desktop Notification', onClick: ->(action) do
9
- # TODO: Send and display desktop notification
9
+ action.dialogs_notification title: 'Hello World', body: 'Body Message', onClick: ->(action) do
10
+ action.dialogs_alert message: 'TODO'
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -0,0 +1,19 @@
1
+ module Glib
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../../templates', __FILE__)
5
+
6
+ class_option :redis_env_key, type: :string, default: 'DT_REDIS_URL'
7
+ class_option :database_env_key, type: :string, default: 'DT_DATABASE_URL'
8
+ class_option :app_name, type: :string, default: Rails.application.class.parent_name
9
+
10
+ def copy_initializer
11
+ template '20191017062519_create_texts.rb', 'db/dynamic_text_migrate/20191017062519_create_texts.rb'
12
+ template '20191024063257_add_scope_to_texts.rb', 'db/dynamic_text_migrate/20191024063257_add_scope_to_texts.rb'
13
+ template '20191112095018_add_lang_to_texts.rb', 'db/dynamic_text_migrate/20191112095018_add_lang_to_texts.rb'
14
+ template 'dynamic_text.rb', 'config/initializers/dynamic_text.rb'
15
+ template 'database.yml', 'config/database.yml'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ class CreateTexts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :texts do |t|
4
+ t.string :key
5
+ t.text :content
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :texts, :key, unique: true
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class AddScopeToTexts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :texts, :scope, :string
4
+ remove_index :texts, :key
5
+ add_index :texts, [:scope, :key], unique: true
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class AddLangToTexts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :texts, :lang, :string
4
+ remove_index :texts, [:scope, :key]
5
+ add_index :texts, [:scope, :lang, :key], unique: true
6
+ end
7
+ end
@@ -0,0 +1,107 @@
1
+ # PostgreSQL. Versions 9.1 and up are supported.
2
+ #
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On OS X with Homebrew:
6
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
+ # On OS X with MacPorts:
8
+ # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9
+ # On Windows:
10
+ # gem install pg
11
+ # Choose the win32 build.
12
+ # Install PostgreSQL and put its /bin directory on your path.
13
+ #
14
+ # Configure Using Gemfile
15
+ # gem 'pg'
16
+ #
17
+ default: &default
18
+ adapter: postgresql
19
+ encoding: unicode
20
+ # For details on connection pooling, see Rails configuration guide
21
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
22
+ pool: <%= "\<\%\= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } \%\>" %>
23
+ host: <%= "\<\%\= ENV.fetch(\"DATABASE_HOST\") {} \%\>" %>
24
+ username: <%= "\<\%\= ENV.fetch(\"DATABASE_USER\") {} \%\>" %>
25
+ password: <%= "\<\%\= ENV.fetch(\"DATABASE_PASSWORD\") {} \%\>" %>
26
+
27
+ development:
28
+ primary:
29
+ <<: *default
30
+ database: <%= "\<\%\= ENV.fetch(\"DATABASE_NAME\") { \"#{options[:app_name]}\" } + \"_development\" \%\>" %>
31
+ dynamic_text:
32
+ <<: *default
33
+ migrations_paths: db/dynamic_text_migrate
34
+ database: <%= "\<\%\= ENV.fetch(\"DT_DATABASE_NAME\") { \"DynamicText\" } + \"_development\" \%\>" %>
35
+
36
+ # The specified database role being used to connect to postgres.
37
+ # To create additional roles in postgres see `$ createuser --help`.
38
+ # When left blank, postgres will use the default role. This is
39
+ # the same name as the operating system user that initialized the database.
40
+ #username: ItineraryBuilder
41
+
42
+ # The password associated with the postgres role (username).
43
+ #password:
44
+
45
+ # Connect on a TCP socket. Omitted by default since the client uses a
46
+ # domain socket that doesn't need configuration. Windows does not have
47
+ # domain sockets, so uncomment these lines.
48
+ #host: localhost
49
+
50
+ # The TCP port the server listens on. Defaults to 5432.
51
+ # If your server runs on a different port number, change accordingly.
52
+ #port: 5432
53
+
54
+ # Schema search path. The server defaults to $user,public
55
+ #schema_search_path: myapp,sharedapp,public
56
+
57
+ # Minimum log levels, in increasing order:
58
+ # debug5, debug4, debug3, debug2, debug1,
59
+ # log, notice, warning, error, fatal, and panic
60
+ # Defaults to warning.
61
+ #min_messages: notice
62
+
63
+ # Warning: The database defined as "test" will be erased and
64
+ # re-generated from your development database when you run "rake".
65
+ # Do not set this db to the same as development or production.
66
+ test:
67
+ primary:
68
+ <<: *default
69
+ database: <%= "\<\%\= ENV.fetch(\"DATABASE_NAME\") { \"#{options[:app_name]}\" } + \"_test\" \%\>" %>
70
+ dynamic_text:
71
+ <<: *default
72
+ migrations_paths: db/dynamic_text_migrate
73
+ database: <%= "\<\%\= ENV.fetch(\"DT_DATABASE_NAME\") { \"DynamicText\" } + \"_test\" \%\>" %>
74
+
75
+ # As with config/secrets.yml, you never want to store sensitive information,
76
+ # like your database password, in your source code. If your source code is
77
+ # ever seen by anyone, they now have access to your database.
78
+ #
79
+ # Instead, provide the password as a unix environment variable when you boot
80
+ # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
81
+ # for a full rundown on how to provide these environment variables in a
82
+ # production deployment.
83
+ #
84
+ # On Heroku and other platform providers, you may have a full connection URL
85
+ # available as an environment variable. For example:
86
+ #
87
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
88
+ #
89
+ # You can use this database configuration with:
90
+ #
91
+ # production:
92
+ # url: <%= "\<\%\= ENV[\'DATABASE_URL\'] \%\>" %>
93
+ #
94
+
95
+ production_default: &production_default
96
+ adapter: postgresql
97
+ encoding: unicode
98
+ pool: <%= "\<\%\= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } \%\>" %>
99
+
100
+ production:
101
+ primary:
102
+ <<: *production_default
103
+ url: <%= "\<\%\= ENV[\"DATABASE_URL\"] \%\>" %>
104
+ dynamic_text:
105
+ <<: *production_default
106
+ migrations_paths: db/dynamic_text_migrate
107
+ url: <%= "\<\%\= ENV[\"#{options[:database_env_key]}\"] \%\>" %>
@@ -0,0 +1,2 @@
1
+ dt_redis_url = ENV.fetch('<%= options[:redis_env_key] %>', 'redis://localhost:6379')
2
+ $dt_redis = Redis.new(url: dt_redis_url)
@@ -30,7 +30,7 @@ module Glib
30
30
  # # Allow repeating urls because excluding them makes the test results really hard to analyze.
31
31
  # # if history.include?(url)
32
32
 
33
- # if url.blank?
33
+ # if url.blank?
34
34
  # nil
35
35
  # else
36
36
  # @context.assert_match URI_REGEXP, url
@@ -52,7 +52,6 @@ module Glib
52
52
  # end
53
53
  # end
54
54
  # end
55
-
56
55
  end
57
56
 
58
57
  def post(url, controller, params)
@@ -104,14 +103,13 @@ module Glib
104
103
  else
105
104
  response_times << response.headers['X-Runtime'].to_f
106
105
  @context.assert_includes VALID_RESPONSE_CODES, code, "Expected a valid response but was [#{response.code}] #{Rack::Utils::HTTP_STATUS_CODES[response.code.to_i]}:\n#{url}"
107
- if response.content_type == 'application/json'
106
+ if response.media_type == 'application/json'
108
107
  JSON.parse(response.body)
109
108
  else
110
109
  nil
111
110
  end
112
111
  end
113
112
  end
114
-
115
113
  end
116
114
  end
117
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -14,16 +14,22 @@ dependencies:
14
14
  name: activestorage
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 5.2.3
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 6.1.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 5.2.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 6.1.0
27
33
  description:
28
34
  email: ''
29
35
  executables: []
@@ -34,7 +40,12 @@ files:
34
40
  - app/controllers/concerns/application/json/transformation.rb
35
41
  - app/controllers/concerns/application/json/ui.rb
36
42
  - app/controllers/concerns/application/json/validation.rb
43
+ - app/controllers/concerns/glib/json/libs.rb
44
+ - app/controllers/concerns/glib/json/transformation.rb
45
+ - app/controllers/concerns/glib/json/ui.rb
46
+ - app/controllers/concerns/glib/json/validation.rb
37
47
  - app/controllers/glib/home_controller.rb
48
+ - app/helpers/glib/dynamic_texts_helper.rb
38
49
  - app/helpers/glib/json_ui/abstract_builder.rb
39
50
  - app/helpers/glib/json_ui/action_builder.rb
40
51
  - app/helpers/glib/json_ui/list_builders.rb
@@ -49,6 +60,8 @@ files:
49
60
  - app/helpers/glib/json_ui/view_builder/charts.rb
50
61
  - app/helpers/glib/json_ui/view_builder/fields.rb
51
62
  - app/helpers/glib/json_ui/view_builder/panels.rb
63
+ - app/models/glib/dynamic_text_record.rb
64
+ - app/models/glib/text.rb
52
65
  - app/views/app/views/json_ui/vue/renderer.html.erb
53
66
  - app/views/json_ui/garage/_nav_menu.json.jbuilder
54
67
  - app/views/json_ui/garage/actions/index.json.jbuilder
@@ -113,6 +126,12 @@ files:
113
126
  - app/views/json_ui/garage/views/misc.json.jbuilder
114
127
  - app/views/json_ui/garage/views/texts.json.jbuilder
115
128
  - config/routes.rb
129
+ - lib/generators/glib/install_generator.rb
130
+ - lib/generators/templates/20191017062519_create_texts.rb
131
+ - lib/generators/templates/20191024063257_add_scope_to_texts.rb
132
+ - lib/generators/templates/20191112095018_add_lang_to_texts.rb
133
+ - lib/generators/templates/database.yml
134
+ - lib/generators/templates/dynamic_text.rb
116
135
  - lib/glib-web.rb
117
136
  - lib/glib/engine.rb
118
137
  - lib/glib/json_crawler.rb