diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7e49d373..a7d2ceb0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: shell: bash run: | echo "TIER_TEST" > tier.txt - ./build.sh build start + ./build.sh configure build start env: fail-fast: true diff --git a/.gitignore b/.gitignore index 8b78388e1..ca9b124ac 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ node_modules/ resources/bootstrap.inc.sh resources/.bootstrap-version _common/ + +# Cache of keyboard metadata, deleted on site rebuild +keyboard/index.cache \ No newline at end of file diff --git a/.htaccess b/.htaccess index aecd0a3ef..8f136d55c 100644 --- a/.htaccess +++ b/.htaccess @@ -26,6 +26,28 @@ ErrorDocument 404 /_includes/errors/404.php?uri=%{REQUEST_URI} # Handle IIS bug which created links to /DEVELOPER instead of /developer RedirectMatch "/DEVELOPER(.*)" "/developer$1" +# +# Keyboard redirects -- must go before current-version +# + +# Redirect broken legacy keyboard links +RewriteRule "^keyboard/gff_(mdx|muz|suq)_7(/.*)?" "keyboard/gff_mym_7$2" [R,L] + +RewriteRule "^keyboard/redir.php(.*)$" - [END] + +# Rewrite /keyboard/[name][/] to /keyboard/redir.php?q=[name] +# only if index.php does not exist in the folder +RewriteCond "%{DOCUMENT_ROOT}/keyboard/$1/index.php" !-f +RewriteRule "^keyboard/(?!redir.php)([^/?]+)(/)?$" "keyboard/redir.php?q=$1" [END] + +# Rewrite /keyboard/name/current-version[/] to /keyboard/redir.php?q=[name] +RewriteRule "^keyboard/(?!redir.php)([^/?]+)/current-version(/)?$" "keyboard/redir.php?q=$1" [END] + +# Rewrite /keyboard/[name]/[version][/] to /keyboard/redir.php?q=[name]&v=[version] +# only if index.php does not exist in the folder +RewriteCond "%{DOCUMENT_ROOT}/keyboard/$1/$2/index.php" !-f +RewriteRule "^keyboard/(?!redir.php)([^/?]+)/([^/?]+)(/)?$" "keyboard/redir.php?q=$1&v=$2" [END] + # versioning: these rules automatically redirect /foo/current-version to the # newest version of the documentation under /foo, e.g. 13.0, /foo/13.0, and fall # back to previous versions if no newer version is available. When we release a @@ -156,24 +178,6 @@ Redirect "/kb" "/knowledge-base" # Redirect to kb handler RewriteRule "^knowledge-base/(\d+)$" "/knowledge-base/index.php?id=$1" [L] -# -# Keyboard redirects -# - -# Redirect broken legacy keyboard links -RewriteRule "^keyboard/gff_(mdx|muz|suq)_7(/.*)?" "keyboard/gff_mym_7$2" [R,L] - -RewriteRule "^keyboard/redir.php(.*)$" - [END] - -# Rewrite /keyboard/[name][/] to /keyboard/redir.php?q=[name] -# only if index.php does not exist in the folder -RewriteCond "%{DOCUMENT_ROOT}/keyboard/$1/index.php" !-f -RewriteRule "^keyboard/(?!redir.php)([^/?]+)(/)?$" "keyboard/redir.php?q=$1" [END] - -# Rewrite /keyboard/[name]/[version][/] to /keyboard/redir.php?q=[name]&v=[version] -# only if index.php does not exist in the folder -RewriteCond "%{DOCUMENT_ROOT}/keyboard/$1/$2/index.php" !-f -RewriteRule "^keyboard/(?!redir.php)([^/?]+)/([^/?]+)(/)?$" "keyboard/redir.php?q=$1&v=$2" [END] # diff --git a/_includes/header.php b/_includes/header.php index 21ef0e606..10dfcf791 100644 --- a/_includes/header.php +++ b/_includes/header.php @@ -9,13 +9,15 @@ $pagetitle = '?'; } if($folders[1] == 'keyboard'){ + $canonicalLink = "/keyboard/" . $folders[2] . "/current-version"; head([ 'title' =>$pagetitle, 'pagename' => isset($pagename) ? $pagename : $pagetitle, 'css' => ['template.css','keyboard.css','keys.css'], 'js' => ['kbd-docs.js'], 'showMenu' => true, - 'includeKMW' => $IncludeKeymanWeb + 'includeKMW' => $IncludeKeymanWeb, + 'canonicalLink' => $canonicalLink, ]); }else{ head([ diff --git a/_includes/includes/head.php b/_includes/includes/head.php index 976d650a6..a7028a52c 100644 --- a/_includes/includes/head.php +++ b/_includes/includes/head.php @@ -55,6 +55,7 @@ + \n"; ?> diff --git a/_includes/includes/kb_doc_template.php b/_includes/includes/kb_doc_template.php index 1968da739..ee763f627 100644 --- a/_includes/includes/kb_doc_template.php +++ b/_includes/includes/kb_doc_template.php @@ -1,10 +1,10 @@ 1 && $url[1] == 'keyboard') { $url = end($url); - + if(preg_match('/([a-z0-9_]+)/', $url, $sub)) { $kbdname = 'Keyboard_' . $sub[0]; } } + if(isset($args['canonicalLink'])) { + $canonicalLink = $args['canonicalLink']; + } + require_once('head.php'); if($menu == true) { require_once ('phone-menu.php'); @@ -84,14 +89,14 @@ function head($args=[]){ } else { require_once ('no-menu.php'); } - + $foot = isset($args['foot']) ? $args['foot'] : true; $shutdown = 'template_finish'; register_shutdown_function($shutdown,$foot); - + begin_main($args['pagename']); } - + function write_breadcrumbs(){ $crumbs = explode("/",$_SERVER["REQUEST_URI"]); $crumbcount = count($crumbs); @@ -125,22 +130,22 @@ function write_breadcrumbs(){ } echo $crumbtrail; } - + function write_version_history($pagename){ global $kbdname; - + // if(empty($kbdname)) return ''; - + $path = '../'; $results = scandir($path); if(!is_array($results)){ return ''; } rsort($results); - + if(empty($pagename)) $pagename = ''; - + $string = '

All Documentation Versions


'; return $string; } - + function begin_main($pagename){ global $version_history; write_breadcrumbs(); @@ -177,15 +182,15 @@ function begin_main($pagename){ if(!empty($pagename)){ $html.='

'.$pagename.'

'; } - + echo $html; } - + function foot($args=[]){ // Args are display=true/false; - + global $version_history; - + if(isset($args['display'])){ $display = $args['display']; }else{ @@ -198,8 +203,8 @@ function foot($args=[]){ }else{ require_once('no-footer.php'); } - } - + } + function renderLanguageExamples($kbdname = '') { global $languageExamplesRendered, $kbdname; @@ -217,7 +222,7 @@ function renderLanguageExamples($kbdname = '') if(!isset($languageExamplesRendered) && !empty($kbdname)) { $languageExamplesRendered = true; - + $s = renderLanguageExample($kbdname, '', '', false); if(!empty($s)) echo "
$s
"; } diff --git a/cdn/dev/css/template.css b/cdn/dev/css/template.css index 40e54d90d..bab50a6a1 100644 --- a/cdn/dev/css/template.css +++ b/cdn/dev/css/template.css @@ -979,7 +979,7 @@ input[type="search"] { -moz-columns: 2; } -#keyboard-support-list{ +.keyboard-support-list{ margin-bottom: 20px; columns: 4; -webkit-columns: 4; @@ -997,11 +997,11 @@ input[type="search"] { text-align: center; } -#keyboard-support-list li, #product-support-list li, #engine-support-list li, #version-history li{ +.keyboard-support-list li, #product-support-list li, #engine-support-list li, #version-history li{ list-style: none !important; } -#keyboard-support-list li a, #product-support-list li a, #engine-support-list li a, #version-history li a{ +.keyboard-support-list li a, #product-support-list li a, #engine-support-list li a, #version-history li a{ color: #B92034; text-decoration: underline; } @@ -1535,7 +1535,7 @@ body[data-device='Unknown'] #osk-tablet-container { margin: 10px 10px 15px 10px; text-align: center; } - #keyboard-support-list{ + .keyboard-support-list{ columns: 2; -webkit-columns: 2; -moz-columns: 2; diff --git a/keyboard/index.php b/keyboard/index.php index f47f24a25..2dc588d8a 100644 --- a/keyboard/index.php +++ b/keyboard/index.php @@ -1,36 +1,49 @@ array(), 'deprecated' => array()); + foreach($dirs as $directory){ + $version = '1.0'; + $versions = array_filter(glob($directory . '/*'), 'is_dir'); + if(count($versions) == 0) continue; + //var_dump($versions); + $filename = array_pop($versions).'/'.$directory.'.php'; + if(!file_exists($filename)) continue; + $s = @file_get_contents($filename); + + if(preg_match('/\$pagename\s*=\s*[\'"](.*)[\'"]\s*;/', $s, $sub)){ + $title = $sub[1]; + } else if(preg_match('/\$pagetitle\s*=\s*[\'"](.*)[\'"]\s*;/', $s, $sub)){ + $title = $sub[1]; + } else { + continue; // not a keyboard help file + } + + if(substr($title,0,1) == '$') { + continue; + } + + if(preg_match('/^(.*)\s+Keyboard\s+Help/i', $title, $sub)) { + $title = stripslashes($sub[1]); + } + + $dep = strpos($title, "(deprecated)"); + if($dep !== false) { + $items['deprecated'][$directory] = trim(substr($title, 0, $dep)); + } else { + $items['active'][$directory] = $title; + } } - $items[$directory] = $title; + + file_put_contents(INDEX_CACHE, json_encode($items)); + } else { + $items = json_decode(file_get_contents(INDEX_CACHE), true); } - - // Required head([ 'title' =>'Keyman Support | Type to the world in your language', @@ -40,11 +53,20 @@ ]); ?>

Keyboard Layouts Help Index

-