diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e03bc9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Shared files are bootstrapped: +resources/bootstrap.inc.sh +resources/.bootstrap-version +resources/.bootstrap-registry +_common/ + +# State files +_control/debug +_control/release diff --git a/20/fonts/.htaccess b/20/fonts/.htaccess new file mode 100644 index 0000000..50f21b4 --- /dev/null +++ b/20/fonts/.htaccess @@ -0,0 +1,3 @@ + +AddType application/x-apple-aspen-config .mobileconfig +Header add Access-Control-Allow-Origin: "*" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a233eef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# syntax=docker/dockerfile:1 + +# Site +FROM php:7.4-apache@sha256:c9d7e608f73832673479770d66aacc8100011ec751d1905ff63fae3fe2e0ca6d +COPY resources/keyman-site.conf /etc/apache2/conf-available/ +RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini +RUN chown -R www-data:www-data /var/www/html/ +RUN a2enmod rewrite headers proxy proxy_http ssl; a2enconf keyman-site diff --git a/README.md b/README.md index 4d32450..c4be7c1 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,5 @@ r.keymanweb.com - legacy site for keymanweb * api/ redirects to https://api.keyman.com/cloud/ * code/bml.php is the bookmarklet * kbd/ are the endpoints for Chinese and Japanese keyboard pickers. + +Setup to run on Docker \ No newline at end of file diff --git a/_control/.keep b/_control/.keep new file mode 100644 index 0000000..e69de29 diff --git a/api/.htaccess b/api/.htaccess new file mode 100644 index 0000000..15264cc --- /dev/null +++ b/api/.htaccess @@ -0,0 +1,3 @@ + +RewriteEngine on +RewriteRule "^(.+)$" "https://api.keyman.com/cloud/$1" [P] diff --git a/api/web.config b/api/web.config deleted file mode 100644 index 648f2f7..0000000 --- a/api/web.config +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/applicationHost.xdt b/applicationHost.xdt deleted file mode 100644 index 359fa38..0000000 --- a/applicationHost.xdt +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..9aa76a0 --- /dev/null +++ b/build.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +## START STANDARD SITE BUILD SCRIPT INCLUDE +readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh" +BOOTSTRAP_VERSION="$(cat "$(dirname "THIS_SCRIPT")/resources/.bootstrap-required-version")" || exit 1 +readonly BOOTSTRAP_VERSION +if ! [ -f "$BOOTSTRAP" ] || ! source "$BOOTSTRAP"; then + curl -H "Cache-Control: no-cache" --fail --silent --show-error -w "curl: Finished attempt to download %{url}" "https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh" -o "$BOOTSTRAP.tmp" || exit 1 + source "$BOOTSTRAP.tmp" + rm -f "$BOOTSTRAP.tmp" +fi +## END STANDARD SITE BUILD SCRIPT INCLUDE + +readonly R_KEYMANWEB_CONTAINER_NAME=r-keymanweb-com-website +readonly R_KEYMANWEB_CONTAINER_DESC=r-keymanweb-com-app +readonly R_KEYMANWEB_IMAGE_NAME=r-keymanweb-com-website +readonly HOST_R_KEYMANWEB_COM=r.keymanweb.com.localhost +readonly PORT_R_KEYMANWEB_COM=8062 + +source _common/keyman-local-ports.inc.sh +source _common/docker.inc.sh + +################################ Main script ################################ + +builder_describe \ + "Setup r.keymanweb.com site to run via Docker." \ + configure \ + clean \ + build \ + start \ + stop \ + test \ + "--no-unit-test" \ + "--no-lint" \ + "--no-link-check" + +builder_parse "$@" + + +builder_run_action configure bootstrap_configure +builder_run_action clean clean_docker_container $R_KEYMANWEB_IMAGE_NAME $R_KEYMANWEB_CONTAINER_NAME +builder_run_action stop stop_docker_container $R_KEYMANWEB_IMAGE_NAME $R_KEYMANWEB_CONTAINER_NAME +builder_run_action build build_docker_container $R_KEYMANWEB_IMAGE_NAME $R_KEYMANWEB_CONTAINER_NAME $BUILDER_CONFIGURATION +builder_run_action start start_docker_container $R_KEYMANWEB_IMAGE_NAME $R_KEYMANWEB_CONTAINER_NAME $R_KEYMANWEB_CONTAINER_DESC $HOST_R_KEYMANWEB_COM $PORT_R_KEYMANWEB_COM $BUILDER_CONFIGURATION + +builder_run_action test test_docker_container $R_KEYMANWEB_CONTAINER_DESC $PORT_R_KEYMANWEB_COM "/_test" + diff --git a/code/.htaccess b/code/.htaccess new file mode 100644 index 0000000..836955d --- /dev/null +++ b/code/.htaccess @@ -0,0 +1,5 @@ + +RewriteEngine on +RewriteRule "^get-version(\/([^/]+)(\/([^/]+))?)?$" "https://api.keyman.com/script/version/version.php?platform=$2&level=$4" [P] +RewriteRule "^get-version.php" "https://api.keyman.com/script/version/version.php" [QSA,P] +RewriteRule "^bml20.php" "bml.php" [QSA,L] diff --git a/code/_get-version.php b/code/_get-version.php index bb34209..e3f746e 100644 --- a/code/_get-version.php +++ b/code/_get-version.php @@ -1,27 +1,25 @@ downloadsApiVersionUrl = 'https://downloads.keyman.com/api/version'; - } + use Keyman\Site\Common\KeymanHosts; + class KeymanVersion { function remove_utf8_bom($text) { $bom = pack('H*','EFBBBF'); $text = preg_replace("/^$bom/", '', $text); return $text; } - + function getVersion($platform, $level) { - $json = @file_get_contents("{$this->downloadsApiVersionUrl}/$platform"); + $json = @file_get_contents(KeymanHosts::Instance()->SERVER_downloads_keyman_com . "/api/version/$platform"); if($json !== NULL && $json !== FALSE) { - $json = $this->remove_utf8_bom($json); + $json = $this->remove_utf8_bom($json); $json = json_decode($json); - + if($json !== NULL && $json !== FALSE) { if(property_exists($json, $platform)) { - $json = $json->$platform; + $json = $json->$platform; if($json !== NULL && property_exists($json, $level)) { return $json->$level; } diff --git a/code/autoload.php b/code/autoload.php new file mode 100644 index 0000000..02964e1 --- /dev/null +++ b/code/autoload.php @@ -0,0 +1,24 @@ + - - - - - - - - - - - - - - - - - - - - - - diff --git a/kbd/.htaccess b/kbd/.htaccess new file mode 100644 index 0000000..8ccdb33 --- /dev/null +++ b/kbd/.htaccess @@ -0,0 +1,5 @@ +# Proxy /kbd/japanese.php and /kbd/chinese_pinyin.php to +# api.keyman.com/script/cjk/... (including parameters) + +RewriteEngine on +RewriteRule "^((japanese\.php|chinese_pinyin\.php).*)$" "https://api.keyman.com/script/cjk/$1" [P] diff --git a/kbd/web.config b/kbd/web.config deleted file mode 100644 index d47dcf0..0000000 --- a/kbd/web.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/resources/.bootstrap-required-version b/resources/.bootstrap-required-version new file mode 100644 index 0000000..64f2c94 --- /dev/null +++ b/resources/.bootstrap-required-version @@ -0,0 +1 @@ +v1.0.15 \ No newline at end of file diff --git a/resources/keyman-site.conf b/resources/keyman-site.conf new file mode 100644 index 0000000..3ba2b40 --- /dev/null +++ b/resources/keyman-site.conf @@ -0,0 +1,14 @@ + + SetHandler text/html + + +DirectoryIndex index.md index.php index.html + + + Options +Includes +FollowSymLinks -MultiViews + AllowOverride All + + +# php_value include_path "/var/www/html/_includes:." + +SSLProxyEngine On diff --git a/web.config b/web.config deleted file mode 100644 index a2cca1c..0000000 --- a/web.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - -