phraseapp-in-context-editor-ruby 1.4.0 → 2.0.0
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/.github/workflows/test.yml +7 -11
- data/.gitignore +0 -1
- data/.tool-versions +1 -1
- data/CODEOWNERS +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +241 -0
- data/Guardfile +13 -13
- data/README.md +81 -51
- data/RELEASING.md +10 -0
- data/lib/generators/phraseapp_in_context_editor/install_generator.rb +3 -9
- data/lib/generators/phraseapp_in_context_editor/templates/phraseapp_in_context_editor.rb +9 -17
- data/lib/phraseapp-in-context-editor-ruby/adapters/fast_gettext.rb +20 -20
- data/lib/phraseapp-in-context-editor-ruby/adapters/i18n.rb +10 -10
- data/lib/phraseapp-in-context-editor-ruby/backend_service.rb +12 -99
- data/lib/phraseapp-in-context-editor-ruby/config.rb +13 -50
- data/lib/phraseapp-in-context-editor-ruby/delegate/fast_gettext.rb +13 -15
- data/lib/phraseapp-in-context-editor-ruby/delegate/i18n_delegate.rb +4 -50
- data/lib/phraseapp-in-context-editor-ruby/delegate.rb +13 -14
- data/lib/phraseapp-in-context-editor-ruby/engine.rb +5 -6
- data/lib/phraseapp-in-context-editor-ruby/view_helpers.rb +25 -19
- data/lib/phraseapp-in-context-editor-ruby.rb +15 -54
- data/phraseapp-in-context-editor-ruby.gemspec +18 -33
- metadata +27 -101
- data/lib/generators/phraseapp_in_context_editor/templates/README +0 -10
- data/lib/phraseapp-in-context-editor-ruby/api_collection.rb +0 -41
- data/lib/phraseapp-in-context-editor-ruby/api_wrapper.rb +0 -59
- data/lib/phraseapp-in-context-editor-ruby/cache.rb +0 -37
- data/lib/phraseapp-in-context-editor-ruby/displayable_key_identifier.rb +0 -46
- data/lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb +0 -44
- data/lib/phraseapp-in-context-editor-ruby/hash_flattener.rb +0 -53
- data/lib/phraseapp-in-context-editor-ruby/key_names_cache.rb +0 -53
- data/lib/phraseapp-in-context-editor-ruby/version.rb +0 -5
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'phraseapp-in-context-editor-ruby/api_collection'
|
3
|
-
require 'phraseapp-in-context-editor-ruby/delegate/i18n_delegate'
|
1
|
+
require_relative "delegate/i18n_delegate"
|
4
2
|
|
5
3
|
module PhraseApp
|
6
4
|
module InContextEditor
|
7
5
|
class BackendService
|
8
|
-
|
9
6
|
attr_accessor :blacklisted_keys
|
10
7
|
|
11
8
|
def initialize(args = {})
|
@@ -40,47 +37,20 @@ module PhraseApp
|
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
43
|
-
|
44
|
-
def to_be_translated_without_phraseapp?(args)
|
45
|
-
PhraseApp::InContextEditor.disabled? or has_been_given_blacklisted_key?(args) or has_been_given_ignored_key?(args) or has_been_forced_to_resolve_with_phraseapp?(args)
|
46
|
-
end
|
47
|
-
|
48
|
-
def has_been_given_blacklisted_key?(args)
|
49
|
-
key = given_key_from_args(args)
|
50
|
-
has_blacklist_entry_for_key?(key)
|
51
|
-
end
|
40
|
+
protected
|
52
41
|
|
53
|
-
def
|
54
|
-
|
55
|
-
key_is_ignored?(key)
|
42
|
+
def to_be_translated_without_phraseapp?(args)
|
43
|
+
PhraseApp::InContextEditor.disabled? || has_been_forced_to_resolve_with_phraseapp?(args)
|
56
44
|
end
|
57
45
|
|
58
46
|
def has_been_forced_to_resolve_with_phraseapp?(args)
|
59
|
-
(args.last.is_a?(Hash)
|
47
|
+
(args.last.is_a?(Hash) && args.last[:resolve] == false)
|
60
48
|
end
|
61
49
|
|
62
50
|
def given_key_from_args(args)
|
63
51
|
extract_normalized_key_from_args(args)
|
64
52
|
end
|
65
53
|
|
66
|
-
def has_blacklist_entry_for_key?(key)
|
67
|
-
blacklisted_keys.each do |blacklisted_key|
|
68
|
-
return true if present?(key.to_s[/\A#{blacklisted_key.gsub("*", ".*")}\Z/])
|
69
|
-
end
|
70
|
-
false
|
71
|
-
end
|
72
|
-
|
73
|
-
def key_is_ignored?(key)
|
74
|
-
PhraseApp::InContextEditor.ignored_keys.each do |ignored_key|
|
75
|
-
return true if present?(key.to_s[/\A#{ignored_key.gsub("*", ".*")}\Z/])
|
76
|
-
end
|
77
|
-
false
|
78
|
-
end
|
79
|
-
|
80
|
-
def blacklisted_keys
|
81
|
-
@blacklisted_keys ||= api_wrapper.blacklisted_keys
|
82
|
-
end
|
83
|
-
|
84
54
|
def phraseapp_delegate_for(args)
|
85
55
|
key = given_key_from_args(args)
|
86
56
|
return nil unless present?(key)
|
@@ -95,15 +65,14 @@ module PhraseApp
|
|
95
65
|
end
|
96
66
|
|
97
67
|
def transform_args(args)
|
98
|
-
duped_args = args.map { |item| (item.is_a?(Symbol)
|
99
|
-
transform_args_based_on_caller(duped_args)
|
68
|
+
duped_args = args.map { |item| (item.is_a?(Symbol) || item.nil?) ? item : item.dup }
|
100
69
|
end
|
101
70
|
|
102
71
|
def normalized_key(duped_args)
|
103
72
|
splitted_args = split_args(duped_args)
|
104
73
|
key = I18n::Backend::Flatten.normalize_flat_keys(*splitted_args)
|
105
74
|
key.gsub!("..", ".")
|
106
|
-
key.gsub!(/^\./,
|
75
|
+
key.gsub!(/^\./, "")
|
107
76
|
key
|
108
77
|
end
|
109
78
|
|
@@ -111,77 +80,21 @@ module PhraseApp
|
|
111
80
|
options = options_from_args(args)
|
112
81
|
key ||= args.shift
|
113
82
|
locale = options.delete(:locale) || I18n.locale
|
114
|
-
|
83
|
+
[locale, key, options[:scope], nil]
|
115
84
|
end
|
116
85
|
|
117
86
|
def options_from_args(args)
|
118
87
|
args.last.is_a?(Hash) ? args.pop : {}
|
119
88
|
end
|
120
89
|
|
121
|
-
def transform_args_based_on_caller(args)
|
122
|
-
translation_caller = identify_caller
|
123
|
-
|
124
|
-
if translation_caller and args.first =~ /^\./
|
125
|
-
options = options_from_args(args)
|
126
|
-
|
127
|
-
if not present?(options[:scope]) and present?(translation_caller)
|
128
|
-
options[:scope] = translation_caller
|
129
|
-
end
|
130
|
-
|
131
|
-
args.push(options)
|
132
|
-
parts = args.first.to_s.split(".").select { |e| not blank?(e) }
|
133
|
-
args[0] = parts[0] if parts.size == 1
|
134
|
-
end
|
135
|
-
|
136
|
-
args
|
137
|
-
end
|
138
|
-
|
139
|
-
def identify_caller
|
140
|
-
translation_caller = nil
|
141
|
-
send(:caller)[0..6].each do |intermediate_caller|
|
142
|
-
translation_caller = calling_template(intermediate_caller) unless translation_caller
|
143
|
-
end
|
144
|
-
|
145
|
-
if present?(translation_caller)
|
146
|
-
find_lookup_scope(translation_caller)
|
147
|
-
else
|
148
|
-
nil
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def calling_template(string)
|
153
|
-
string.match(/(views)(\/.+)(?>:[0-9]+:in)/)
|
154
|
-
end
|
155
|
-
|
156
90
|
def blank?(str)
|
157
|
-
raise "blank?(str) can only be given a String or nil" unless str.is_a?(String)
|
158
|
-
str.nil?
|
91
|
+
raise "blank?(str) can only be given a String or nil" unless str.is_a?(String) || str.nil?
|
92
|
+
str.nil? || str == ""
|
159
93
|
end
|
160
94
|
|
161
95
|
def present?(str)
|
162
|
-
raise "present?(str) can only be given a String or nil" unless str.is_a?(String)
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
def find_lookup_scope(caller)
|
167
|
-
split_path = caller[2][1..-1].split(".")[0].split("/")
|
168
|
-
|
169
|
-
template_or_partial = remove_underscore_form_partial(split_path[-1])
|
170
|
-
split_path[-1] = template_or_partial
|
171
|
-
|
172
|
-
split_path.map!(&:to_sym)
|
173
|
-
end
|
174
|
-
|
175
|
-
def remove_underscore_form_partial(template_or_partial)
|
176
|
-
if template_or_partial.to_s[0,1] == "_"
|
177
|
-
template_or_partial.to_s[1..-1]
|
178
|
-
else
|
179
|
-
template_or_partial.to_s
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def api_wrapper
|
184
|
-
@api_wrapper ||= PhraseApp::InContextEditor::ApiWrapper.new
|
96
|
+
raise "present?(str) can only be given a String or nil" unless str.is_a?(String) || str.nil?
|
97
|
+
!blank?(str)
|
185
98
|
end
|
186
99
|
end
|
187
100
|
end
|
@@ -1,62 +1,39 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module PhraseApp
|
3
2
|
module InContextEditor
|
4
3
|
class Config
|
5
4
|
CONFIG_OPTIONS = {
|
5
|
+
account_id: nil,
|
6
6
|
project_id: nil,
|
7
|
-
|
7
|
+
datacenter: "eu",
|
8
8
|
enabled: false,
|
9
|
-
skip_ssl_verification: false,
|
10
9
|
backend: PhraseApp::InContextEditor::BackendService.new,
|
11
10
|
prefix: "{{__",
|
12
|
-
suffix: "__}}"
|
13
|
-
api_host: "https://api.phrase.com",
|
14
|
-
js_host: "phraseapp.com",
|
15
|
-
js_use_ssl: true,
|
16
|
-
js_path: "/assets/in-context-editor/2.0/app.js",
|
17
|
-
js_options: {},
|
18
|
-
cache_key_segments_initial: ["simple_form"],
|
19
|
-
cache_lifetime: 300,
|
20
|
-
ignored_keys: [],
|
11
|
+
suffix: "__}}"
|
21
12
|
}.freeze
|
22
13
|
|
23
|
-
CONFIG_OPTIONS_GLOBAL_ONLY = [
|
24
|
-
:access_token,
|
25
|
-
:skip_ssl_verification,
|
26
|
-
:api_host
|
27
|
-
].freeze
|
28
|
-
|
29
14
|
CONFIG_OPTIONS.each do |option, default_value|
|
30
|
-
class_eval "@@#{option} = CONFIG_OPTIONS[:#{option}]"
|
15
|
+
class_eval "@@#{option} = CONFIG_OPTIONS[:#{option}]", __FILE__, __LINE__
|
31
16
|
|
32
17
|
define_method("#{option}=") do |value|
|
33
|
-
instance_eval "@#{option} = value
|
34
|
-
end
|
18
|
+
instance_eval "@#{option} = value", __FILE__, __LINE__
|
19
|
+
end
|
35
20
|
|
36
|
-
define_method(
|
37
|
-
instance_eval "defined?(@#{option}) ? @#{option} : self.class.#{option}"
|
21
|
+
define_method(option.to_s) do
|
22
|
+
instance_eval "defined?(@#{option}) ? @#{option} : self.class.#{option}", __FILE__, __LINE__
|
38
23
|
end
|
39
24
|
|
40
25
|
define_singleton_method("#{option}=") do |value|
|
41
|
-
instance_eval "@@#{option} = value
|
26
|
+
instance_eval "@@#{option} = value", __FILE__, __LINE__
|
42
27
|
end
|
43
28
|
|
44
|
-
define_singleton_method(
|
45
|
-
instance_eval "@@#{option}"
|
29
|
+
define_singleton_method(option.to_s) do
|
30
|
+
instance_eval "@@#{option}", __FILE__, __LINE__
|
46
31
|
end
|
47
32
|
end
|
48
33
|
|
49
|
-
def
|
50
|
-
@@api_client ||= build_api_client
|
51
|
-
end
|
52
|
-
|
53
|
-
def api_client
|
54
|
-
self.class.api_client
|
55
|
-
end
|
56
|
-
|
57
|
-
def assign_values(config_options={})
|
34
|
+
def assign_values(config_options = {})
|
58
35
|
config_options.each do |config_option, value|
|
59
|
-
|
36
|
+
send("#{config_option}=", value)
|
60
37
|
end
|
61
38
|
end
|
62
39
|
|
@@ -65,20 +42,6 @@ module PhraseApp
|
|
65
42
|
send("#{option}=", default_value)
|
66
43
|
end
|
67
44
|
end
|
68
|
-
|
69
|
-
protected
|
70
|
-
def self.invalidate_api_client
|
71
|
-
@@api_client = nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.build_api_client
|
75
|
-
credentials = PhraseApp::Auth::Credentials.new(
|
76
|
-
token: @@access_token,
|
77
|
-
host: @@api_host,
|
78
|
-
skip_ssl_verification: @@skip_ssl_verification
|
79
|
-
)
|
80
|
-
PhraseApp::Client.new(credentials)
|
81
|
-
end
|
82
45
|
end
|
83
46
|
end
|
84
47
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'phraseapp-in-context-editor-ruby/delegate'
|
1
|
+
require_relative "../delegate"
|
4
2
|
|
5
3
|
module PhraseApp
|
6
4
|
module InContextEditor
|
@@ -12,20 +10,20 @@ module PhraseApp
|
|
12
10
|
@display_key = params[:msgid]
|
13
11
|
end
|
14
12
|
|
15
|
-
|
13
|
+
private
|
14
|
+
|
16
15
|
def params_from_args(args)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
case @method
|
17
|
+
when :_
|
18
|
+
{msgid: args.first}
|
19
|
+
when :n_
|
20
|
+
{msgid: args.first, msgid_plural: args[1], count: args.last}
|
21
|
+
when :s_
|
22
|
+
{msgid: args.first}
|
23
|
+
else
|
24
|
+
self.class.log("Unsupported FastGettext method #{@method}")
|
25
|
+
{}
|
27
26
|
end
|
28
|
-
params
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
@@ -1,12 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'phraseapp-in-context-editor-ruby/cache'
|
4
|
-
require 'phraseapp-in-context-editor-ruby/hash_flattener'
|
5
|
-
require 'phraseapp-in-context-editor-ruby/delegate'
|
6
|
-
require 'phraseapp-in-context-editor-ruby/api_wrapper'
|
7
|
-
require 'phraseapp-in-context-editor-ruby/displayable_key_identifier'
|
8
|
-
|
9
|
-
require 'set'
|
1
|
+
require_relative "../delegate"
|
10
2
|
|
11
3
|
module PhraseApp
|
12
4
|
module InContextEditor
|
@@ -14,11 +6,11 @@ module PhraseApp
|
|
14
6
|
class I18nDelegate < Base
|
15
7
|
attr_accessor :key, :display_key, :options, :api_client, :fallback_keys, :original_args
|
16
8
|
|
17
|
-
def initialize(key, options={}, original_args=nil)
|
9
|
+
def initialize(key, options = {}, original_args = nil)
|
18
10
|
@key = key
|
19
11
|
@options = options
|
20
12
|
@original_args = original_args
|
21
|
-
@display_key =
|
13
|
+
@display_key = @key
|
22
14
|
super(decorated_key_name)
|
23
15
|
end
|
24
16
|
|
@@ -27,7 +19,7 @@ module PhraseApp
|
|
27
19
|
if @key.respond_to?(args.first)
|
28
20
|
to_s.send(*args)
|
29
21
|
else
|
30
|
-
data =
|
22
|
+
data = [@key]
|
31
23
|
if data.respond_to?(args.first)
|
32
24
|
data.send(*args, &block)
|
33
25
|
else
|
@@ -37,44 +29,6 @@ module PhraseApp
|
|
37
29
|
end
|
38
30
|
end
|
39
31
|
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def translation_or_subkeys
|
44
|
-
return nil if @key.nil? || @key.to_s == ""
|
45
|
-
|
46
|
-
keys = api_wrapper.keys_with_prefix(@key)
|
47
|
-
return nil unless keys.present?
|
48
|
-
|
49
|
-
if keys.size == 1
|
50
|
-
translation_content_for_key(keys.first)
|
51
|
-
else
|
52
|
-
translation_hash = keys.inject({}) do |hash, key|
|
53
|
-
hash[key.name] = translation_content_for_key(key)
|
54
|
-
hash
|
55
|
-
end
|
56
|
-
|
57
|
-
PhraseApp::InContextEditor::HashFlattener.expand_flat_hash(translation_hash, @key)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def translation_content_for_key(key)
|
62
|
-
default_translations = api_wrapper.default_translation(key)
|
63
|
-
return unless default_translations.present?
|
64
|
-
|
65
|
-
if key.plural
|
66
|
-
default_translations.inject({}) do |hash, translation|
|
67
|
-
hash[translation.plural_suffix.to_sym] = translation.content
|
68
|
-
hash
|
69
|
-
end
|
70
|
-
else
|
71
|
-
default_translations.first.content
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def api_wrapper
|
76
|
-
@api_wrapper ||= InContextEditor::ApiWrapper.new
|
77
|
-
end
|
78
32
|
end
|
79
33
|
end
|
80
34
|
end
|
@@ -1,17 +1,15 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
1
|
module PhraseApp
|
4
2
|
module InContextEditor
|
5
3
|
module Delegate
|
6
4
|
class Base < String
|
7
5
|
def to_s
|
8
|
-
|
6
|
+
decorated_key_name.to_s
|
9
7
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
alias_method :camelize, :to_s
|
9
|
+
alias_method :underscore, :to_s
|
10
|
+
alias_method :classify, :to_s
|
11
|
+
alias_method :dasherize, :to_s
|
12
|
+
alias_method :tableize, :to_s
|
15
13
|
|
16
14
|
# Delegate .html_safe from accessing Delegate object as if it was a hash,
|
17
15
|
# but instead perform it on the resulting string
|
@@ -19,23 +17,24 @@ module PhraseApp
|
|
19
17
|
|
20
18
|
def self.log(message)
|
21
19
|
message = "phrase: #{message}"
|
22
|
-
if defined?(Rails)
|
20
|
+
if defined?(Rails) && Rails.respond_to?(:logger)
|
23
21
|
Rails.logger.warn(message)
|
24
22
|
else
|
25
|
-
|
23
|
+
warn message
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
|
27
|
+
protected
|
28
|
+
|
30
29
|
def decorated_key_name
|
31
30
|
"#{PhraseApp::InContextEditor.prefix}phrase_#{normalized_display_key}#{PhraseApp::InContextEditor.suffix}"
|
32
31
|
end
|
33
32
|
|
34
33
|
def normalized_display_key
|
35
|
-
|
36
|
-
@display_key.gsub("<", "[[[[[[html_open]]]]]]").gsub(">", "[[[[[[html_close]]]]]]")
|
37
|
-
else
|
34
|
+
if @display_key.nil?
|
38
35
|
@display_key
|
36
|
+
else
|
37
|
+
@display_key.gsub("<", "[[[[[[html_open]]]]]]").gsub(">", "[[[[[[html_close]]]]]]")
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
@@ -1,14 +1,13 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require 'i18n'
|
1
|
+
require "phraseapp-in-context-editor-ruby"
|
2
|
+
require "i18n"
|
4
3
|
|
5
4
|
if defined? Rails
|
6
5
|
module PhraseApp
|
7
6
|
module InContextEditor
|
8
7
|
class Engine < Rails::Engine
|
9
|
-
initializer
|
10
|
-
require
|
11
|
-
require
|
8
|
+
initializer "phraseapp-in-context-editor-ruby", before: :disable_dependency_loading do |app|
|
9
|
+
require "phraseapp-in-context-editor-ruby/adapters/i18n"
|
10
|
+
require "phraseapp-in-context-editor-ruby/adapters/fast_gettext"
|
12
11
|
|
13
12
|
ActionView::Base.send :include, PhraseApp::InContextEditor::ViewHelpers
|
14
13
|
end
|
@@ -1,35 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require "json"
|
2
2
|
|
3
3
|
module PhraseApp
|
4
4
|
module InContextEditor
|
5
5
|
module ViewHelpers
|
6
|
-
def
|
6
|
+
def load_in_context_editor(opts = {})
|
7
7
|
return "" unless PhraseApp::InContextEditor.enabled?
|
8
8
|
|
9
9
|
# stringify to reduce possible errors when passing symbols
|
10
|
-
|
11
|
-
|
10
|
+
opts = opts.nil? ? {} : opts.each_with_object({}) { |(k, v), conf|
|
11
|
+
conf[k.to_s] = v
|
12
|
+
}
|
12
13
|
|
13
14
|
# js options
|
14
15
|
configuration = {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
"projectId" => PhraseApp::InContextEditor.project_id,
|
17
|
+
"accountId" => PhraseApp::InContextEditor.account_id,
|
18
|
+
"datacenter" => PhraseApp::InContextEditor.datacenter,
|
19
|
+
"prefix" => PhraseApp::InContextEditor.prefix,
|
20
|
+
"suffix" => PhraseApp::InContextEditor.suffix
|
21
|
+
}.merge(opts)
|
20
22
|
|
21
|
-
snippet = <<-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
snippet = <<-EOS
|
24
|
+
<script>
|
25
|
+
window.PHRASEAPP_CONFIG = #{configuration.to_json};
|
26
|
+
(function() {
|
27
|
+
let phraseapp = document.createElement('script');
|
28
|
+
phraseapp.type = 'module';
|
29
|
+
phraseapp.async = true;
|
30
|
+
phraseapp.src = "https://d2bgdldl6xit7z.cloudfront.net/latest/ice/index.js";
|
31
|
+
let script = document.getElementsByTagName('script')[0];
|
32
|
+
script.parentNode.insertBefore(phraseapp, script);
|
33
|
+
})();
|
34
|
+
</script>
|
35
|
+
EOS
|
31
36
|
snippet.respond_to?(:html_safe) ? snippet.html_safe : snippet
|
32
37
|
end
|
38
|
+
alias_method :phraseapp_in_context_editor_js, :load_in_context_editor
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'phraseapp-ruby'
|
3
|
-
require 'request_store'
|
1
|
+
require "request_store"
|
4
2
|
|
5
3
|
module PhraseApp
|
6
4
|
module InContextEditor
|
7
|
-
autoload :Config,
|
5
|
+
autoload :Config, "phraseapp-in-context-editor-ruby/config"
|
8
6
|
|
9
7
|
class << self
|
10
8
|
def config
|
@@ -31,24 +29,12 @@ module PhraseApp
|
|
31
29
|
config.project_id
|
32
30
|
end
|
33
31
|
|
34
|
-
def
|
35
|
-
config.
|
32
|
+
def account_id
|
33
|
+
config.account_id
|
36
34
|
end
|
37
35
|
|
38
|
-
def
|
39
|
-
config.
|
40
|
-
end
|
41
|
-
|
42
|
-
def cache_key_segments_initial
|
43
|
-
config.cache_key_segments_initial
|
44
|
-
end
|
45
|
-
|
46
|
-
def cache_lifetime
|
47
|
-
config.cache_lifetime
|
48
|
-
end
|
49
|
-
|
50
|
-
def ignored_keys
|
51
|
-
config.ignored_keys
|
36
|
+
def datacenter
|
37
|
+
config.datacenter
|
52
38
|
end
|
53
39
|
|
54
40
|
def enabled=(value)
|
@@ -62,38 +48,14 @@ module PhraseApp
|
|
62
48
|
def disabled?
|
63
49
|
!config.enabled
|
64
50
|
end
|
65
|
-
|
66
|
-
def js_use_ssl
|
67
|
-
config.js_use_ssl
|
68
|
-
end
|
69
|
-
|
70
|
-
def js_host
|
71
|
-
config.js_host
|
72
|
-
end
|
73
|
-
|
74
|
-
def js_path
|
75
|
-
config.js_path
|
76
|
-
end
|
77
|
-
|
78
|
-
def js_options
|
79
|
-
config.js_options
|
80
|
-
end
|
81
|
-
|
82
|
-
def api_host
|
83
|
-
config.api_host
|
84
|
-
end
|
85
|
-
|
86
|
-
def api_client
|
87
|
-
config.api_client
|
88
|
-
end
|
89
51
|
end
|
90
52
|
|
91
53
|
def self.configure
|
92
54
|
yield(PhraseApp::InContextEditor::Config)
|
93
55
|
end
|
94
56
|
|
95
|
-
def self.with_config(config_options={}, &block)
|
96
|
-
original_config =
|
57
|
+
def self.with_config(config_options = {}, &block)
|
58
|
+
original_config = config.dup
|
97
59
|
config.assign_values(config_options)
|
98
60
|
yield
|
99
61
|
ensure
|
@@ -101,17 +63,16 @@ module PhraseApp
|
|
101
63
|
end
|
102
64
|
end
|
103
65
|
|
104
|
-
autoload :ViewHelpers,
|
66
|
+
autoload :ViewHelpers, "phraseapp-in-context-editor-ruby/view_helpers"
|
105
67
|
|
106
|
-
require
|
107
|
-
require
|
108
|
-
require
|
109
|
-
require
|
110
|
-
require 'phraseapp-in-context-editor-ruby/view_helpers'
|
68
|
+
require "phraseapp-in-context-editor-ruby/engine"
|
69
|
+
require "phraseapp-in-context-editor-ruby/delegate"
|
70
|
+
require "phraseapp-in-context-editor-ruby/backend_service"
|
71
|
+
require "phraseapp-in-context-editor-ruby/view_helpers"
|
111
72
|
end
|
112
73
|
|
113
74
|
# Only load adapters directly if non-rails app, otherwise use engine
|
114
75
|
unless defined? Rails
|
115
|
-
require
|
116
|
-
require
|
76
|
+
require "phraseapp-in-context-editor-ruby/adapters/i18n"
|
77
|
+
require "phraseapp-in-context-editor-ruby/adapters/fast_gettext"
|
117
78
|
end
|