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 = '