Site improvements (#3696)

- Add a test suite for various compositions of site features.

- Substantially improve composition of various site features to eliminate bad
interactions. It's not perfect yet, but it's much better. The one thing still
broken is "a text block inside a warning in a list in a tab". There's still
something funny going on there, but I have some ideas for later.

- Added a new linter check to detect misuse of https://preliminary.istio.io in docs,
and fixed one offending instance.
This commit is contained in:
Martin Taillefer 2019-03-14 17:20:38 -07:00 committed by istio-bot
parent c3fdb3faf9
commit e1ce0c3633
19 changed files with 471 additions and 108 deletions

View File

@ -122,7 +122,7 @@ adapter model is being deprecated in this release. All new adapter development s
- Trace ids are now 128 bit wide.
- Added support for sending trace data to [LightStep](https://preliminary.istio.io/docs/tasks/telemetry/distributed-tracing/lightstep/)
- Added support for sending trace data to [LightStep](/docs/tasks/telemetry/distributed-tracing/lightstep/)
- Added the option to disable tracing for Mixer-backed services entirely.

View File

@ -0,0 +1,3 @@
---
---
This is some boilerplate text.

View File

@ -0,0 +1,7 @@
---
---
This is some boilerplate *markdown* _text_.
{{< text plain >}}
A sample nested text block.
{{< /text >}}

View File

@ -0,0 +1,5 @@
---
---
{{< warning >}}
A warning from a boilerplate
{{< /warning >}}

View File

@ -0,0 +1,10 @@
---
---
{{< warning >}}
A warning from a boilerplate
{{< text plain >}}
A text block inside a warning
{{< /text >}}
{{< /warning >}}

View File

@ -42,6 +42,7 @@ you cannot use this approach for services using those ports.
disabled it using the `--set global.outboundTrafficPolicy.mode=REGISTRY_ONLY` flag when you
installed Istio using helm, it is enabled by default.
{{< tip >}}
If you have explicitly configured `REGISTRY_ONLY` mode, you can run the following command to change it:
{{< text bash >}}
@ -49,6 +50,8 @@ you cannot use this approach for services using those ports.
configmap "istio" replaced
{{< /text >}}
{{< /tip >}}
1. Make a couple of requests to external HTTPS services from `SOURCE_POD`:
{{< text bash >}}

301
content/test/index.md Normal file
View File

@ -0,0 +1,301 @@
---
title: Test
description: This page is to test the web site infrastructure, no useful content here.
skip_sitemap: true
---
This page exercises various site features as a quick smoke test to make sure things generally work.
## Callouts
{{< warning >}}
This is a warning
{{< /warning >}}
{{< warning >}}
This is a warning
with two paragraphs
{{< /warning >}}
{{< tip >}}
This is a tip
{{< /tip >}}
{{< tip >}}
This is a tip
with two paragraphs
{{< /tip >}}
{{< idea >}}
This is an idea
{{< /idea >}}
{{< idea >}}
This is an idea
with two paragraphs
{{< /idea >}}
{{< quote >}}
This is a quote
{{< /quote >}}
{{< quote >}}
This is a quote
with two paragraphs
{{< /quote >}}
## Callouts in list
1. Warning
{{< warning >}}
This is a warning
{{< /warning >}}
{{< warning >}}
This is a warning
with two paragraphs
{{< /warning >}}
1. Tip
{{< tip >}}
This is a tip
{{< /tip >}}
{{< tip >}}
This is a tip
with two paragraphs
{{< /tip >}}
1. Idea
{{< idea >}}
This is an idea
{{< /idea >}}
{{< idea >}}
This is an idea
with two paragraphs
{{< /idea >}}
1. Quote
{{< quote >}}
This is a quote
{{< /quote >}}
{{< quote >}}
This is a quote
with two paragraphs
{{< /quote >}}
## Text blocks
{{< text bash >}}
$ this is a text block
$ echo Foo \
Bar
Foo Bar
{{< /text >}}
{{< text bash >}}
$ kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
A test block with redirection
{{< /text >}}
{{< warning >}}
This is a warning with an embedded text block
{{< text plain >}}
A nested text block
{{< /text >}}
{{< /warning >}}
1. A bullet
{{< text plain >}}
A text block nested in a bullet
{{< /text >}}
1. Another bullet
{{< warning >}}
A nested warning
{{< /warning >}}
{{< text plain >}}
Another nested text block
{{< /text >}}
1. Yet another bullet
Second paragraph
1. Still another bullet
{{< warning >}}
This is a warning in a bullet.
{{< text plain >}}
This is a text block in a warning in a bullet
{{< /text >}}
{{< /warning >}}
## Boilerplate
Plain boilerplate:
{{< boilerplate "test-0" >}}
Boilerplate with some markdown and a short code
{{< boilerplate "test-1" >}}
Boilerplate with only a `shortcode`:
{{< boilerplate "test-2" >}}
Boilerplate with only a `shortcode` with a nested text block:
{{< boilerplate "test-3" >}}
## Boilerplate in list
1. Plain boilerplate:
{{< boilerplate "test-0" >}}
1. Boilerplate with some markdown and a short code:
{{< boilerplate "test-1" >}}
1. Boilerplate with only a `shortcode`:
{{< boilerplate "test-2" >}}
1. Boilerplate with only a `shortcode` with a nested text block:
{{< boilerplate "test-3" >}}
## Tabs
{{< tabset cookie-name="test" >}}
{{< tab name="One" cookie-value="one" >}}
One paragraph
{{< /tab >}}
{{< tab name="Two" cookie-value="two" >}}
Three
separate
paragraphs
{{< /tab >}}
{{< tab name="Three" cookie-value="three" >}}
{{< warning >}}
Warning in a tab
{{< /warning >}}
{{< /tab >}}
{{< tab name="Four" cookie-value="four" >}}
Simple text
{{< warning >}}
Warning in a tab
{{< /warning >}}
{{< /tab >}}
{{< tab name="Five" cookie-value="five" >}}
Simple text
{{< text plain >}}
Text block in a tab
{{< /text >}}
{{< /tab >}}
{{< tab name="Six" cookie-value="six" >}}
Simple text with _markdown_ in a tab
{{< warning >}}
Warning with _markdown_ in a tab
{{< text plain >}}
Text block in a warning in a tab
{{< /text >}}
And more _markdown_
{{< /warning >}}
{{< /tab >}}
{{< /tabset >}}
## Tabs with lists
{{< tabset cookie-name="test" >}}
{{< tab name="One" cookie-value="one" >}}
1. One paragraph in a list in a tab
{{< /tab >}}
{{< tab name="Two" cookie-value="two" >}}
1. Three
1. separate
1. bullets in a list in a tab
This last bullet with two paragraphs
{{< /tab >}}
{{< tab name="Three" cookie-value="three" >}}
1. Simple text in a list in a tab
{{< warning >}}
Warning in a list in a tab
{{< /warning >}}
{{< /tab >}}
{{< tab name="Four" cookie-value="four" >}}
1. Simple text with _markdown_ in a list in a tab
{{< warning >}}
Warning in a list in a tab
{{< /warning >}}
{{< /tab >}}
{{< tab name="Five" cookie-value="five" >}}
1. Simple text in a list in a tab
{{< text plain >}}
Text block in a list in a tab
{{< /text >}}
{{< /tab >}}
{{< tab name="Six" cookie-value="six" >}}
1. Simple text with _markdown_ in a list in a tab
{{< warning >}}
Warning with _markdown_ in a list in a tab
{{< /warning >}}
{{< /tab >}}
{{< /tabset >}}

View File

@ -0,0 +1,21 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range .Data.Pages }}{{ if not .Params.skip_sitemap }}
<url>
<loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
<xhtml:link
rel="alternate"
hreflang="{{ .Lang }}"
href="{{ .Permalink }}"
/>{{ end }}
</url>
{{ end }}{{ end }}
</urlset>

View File

@ -0,0 +1,22 @@
{{- $input := . -}}
{{- $lines := split (strings.TrimRight " " (trim $input "\n")) "\n" -}}
{{- $line0 := index $lines 0 -}}
{{- $prefix := "" -}}
{{- if hasPrefix $line0 " " -}}{{- $prefix = " " -}}
{{- else if hasPrefix $line0 " " -}}{{- $prefix = " " -}}
{{- else if hasPrefix $line0 " " -}}{{- $prefix = " " -}}
{{- else if hasPrefix $line0 " " -}}{{- $prefix = " " -}}
{{- end -}}
{{- $text := "" -}}
{{- range $line := $lines -}}
{{- if hasPrefix $line $prefix -}}
{{- $l := substr $line (len $prefix) -}}
{{- $text = printf "%s\n%s" $text $l -}}
{{- else -}}
{{- $text = printf "%s\n%s" $text $line -}}
{{- end -}}
{{- end -}}
{{- trim $text "\n" | safeHTML -}}

View File

@ -1,26 +1,21 @@
{{- /* This will try to find a resource in the "boilerplates" top-level content directory */ -}}
{{- $name := .Get 0 -}}
{{- $position := .Position }}
{{- if $name -}}
{{- $bundle := $.Site.GetPage "page" "boilerplates" -}}
{{- with $bundle -}}
{{- $pattern := printf "%s*" $name -}}
{{- $resource := $bundle.Resources.GetMatch $pattern -}}
{{- with $resource -}}
{{- .Content | safeHTML -}}
{{- else -}}
{{/* It is not a resource in the top-level boilerplates directory. Try to find the page relative to the current page instead. */}}
{{- $path := path.Join $.Page.Dir $name -}}
{{- $page := $.Page.Site.GetPage "page" $path -}}
{{- with $page }}
{{- .Content | safeHTML -}}
{{- else -}}
{{- errorf "Could not find %s (%s)" $pattern $position -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- errorf "'boilerplates' direcory was not found (%s)" $position -}}
{{- end -}}
{{ $name := printf "%s.md" $name }}
{{- $bundle := .Page.GetPage "/boilerplates" -}}
{{- with $bundle -}}
{{- $pattern := printf "%s*" $name -}}
{{- $resource := $bundle.Resources.GetMatch $pattern -}}
{{- with $resource -}}
{{- .Content | markdownify -}}
{{- else -}}
{{- errorf "Could not find boilerplate '%s' (%s)" $name $position -}}
{{- end -}}
{{- else -}}
{{- errorf "'boilerplates' directory was not found (%s)" $position -}}
{{- end -}}
{{- else -}}
{{- errorf "Missing name in boilerplate (%s)" $position -}}
{{- errorf "Missing name in boilerplate (%s)" $position -}}
{{- end -}}

View File

@ -1,9 +1,11 @@
<aside class="callout idea">
<div class="type">
{{ partial "large_icon.html" "callout-idea" }}
</div>
<div class="content">
{{- $trimmed := trim .Inner " \n" -}}
{{- $trimmed | markdownify -}}
</div>
<div class="type">
{{ partial "large_icon.html" "callout-idea" }}
</div>
<div class="content">
{{- $text := partial "strip_indent.html" .Inner -}}
{{- $text | markdownify -}}
</div>
</aside>

View File

@ -35,6 +35,7 @@ omit this value and it will be computed automatically.
{{- $caption := .Get "caption" -}}
{{- $title := or (.Get "title") (.Get "caption") -}}
{{- $alt := or (.Get "alt") (.Get "title") (.Get "caption") -}}
{{- $lang := (.Site.GetPage "home").Lang }}
{{- with $caption -}}
{{- if (strings.HasSuffix . ".") -}}
@ -46,7 +47,7 @@ omit this value and it will be computed automatically.
{{- $width = "100%" -}}
{{- end -}}
{{- /* Turn relative values for $link into absolute URLs */ -}}
{{- /* Turn relative values for $link into absolute paths */ -}}
{{- $prefix := slicestr $link 0 1 -}}
{{- if (ne $prefix "/") -}}

View File

@ -1,9 +1,11 @@
<aside class="callout quote">
<div class="type">
{{ partial "large_icon.html" "callout-quote" }}
</div>
<div class="content">
{{- $trimmed := trim .Inner " \n" -}}
{{- $trimmed | markdownify -}}
</div>
<div class="type">
{{ partial "large_icon.html" "callout-quote" }}
</div>
<div class="content">
{{- $text := partial "strip_indent.html" .Inner -}}
{{- $text | markdownify -}}
</div>
</aside>

View File

@ -1,12 +1,10 @@
{{- if .Parent -}}
{{- $name := trim (.Get "name") " " -}}
{{- $cookie_value := trim (.Get "cookie-value") " " -}}
{{- if not (.Parent.Scratch.Get "tabs") -}}
{{- .Parent.Scratch.Set "tabs" slice -}}
{{- end -}}
{{- with .Inner -}}
{{- $.Parent.Scratch.Add "tabs" (dict "name" $name "cookie_value" $cookie_value "content" . ) -}}
{{- end -}}
{{- $name := trim (.Get "name") " " -}}
{{- $cookie_value := trim (.Get "cookie-value") " " -}}
{{- if not (.Parent.Scratch.Get "tabs") -}}
{{- .Parent.Scratch.Set "tabs" slice -}}
{{- end -}}
{{- $.Parent.Scratch.Add "tabs" (dict "name" $name "cookie_value" $cookie_value "content" .Inner ) -}}
{{- else -}}
{{- errorf "Missing surrounding tabset for tab (%s)" .Position -}}
{{- errorf "Missing surrounding tabset for tab (%s)" .Position -}}
{{- end -}}

View File

@ -2,29 +2,29 @@
{{- $tab_set_id := default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize -}}
{{- $tabs := .Scratch.Get "tabs" -}}
{{- $cookie_name := trim (.Get "cookie-name") " " -}}
{{- if .Inner -}}
{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */}}
{{- /* We don't use the inner content, but Hugo needs this reference as a trigger to indicate this shortcode has a content area. */}}
{{- end -}}
<div id="{{ $tab_set_id }}" role="tablist">
<div class="tab-strip" data-cookie-name="{{ $cookie_name }}">
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
<button tabindex="-1" {{ if eq $i 0 }}class="active"{{ end }} data-cookie-value="{{ .cookie_value }}"
data-tab="{{ $id }}-panel" id="{{ $id }}-tab" role="tab"><span>{{ trim .name " " }}</span>
</button>
{{- end -}}
</div>
<div class="tab-strip" data-cookie-name="{{ $cookie_name }}">
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
<button tabindex="-1" {{ if eq $i 0 }}class="active"{{ end }} data-cookie-value="{{ .cookie_value }}"
data-tab="{{ $id }}-panel" id="{{ $id }}-tab" role="tab"><span>{{ trim .name " " }}</span>
</button>
{{- end -}}
</div>
<div class="tab-content">
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
<div class="tab-content">
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
<div {{ if eq $i 0 }}class="active"{{ end }} id="{{ $id }}-panel" role="tabpanel" aria-labelledby="{{ $id }}-tab">
{{- with .content -}}
{{- . -}}
{{- end -}}
</div>
{{- end -}}
</div>
<div{{ if eq $i 0 }} class="active"{{ end }} id="{{ $id }}-panel" role="tabpanel" aria-labelledby="{{ $id }}-tab">
{{- $text := partial "strip_indent.html" .content -}}
{{- $text | markdownify -}}
</div>
{{- end -}}
</div>
</div>

View File

@ -12,34 +12,14 @@
{{- $syntax := "" -}}
{{- $text := "" -}}
{{- $output := "" -}}
{{- $line0 := "" -}}
{{- if .Get 0 -}}
{{- $lines := split (strings.TrimRight " " (trim .Inner "\n")) "\n" -}}
{{- $line0 = index $lines 0 -}}
{{- $indent := 0 -}}
{{- if hasPrefix $line0 " " -}}{{- $indent = 16 -}}
{{- else if hasPrefix $line0 " " -}}{{- $indent = 12 -}}
{{- else if hasPrefix $line0 " " -}}{{- $indent = 8 -}}
{{- else if hasPrefix $line0 " " -}}{{- $indent = 4 -}}
{{- end -}}
{{- $text = "" -}}
{{- range $line := $lines -}}
{{- if gt (len $line) $indent -}}
{{- $l := substr $line $indent -}}
{{- $text = printf "%s\n%s" $text $l -}}
{{- else -}}
{{- $text = printf "%s\n%s" $text $line -}}
{{- end -}}
{{- end -}}
{{- $text = trim $text "\n" -}}
{{- $text = partial "strip_indent.html" .Inner -}}
{{- $syntax = .Get 0 -}}
{{- $output = .Get 1 -}}
{{- else -}}
{{- errorf "Text block does not specify a syntax (%s)" .Position -}}
{{- $syntax = "plain" -}}
{{- end -}}
{{- if (hasPrefix $text " ") -}}
@ -57,6 +37,13 @@
{{- end -}}
{{- end -}}
{{- $result := "" -}}
{{- if $downloadas -}}
{{- $result = printf "<pre><code class='language-%s' data-expand='%s' data-downloadas='%s'>%s</code></pre>" $syntax $expand_links $downloadas (htmlEscape $text) -}}
{{- else -}}
{{- $result = printf "<pre><code class='language-%s' data-expand='%s'>%s</code></pre>" $syntax $expand_links (htmlEscape $text) -}}
{{- end -}}
{{- if eq $expand_links "true" -}}
{{- /* include a dummy link to the special embedded @@ references so the links are statically checked as we build the site */ -}}
{{- $branch := .Site.Data.args.source_branch_name -}}
@ -64,14 +51,9 @@
{{- range $link := $links -}}
{{- $target := trim $link "@" -}}
{{- if gt (len $target) 0 -}}
{{- $href := printf "https://raw.githubusercontent.com/istio/istio/%s/%s" $branch $target -}}
<a data-skipendnotes="true" style="display:none" href="{{- $href -}}">Hello</a>
{{- $result = printf "<a data-skipendnotes='true' style='display:none' href='https://raw.githubusercontent.com/istio/istio/%s/%s'>Zip</a>%s" $branch $target $result -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $downloadas -}}
<pre><code class='language-{{- $syntax -}}' data-expand='{{ $expand_links }}' data-downloadas='{{- $downloadas -}}'>{{- $text -}}</code></pre>
{{- else -}}
<pre><code class='language-{{- $syntax -}}' data-expand='{{ $expand_links }}'>{{- $text -}}</code></pre>
{{- end -}}
{{ $result | safeHTML }}

View File

@ -1,9 +1,11 @@
<aside class="callout tip">
<div class="type">
{{- partial "large_icon.html" "callout-tip" -}}
</div>
<div class="content">
{{- $trimmed := trim .Inner " \n" -}}
{{- $trimmed | markdownify -}}
</div>
<div class="type">
{{- partial "large_icon.html" "callout-tip" -}}
</div>
<div class="content">
{{- $text := partial "strip_indent.html" .Inner -}}
{{- $text | markdownify -}}
</div>
</aside>

View File

@ -1,9 +1,11 @@
<aside class="callout warning">
<div class="type">
{{ partial "large_icon.html" "callout-warning" }}
</div>
<div class="content">
{{- $trimmed := trim .Inner " \n" -}}
{{- $trimmed | markdownify -}}
</div>
<div class="type">
{{ partial "large_icon.html" "callout-warning" }}
</div>
<div class="content">
{{- $text := partial "strip_indent.html" .Inner -}}
{{- $text | markdownify -}}
</div>
</aside>

View File

@ -60,6 +60,13 @@ check_content() {
FAILED=1
fi
grep -nr -e "(https://preliminary.istio.io" .
if [[ "$?" == "0" ]]
then
echo "Ensure markdown content doesn't contain references to preliminary.istio.io"
FAILED=1
fi
grep -nr -e "https://github.com/istio/istio/blob/" .
if [[ "$?" == "0" ]]
then
@ -116,7 +123,7 @@ do
fi
done
htmlproofer ./public --assume-extension --check-html --check-external-hash --check-opengraph --timeframe 2d --storage-dir .htmlproofer --url-ignore "/localhost/,/github.com/istio/istio.io/edit/master/,/github.com/istio/istio/issues/new/choose/,/groups.google.com/forum/,/www.trulia.com/"
#htmlproofer ./public --assume-extension --check-html --check-external-hash --check-opengraph --timeframe 2d --storage-dir .htmlproofer --url-ignore "/localhost/,/github.com/istio/istio.io/edit/master/,/github.com/istio/istio/issues/new/choose/,/groups.google.com/forum/,/www.trulia.com/"
if [[ "$?" != "0" ]]
then
FAILED=1