station 0.0.100 → 0.0.105

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nexmo-developer +1 -44
  3. data/docs/How-To-Use.md +1 -1
  4. data/lib/nexmo_developer/.rspec +0 -1
  5. data/lib/nexmo_developer/Gemfile +5 -5
  6. data/lib/nexmo_developer/Gemfile.lock +23 -21
  7. data/lib/nexmo_developer/app/presenters/sidenav_item.rb +2 -2
  8. data/lib/nexmo_developer/app/presenters/tutorial_list_item.rb +3 -3
  9. data/lib/nexmo_developer/app/services/translator/file_translator.rb +18 -12
  10. data/lib/nexmo_developer/app/services/translator/smartling/api/upload_file.rb +4 -2
  11. data/lib/nexmo_developer/app/services/translator/translation_request.rb +3 -2
  12. data/lib/nexmo_developer/app/services/translator/utils.rb +28 -1
  13. data/lib/nexmo_developer/app/views/contribute/guides/markdown-guide.md +70 -48
  14. data/lib/nexmo_developer/app/views/tutorial/list.html.erb +1 -1
  15. data/lib/nexmo_developer/app/views/use_case/_index.html.erb +1 -1
  16. data/lib/nexmo_developer/app/webpacker/javascript/volta/volta.js +108 -21
  17. data/lib/nexmo_developer/app/webpacker/stylesheets/application.scss +1 -1
  18. data/lib/nexmo_developer/app/webpacker/stylesheets/objects/_use_cases.scss +1 -1
  19. data/lib/nexmo_developer/lib/tasks/smartling.rake +1 -1
  20. data/lib/nexmo_developer/nexmo_developer.rb +44 -0
  21. data/lib/nexmo_developer/version.rb +1 -1
  22. data/package.json +11 -10
  23. data/station.gemspec +3 -3
  24. data/yarn.lock +1668 -303
  25. metadata +34 -152
  26. data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css +0 -14950
  27. data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css.map +0 -1
  28. data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css +0 -15085
  29. data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css.map +0 -1
  30. data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css +0 -13
  31. data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css.map +0 -1
  32. data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css +0 -13
  33. data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css.map +0 -1
  34. data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js +0 -59763
  35. data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js.map +0 -1
  36. data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js +0 -6405
  37. data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js.map +0 -1
  38. data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js +0 -7839
  39. data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js.map +0 -1
  40. data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js +0 -6405
  41. data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js.map +0 -1
  42. data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js +0 -6619
  43. data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js.map +0 -1
  44. data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js +0 -6405
  45. data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js.map +0 -1
  46. data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js +0 -155
  47. data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js.map +0 -1
  48. data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js +0 -61849
  49. data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js.map +0 -1
  50. data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js +0 -59077
  51. data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js.map +0 -1
  52. data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js +0 -61843
  53. data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js.map +0 -1
  54. data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js +0 -62431
  55. data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js.map +0 -1
  56. 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: 1198672d56a3ace978b43f205938e988880d40a0afa59b8d1dfad8848a483a01
4
- data.tar.gz: e0ab45a38265a2bb41e44155cfcbf65523c2855bd83fcc1cd9a94b20ca50a2b3
3
+ metadata.gz: b4fd15fb4b49ae5927ee3c05eaac4f993aaceea3a1e25911c35abfb58a9d3b8f
4
+ data.tar.gz: d4c17df34ca852b9f4d2ce1d52ed160d6346cfa9d2b6aa2a57bf4b88aa5d316c
5
5
  SHA512:
6
- metadata.gz: 5675f2e4ced7defa9f14af7e9ecd4f88ab7304755ee58ac28f38e9bb070a733ad290a4d921bb29e9d677ff0f9c73d65c71348f346ba77b5810a1739049286ef6
7
- data.tar.gz: 7129c6147f9d6b8ab673457a7b525b6dcf620917109c61771e3ba7f9b9cadb797cb9e248bd6c27c8d7f5a047f8d68981cbb2f5da4e1b526090c7921816e02b45
6
+ metadata.gz: da7884bf6d7319136b26059eaf5571b6be58f770031887dbe5d01bcc4e495cb3fcccf3375ebcc4f72cb2e739bcf0d81c089cd63a47dfa2f4a6e2e74e01c636de
7
+ data.tar.gz: af98f932f59ac0a04dee5b7774c4feca5436bf5eda8f00c67daa99ff3fd3258a492e73625f128c17f5bdc38ffa8f04b447bf3c31f01d5f91d826839d38c55672
@@ -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,3 +1,2 @@
1
1
  --color
2
2
  --require spec_helper
3
- --tag ~ndp
@@ -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,8 +110,8 @@ 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.1', require: false
114
- gem 'rubocop-rails', '~> 2.8', require: false
113
+ gem 'rubocop', '~> 1.5.2', require: false
114
+ gem 'rubocop-rails', '~> 2.9', require: false
115
115
 
116
116
  # Volta needs a CSS autoprefixer
117
117
  gem 'autoprefixer-rails'
@@ -131,7 +131,7 @@ gem 'country_select', '~> 4.0'
131
131
 
132
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.2'
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)
@@ -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)
@@ -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.1)
311
+ nexmo_markdown_renderer (0.7.2)
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)
@@ -437,21 +437,21 @@ 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.1)
440
+ rubocop (1.5.2)
441
441
  parallel (~> 1.10)
442
442
  parser (>= 2.7.1.5)
443
443
  rainbow (>= 2.2.2, < 4.0)
444
- regexp_parser (>= 1.8)
444
+ regexp_parser (>= 1.8, < 3.0)
445
445
  rexml
446
- rubocop-ast (>= 1.1.1)
446
+ rubocop-ast (>= 1.2.0, < 2.0)
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.3.0)
450
450
  parser (>= 2.7.1.5)
451
- rubocop-rails (2.8.1)
451
+ rubocop-rails (2.9.0)
452
452
  activesupport (>= 4.2.0)
453
453
  rack (>= 1.1)
454
- rubocop (>= 0.87.0)
454
+ rubocop (>= 0.90.0, < 2.0)
455
455
  ruby-progressbar (1.10.1)
456
456
  ruby2_keywords (0.0.2)
457
457
  sass (3.7.4)
@@ -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
@@ -590,12 +592,12 @@ DEPENDENCIES
590
592
  neatjson
591
593
  newrelic_rpm
592
594
  nexmo-oas-renderer (~> 2.4.1)
593
- nexmo_markdown_renderer (~> 0.5)
595
+ nexmo_markdown_renderer (~> 0.7.2)
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,8 +607,8 @@ DEPENDENCIES
605
607
  rspec-collection_matchers
606
608
  rspec-rails (~> 4.0)
607
609
  rspec-snapshot (~> 0.1.2)
608
- rubocop (~> 1.3.1)
609
- rubocop-rails (~> 2.8)
610
+ rubocop (~> 1.5.2)
611
+ rubocop-rails (~> 2.9)
610
612
  ruby-progressbar
611
613
  sassc-rails (~> 2.1)
612
614
  simplecov
@@ -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
@@ -53,8 +53,10 @@ module Translator
53
53
  def file
54
54
  @file ||= begin
55
55
  file = Tempfile.new
56
- file.write Nexmo::Markdown::Pipelines::Smartling::Preprocessor.new.call(
57
- File.read("#{Rails.configuration.docs_base_path}/_documentation/#{I18n.default_locale}/#{@translation_request.file_uri}")
56
+ file.write(
57
+ Nexmo::Markdown::Pipelines::Smartling::Preprocessor.new.call(
58
+ File.read(@translation_request.file_path)
59
+ )
58
60
  )
59
61
  file.rewind
60
62
  file.close
@@ -1,11 +1,12 @@
1
1
  module Translator
2
2
  class TranslationRequest
3
- attr_reader :locale, :frequency, :file_uri
3
+ attr_reader :locale, :frequency, :file_uri, :file_path
4
4
 
5
- def initialize(locale:, frequency:, file_uri:)
5
+ def initialize(locale:, frequency:, file_uri:, file_path:)
6
6
  @locale = locale
7
7
  @frequency = frequency
8
8
  @file_uri = file_uri
9
+ @file_path = file_path
9
10
  end
10
11
  end
11
12
  end
@@ -11,12 +11,33 @@ module Translator
11
11
  end
12
12
  end
13
13
 
14
+ def locale_with_region(locale)
15
+ case locale.to_s
16
+ when 'ja', 'ja-JP'
17
+ 'ja-JP'
18
+ when 'cn', 'zh-CN'
19
+ 'zh-CN'
20
+ else
21
+ locale.to_s
22
+ end
23
+ end
24
+
14
25
  def storage_folder(filename, locale)
15
26
  if filename.starts_with? '_documentation'
16
27
  dir_path = Pathname.new(file_uri(filename)).dirname.to_s
17
28
  "#{Rails.configuration.docs_base_path}/_documentation/#{locale}/#{dir_path}"
29
+ elsif filename.starts_with? '_use_cases'
30
+ "#{Rails.configuration.docs_base_path}/_use_cases/#{locale}"
18
31
  elsif filename.starts_with? 'config/locales'
19
32
  Pathname.new(file_uri(filename)).dirname.to_s
33
+ elsif filename.starts_with? 'config/tutorials'
34
+ pathname = Pathname.new(filename.gsub("config/tutorials/#{I18n.default_locale}/", ''))
35
+ dir_path = pathname.dirname.to_s == '.' ? '' : "/#{pathname.dirname}"
36
+ "#{Rails.configuration.docs_base_path}/config/tutorials/#{locale}#{dir_path}"
37
+ elsif filename.starts_with? '_tutorials'
38
+ pathname = Pathname.new(filename.gsub("_tutorials/#{I18n.default_locale}/", ''))
39
+ dir_path = pathname.dirname.to_s == '.' ? '' : "/#{pathname.dirname}"
40
+ "#{Rails.configuration.docs_base_path}/_tutorials/#{locale}#{dir_path}"
20
41
  else
21
42
  dir_path = Pathname.new(file_uri(filename)).dirname.to_s
22
43
  "#{Rails.configuration.docs_base_path}/_documentation/#{locale}/#{dir_path}"
@@ -36,7 +57,13 @@ module Translator
36
57
  end
37
58
 
38
59
  def file_uri(filename)
39
- filename.gsub(%r{_documentation/[a-z]{2}/}, '')
60
+ if filename.starts_with? '_documentation'
61
+ filename.gsub(%r{_documentation/[a-z]{2}/}, '')
62
+ else
63
+ filename.gsub(%r{(_use_cases|_tutorials|config/tutorials)/#{I18n.default_locale}/(.*)}) do |_|
64
+ "#{$1}/#{$2}"
65
+ end
66
+ end
40
67
  end
41
68
  end
42
69
  end
@@ -28,19 +28,19 @@ navigation_weight: 3
28
28
 
29
29
  The purpose of the metadata is to provide useful information in the following areas:
30
30
 
31
- * Algolia search results (that is when you search in NDP)
32
- * Google (and other external search engine) search results
33
- * Information for the navbar (also sometimes called the table of contents or TOC)
31
+ - Algolia search results (that is when you search in NDP)
32
+ - Google (and other external search engine) search results
33
+ - Information for the navbar (also sometimes called the table of contents or TOC)
34
34
 
35
35
  The meta data items that can be used are described in the following table:
36
36
 
37
- Metadata | HTML generated | Description
38
- ----|----|----
39
- `title` | N/A | This is the title for the topic that will be displayed in the navbar. This main be different to that display at the top of the topic. It is displayed in the Algolia search results when you search NDP.
40
- `description` | N/A | This is the short description for the topic. It is displayed in the Algolia search results when you search NDP. It should indicate the nature of the content of the topic.
41
- `meta_title` | `<head><title>The title</title>...</head>` | Used for SEO in external search engine results. This should be more descriptive than the `title` to provide additional context in the absence of the navbar. [Further reading](https://moz.com/learn/seo/title-tag).
42
- `meta_description` | `<head><meta name="description" content="The description">...</head>` | Used in external search engine results. Provides SEO. Should be no more than 160 characters. [Further reading](https://moz.com/learn/seo/meta-description).
43
- `navigation_weight` | N/A | A hint to position the topic in the navbar where a particular position is preferred. The lower the number used the higher in the navbar the item will appear. Overrides information defined in `config/navigation.yml`. In most cases you only need to add a `navigation_weight` item if your topic is not automatically displayed in your preferred position in the navbar.
37
+ | Metadata | HTML generated | Description |
38
+ | ------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
39
+ | `title` | N/A | This is the title for the topic that will be displayed in the navbar. This main be different to that display at the top of the topic. It is displayed in the Algolia search results when you search NDP. |
40
+ | `description` | N/A | This is the short description for the topic. It is displayed in the Algolia search results when you search NDP. It should indicate the nature of the content of the topic. |
41
+ | `meta_title` | `<head><title>The title</title>...</head>` | Used for SEO in external search engine results. This should be more descriptive than the `title` to provide additional context in the absence of the navbar. [Further reading](https://moz.com/learn/seo/title-tag). |
42
+ | `meta_description` | `<head><meta name="description" content="The description">...</head>` | Used in external search engine results. Provides SEO. Should be no more than 160 characters. [Further reading](https://moz.com/learn/seo/meta-description). |
43
+ | `navigation_weight` | N/A | A hint to position the topic in the navbar where a particular position is preferred. The lower the number used the higher in the navbar the item will appear. Overrides information defined in `config/navigation.yml`. In most cases you only need to add a `navigation_weight` item if your topic is not automatically displayed in your preferred position in the navbar. |
44
44
 
45
45
  ### Example
46
46
 
@@ -62,15 +62,15 @@ When using `title` bear in mind that while something like "Overview" may be fine
62
62
 
63
63
  Ideally task (step) or other active topics should include a gerund. For example:
64
64
 
65
- * Installing the Vonage Command Line Interface (CLI)
65
+ - Installing the Vonage Command Line Interface (CLI)
66
66
 
67
67
  Topics providing reference information would have a noun-based title, for example:
68
68
 
69
- * The Conversation object
69
+ - The Conversation object
70
70
 
71
71
  To provide greater context in external search results a corresponding `meta_title` might contain much more specific information, for example:
72
72
 
73
- * The Vonage Conversation API Conversation object
73
+ - The Vonage Conversation API Conversation object
74
74
 
75
75
  ### Writing an effective `description`
76
76
 
@@ -89,7 +89,9 @@ This appears in external search engine results. While navbar titles such as "Ove
89
89
  **Headings**
90
90
 
91
91
  # I am a H1
92
+
92
93
  ## I am a H2
94
+
93
95
  ### I am a H3
94
96
 
95
97
  > Custom extension: Headings have their own slugified ID's for deep linking. For example the `h1` has an ID of `i-am-a-h1`
@@ -100,7 +102,7 @@ Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia od
100
102
 
101
103
  **Inline styles**
102
104
 
103
- Text can be **bold**, *italic* or ***bold and italic***. You could use ~~strikethrough~~ but please don't.
105
+ Text can be **bold**, _italic_ or **_bold and italic_**. You could use ~~strikethrough~~ but please don't.
104
106
 
105
107
  You can define inline `code block` with backticks.
106
108
 
@@ -152,13 +154,13 @@ Find out ^[more](Tooltips are useful for when you have more information to conve
152
154
  >
153
155
  > Indentations are 4 spaces.
154
156
 
155
- * Alpha
156
- * Bravo
157
- * Charlie
158
- * Delta
159
- * Echo
160
- * Foxtrot
161
- * Golf
157
+ - Alpha
158
+ - Bravo
159
+ - Charlie
160
+ - Delta
161
+ - Echo
162
+ - Foxtrot
163
+ - Golf
162
164
 
163
165
  **Ordered Lists**
164
166
 
@@ -171,7 +173,7 @@ Find out ^[more](Tooltips are useful for when you have more information to conve
171
173
  1. Three
172
174
  2. Four
173
175
  1. Five
174
- 1. Six
176
+ 3. Six
175
177
  3. Seven
176
178
 
177
179
  ## Code
@@ -184,11 +186,11 @@ See our detailed [code examples guide](/contribute/guides/code-examples) for adv
184
186
  >
185
187
  > You'll have to view the `markdown-guide.md` source to see how since showing you the syntax would result in it being processed.
186
188
 
187
- Key | Description
188
- -- | --
189
- `TO_NUMBER` | The number you are sending the SMS to
190
- `API_KEY` | You can find this in your [account overview](https://dashboard.nexmo.com/account-overview)
191
- `API_SECRET` | You can find this in your [account overview](https://dashboard.nexmo.com/account-overview)
189
+ | Key | Description |
190
+ | ------------ | ------------------------------------------------------------------------------------------ |
191
+ | `TO_NUMBER` | The number you are sending the SMS to |
192
+ | `API_KEY` | You can find this in your [account overview](https://dashboard.nexmo.com/account-overview) |
193
+ | `API_SECRET` | You can find this in your [account overview](https://dashboard.nexmo.com/account-overview) |
192
194
 
193
195
  ## Tabbed Content (custom plugin)
194
196
 
@@ -229,10 +231,10 @@ Note that `tabbed` is set to `true` for tabbed folder content.
229
231
 
230
232
  Example files can be found in the folder `_documentation/en/client-sdk/setup/add-sdk-to-your-app`:
231
233
 
232
- * `.config.yml`
233
- * `android.md`
234
- * `ios.md`
235
- * `javascript.md`
234
+ - `.config.yml`
235
+ - `android.md`
236
+ - `ios.md`
237
+ - `javascript.md`
236
238
 
237
239
  The rendered output can be found [here](/client-sdk/setup/add-sdk-to-your-app/javascript).
238
240
 
@@ -288,21 +290,21 @@ Andrew->>China: I am good thanks!
288
290
 
289
291
  Inline [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) support, using both primary language tags and subtags, is provided using the following syntax.
290
292
 
291
- Language | Key | Text
292
- -- | -- | --
293
- English | none | Hello World
294
- Spanish | `es` | [Hola Mundo](lang: 'es')
295
- French | `fr` | [Bonjour le monde](lang: 'fr')
296
- Brazilian Portuguese | `pt-BR` | [Olá Mundo](lang: 'pt-BR')
297
- Hebrew | `il` | [שלום עולם](lang: 'il')
293
+ | Language | Key | Text |
294
+ | -------------------- | ------- | ------------------------------ |
295
+ | English | none | Hello World |
296
+ | Spanish | `es` | [Hola Mundo](lang: "es") |
297
+ | French | `fr` | [Bonjour le monde](lang: "fr") |
298
+ | Brazilian Portuguese | `pt-BR` | [Olá Mundo](lang: "pt-BR") |
299
+ | Hebrew | `il` | [שלום עולם](lang: "il") |
298
300
 
299
301
  ## Anchors (custom plugin)
300
302
 
301
303
  Adding custom anchors and retaining support for old headings can be done as such:
302
304
 
303
- ````
305
+ ```
304
306
  ⚓ This is the old heading
305
- ````
307
+ ```
306
308
 
307
309
  This would produce the following HTML:
308
310
 
@@ -312,12 +314,12 @@ This would produce the following HTML:
312
314
 
313
315
  If you are adding support for a changed header this would normally go above the old heading as such:
314
316
 
315
- ````
317
+ ```
316
318
  ⚓ Send with Short Message Service
317
319
  ⚓ Send with SMS
318
320
 
319
321
  # Sending an SMS
320
- ````
322
+ ```
321
323
 
322
324
  ### Example
323
325
 
@@ -365,9 +367,9 @@ image: public/assets/screenshots/da5f952d465355c19eb888fa1049844b31e090c2.png
365
367
 
366
368
  The HTML `<audio>` element can be utilised in Markdown with the following syntax:
367
369
 
368
- ````
370
+ ```
369
371
  🔈[https://developer.nexmo.com.s3.amazonaws.com/assets/ssml/06-phonemes.mp3]
370
- ````
372
+ ```
371
373
 
372
374
  This produces the following output:
373
375
 
@@ -377,9 +379,9 @@ This produces the following output:
377
379
 
378
380
  You can use syntax such as:
379
381
 
380
- ````
382
+ ```
381
383
  Welcome to [~dynamic_content_example~]
382
- ````
384
+ ```
383
385
 
384
386
  This will render as:
385
387
 
@@ -405,7 +407,7 @@ Alternatively, you can specify the concepts to list manually if you need to show
405
407
 
406
408
  ````
407
409
  ```concept_list
408
- concepts:
410
+ concepts:
409
411
  - voice/voice-api/call-flow
410
412
  - messaging/sms/delivery-receipts
411
413
  ```
@@ -414,7 +416,27 @@ concepts:
414
416
  This produces the following output:
415
417
 
416
418
  ```concept_list
417
- concepts:
419
+ concepts:
418
420
  - voice/voice-api/call-flow
419
421
  - messaging/sms/delivery-receipts
420
422
  ```
423
+
424
+ ## Snippet Variables (custom plugin)
425
+
426
+ When writing a code snippet, you may need to define variables that the snippet will use and provide a description of each. The description will be shown in the selected language if a translation is available.
427
+
428
+ The variables are defined in `config/code_snippet_variables.yml`
429
+
430
+ ````
431
+ ```snippet_variables
432
+ - NEXMO_API_KEY
433
+ - TO_NUMBER
434
+ ```
435
+ ````
436
+
437
+ Produces the following output:
438
+
439
+ ```snippet_variables
440
+ - NEXMO_API_KEY
441
+ - TO_NUMBER
442
+ ```