station 0.0.97 → 0.0.104

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +6 -5
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +1 -1
  5. data/bin/nexmo-developer +1 -44
  6. data/docs/How-To-Use.md +1 -1
  7. data/lib/nexmo_developer/.ruby-version +1 -1
  8. data/lib/nexmo_developer/Dockerfile +1 -1
  9. data/lib/nexmo_developer/Gemfile +6 -6
  10. data/lib/nexmo_developer/Gemfile.lock +24 -22
  11. data/lib/nexmo_developer/app/controllers/dashboard_controller.rb +1 -1
  12. data/lib/nexmo_developer/app/presenters/sidenav_item.rb +2 -2
  13. data/lib/nexmo_developer/app/presenters/tutorial_list_item.rb +3 -3
  14. data/lib/nexmo_developer/app/services/translator/file_translator.rb +18 -12
  15. data/lib/nexmo_developer/app/services/translator/smartling/api/upload_file.rb +4 -2
  16. data/lib/nexmo_developer/app/services/translator/translation_request.rb +3 -2
  17. data/lib/nexmo_developer/app/services/translator/utils.rb +28 -1
  18. data/lib/nexmo_developer/app/views/contribute/guides/markdown-guide.md +70 -48
  19. data/lib/nexmo_developer/app/views/tutorial/list.html.erb +1 -1
  20. data/lib/nexmo_developer/app/views/use_case/_index.html.erb +1 -1
  21. data/lib/nexmo_developer/app/webpacker/javascript/volta/volta.js +108 -21
  22. data/lib/nexmo_developer/app/webpacker/stylesheets/application.scss +1 -1
  23. data/lib/nexmo_developer/app/webpacker/stylesheets/objects/_use_cases.scss +1 -1
  24. data/lib/nexmo_developer/lib/tasks/smartling.rake +1 -1
  25. data/lib/nexmo_developer/nexmo_developer.rb +44 -0
  26. data/lib/nexmo_developer/version.rb +1 -1
  27. data/package.json +13 -13
  28. data/station.gemspec +5 -5
  29. data/yarn.lock +378 -320
  30. metadata +38 -156
  31. data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css +0 -14950
  32. data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css.map +0 -1
  33. data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css +0 -15085
  34. data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css.map +0 -1
  35. data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css +0 -13
  36. data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css.map +0 -1
  37. data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css +0 -13
  38. data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css.map +0 -1
  39. data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js +0 -59763
  40. data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js.map +0 -1
  41. data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js +0 -6405
  42. data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js.map +0 -1
  43. data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js +0 -7839
  44. data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js.map +0 -1
  45. data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js +0 -6405
  46. data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js.map +0 -1
  47. data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js +0 -6619
  48. data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js.map +0 -1
  49. data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js +0 -6405
  50. data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js.map +0 -1
  51. data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js +0 -155
  52. data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js.map +0 -1
  53. data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js +0 -61849
  54. data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js.map +0 -1
  55. data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js +0 -59077
  56. data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js.map +0 -1
  57. data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js +0 -61843
  58. data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js.map +0 -1
  59. data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js +0 -62431
  60. data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js.map +0 -1
  61. data/lib/nexmo_developer/public/packs-test/manifest.json +0 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ec14988c40b629659856dfd94223e89e9397f5516908dcdc6f0228042b252d0
4
- data.tar.gz: 45e455cd1a02e1e617f5cb45b1250813abe2ba9ba42b80ab20e7dc65df5ca70e
3
+ metadata.gz: 924c27c28823f6ab3fab402ec78cbd7fee942ff8ab422b3090abaa2929df1773
4
+ data.tar.gz: be61a033963db399d7ee15fbdf368c6f37b09ff4147abbf647006609bc0c194c
5
5
  SHA512:
6
- metadata.gz: 174f223da92039d868ba3a4b980f97f2e592060509771d313d00ca53e1f897cd87ad7db44a375a4cd736b6d625aa2d9de38be5dee88e4e528535bd5df469c628
7
- data.tar.gz: 3caf4c0a9b9f5ff90e956ff3a9fd48b0a7adda24f9883cc9b70a4d5f43170ea80a5f1316ce28181ba03eebe3f3a84f898f8336d791bf1a85b46d9d89dcc984a8
6
+ metadata.gz: 98e6db0b514214ba277b414bf290097d31f82b34cdbfe45f398d5a3da0dd48a3b2899a2c0168615e7d407d4e43b1701d28875cff1c053b1d8eda0d7ed89c789c
7
+ data.tar.gz: c90833f37990c46252acabdff1a25708e9e97071f7c1eee2306903b46187f244c5da6c3d71d821e7ff3977b3e4321fd9ccf6bfaeaf5b66bb099a1f436356ee75
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.5.8-alpine AS build-env
1
+ FROM ruby:2.7.2-alpine AS build-env
2
2
  ARG RAILS_ROOT=/station
3
3
  ARG BUILD_PACKAGES="build-base curl-dev git"
4
4
  ARG DEV_PACKAGES="postgresql-dev yaml-dev zlib-dev nodejs yarn"
@@ -19,11 +19,12 @@ COPY lib/nexmo_developer/Gemfile* package.json yarn.lock $RAILS_ROOT/
19
19
  RUN bundle config --global frozen 1 \
20
20
  && gem update --system \
21
21
  && gem install bundler
22
+
22
23
  RUN bundle install --without development:test:assets -j4 --retry 3 --path=vendor/bundle \
23
24
  # Remove unneeded files (cached *.gem, *.o, *.c)
24
- && rm -rf vendor/bundle/ruby/2.5.0/cache/*.gem \
25
- && find vendor/bundle/ruby/2.5.0/gems/ -name "*.c" -delete \
26
- && find vendor/bundle/ruby/2.5.0/gems/ -name "*.o" -delete
25
+ && rm -rf vendor/bundle/ruby/2.7.0/cache/*.gem \
26
+ && find vendor/bundle/ruby/2.7.0/gems/ -name "*.c" -delete \
27
+ && find vendor/bundle/ruby/2.7.0/gems/ -name "*.o" -delete
27
28
 
28
29
  # Install node dependencies
29
30
  RUN yarn install --frozen-lockfile
@@ -36,7 +37,7 @@ RUN bundle exec rake assets:precompile
36
37
  RUN rm -rf node_modules tmp/cache vendor/assets spec
37
38
 
38
39
  ################ Build step done ###############
39
- FROM ruby:2.5.8-alpine
40
+ FROM ruby:2.7.2-alpine
40
41
  ARG RAILS_ROOT=/station
41
42
 
42
43
  ENV RACK_ENV production
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.5.8'
2
+ ruby '2.7.2'
@@ -8,7 +8,7 @@ PLATFORMS
8
8
  DEPENDENCIES
9
9
 
10
10
  RUBY VERSION
11
- ruby 2.5.8p224
11
+ ruby 2.7.2p137
12
12
 
13
13
  BUNDLED WITH
14
14
  2.1.4
@@ -44,50 +44,7 @@ end.parse!
44
44
  $LOAD_PATH.unshift(File.expand_path('../lib/nexmo_developer', __dir__))
45
45
  APP_PATH = File.expand_path('../lib/nexmo_developer/config/application', __dir__)
46
46
 
47
- require 'rails/all'
48
- require 'activeadmin'
49
- require 'bootsnap'
50
- require 'bugsnag'
51
- require 'devise'
52
- require 'geocoder'
53
- require 'gravatar_image_tag'
54
- require 'greenhouse_io'
55
- require 'recaptcha'
56
- require 'split/dashboard'
57
- require 'listen'
58
- require 'inherited_resources'
59
- require 'msgpack'
60
- require 'pg'
61
- require 'coffee-rails'
62
- require 'octokit'
63
- require 'webpacker'
64
- require 'clipboard/rails'
65
- require 'gmaps4rails'
66
- require 'nexmo_markdown_renderer'
67
- require 'truncato'
68
- require 'puma'
69
- require 'barnes'
70
- require 'woothee'
71
- require 'algoliasearch'
72
- require 'rest-client'
73
- require 'chartkick'
74
- require 'groupdate'
75
- require 'terminal-table'
76
- require 'lograge'
77
- require 'jbuilder'
78
- require 'nokogiri'
79
- require 'colorize'
80
- require 'neatjson'
81
- require 'slack-notifier'
82
- require 'autoprefixer-rails'
83
- require 'titleize'
84
- require 'countries'
85
- require 'country_select'
86
- require 'smartling'
87
- require 'newrelic_rpm'
88
- require 'redis'
89
- require 'rake'
90
-
47
+ require_relative '../lib/nexmo_developer/nexmo_developer'
91
48
  require 'config/application'
92
49
  require 'rails/command'
93
50
 
@@ -49,7 +49,7 @@ The files required are:
49
49
  * `business_info.yml`: Specific business/organizational information for the platform. This includes the platform name, the path to the header and footer logos, and more.
50
50
  * `top_navigation.yml`: The links for the top navigation bar of the platform.
51
51
  * `meta_info.yml`: Information used to generate the links in the platform's `<head>` tags, such as search engine optimization details.
52
- * `products.yml`: A list of each product or item covered in the platform's content. The icon, documentation path and color schema for each product is also specified here.
52
+ * `products.yml`: A list of each product or item covered in the platform's content. The icon, documentation path, color schema and automated translation frequency for each product is also specified here.
53
53
 
54
54
  In addition to the above configuration files, Station also expects the following files to be created and placed inside the `/public/meta` path. These files are meta icons also used in the generation of the `<head>` content:
55
55
 
@@ -1 +1 @@
1
- 2.5.8
1
+ 2.7.2
@@ -1,5 +1,5 @@
1
1
  # Base image:
2
- FROM ruby:2.5.8
2
+ FROM ruby:2.7.2
3
3
 
4
4
  # Install dependencies
5
5
  RUN apt-get update -qq && apt-get install -y build-essential libpq-dev lsof
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.5.8'
2
+ ruby '2.7.2'
3
3
 
4
4
  git_source(:github) do |repo_name|
5
5
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
@@ -13,7 +13,7 @@ gem 'webpacker'
13
13
  # Use postgresql as the database for Active Record
14
14
  gem 'pg', '~> 1.2'
15
15
  # Use Puma as the app server
16
- gem 'puma', '~> 5.0'
16
+ gem 'puma', '~> 5.1'
17
17
  # Use SCSS for stylesheets
18
18
  gem 'sassc-rails', '~> 2.1'
19
19
  # Use Uglifier as compressor for JavaScript assets
@@ -74,7 +74,7 @@ gem 'icalendar', require: false
74
74
  gem 'neatjson'
75
75
 
76
76
  # Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.
77
- gem 'faker', '2.14.0', require: false
77
+ gem 'faker', '2.15.1', require: false
78
78
 
79
79
  # factory_girl_rails provides integration between factory_girl and rails 3 or newer (currently just automatic factory definition loading)
80
80
  gem 'factory_bot_rails', '6.1.0', require: false
@@ -110,7 +110,7 @@ gem 'bootsnap', require: false
110
110
  gem 'diffy', require: false
111
111
 
112
112
  # Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.
113
- gem 'rubocop', '~> 1.3.0', require: false
113
+ gem 'rubocop', '~> 1.4.2', require: false
114
114
  gem 'rubocop-rails', '~> 2.8', require: false
115
115
 
116
116
  # Volta needs a CSS autoprefixer
@@ -129,9 +129,9 @@ gem 'lograge'
129
129
  gem 'countries'
130
130
  gem 'country_select', '~> 4.0'
131
131
 
132
- gem 'nexmo-oas-renderer', '~> 2.4.0', require: false
132
+ gem 'nexmo-oas-renderer', '~> 2.4.1', require: false
133
133
 
134
- gem 'nexmo_markdown_renderer', '~> 0.5'
134
+ gem 'nexmo_markdown_renderer', '~> 0.7.1'
135
135
 
136
136
  gem 'smartling'
137
137
 
@@ -93,7 +93,7 @@ GEM
93
93
  activesupport (>= 3.0.0, < 6.1)
94
94
  ruby2_keywords (>= 0.0.2, < 1.0)
95
95
  ast (2.4.1)
96
- autoprefixer-rails (10.0.2.0)
96
+ autoprefixer-rails (10.0.3.0)
97
97
  execjs
98
98
  awesome_print (1.8.0)
99
99
  banzai (0.1.3)
@@ -114,7 +114,7 @@ GEM
114
114
  concurrent-ruby (~> 1.0)
115
115
  builder (3.2.4)
116
116
  byebug (11.1.3)
117
- capybara (3.33.0)
117
+ capybara (3.34.0)
118
118
  addressable
119
119
  mini_mime (>= 0.1.3)
120
120
  nokogiri (~> 1.8)
@@ -163,7 +163,7 @@ GEM
163
163
  em-websocket (0.5.2)
164
164
  eventmachine (>= 0.12.9)
165
165
  http_parser.rb (~> 0.6.0)
166
- erubi (1.9.0)
166
+ erubi (1.10.0)
167
167
  eventmachine (1.2.7)
168
168
  execjs (2.7.0)
169
169
  factory_bot (6.1.0)
@@ -171,7 +171,7 @@ GEM
171
171
  factory_bot_rails (6.1.0)
172
172
  factory_bot (~> 6.1.0)
173
173
  railties (>= 5.0.0)
174
- faker (2.14.0)
174
+ faker (2.15.1)
175
175
  i18n (>= 1.6, < 2)
176
176
  faraday (1.1.0)
177
177
  multipart-post (>= 1.2, < 3)
@@ -258,7 +258,7 @@ GEM
258
258
  activerecord
259
259
  kaminari-core (= 1.2.1)
260
260
  kaminari-core (1.2.1)
261
- listen (3.3.1)
261
+ listen (3.3.3)
262
262
  rb-fsevent (~> 0.10, >= 0.10.3)
263
263
  rb-inotify (~> 0.9, >= 0.9.10)
264
264
  lograge (0.11.2)
@@ -266,7 +266,7 @@ GEM
266
266
  activesupport (>= 4)
267
267
  railties (>= 4)
268
268
  request_store (~> 1.0)
269
- loofah (2.7.0)
269
+ loofah (2.8.0)
270
270
  crass (~> 1.0.2)
271
271
  nokogiri (>= 1.5.9)
272
272
  lumberjack (1.2.8)
@@ -294,8 +294,8 @@ GEM
294
294
  neatjson (0.9)
295
295
  nenv (0.3.0)
296
296
  netrc (0.11.0)
297
- newrelic_rpm (6.13.1)
298
- nexmo-oas-renderer (2.4.0)
297
+ newrelic_rpm (6.14.0)
298
+ nexmo-oas-renderer (2.4.1)
299
299
  activemodel (~> 6.0)
300
300
  activesupport (~> 6.0)
301
301
  banzai (~> 0.1.2)
@@ -308,7 +308,7 @@ GEM
308
308
  sass (~> 3.1)
309
309
  shotgun (~> 0.9)
310
310
  sinatra (~> 2.0)
311
- nexmo_markdown_renderer (0.5.0)
311
+ nexmo_markdown_renderer (0.7.1)
312
312
  activemodel (~> 6.0)
313
313
  banzai (~> 0.1.2)
314
314
  i18n (~> 1.7)
@@ -340,7 +340,7 @@ GEM
340
340
  sawyer (~> 0.8.0, >= 0.5.3)
341
341
  oj (3.10.15)
342
342
  orm_adapter (0.5.0)
343
- parallel (1.20.0)
343
+ parallel (1.20.1)
344
344
  parser (2.7.2.0)
345
345
  ast (~> 2.4.1)
346
346
  pg (1.2.3)
@@ -350,7 +350,7 @@ GEM
350
350
  coderay (~> 1.1)
351
351
  method_source (~> 1.0)
352
352
  public_suffix (4.0.6)
353
- puma (5.0.4)
353
+ puma (5.1.0)
354
354
  nio4r (~> 2.0)
355
355
  rack (2.2.3)
356
356
  rack-protection (2.1.0)
@@ -398,7 +398,7 @@ GEM
398
398
  recaptcha (5.6.0)
399
399
  json
400
400
  redcarpet (3.4.0)
401
- redis (4.2.2)
401
+ redis (4.2.5)
402
402
  regexp_parser (1.8.2)
403
403
  request_store (1.5.0)
404
404
  rack (>= 1.4)
@@ -437,7 +437,7 @@ GEM
437
437
  rspec-snapshot (0.1.2)
438
438
  rspec (> 3.0.0)
439
439
  rspec-support (3.10.0)
440
- rubocop (1.3.0)
440
+ rubocop (1.4.2)
441
441
  parallel (~> 1.10)
442
442
  parser (>= 2.7.1.5)
443
443
  rainbow (>= 2.2.2, < 4.0)
@@ -446,7 +446,7 @@ GEM
446
446
  rubocop-ast (>= 1.1.1)
447
447
  ruby-progressbar (~> 1.7)
448
448
  unicode-display_width (>= 1.4.0, < 2.0)
449
- rubocop-ast (1.1.1)
449
+ rubocop-ast (1.2.0)
450
450
  parser (>= 2.7.1.5)
451
451
  rubocop-rails (2.8.1)
452
452
  activesupport (>= 4.2.0)
@@ -475,10 +475,12 @@ GEM
475
475
  shotgun (0.9.2)
476
476
  rack (>= 1.0)
477
477
  simple-random (1.0.3)
478
- simplecov (0.19.1)
478
+ simplecov (0.20.0)
479
479
  docile (~> 1.1)
480
480
  simplecov-html (~> 0.11)
481
+ simplecov_json_formatter (~> 0.1)
481
482
  simplecov-html (0.12.3)
483
+ simplecov_json_formatter (0.1.2)
482
484
  sinatra (2.1.0)
483
485
  mustermann (~> 1.0)
484
486
  rack (~> 2.2)
@@ -544,7 +546,7 @@ GEM
544
546
  woothee (1.11.1)
545
547
  xpath (3.2.0)
546
548
  nokogiri (~> 1.8)
547
- zeitwerk (2.4.1)
549
+ zeitwerk (2.4.2)
548
550
 
549
551
  PLATFORMS
550
552
  ruby
@@ -573,7 +575,7 @@ DEPENDENCIES
573
575
  diffy
574
576
  dotenv-rails
575
577
  factory_bot_rails (= 6.1.0)
576
- faker (= 2.14.0)
578
+ faker (= 2.15.1)
577
579
  ffi (>= 1.9.24)
578
580
  geocoder
579
581
  gmaps4rails
@@ -589,13 +591,13 @@ DEPENDENCIES
589
591
  lograge
590
592
  neatjson
591
593
  newrelic_rpm
592
- nexmo-oas-renderer (~> 2.4.0)
593
- nexmo_markdown_renderer (~> 0.5)
594
+ nexmo-oas-renderer (~> 2.4.1)
595
+ nexmo_markdown_renderer (~> 0.7.1)
594
596
  nokogiri (~> 1.10.9)
595
597
  octokit
596
598
  pg (~> 1.2)
597
599
  pry
598
- puma (~> 5.0)
600
+ puma (~> 5.1)
599
601
  rack (>= 2.0.6)
600
602
  rails (~> 6.0.3)
601
603
  rawler!
@@ -605,7 +607,7 @@ DEPENDENCIES
605
607
  rspec-collection_matchers
606
608
  rspec-rails (~> 4.0)
607
609
  rspec-snapshot (~> 0.1.2)
608
- rubocop (~> 1.3.0)
610
+ rubocop (~> 1.4.2)
609
611
  rubocop-rails (~> 2.8)
610
612
  ruby-progressbar
611
613
  sassc-rails (~> 2.1)
@@ -624,7 +626,7 @@ DEPENDENCIES
624
626
  woothee
625
627
 
626
628
  RUBY VERSION
627
- ruby 2.5.8p224
629
+ ruby 2.7.2p137
628
630
 
629
631
  BUNDLED WITH
630
632
  2.1.4
@@ -197,7 +197,7 @@ class DashboardController < ApplicationController
197
197
 
198
198
  parts.insert(1, 'top-level') if parts.count < 3
199
199
 
200
- parts = [parts[0], parts[1], parts[2..-1].join('/')] if parts.count > 3
200
+ parts = [parts[0], parts[1], parts[2..].join('/')] if parts.count > 3
201
201
  next if parts[0] == 'migrate'
202
202
 
203
203
  x = @complete_coverage
@@ -38,8 +38,8 @@ class SidenavItem
38
38
 
39
39
  def css_classes
40
40
  classes = ['Nxd-sidenav-badge Vlt-badge Vlt-badge--margin-left Vlt-badge--small']
41
- classes << 'Vlt-bg-green-lighter Vlt-green' if label.casecmp('beta').zero?
42
- classes << 'Vlt-bg-blue-lighter Vlt-blue' if label.casecmp('dev preview').zero?
41
+ classes << 'Vlt-badge--transparent Vlt-badge--green' if label.casecmp('beta').zero?
42
+ classes << 'Vlt-badge--transparent Vlt-badge--blue' if label.casecmp('dev preview').zero?
43
43
 
44
44
  classes.join(' ')
45
45
  end
@@ -62,11 +62,11 @@ class TutorialListItem
62
62
  end
63
63
 
64
64
  def product_url
65
- "/#{I18n.locale}/#{products.join('')}/tutorials"
65
+ "/#{I18n.locale}/#{products.join}/tutorials"
66
66
  end
67
67
 
68
68
  def url
69
- external_link || "/#{I18n.locale}/#{products.join('')}/tutorials/#{filename}/#{first_step}"
69
+ external_link || "/#{I18n.locale}/#{products.join}/tutorials/#{filename}/#{first_step}"
70
70
  end
71
71
 
72
72
  def available_languages
@@ -74,7 +74,7 @@ class TutorialListItem
74
74
  OpenStruct.new(
75
75
  language: language,
76
76
  label: Nexmo::Markdown::CodeLanguage.find(language).label,
77
- url: external_link || "/#{products.join('')}/tutorials/#{filename}/#{first_step}/#{language}"
77
+ url: external_link || "/#{products.join}/tutorials/#{filename}/#{first_step}/#{language}"
78
78
  )
79
79
  end
80
80
  end
@@ -1,5 +1,7 @@
1
1
  module Translator
2
2
  class FileTranslator
3
+ include Utils
4
+
3
5
  attr_reader :doc_path
4
6
 
5
7
  def initialize(doc_path)
@@ -12,41 +14,45 @@ module Translator
12
14
  Translator::TranslationRequest.new(
13
15
  locale: locale_with_region(locale),
14
16
  frequency: frequency,
15
- file_uri: doc_path
17
+ file_uri: uri,
18
+ file_path: full_path
16
19
  )
17
20
  end
18
21
  end
19
22
  end
20
23
 
24
+ def uri
25
+ @uri ||= file_uri(doc_path)
26
+ end
27
+
21
28
  def frontmatter
22
29
  @frontmatter ||= YAML.safe_load(File.read(full_path))
23
30
  end
24
31
 
25
32
  def full_path
26
- @full_path ||= "#{Rails.configuration.docs_base_path}/_documentation/en/#{doc_path}"
33
+ @full_path ||= "#{Rails.configuration.docs_base_path}/#{doc_path}"
27
34
  end
28
35
 
29
36
  def frequency
30
37
  @frequency ||= frontmatter['translation_frequency'] || product_translation_frequency
31
38
  end
32
39
 
33
- def locale_with_region(locale)
34
- case locale.to_s
35
- when 'ja', 'ja-JP'
36
- 'ja-JP'
37
- when 'cn', 'zh-CN'
38
- 'zh-CN'
39
- else
40
- locale.to_s
40
+ def product_from_path
41
+ @product_from_path ||= begin
42
+ Pathname.new(
43
+ doc_path.gsub(%r{(_documentation|_tutorials|_use_cases)/#{I18n.default_locale}/}, '')
44
+ ).dirname.to_s
41
45
  end
42
46
  end
43
47
 
44
48
  def product
45
49
  @product ||= begin
46
50
  products = YAML.safe_load(File.open("#{Rails.configuration.docs_base_path}/config/products.yml"))
47
- product = products['products'].detect { |p| doc_path.starts_with? p['path'] }
51
+ product = products['products'].detect do |p|
52
+ product_from_path.starts_with?(p['path']) || frontmatter['products']&.include?(p['path'])
53
+ end
48
54
 
49
- raise ArgumentError, 'Unable to match document with products list in config/products.yml' unless product
55
+ raise ArgumentError, "Unable to match document with products list in config/products.yml for #{full_path}" unless product
50
56
 
51
57
  product
52
58
  end