Remove shortcode 'code' (#19035)

A long time ago, we added a new shortcode `codenew` as a replacement of
the `code` shortcode. The intention was to consolidate all example
manifests to a single subdirectory, i.e. `content/<lang>/examples`. Now
this transition is almost over. We have only two instances where the old
`code` shortcode is referenced.

This PR makes the `policy.rego` file inlined content so that all
referenes to `code` are killed. We can safely drop the `code` shortcode.
If desired, we can rename the `codenew` shortcode to `code` in a
(series of) separate PR(s).
This commit is contained in:
Qiming Teng
2020-02-11 11:52:00 +08:00
committed by GitHub
parent 2faf1024d9
commit b550c6c051
5 changed files with 152 additions and 188 deletions
-38
View File
@@ -1,38 +0,0 @@
{{ $p := .Page }}
{{ $file := .Get "file" }}
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
{{ $fileDir := path.Split $file }}
{{ $bundlePath := path.Join .Page.File.Dir $fileDir.Dir }}
{{ $filename := path.Join $p.File.Dir $file }}
{{ $ghlink := printf "https://%s/blob/master/content/%s/%s" site.Params.githubwebsiterepo .Page.Lang $filename | safeURL }}
{{/* First assume this is a bundle and the file is inside it. */}}
{{ $resource := $p.Resources.GetMatch (printf "%s*" $file ) }}
{{ with $resource }}
{{ $.Scratch.Set "content" .Content }}
{{ else }}
{{/* Read the file relative to the content root. */}}
{{ $resource := readFile $filename}}
{{ with $resource }}{{ $.Scratch.Set "content" . }}{{ end }}
{{ end }}
{{ if not ($.Scratch.Get "content") }}
{{ errorf "[%s] %q not found in %q" site.Language.Lang $fileDir.File $bundlePath }}
{{ end }}
{{ with $.Scratch.Get "content" }}
<table class="includecode" id="{{ $file | anchorize }}">
<thead>
<tr>
<th>
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}
<code>{{ $file }} {{ $bundlePath }}</code>
{{ if $ghlink }}</a>{{ end }}
<img src="{{ "images/copycode.svg" | relURL }}" style="max-height:24px" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard">
</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ highlight . $codelang "" }} </td>
</tr>
</tbody>
</table>
{{ end }}