tml-rails 5.2.10 → 5.4.1

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
  SHA1:
3
- metadata.gz: 10e00976717eba544565f915477a05253594f482
4
- data.tar.gz: 998dc4e52809973ddfbc7e7966dcb5e5030cd4e7
3
+ metadata.gz: 11f869577b8a514101af7c5508ac7a501627e63d
4
+ data.tar.gz: 7cbf82fccb422d33f184652c165070684e01b5a8
5
5
  SHA512:
6
- metadata.gz: 029012c3c9ae7e18d7643f37016bae17a3459840c1959475f27de0db5fc34a35e1c298729ed248f9146ab22e293cc1b942ce90d33838ba8d5f22623ad7043630
7
- data.tar.gz: 3f94fffb02897b5065d6b9abdd1b176e0bc03a0fea4af75fcce68521bdf27d6b046a8cde5435c5e6e48b99d615dd0fcf678c94249fef603d2cb0395e1578a743
6
+ metadata.gz: b5623ad4b1e9a763482221d0c60756984945bb354f24df59933fe1b4bec5c336b1bec8db6c16a45b7e2b1906e633605a9271dd21900190a137a4383bfa2f5fd8
7
+ data.tar.gz: 6816ea3ceca5214eba8d5f22f79ded24c6d519c7361445ff9387e748bdeb02a3e83b24e1817030c96a38d104be757d3142a20309e02be9b0c9e3609977ff004e
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc.
2
+ # Copyright (c) 2016 Translation Exchange Inc.
3
3
  #
4
4
  # http://translationexchange.com
5
5
  #
@@ -35,15 +35,14 @@ I18n.backend = I18n::Backend::Tml.new
35
35
 
36
36
  Tml.configure do |config|
37
37
  config.application = {
38
- token: 'YOUR TOKEN'
38
+ key: 'YOUR KEY'
39
39
  }
40
40
 
41
41
  # If you are using Rails.cache, use the following settings:
42
42
 
43
43
  config.cache = {
44
44
  :enabled => true,
45
- :adapter => :rails,
46
- :version => 1
45
+ :adapter => :rails
47
46
  }
48
47
 
49
48
  # If you are using File based pre-generated cache, use the following settings:
data/lib/tasks/tml.rake CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -46,24 +46,43 @@ namespace :tml do
46
46
 
47
47
  namespace :cache do
48
48
 
49
- desc 'upgrades shared translation cache'
50
- task :upgrade => :environment do
51
- Tml.cache.upgrade_version
52
- end
49
+ namespace :shared do
50
+ ##########################################
51
+ ## Shared Cache Management
52
+ ##########################################
53
53
 
54
- desc 'generates local file cache'
55
- task :generate => :environment do
56
- Tml::Generators::File.new.run
57
- end
54
+ desc 'upgrades shared translation cache'
55
+ task :upgrade => :environment do
56
+ Tml.cache.upgrade_version
57
+ end
58
58
 
59
- desc 'rolls back to the previous version'
60
- task :rollback => :environment do
61
- Tml::Generators::File.new.rollback
59
+ desc 'warms up dynamic cache'
60
+ task :warmup => :environment do
61
+ Tml.cache.warmup
62
+ end
62
63
  end
63
64
 
64
- desc 'rolls up to the next version'
65
- task :rollup => :environment do
66
- Tml::Generators::File.new.rollup
65
+ namespace :local do
66
+ ##########################################
67
+ ## Local Cache Management
68
+ ##########################################
69
+
70
+ desc 'downloads local file cache'
71
+ task :download => :environment do
72
+ Tml.cache.download
73
+ end
74
+
75
+ desc 'rolls back to the previous version'
76
+ task :rollback => :environment do
77
+ raise "Not yet supported"
78
+ # Tml.cache.rollback
79
+ end
80
+
81
+ desc 'rolls up to the next version'
82
+ task :rollup => :environment do
83
+ raise "Not yet supported"
84
+ # Tml.cache.rollup
85
+ end
67
86
  end
68
87
 
69
88
  end
data/lib/tml-rails.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  #--
3
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
3
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
4
4
  #
5
5
  # _______ _ _ _ ______ _
6
6
  # |__ __| | | | | (_) | ____| | |
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -32,6 +32,7 @@
32
32
  module TmlRails
33
33
  module ActionControllerExtension
34
34
 
35
+ # add functionality upon inclusion
35
36
  def self.included(base)
36
37
  base.send(:include, TmlRails::ActionCommonMethods)
37
38
  base.send(:include, InstanceMethods)
@@ -134,6 +135,10 @@ module TmlRails
134
135
  end
135
136
  end
136
137
 
138
+ def tml_access_token
139
+ tml_cookie[:oauth] ? tml_cookie[:oauth][:token] : nil
140
+ end
141
+
137
142
  def tml_init
138
143
  return if Tml.config.disabled?
139
144
 
@@ -145,7 +150,8 @@ module TmlRails
145
150
  :source => tml_source,
146
151
  :locale => tml_locale,
147
152
  :user => tml_viewing_user,
148
- :translator => tml_translator
153
+ :translator => tml_translator,
154
+ :access_token => tml_access_token
149
155
  )
150
156
 
151
157
  if I18n.backend.class.name == 'I18n::Backend::Tml'
@@ -167,6 +173,7 @@ module TmlRails
167
173
  Tml.session.reset
168
174
  Tml.cache.reset_version
169
175
  Tml.logger.info("Request took #{@tml_finished_at - @tml_started_at} mls") if @tml_started_at
176
+ Tml.logger.info('-----------------------------------------------------------')
170
177
  end
171
178
 
172
179
  def tml_filter_reset
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -98,8 +98,29 @@ module TmlRails
98
98
  end
99
99
 
100
100
  def tml_scripts_tag(opts = {})
101
- agent_config = Tml.config.respond_to?(:agent) ? Tml.config.agent : {}
101
+ return '' unless Tml.config.enabled?
102
+
103
+ if opts[:js]
104
+ js_opts = opts[:js].is_a?(Hash) ? opts[:js] : {}
105
+ js_host = js_opts[:host] || 'https://tools.translationexchange.com/tml/stable/tml.min.js'
106
+ html = []
107
+ html << "<script src='#{js_host}'></script>"
108
+ html << '<script>'
109
+ html << 'tml.init({'
110
+ html << " key: '#{tml_application.key}', "
111
+ html << " token: '#{tml_application.token}', "
112
+ html << " debug: #{js_opts[:debug] || false},"
113
+ if js_opts[:onload]
114
+ html << ' onLoad: function() {'
115
+ html << " #{js_opts[:onload]}"
116
+ html << ' }'
117
+ end
118
+ html << '});'
119
+ html << '</script>'
120
+ return html.join.html_safe
121
+ end
102
122
 
123
+ agent_config = Tml.config.respond_to?(:agent) ? Tml.config.agent : {}
103
124
  agent_host = agent_config[:host] || 'https://tools.translationexchange.com/agent/stable/agent.min.js'
104
125
  if agent_config[:cache]
105
126
  t = Time.now
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
2
+ # Copyright (c) 2016 Translation Exchange Inc. http://translationexchange.com
3
3
  #
4
4
  # _______ _ _ _ ______ _
5
5
  # |__ __| | | | | (_) | ____| | |
@@ -30,5 +30,5 @@
30
30
  #++
31
31
 
32
32
  module TmlRails
33
- VERSION = '5.2.10'
33
+ VERSION = '5.4.1'
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tml-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.10
4
+ version: 5.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.2'
33
+ version: 5.4.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.2'
40
+ version: 5.4.5
41
41
  description: Translation Markup Language from Translation Exchange.
42
42
  email:
43
43
  - support@translationexchange.com
@@ -48,8 +48,6 @@ files:
48
48
  - LICENSE
49
49
  - README.md
50
50
  - Rakefile
51
- - app/controllers/tml_rails/tools_controller.rb
52
- - config/routes.rb
53
51
  - lib/i18n/backend/tml.rb
54
52
  - lib/tasks/templates/tml.rb
55
53
  - lib/tasks/tml.rake
@@ -1,55 +0,0 @@
1
- #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
3
- #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
- # Permission is hereby granted, free of charge, to any person obtaining
13
- # a copy of this software and associated documentation files (the
14
- # "Software"), to deal in the Software without restriction, including
15
- # without limitation the rights to use, copy, modify, merge, publish,
16
- # distribute, sublicense, and/or sell copies of the Software, and to
17
- # permit persons to whom the Software is furnished to do so, subject to
18
- # the following conditions:
19
- #
20
- # The above copyright notice and this permission notice shall be
21
- # included in all copies or substantial portions of the Software.
22
- #
23
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- #++
31
-
32
- module TmlRails
33
- class ToolsController < ApplicationController
34
-
35
- def upgrade
36
- if Tml.config.invalidator[:auth].is_a?(Proc)
37
- authorized = Tml.config.invalidator[:auth].call(request)
38
- else
39
- authorized = params[:access_token] == Tml.config.access_token
40
- end
41
-
42
- if authorized
43
- Tml.cache.upgrade_version
44
- end
45
-
46
- redirect_back
47
- end
48
-
49
- private
50
-
51
- def redirect_back
52
- redirect_to(request.env['HTTP_REFERER'] || '/')
53
- end
54
- end
55
- end
data/config/routes.rb DELETED
@@ -1,38 +0,0 @@
1
- #--
2
- # Copyright (c) 2015 Translation Exchange Inc. http://translationexchange.com
3
- #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
- # Permission is hereby granted, free of charge, to any person obtaining
13
- # a copy of this software and associated documentation files (the
14
- # "Software"), to deal in the Software without restriction, including
15
- # without limitation the rights to use, copy, modify, merge, publish,
16
- # distribute, sublicense, and/or sell copies of the Software, and to
17
- # permit persons to whom the Software is furnished to do so, subject to
18
- # the following conditions:
19
- #
20
- # The above copyright notice and this permission notice shall be
21
- # included in all copies or substantial portions of the Software.
22
- #
23
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- #++
31
-
32
- Rails.application.routes.draw do
33
-
34
- if Tml.config.invalidator and Tml.config.invalidator[:enabled]
35
- get Tml.config.invalidator[:path] => 'tml_rails/tools#upgrade'
36
- end
37
-
38
- end