Several translation-related improvements.

- Move common stuff for the landing page and search page from the content to the
layout such that the stuff only exists once instead of being cut & pasted into
each translation.

- Fixed the Chinese search page so it works and displays correctly.

- Correctly set the "lang" attribute on the <html> element to
reflect the correct language instead of being hardcoded to "en".
This commit is contained in:
mtail 2018-06-13 22:02:37 -07:00
parent 9a2e0a3276
commit 94ff6c9c44
7 changed files with 128 additions and 264 deletions

View File

@ -125,18 +125,4 @@ title: Istio
</div>
</div>
</div>
<style>
header .navbar {
box-shadow: none;
}
body {
padding-top: 2.8rem;
}
.navbar-brand {
visibility: hidden;
}
</style>
</main>

View File

@ -2,103 +2,6 @@
title: Search Results
url: /search.html
sidebar_none: true
type: search
toc: false
---
<style>
.gs-webResult div.gs-visibleUrl-long, .gs-promotion div.gs-visibleUrl-long {
padding-bottom: 0;
}
table, th, td, tr {
border: 0;
padding: 0;
}
table {
margin-left: .5em;
margin-right: 0;
}
table p:first-of-type {
margin-top: 0;
}
table p:last-of-type {
margin-bottom: 0
}
tr.oneof>td {
border: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
tr:first-child th:first-child {
border: 0;
}
tr:first-child td:first-child {
border: 0;
}
tr:first-child th:last-child {
border: 0;
}
tr:first-child td:last-child {
border: 0;
}
tr:last-child td {
border: 0;
}
tr:last-child td:first-child {
border: 0;
}
tr:last-child td:last-child {
border: 0;
}
tr th:last-child {
border: 0;
}
tr td:last-child {
border: 0;
}
</style>
<div class="search-results">
<script>
(function() {
var cx = '{{< search_engine_id >}}';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>
</div>
<script>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var q = getParameterByName('q', window.location.href);
document.getElementsByName('q')[0].value = q;
</script>

View File

@ -1,42 +1,6 @@
---
title: Istio
---
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"url": "https://istio.io",
"logo": "https://istio.io/img/logo.png",
"sameAs": [
"https://twitter.com/IstioMesh",
"https://istio.rocket.chat/"
]
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "https://istio.io/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://istio.io/search.html?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": "Istio",
"image": [
"https://istio.io/img/logo.png"
],
"description": "Istio是一个用来连接、管理和保护微服务的开放平台。"
}
</script>
<main class="landing">
<div class="hero">
<div class="container">
@ -123,18 +87,4 @@ title: Istio
</div>
</div>
</div>
<style>
header .navbar {
box-shadow: none;
}
body {
padding-top: 2.8rem;
}
.navbar-brand {
visibility: hidden;
}
</style>
</main>

View File

@ -1,104 +1,7 @@
---
title: 搜索结果
url: /search.html
url: /cn/search.html
sidebar_none: true
type: search
toc: false
---
<style>
.gs-webResult div.gs-visibleUrl-long, .gs-promotion div.gs-visibleUrl-long {
padding-bottom: 0;
}
table, th, td, tr {
border: 0;
padding: 0;
}
table {
margin-left: .5em;
margin-right: 0;
}
table p:first-of-type {
margin-top: 0;
}
table p:last-of-type {
margin-bottom: 0
}
tr.oneof>td {
border: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
tr:first-child th:first-child {
border: 0;
}
tr:first-child td:first-child {
border: 0;
}
tr:first-child th:last-child {
border: 0;
}
tr:first-child td:last-child {
border: 0;
}
tr:last-child td {
border: 0;
}
tr:last-child td:first-child {
border: 0;
}
tr:last-child td:last-child {
border: 0;
}
tr th:last-child {
border: 0;
}
tr td:last-child {
border: 0;
}
</style>
<div class="search-results">
<script>
(function() {
var cx = '{{< search_engine_id >}}';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>
</div>
<script>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var q = getParameterByName('q', window.location.href);
document.getElementsByName('q')[0].value = q;
</script>

View File

@ -1,7 +1,7 @@
{{ $home := .Site.BaseURL }}
<!DOCTYPE html>
<html lang="en" itemscope itemtype="https://schema.org/WebPage">
<html lang="{{ .Site.Language }}" itemscope itemtype="https://schema.org/WebPage">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

View File

@ -1,3 +1,17 @@
{{ define "main" }}
{{ .Content }}
<style>
header .navbar {
box-shadow: none;
}
body {
padding-top: 2.8rem;
}
.navbar-brand {
visibility: hidden;
}
</style>
{{ end }}

108
layouts/search/list.html Normal file
View File

@ -0,0 +1,108 @@
{{ define "main" }}
{{ partial "primary-top.html" . }}
<style>
.gs-webResult div.gs-visibleUrl-long, .gs-promotion div.gs-visibleUrl-long {
padding-bottom: 0;
}
table, th, td, tr {
border: 0;
padding: 0;
}
table {
margin-left: .5em;
margin-right: 0;
}
table p:first-of-type {
margin-top: 0;
}
table p:last-of-type {
margin-bottom: 0
}
tr.oneof>td {
border: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
tr:first-child th:first-child {
border: 0;
}
tr:first-child td:first-child {
border: 0;
}
tr:first-child th:last-child {
border: 0;
}
tr:first-child td:last-child {
border: 0;
}
tr:last-child td {
border: 0;
}
tr:last-child td:first-child {
border: 0;
}
tr:last-child td:last-child {
border: 0;
}
tr th:last-child {
border: 0;
}
tr td:last-child {
border: 0;
}
</style>
<div class="search-results">
<script>
(function() {
var cx = '{{ .Site.Data.args.search_engine_id }}';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>
</div>
<script>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var q = getParameterByName('q', window.location.href);
document.getElementsByName('q')[0].value = q;
</script>
{{ .Content }}
{{ partial "primary-bottom.html" . }}
{{ end }}