wovnrb 3.5.0 → 3.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/{makefile → Makefile} +0 -0
  4. data/README.en.md +30 -13
  5. data/build.sh +7 -0
  6. data/docker/nginx/Dockerfile +18 -0
  7. data/docker/nginx/README.md +13 -0
  8. data/docker/nginx/build.sh +8 -0
  9. data/docker/nginx/scripts/configure_sshd.sh +25 -0
  10. data/docker/nginx/scripts/startup.sh +10 -0
  11. data/docker/nginx/wovnrb.conf +19 -0
  12. data/docker/rails/Dockerfile +11 -2
  13. data/docker/rails/Dockerfile.ECS +17 -0
  14. data/docker/rails/TestSite/Gemfile +1 -3
  15. data/docker/rails/TestSite/app/controllers/custom_response_controller.rb +1 -1
  16. data/docker/rails/TestSite/config/environments/development.rb +2 -0
  17. data/docker/rails/TestSite/config/environments/production.rb +2 -0
  18. data/docker/rails/TestSite/config/environments/test.rb +2 -0
  19. data/docker/rails/TestSite/package.json +3 -3
  20. data/docker/rails/TestSite/public/index.html +1 -1
  21. data/docker/rails/TestSite/start.sh +2 -11
  22. data/docker/rails/TestSite/start_rails.sh +9 -0
  23. data/docker/rails/TestSite/yarn.lock +1150 -1466
  24. data/docker/scripts/jenkins/build.sh +45 -0
  25. data/docker/scripts/jenkins/tag_and_push_image.sh +30 -0
  26. data/docker/scripts/jenkins/taskdef.json +104 -0
  27. data/docker/scripts/jenkins/taskdef.json.bak +99 -0
  28. data/lib/wovnrb/api_translator.rb +6 -1
  29. data/lib/wovnrb/headers.rb +40 -66
  30. data/lib/wovnrb/services/html_converter.rb +17 -1
  31. data/lib/wovnrb/services/url.rb +136 -0
  32. data/lib/wovnrb/store.rb +9 -3
  33. data/lib/wovnrb/url_language_switcher.rb +148 -0
  34. data/lib/wovnrb/version.rb +1 -1
  35. data/lib/wovnrb.rb +5 -2
  36. data/test/lib/api_translator_test.rb +49 -2
  37. data/test/lib/headers_test.rb +659 -6223
  38. data/test/lib/lang_test.rb +0 -265
  39. data/test/lib/services/html_converter_test.rb +219 -40
  40. data/test/lib/services/url_test.rb +308 -0
  41. data/test/lib/store_test.rb +1 -1
  42. data/test/lib/url_language_switcher_test.rb +946 -0
  43. data/test/lib/wovnrb_test.rb +15 -3
  44. data/test/test_helper.rb +15 -4
  45. data/wovnrb.gemspec +0 -1
  46. metadata +25 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13d349b3045beb3370a29aca8ebe22f93fdcdeb143a7fefe0f4ecb031b8ffda9
4
- data.tar.gz: da704d4f640423bc7a5c85151d3e531e95d564949812a032a925326b3a278219
3
+ metadata.gz: f8da9741562e23b433e622ef091da98042d6eab8dbe621cdfaa7d59bf29e58c6
4
+ data.tar.gz: 5a6e81693935de46ea0e7eaa3fac7d6eab40a3f1bb8e4fff594adc76699f5023
5
5
  SHA512:
6
- metadata.gz: de57bbecbd55635636928d9de85a7e3e196098476684cdac3cc1f6f399434543dfd7cc7afa0cb947676cd9403c37d9122d82fa1c60dd20a304cf4cb3e5481ad4
7
- data.tar.gz: aa54a84bb9b8a4d42126283ba7ca17c00214c6daf745132c1f7a4c4b50407772e8b6c8bd141f483e8d1b95b02ba3181e047a6ee51b0898daec75b688ed32881a
6
+ metadata.gz: 3ad1400b4c55e9989ab1c251330f5c3659ef0830a02a7e689f87e4ca248e23d9e40b65d9912a0745070151509c7243807981af7b2e985a7a973875e90ed68b71
7
+ data.tar.gz: c323c7912fc06eb004ab4b0ce3d130c6a7fa01b65d23472091dda391ab77f1fe4a37ac4a3edccf40462063fd4af1747530fc889306bfd0995564120a5f0b77f3
data/.rubocop.yml CHANGED
@@ -4,3 +4,4 @@ inherit_from: .rubocop_todo.yml
4
4
 
5
5
  AllCops:
6
6
  SuggestExtensions: false
7
+ TargetRubyVersion: 2.5
File without changes
data/README.en.md CHANGED
@@ -74,19 +74,22 @@ After completing setup, start the Ruby Application, and make sure the WOVN.io li
74
74
 
75
75
  The following is a list of the WOVN.io Ruby Library's valid parameters.
76
76
 
77
- Parameter Name | Required | Default Setting
78
- ----------------------| -------- | ----------------
79
- project_token | yes | ''
80
- default_lang | yes | 'ja'
81
- supported_langs | yes | ['ja', 'en']
82
- url_pattern | yes | 'path'
83
- lang_param_name | | 'wovn'
84
- query | | []
85
- ignore_class | | []
86
- translate_fragment | | true
87
- ignore_paths | | []
88
- install_middleware | | true
89
- compress_api_requests | | true
77
+ Parameter Name | Required | Default Setting
78
+ -------------------------------| -------- | ----------------
79
+ project_token | yes | ''
80
+ default_lang | yes | 'ja'
81
+ supported_langs | yes | ['ja', 'en']
82
+ url_pattern | yes | 'path'
83
+ lang_param_name | | 'wovn'
84
+ query | | []
85
+ ignore_class | | []
86
+ translate_fragment | | true
87
+ ignore_paths | | []
88
+ install_middleware | | true
89
+ compress_api_requests | | true
90
+ api_timeout_seconds | | 1.0
91
+ api_timeout_search_engine_bots | | 5.0
92
+ translate_canonical_tag | | true
90
93
 
91
94
  ### 2.1. project_token
92
95
 
@@ -201,3 +204,17 @@ WOVN.rb needs to be added after any compression middleware.
201
204
  ### 2.11 compress_api_requests
202
205
 
203
206
  By default, requests to the translation API will be sent with gzip compression. Set to false to disable compression.
207
+
208
+ ### 2.12 api_timeout_seconds
209
+ Configures the amount of time in seconds wovnrb will wait for the translation API for a response before the
210
+ request is considered timed-out. This setting defaults to `1.0`.
211
+
212
+ ### 2.13 api_timeout_search_engine_bots
213
+ Similar to `api_timeout_seconds`, this timeout setting is applied when handling requests made by search engine bots.
214
+ Currently, bots from Google, Yahoo, Bing, Yandex, DuckDuckGo and Baidu are supported. This setting
215
+ defaults to `5.0`.
216
+
217
+ ### 2.14 translate_canonical_tag
218
+ Configures if wovnrb should automatically translate existing canonical tag in the HTML. When set to `true`, wovnrb
219
+ will translate the canonical URL with the current language code according to your `url_pattern` setting.
220
+ This setting defaults to `true`.
data/build.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -eux
3
+
4
+ TAG=$1
5
+ cd $(dirname $0)
6
+ docker build -t "${TAG}" -f docker/rails/Dockerfile.ECS .
7
+ cd -
@@ -0,0 +1,18 @@
1
+ FROM nginx:stable
2
+
3
+ WORKDIR /var/tmp/nginx
4
+
5
+ ADD wovnrb.conf .
6
+ ADD scripts/startup.sh .
7
+ ADD scripts/configure_sshd.sh .
8
+
9
+ RUN apt-get update --allow-releaseinfo-change \
10
+ && apt install --no-install-recommends -y \
11
+ vim \
12
+ && apt-get clean \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Setup sshd
16
+ RUN ./configure_sshd.sh
17
+
18
+ CMD ["/var/tmp/nginx/startup.sh"]
@@ -0,0 +1,13 @@
1
+ Update `nginx/{ENV_ID}/config`.
2
+ And build new image.
3
+
4
+
5
+ ## How to Build
6
+
7
+ *Notice*
8
+ You need aws credentials `wovn-code-pipeline` for building image.
9
+ If you need it, please contact to Infrastructure Team.
10
+
11
+ ```
12
+ ./build.sh
13
+ ```
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ set -eux
3
+
4
+ TAG="${1}"
5
+ cd $(dirname $0)
6
+ docker build -t ${TAG} .
7
+
8
+ cd -
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+ set -eu
3
+
4
+ # Install openssh-server
5
+ apt-get update --allow-releaseinfo-change \
6
+ && apt install --no-install-recommends -y \
7
+ openssh-server \
8
+ && apt-get clean \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Update sshd_config
12
+ echo -e "Port 22\n" >> /etc/ssh/sshd_config
13
+ echo -e "AllowUsers ec2-user\n" >> /etc/ssh/sshd_config
14
+ echo -e "AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 /etc/authorized_keys/%u\n" >> /etc/ssh/sshd_config
15
+ mkdir /etc/authorized_keys
16
+
17
+ # Setup user and authorized_keys
18
+ useradd -m -d /home/ec2-user -s /bin/bash ec2-user
19
+ echo "ec2-user:$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)" | chpasswd
20
+ echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCp1wkFbEfS2CuUwSMJy5zx3SenZF6WOL0o60ngHYJ0bHWEe7e7KCdwkyKkgF8A57in2faI+nKO0ScnAYcuwEy5BJNh6789TEdNtC4mpKr7A5x0MEkAdWyjjQu/upsaDASSEmJO8dFV/xu/IEUticxA960Rz2ncOPRHFubnbFkCOUg2vy8dfZybx1d9bZWEdDrcnPFjhhxeti+Cq/OdwtTlteffUKhi7qcDKHZEGi3zHzrvXiSwKJHgyMdUNf/PzIV+9Z0G0XwrnZ/q6WQNESNaEra7Iwvl921hzlxP8RKDCaxsryAHR67BCJjqhok7qtnujQYWMNc40z1ewC0o+oat" > /etc/authorized_keys/ec2-user
21
+
22
+ # Add ec2-user to wheel group
23
+ groupadd -g 999 wheel
24
+ sed -i -e 's/wheel:x:999:/wheel:x:999:root,ec2-user/g' /etc/group
25
+ sed -i -e 's/^# auth required pam_wheel.so/auth sufficient pam_wheel.so trust/g' /etc/pam.d/su
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Add port for sshd
5
+ echo "Port 40022" >> /etc/ssh/sshd_config
6
+ service ssh restart
7
+
8
+ cp -a /var/tmp/nginx/wovnrb.conf /etc/nginx/conf.d/
9
+
10
+ nginx -g 'daemon off;'
@@ -0,0 +1,19 @@
1
+ map $http_user_agent $check_ua {
2
+ ~ELB-HealthChecker/ 0;
3
+ default 1;
4
+ }
5
+
6
+ server {
7
+ listen 80 default_server;
8
+ server_name wovn.io;
9
+
10
+ location / {
11
+ proxy_pass http://localhost:4000;
12
+ proxy_http_version 1.1;
13
+ proxy_set_header Upgrade $http_upgrade;
14
+ proxy_set_header Connection 'upgrade';
15
+ proxy_set_header Host $host;
16
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17
+ proxy_cache_bypass $http_upgrade;
18
+ }
19
+ }
@@ -1,6 +1,15 @@
1
- FROM ruby:2.6.5
1
+ FROM ruby:2.7.6
2
2
 
3
3
  WORKDIR /usr/src/app
4
4
 
5
5
  COPY ./TestSite/ .
6
- CMD ["/bin/bash", "start.sh"]
6
+
7
+ RUN gem update --system
8
+ RUN gem uninstall bundler && rm /usr/local/bin/bundle && rm /usr/local/bin/bundler
9
+ RUN gem install bundler:2.1.4
10
+ RUN apt update && apt install npm -y
11
+ RUN npm install --global yarn
12
+ RUN yarn install --check-files
13
+ RUN bundle install
14
+
15
+ CMD ["/bin/bash", "start.sh"]
@@ -0,0 +1,17 @@
1
+ FROM ruby:2.7.6
2
+
3
+ WORKDIR /usr/src/app
4
+
5
+ COPY docker/rails/TestSite .
6
+ COPY lib ./wovnrb/lib
7
+ COPY Gemfile ./wovnrb/
8
+ COPY wovnrb.gemspec ./wovnrb/
9
+
10
+ RUN gem update --system && gem uninstall bundler && \
11
+ rm /usr/local/bin/bundle && rm /usr/local/bin/bundler
12
+ RUN gem install bundler:2.1.4 && bundle install
13
+ RUN apt update -y && apt install npm -y && apt-get install openssh-server -y && apt-get install vim -y
14
+ RUN npm install --global yarn
15
+ RUN yarn install --check-files
16
+
17
+ CMD ["/bin/bash", "start_rails.sh"]
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- ruby '2.6.5'
4
+ ruby '2.7.6'
5
5
 
6
6
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7
7
  gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
@@ -52,5 +52,3 @@ end
52
52
 
53
53
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
54
54
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
55
-
56
- gem 'wovnrb', path: './wovnrb'
@@ -1,5 +1,5 @@
1
1
  class CustomResponseController < ApplicationController
2
- skip_before_action :verify_authenticity_token2
2
+ skip_before_action :verify_authenticity_token
3
3
 
4
4
  def make_response
5
5
  response_args_json = params[:response]
@@ -59,4 +59,6 @@ Rails.application.configure do
59
59
  # Use an evented file watcher to asynchronously detect changes in source code,
60
60
  # routes, locales, etc. This feature depends on the listen gem.
61
61
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker
62
+
63
+ config.hosts << "example.com"
62
64
  end
@@ -109,4 +109,6 @@ Rails.application.configure do
109
109
  # config.active_record.database_selector = { delay: 2.seconds }
110
110
  # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
111
111
  # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
112
+
113
+ config.hosts << "example.com"
112
114
  end
@@ -46,4 +46,6 @@ Rails.application.configure do
46
46
 
47
47
  # Raises error for missing translations.
48
48
  # config.action_view.raise_on_missing_translations = true
49
+
50
+ config.hosts << "example.com"
49
51
  end
@@ -3,9 +3,9 @@
3
3
  "private": true,
4
4
  "dependencies": {
5
5
  "@rails/actioncable": "^6.0.0",
6
- "@rails/activestorage": "^6.0.0",
7
- "@rails/ujs": "^6.0.0",
8
- "@rails/webpacker": "4.3.0",
6
+ "@rails/activestorage": "^6.1.6",
7
+ "@rails/ujs": "^6.1.7",
8
+ "@rails/webpacker": "5.2.2",
9
9
  "turbolinks": "^5.2.0"
10
10
  },
11
11
  "version": "0.1.0",
@@ -4,6 +4,6 @@
4
4
  <title>test</title>
5
5
  </head>
6
6
  <body>
7
- <h1>Hello WOVN.php world!</h1>
7
+ <h1>Hello WOVN.rb world!</h1>
8
8
  </body>
9
9
  </html>
@@ -1,13 +1,4 @@
1
- cd /usr/src/app
2
- gem update --system
3
- gem uninstall bundler
4
- rm /usr/local/bin/bundle
5
- rm /usr/local/bin/bundler
6
- gem install bundler:2.1.4
7
- update --bundler
1
+ # ./wovnrb should not be cached
2
+ echo "gem 'wovnrb', path: './wovnrb'" >> Gemfile
8
3
  bundle install
9
- apt update
10
- apt install npm -y
11
- npm install --global yarn
12
- yarn install --check-files
13
4
  bin/rails server -b 0.0.0.0 -e development -p 4000
@@ -0,0 +1,9 @@
1
+ mkdir /root/.ssh
2
+ touch /root/.ssh/authorized_keys
3
+ echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCp1wkFbEfS2CuUwSMJy5zx3SenZF6WOL0o60ngHYJ0bHWEe7e7KCdwkyKkgF8A57in2faI+nKO0ScnAYcuwEy5BJNh6789TEdNtC4mpKr7A5x0MEkAdWyjjQu/upsaDASSEmJO8dFV/xu/IEUticxA960Rz2ncOPRHFubnbFkCOUg2vy8dfZybx1d9bZWEdDrcnPFjhhxeti+Cq/OdwtTlteffUKhi7qcDKHZEGi3zHzrvXiSwKJHgyMdUNf/PzIV+9Z0G0XwrnZ/q6WQNESNaEra7Iwvl921hzlxP8RKDCaxsryAHR67BCJjqhok7qtnujQYWMNc40z1ewC0o+oat" > /root/.ssh/authorized_keys
4
+ echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8M0XAzp2KYW6pA4dmoRmC5jpfGqotxMTUXuUVTyCBc" >> /root/.ssh/authorized_keys
5
+ echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config
6
+ echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
7
+ echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
8
+ service ssh start
9
+ bin/rails server -b 0.0.0.0 -e development -p 4000