Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions 20/fonts/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

AddType application/x-apple-aspen-config .mobileconfig
Header add Access-Control-Allow-Origin: "*"
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file added _control/.keep
Empty file.
3 changes: 3 additions & 0 deletions api/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

RewriteEngine on
RewriteRule "^(.+)$" "https://api.keyman.com/cloud/$1" [P]
19 changes: 0 additions & 19 deletions api/web.config

This file was deleted.

15 changes: 0 additions & 15 deletions applicationHost.xdt

This file was deleted.

47 changes: 47 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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"

5 changes: 5 additions & 0 deletions code/.htaccess
Original file line number Diff line number Diff line change
@@ -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]
18 changes: 8 additions & 10 deletions code/_get-version.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?php
class KeymanVersion {
private $downloadsApiVersionUrl;
require_once('autoload.php');

function __construct() {
$this->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;
}
Expand Down
24 changes: 24 additions & 0 deletions code/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
spl_autoload_register(function ($class_name) {
if(preg_match('/^Keyman\\\\Site\\\\com\\\\keyman\\\\api\\\\(.+)/', $class_name, $matches)) {
// Fix namespace pathing for Linux
$filename = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $matches[1]);
$success = @include(__DIR__ . "/2020/{$filename}.php");
if($success === FALSE) {
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
die("Unable to find class $class_name");
}
}
});

spl_autoload_register(function ($class_name) {
if(preg_match('/^Keyman\\\\Site\\\\Common\\\\(.+)/', $class_name, $matches)) {
// Fix namespace pathing for Linux
$filename = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $matches[1]);
$success = @include(__DIR__ . "/../_common/{$filename}.php");
if($success === FALSE) {
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
die("Unable to find class $class_name");
}
}
});
23 changes: 0 additions & 23 deletions code/web.config

This file was deleted.

5 changes: 5 additions & 0 deletions kbd/.htaccess
Original file line number Diff line number Diff line change
@@ -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]
13 changes: 0 additions & 13 deletions kbd/web.config

This file was deleted.

1 change: 1 addition & 0 deletions resources/.bootstrap-required-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.15
14 changes: 14 additions & 0 deletions resources/keyman-site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<FilesMatch .md$>
SetHandler text/html
</FilesMatch>

DirectoryIndex index.md index.php index.html

<Directory /var/www/html>
Options +Includes +FollowSymLinks -MultiViews
AllowOverride All
</Directory>

# php_value include_path "/var/www/html/_includes:."

SSLProxyEngine On
17 changes: 0 additions & 17 deletions web.config

This file was deleted.