wovnrb 3.5.0 → 3.6.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/README.en.md +30 -13
- data/build.sh +7 -0
- data/docker/nginx/Dockerfile +18 -0
- data/docker/nginx/README.md +13 -0
- data/docker/nginx/build.sh +8 -0
- data/docker/nginx/scripts/configure_sshd.sh +25 -0
- data/docker/nginx/scripts/startup.sh +10 -0
- data/docker/nginx/wovnrb.conf +19 -0
- data/docker/rails/Dockerfile +9 -0
- data/docker/rails/Dockerfile.ECS +17 -0
- data/docker/rails/TestSite/Gemfile +0 -2
- data/docker/rails/TestSite/app/controllers/custom_response_controller.rb +1 -1
- data/docker/rails/TestSite/config/environments/development.rb +2 -0
- data/docker/rails/TestSite/config/environments/production.rb +2 -0
- data/docker/rails/TestSite/config/environments/test.rb +2 -0
- data/docker/rails/TestSite/public/index.html +1 -1
- data/docker/rails/TestSite/start.sh +2 -11
- data/docker/rails/TestSite/start_rails.sh +9 -0
- data/docker/rails/TestSite/yarn.lock +3 -3
- data/docker/scripts/jenkins/build.sh +45 -0
- data/docker/scripts/jenkins/tag_and_push_image.sh +30 -0
- data/docker/scripts/jenkins/taskdef.json +104 -0
- data/docker/scripts/jenkins/taskdef.json.bak +99 -0
- data/lib/wovnrb/api_translator.rb +6 -1
- data/lib/wovnrb/headers.rb +19 -2
- data/lib/wovnrb/services/html_converter.rb +17 -1
- data/lib/wovnrb/services/url.rb +136 -0
- data/lib/wovnrb/store.rb +8 -2
- data/lib/wovnrb/url_language_switcher.rb +124 -0
- data/lib/wovnrb/version.rb +1 -1
- data/lib/wovnrb.rb +3 -1
- data/test/lib/api_translator_test.rb +44 -0
- data/test/lib/services/html_converter_test.rb +210 -37
- data/test/lib/services/url_test.rb +308 -0
- data/test/lib/url_language_switcher_test.rb +798 -0
- data/test/lib/wovnrb_test.rb +2 -1
- data/test/test_helper.rb +4 -1
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29bd88528d91b54ec9a05a04618c94466ecc514b32964c6a771a4a8b3f2e5578
|
4
|
+
data.tar.gz: aa3c23a353b77ccb3abc93036e88b42f4794d1ea983af8b6b36a0287f2665c6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 391f38b423bc709f052a33515452a04202c507060d7fb24fe202d3eb7788fb646a114b5258065f896bbd540d4e3187ccc29510f1b6b0744ceea45f6372e8b533
|
7
|
+
data.tar.gz: 43175960da9790a1ced786d357469f2c590b530add67b4e8a938deacbf9be45b70f917c1ef26279432e6dbb9ad7b99cc889aa07ebe5ece177e7c30bc1677727f
|
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
|
78
|
-
|
79
|
-
project_token
|
80
|
-
default_lang
|
81
|
-
supported_langs
|
82
|
-
url_pattern
|
83
|
-
lang_param_name
|
84
|
-
query
|
85
|
-
ignore_class
|
86
|
-
translate_fragment
|
87
|
-
ignore_paths
|
88
|
-
install_middleware
|
89
|
-
compress_api_requests
|
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,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,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,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
|
+
}
|
data/docker/rails/Dockerfile
CHANGED
@@ -3,4 +3,13 @@ FROM ruby:2.6.5
|
|
3
3
|
WORKDIR /usr/src/app
|
4
4
|
|
5
5
|
COPY ./TestSite/ .
|
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
|
+
|
6
15
|
CMD ["/bin/bash", "start.sh"]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FROM ruby:2.6.5
|
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"]
|
@@ -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
|
@@ -1,13 +1,4 @@
|
|
1
|
-
|
2
|
-
gem
|
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
|
@@ -3094,9 +3094,9 @@ flush-write-stream@^1.0.0:
|
|
3094
3094
|
readable-stream "^2.3.6"
|
3095
3095
|
|
3096
3096
|
follow-redirects@^1.0.0:
|
3097
|
-
version "1.14.
|
3098
|
-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.
|
3099
|
-
integrity sha512
|
3097
|
+
version "1.14.7"
|
3098
|
+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
|
3099
|
+
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==
|
3100
3100
|
|
3101
3101
|
for-in@^1.0.2:
|
3102
3102
|
version "1.0.2"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -eux
|
3
|
+
export AWS_PROFILE="wovn-code-staging-pipeline"
|
4
|
+
export AWS_REGION="us-west-2"
|
5
|
+
export ECR_HOST="257024234524.dkr.ecr.us-west-2.amazonaws.com"
|
6
|
+
REPO_NAME_WOVNRB="wovnrb"
|
7
|
+
REPO_NAME_NGINX="wovnrb-nginx"
|
8
|
+
CLUSTER_NAME="wovn-library-testing"
|
9
|
+
TASKDEF_FAMILY_NAME="wovnrb"
|
10
|
+
ECS_SERVICE_NAME="wovnrb"
|
11
|
+
PROJECT_DIR=$(dirname "$0")/../../..
|
12
|
+
|
13
|
+
commit_hash=$(git rev-parse --short HEAD)
|
14
|
+
image_tag="${commit_hash}"
|
15
|
+
|
16
|
+
sh ${PROJECT_DIR}/build.sh "${REPO_NAME_WOVNRB}":"${image_tag}"
|
17
|
+
sh ${PROJECT_DIR}/docker/nginx/build.sh "${REPO_NAME_NGINX}":"${image_tag}"
|
18
|
+
|
19
|
+
source ${PROJECT_DIR}/docker/scripts/jenkins/tag_and_push_image.sh
|
20
|
+
|
21
|
+
set +x
|
22
|
+
$(aws ecr get-login --no-include-email --region "${AWS_REGION}" --profile "${AWS_PROFILE}")
|
23
|
+
set -x
|
24
|
+
|
25
|
+
tag_and_push_image "${AWS_REGION}" "${REPO_NAME_WOVNRB}" "${image_tag}" "staging"
|
26
|
+
tag_and_push_image "${AWS_REGION}" "${REPO_NAME_NGINX}" "${image_tag}" "staging"
|
27
|
+
|
28
|
+
sed -i "s#wovnrb:latest#"${REPO_NAME_WOVNRB}":"${image_tag}"#g" ${PROJECT_DIR}/docker/scripts/jenkins/taskdef.json
|
29
|
+
sed -i "s#wovnrb-nginx:latest#"${REPO_NAME_NGINX}":"${image_tag}"#g" ${PROJECT_DIR}/docker/scripts/jenkins/taskdef.json
|
30
|
+
|
31
|
+
cd ${PROJECT_DIR}/docker/scripts/jenkins/
|
32
|
+
TASKDEF_REVISION=$(aws ecs register-task-definition \
|
33
|
+
--profile "${AWS_PROFILE}" --region "${AWS_REGION}" \
|
34
|
+
--cli-input-json file://$(pwd)/taskdef.json \
|
35
|
+
| jq ."taskDefinition.revision")
|
36
|
+
echo "${TASKDEF_REVISION}"
|
37
|
+
|
38
|
+
echo "Start ECS Rolling deploy. Update ${ECS_SERVICE_NAME} by ${TASKDEF_FAMILY_NAME}:${TASKDEF_REVISION}"
|
39
|
+
aws ecs update-service \
|
40
|
+
--profile "${AWS_PROFILE}" --region "${AWS_REGION}" \
|
41
|
+
--cluster "${CLUSTER_NAME}" \
|
42
|
+
--service "${ECS_SERVICE_NAME}" \
|
43
|
+
--task-definition "${TASKDEF_FAMILY_NAME}:${TASKDEF_REVISION}"
|
44
|
+
|
45
|
+
cd -
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Tag to docker image and push it to specified ECR
|
4
|
+
#
|
5
|
+
# Required environment variables:
|
6
|
+
# - AWS_PROFILE (AWS profile authorized for ECR login and S3 release)
|
7
|
+
#
|
8
|
+
# Args:
|
9
|
+
# - region: ECR region (e.g. us-west-1 | us-west-2 )
|
10
|
+
# - image-name: docker image name (e.g. equalizer-nginx)
|
11
|
+
# - tag: docker image tag. we use git commit hash ordinary (git rev-parse --short HEAD)
|
12
|
+
|
13
|
+
tag_and_push_image() {
|
14
|
+
local aws_region="${1}"
|
15
|
+
local image_name="${2}"
|
16
|
+
local tag="${3}"
|
17
|
+
local account="${4}"
|
18
|
+
|
19
|
+
if [ ${account} == "production" ]; then
|
20
|
+
local ecr_host="140249473629.dkr.ecr.${aws_region}.amazonaws.com"
|
21
|
+
elif [ ${account} == "staging" ]; then
|
22
|
+
local ecr_host="257024234524.dkr.ecr.${aws_region}.amazonaws.com"
|
23
|
+
else
|
24
|
+
echo "Passed account not recognized"
|
25
|
+
local ecr_host=""
|
26
|
+
fi
|
27
|
+
|
28
|
+
docker tag ${image_name}:${tag} ${ecr_host}/${image_name}:${tag}
|
29
|
+
docker push ${ecr_host}/${image_name}:${tag}
|
30
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
{
|
2
|
+
"executionRoleArn": "arn:aws:iam::257024234524:role/ecsTaskExecutionRole",
|
3
|
+
"containerDefinitions": [
|
4
|
+
{
|
5
|
+
"name": "wovnrb-nginx",
|
6
|
+
"cpu": 0,
|
7
|
+
"image": "257024234524.dkr.ecr.us-west-2.amazonaws.com/wovnrb-nginx:latest",
|
8
|
+
"mountPoints": [],
|
9
|
+
"ulimits": [
|
10
|
+
{
|
11
|
+
"name": "nofile",
|
12
|
+
"softLimit": 65535,
|
13
|
+
"hardLimit": 65535
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"logConfiguration": {
|
17
|
+
"logDriver": "awslogs",
|
18
|
+
"options": {
|
19
|
+
"awslogs-group": "/ecs/wovnrb",
|
20
|
+
"awslogs-region": "us-west-2",
|
21
|
+
"awslogs-stream-prefix": "ecs"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"essential": true,
|
25
|
+
"portMappings": [
|
26
|
+
{
|
27
|
+
"hostPort": 80,
|
28
|
+
"protocol": "tcp",
|
29
|
+
"containerPort": 80
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"hostPort": 40022,
|
33
|
+
"protocol": "tcp",
|
34
|
+
"containerPort": 40022
|
35
|
+
}
|
36
|
+
],
|
37
|
+
"stopTimeout": 120,
|
38
|
+
"dependsOn": [
|
39
|
+
{
|
40
|
+
"containerName": "wovnrb",
|
41
|
+
"condition": "HEALTHY"
|
42
|
+
}
|
43
|
+
]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "wovnrb",
|
47
|
+
"cpu": 0,
|
48
|
+
"image": "257024234524.dkr.ecr.us-west-2.amazonaws.com/wovnrb:latest",
|
49
|
+
"mountPoints": [],
|
50
|
+
"workingDirectory": "/usr/src/app",
|
51
|
+
"linuxParameters": {
|
52
|
+
"initProcessEnabled": true
|
53
|
+
},
|
54
|
+
"environment": [],
|
55
|
+
"ulimits": [
|
56
|
+
{
|
57
|
+
"name": "nofile",
|
58
|
+
"softLimit": 65535,
|
59
|
+
"hardLimit": 65535
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"logConfiguration": {
|
63
|
+
"logDriver": "awslogs",
|
64
|
+
"options": {
|
65
|
+
"awslogs-group": "/ecs/wovnrb",
|
66
|
+
"awslogs-region": "us-west-2",
|
67
|
+
"awslogs-stream-prefix": "ecs"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
"portMappings": [
|
71
|
+
{
|
72
|
+
"hostPort": 4000,
|
73
|
+
"protocol": "tcp",
|
74
|
+
"containerPort": 4000
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"hostPort": 22,
|
78
|
+
"protocol": "tcp",
|
79
|
+
"containerPort": 22
|
80
|
+
}
|
81
|
+
],
|
82
|
+
"volumesFrom": [],
|
83
|
+
"stopTimeout": 120,
|
84
|
+
"healthCheck": {
|
85
|
+
"retries": 3,
|
86
|
+
"command": [
|
87
|
+
"CMD-SHELL",
|
88
|
+
"curl -f http://localhost:4000/ || exit 1"
|
89
|
+
],
|
90
|
+
"timeout": 20,
|
91
|
+
"interval": 60,
|
92
|
+
"startPeriod": 180
|
93
|
+
},
|
94
|
+
"essential": true
|
95
|
+
}
|
96
|
+
],
|
97
|
+
"placementConstraints": [],
|
98
|
+
"cpu": "1024",
|
99
|
+
"memory": "2048",
|
100
|
+
"requiresCompatibilities": [ "FARGATE" ],
|
101
|
+
"family": "wovnrb",
|
102
|
+
"networkMode": "awsvpc",
|
103
|
+
"volumes": []
|
104
|
+
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
{
|
2
|
+
"executionRoleArn": "arn:aws:iam::257024234524:role/ecsTaskExecutionRole",
|
3
|
+
"containerDefinitions": [
|
4
|
+
{
|
5
|
+
"name": "wovnrb-nginx",
|
6
|
+
"cpu": 0,
|
7
|
+
"image": "257024234524.dkr.ecr.us-west-2.amazonaws.com/wovnrb-nginx:latest",
|
8
|
+
"mountPoints": [],
|
9
|
+
"ulimits": [
|
10
|
+
{
|
11
|
+
"name": "nofile",
|
12
|
+
"softLimit": 65535,
|
13
|
+
"hardLimit": 65535
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"logConfiguration": {
|
17
|
+
"logDriver": "awslogs",
|
18
|
+
"options": {
|
19
|
+
"awslogs-group": "/ecs/wovnrb",
|
20
|
+
"awslogs-region": "us-west-2",
|
21
|
+
"awslogs-stream-prefix": "ecs"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"essential": true,
|
25
|
+
"portMappings": [
|
26
|
+
{
|
27
|
+
"hostPort": 80,
|
28
|
+
"protocol": "tcp",
|
29
|
+
"containerPort": 80
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"hostPort": 40022,
|
33
|
+
"protocol": "tcp",
|
34
|
+
"containerPort": 40022
|
35
|
+
}
|
36
|
+
],
|
37
|
+
"stopTimeout": 120,
|
38
|
+
"dependsOn": [
|
39
|
+
{
|
40
|
+
"containerName": "wovnrb",
|
41
|
+
"condition": "HEALTHY"
|
42
|
+
}
|
43
|
+
]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "wovnrb",
|
47
|
+
"cpu": 0,
|
48
|
+
"image": "257024234524.dkr.ecr.us-west-2.amazonaws.com/wovnrb:36d9648",
|
49
|
+
"mountPoints": [],
|
50
|
+
"workingDirectory": "/usr/src/app",
|
51
|
+
"linuxParameters": {
|
52
|
+
"initProcessEnabled": true
|
53
|
+
},
|
54
|
+
"environment": [],
|
55
|
+
"ulimits": [
|
56
|
+
{
|
57
|
+
"name": "nofile",
|
58
|
+
"softLimit": 65535,
|
59
|
+
"hardLimit": 65535
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"logConfiguration": {
|
63
|
+
"logDriver": "awslogs",
|
64
|
+
"options": {
|
65
|
+
"awslogs-group": "/ecs/wovnrb",
|
66
|
+
"awslogs-region": "us-west-2",
|
67
|
+
"awslogs-stream-prefix": "ecs"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
"portMappings": [
|
71
|
+
{
|
72
|
+
"hostPort": 4000,
|
73
|
+
"protocol": "tcp",
|
74
|
+
"containerPort": 4000
|
75
|
+
}
|
76
|
+
],
|
77
|
+
"volumesFrom": [],
|
78
|
+
"stopTimeout": 120,
|
79
|
+
"healthCheck": {
|
80
|
+
"retries": 3,
|
81
|
+
"command": [
|
82
|
+
"CMD-SHELL",
|
83
|
+
"curl -f http://localhost:4000/ || exit 1"
|
84
|
+
],
|
85
|
+
"timeout": 20,
|
86
|
+
"interval": 60,
|
87
|
+
"startPeriod": 180
|
88
|
+
},
|
89
|
+
"essential": true
|
90
|
+
}
|
91
|
+
],
|
92
|
+
"placementConstraints": [],
|
93
|
+
"cpu": "1024",
|
94
|
+
"memory": "2048",
|
95
|
+
"requiresCompatibilities": [ "FARGATE" ],
|
96
|
+
"family": "wovnrb",
|
97
|
+
"networkMode": "awsvpc",
|
98
|
+
"volumes": []
|
99
|
+
}
|
@@ -111,6 +111,7 @@ module Wovnrb
|
|
111
111
|
'lang_code' => lang_code,
|
112
112
|
'url_pattern' => url_pattern,
|
113
113
|
'lang_param_name' => lang_param_name,
|
114
|
+
'translate_canonical_tag' => translate_canonical_tag,
|
114
115
|
'product' => 'WOVN.rb',
|
115
116
|
'version' => VERSION,
|
116
117
|
'body' => body
|
@@ -130,7 +131,7 @@ module Wovnrb
|
|
130
131
|
end
|
131
132
|
|
132
133
|
def api_timeout
|
133
|
-
@store.settings['api_timeout_seconds']
|
134
|
+
@headers.search_engine_bot? ? @store.settings['api_timeout_search_engine_bots'] : @store.settings['api_timeout_seconds']
|
134
135
|
end
|
135
136
|
|
136
137
|
def settings_hash
|
@@ -157,6 +158,10 @@ module Wovnrb
|
|
157
158
|
@store.settings['custom_lang_aliases']
|
158
159
|
end
|
159
160
|
|
161
|
+
def translate_canonical_tag
|
162
|
+
@store.settings['translate_canonical_tag']
|
163
|
+
end
|
164
|
+
|
160
165
|
def page_url
|
161
166
|
"#{@headers.protocol}://#{@headers.url}"
|
162
167
|
end
|
data/lib/wovnrb/headers.rb
CHANGED
@@ -56,6 +56,10 @@ module Wovnrb
|
|
56
56
|
@pathname = @pathname.gsub(/\/$/, '')
|
57
57
|
end
|
58
58
|
|
59
|
+
def url_with_scheme
|
60
|
+
"#{@protocol}://#{@url}"
|
61
|
+
end
|
62
|
+
|
59
63
|
def unmasked_pathname_without_trailing_slash
|
60
64
|
@unmasked_pathname.chomp('/')
|
61
65
|
end
|
@@ -197,11 +201,24 @@ module Wovnrb
|
|
197
201
|
end
|
198
202
|
|
199
203
|
def dirname
|
200
|
-
if
|
201
|
-
|
204
|
+
if pathname_with_trailing_slash_if_present.include?('/')
|
205
|
+
pathname_with_trailing_slash_if_present.end_with?('/') ? pathname_with_trailing_slash_if_present : pathname_with_trailing_slash_if_present[0, pathname_with_trailing_slash_if_present.rindex('/') + 1]
|
202
206
|
else
|
203
207
|
'/'
|
204
208
|
end
|
205
209
|
end
|
210
|
+
|
211
|
+
def search_engine_bot?
|
212
|
+
return false unless @env.key?('HTTP_USER_AGENT')
|
213
|
+
|
214
|
+
bots = %w[Googlebot/ bingbot/ YandexBot/ YandexWebmaster/ DuckDuckBot-Https/ Baiduspider/ Slurp Yahoo]
|
215
|
+
bots.any? { |bot| @env['HTTP_USER_AGENT'].include?(bot) }
|
216
|
+
end
|
217
|
+
|
218
|
+
def to_absolute_path(path)
|
219
|
+
absolute_path = path.blank? ? '/' : path
|
220
|
+
absolute_path = absolute_path.starts_with?('/') ? absolute_path : URL.join_paths(dirname, absolute_path)
|
221
|
+
URL.normalize_path_slash(path, absolute_path)
|
222
|
+
end
|
206
223
|
end
|
207
224
|
end
|