diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-05-04 17:53:56 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-05-04 23:12:10 +0200 |
commit | 34ad9a4f178fcf50abe7246ad9d30b294327da16 (patch) | |
tree | 897c9094913420fb1bb6a413332f946d298b8d4f /tpl | |
parent | 914cc85e22af2e6c28f24a5fc70de94e4b9f1b1b (diff) |
tpl/tplimpl: Extract internal templates
Having them in separate files should make maintainance easier.
When adding new or making changes to the templates:
```bash
mage generate
```
This will get the Go code in sync.
Fixes #4457
Diffstat (limited to 'tpl')
26 files changed, 515 insertions, 162 deletions
diff --git a/tpl/tplimpl/embedded/generate/generate.go b/tpl/tplimpl/embedded/generate/generate.go new file mode 100644 index 000000000..14b877c55 --- /dev/null +++ b/tpl/tplimpl/embedded/generate/generate.go @@ -0,0 +1,96 @@ +// Copyright 2018 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:generate go run generate.go + +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" +) + +func main() { + + templateFolder := filepath.Join("..", "templates") + + temlatePath := filepath.Join(".", templateFolder) + + file, err := os.Create("../templates.autogen.go") + if err != nil { + log.Fatal(err) + } + defer file.Close() + + var nameValues []string + + err = filepath.Walk(temlatePath, func(path string, info os.FileInfo, err error) error { + + if info.IsDir() { + return nil + } + if strings.HasPrefix(info.Name(), ".") { + return nil + } + + templateName := filepath.ToSlash(strings.TrimPrefix(path, templateFolder+string(os.PathSeparator))) + + templateContent, err := ioutil.ReadFile(path) + if err != nil { + return err + } + + nameValues = append(nameValues, nameValue(templateName, string(templateContent))) + + return nil + }) + + if err != nil { + log.Fatal(err) + } + + fmt.Fprint(file, `// Copyright 2018 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file is autogenerated. + +// Package embedded defines the internal templates that Hugo provides. +package embedded + +var EmbeddedTemplates = [][2]string{ +`) + + for _, v := range nameValues { + fmt.Fprint(file, " ", v, ",\n") + } + fmt.Fprint(file, "}\n") + +} + +func nameValue(name, value string) string { + return fmt.Sprintf("{`%s`, `%s`}", name, value) +} diff --git a/tpl/tplimpl/template_embedded.go b/tpl/tplimpl/embedded/templates.autogen.go index 18bba44f2..d30352502 100644 --- a/tpl/tplimpl/template_embedded.go +++ b/tpl/tplimpl/embedded/templates.autogen.go @@ -1,4 +1,4 @@ -// Copyright 2017-present The Hugo Authors. All rights reserved. +// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,56 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package tplimpl +// This file is autogenerated. -func (t *templateHandler) embedShortcodes() { - t.addInternalShortcode("ref.html", `{{ if len .Params | eq 2 }}{{ ref .Page (.Get 0) (.Get 1) }}{{ else }}{{ ref .Page (.Get 0) }}{{ end }}`) - t.addInternalShortcode("relref.html", `{{ if len .Params | eq 2 }}{{ relref .Page (.Get 0) (.Get 1) }}{{ else }}{{ relref .Page (.Get 0) }}{{ end }}`) - t.addInternalShortcode("highlight.html", `{{ if len .Params | eq 2 }}{{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .Inner "\n\r") (.Get 0) "" }}{{ end }}`) - t.addInternalShortcode("test.html", `This is a simple Test`) - t.addInternalShortcode("figure.html", `<!-- image --> -<figure{{ with .Get "class" }} class="{{.}}"{{ end }}> - {{ if .Get "link"}}<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>{{ end }} - <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}{{ with .Get "height" }}height="{{.}}" {{ end }}/> - {{ if .Get "link"}}</a>{{ end }} - {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} - <figcaption>{{ if isset .Params "title" }} - <h4>{{ .Get "title" }}</h4>{{ end }} - {{ if or (.Get "caption") (.Get "attr")}}<p> - {{ .Get "caption" }} - {{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }} - {{ .Get "attr" }} - {{ if .Get "attrlink"}}</a> {{ end }} - </p> {{ end }} - </figcaption> - {{ end }} -</figure> -<!-- image -->`) - t.addInternalShortcode("speakerdeck.html", "<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>") - t.addInternalShortcode("youtube.html", `{{ if .IsNamedParams }} -<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> - <iframe src="//www.youtube.com/embed/{{ .Get "id" }}?{{ with .Get "autoplay" }}{{ if eq . "true" }}autoplay=1{{ end }}{{ end }}" - {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0" title="YouTube Video"></iframe> -</div>{{ else }} -<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> - <iframe src="//www.youtube.com/embed/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0" title="YouTube Video"></iframe> - </div> -{{ end }}`) - t.addInternalShortcode("vimeo.html", `{{ if .IsNamedParams }}<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> - <iframe src="//player.vimeo.com/video/{{ .Get "id" }}" {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> - </div>{{ else }} -<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> - <iframe src="//player.vimeo.com/video/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> - </div> -{{ end }}`) - t.addInternalShortcode("gist.html", `<script src="//gist.github.com/{{ index .Params 0 }}/{{ index .Params 1 }}.js{{if len .Params | eq 3 }}?file={{ index .Params 2 }}{{end}}"></script>`) - t.addInternalShortcode("tweet.html", `{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}`) - t.addInternalShortcode("instagram.html", `{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }}`) -} - -func (t *templateHandler) embedTemplates() { +// Package embedded defines the internal templates that Hugo provides. +package embedded - t.addInternalTemplate("_default", "rss.xml", `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> +var EmbeddedTemplates = [][2]string{ + {`_default/robots.txt`, `User-agent: *`}, + {`_default/rss.xml`, `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> <link>{{ .Permalink }}</link> @@ -85,9 +43,8 @@ func (t *templateHandler) embedTemplates() { </item> {{ end }} </channel> -</rss>`) - - t.addInternalTemplate("_default", "sitemap.xml", `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" +</rss>`}, + {`_default/sitemap.xml`, `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> {{ range .Data.Pages }} <url> @@ -107,10 +64,8 @@ func (t *templateHandler) embedTemplates() { />{{ end }} </url> {{ end }} -</urlset>`) - - // For multilanguage sites - t.addInternalTemplate("_default", "sitemapindex.xml", `<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> +</urlset>`}, + {`_default/sitemapindex.xml`, `<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> {{ range . }} <sitemap> <loc>{{ .SitemapAbsURL }}</loc> @@ -120,52 +75,8 @@ func (t *templateHandler) embedTemplates() { </sitemap> {{ end }} </sitemapindex> -`) - - t.addInternalTemplate("", "pagination.html", `{{ $pag := $.Paginator }} -{{ if gt $pag.TotalPages 1 }} -<ul class="pagination"> - {{ with $pag.First }} - <li> - <a href="{{ .URL }}" aria-label="First"><span aria-hidden="true">««</span></a> - </li> - {{ end }} - <li - {{ if not $pag.HasPrev }}class="disabled"{{ end }}> - <a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a> - </li> - {{ $.Scratch.Set "__paginator.ellipsed" false }} - {{ range $pag.Pagers }} - {{ $right := sub .TotalPages .PageNumber }} - {{ $showNumber := or (le .PageNumber 3) (eq $right 0) }} - {{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }} - {{ if $showNumber }} - {{ $.Scratch.Set "__paginator.ellipsed" false }} - {{ $.Scratch.Set "__paginator.shouldEllipse" false }} - {{ else }} - {{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }} - {{ $.Scratch.Set "__paginator.ellipsed" true }} - {{ end }} - {{ if $showNumber }} - <li - {{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li> - {{ else if ($.Scratch.Get "__paginator.shouldEllipse") }} - <li class="disabled"><span aria-hidden="true">…</span></li> - {{ end }} - {{ end }} - <li - {{ if not $pag.HasNext }}class="disabled"{{ end }}> - <a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" aria-label="Next"><span aria-hidden="true">»</span></a> - </li> - {{ with $pag.Last }} - <li> - <a href="{{ .URL }}" aria-label="Last"><span aria-hidden="true">»»</span></a> - </li> - {{ end }} -</ul> -{{ end }}`) - - t.addInternalTemplate("", "disqus.html", `{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div> +`}, + {`disqus.html`, `{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div> <script> var disqus_config = function () { {{with .GetParam "disqus_identifier" }}this.page.identifier = '{{ . }}';{{end}} @@ -184,10 +95,30 @@ func (t *templateHandler) embedTemplates() { })(); </script> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> -<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>{{end}}`) +<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>{{end}}`}, + {`google_analytics.html`, `{{ with .Site.GoogleAnalytics }} +<script> +(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ +(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), +m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) +})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - // Add SEO & Social metadata - t.addInternalTemplate("", "opengraph.html", `<meta property="og:title" content="{{ .Title }}" /> +ga('create', '{{ . }}', 'auto'); +ga('send', 'pageview'); +</script> +{{ end }}`}, + {`google_analytics_async.html`, `{{ with .Site.GoogleAnalytics }} +<script> +window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; +ga('create', '{{ . }}', 'auto'); +ga('send', 'pageview'); +</script> +<script async src='//www.google-analytics.com/analytics.js'></script> +{{ end }}`}, + {`google_news.html`, `{{ if .IsPage }}{{ with .Params.news_keywords }} + <meta name="news_keywords" content="{{ range $i, $kw := first 10 . }}{{ if $i }},{{ end }}{{ $kw }}{{ end }}" /> +{{ end }}{{ end }}`}, + {`opengraph.html`, `<meta property="og:title" content="{{ .Title }}" /> <meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" /> <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" /> <meta property="og:url" content="{{ .Permalink }}" /> @@ -229,9 +160,106 @@ func (t *templateHandler) embedTemplates() { {{ end }}{{ end }} <!-- Facebook Page Admin ID for Domain Insights --> -{{ with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}`) +{{ with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}`}, + {`pagination.html`, `{{ $pag := $.Paginator }} +{{ if gt $pag.TotalPages 1 }} +<ul class="pagination"> + {{ with $pag.First }} + <li> + <a href="{{ .URL }}" aria-label="First"><span aria-hidden="true">««</span></a> + </li> + {{ end }} + <li + {{ if not $pag.HasPrev }}class="disabled"{{ end }}> + <a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a> + </li> + {{ $.Scratch.Set "__paginator.ellipsed" false }} + {{ range $pag.Pagers }} + {{ $right := sub .TotalPages .PageNumber }} + {{ $showNumber := or (le .PageNumber 3) (eq $right 0) }} + {{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }} + {{ if $showNumber }} + {{ $.Scratch.Set "__paginator.ellipsed" false }} + {{ $.Scratch.Set "__paginator.shouldEllipse" false }} + {{ else }} + {{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }} + {{ $.Scratch.Set "__paginator.ellipsed" true }} + {{ end }} + {{ if $showNumber }} + <li + {{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li> + {{ else if ($.Scratch.Get "__paginator.shouldEllipse") }} + <li class="disabled"><span aria-hidden="true">…</span></li> + {{ end }} + {{ end }} + <li + {{ if not $pag.HasNext }}class="disabled"{{ end }}> + <a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" aria-label="Next"><span aria-hidden="true">»</span></a> + </li> + {{ with $pag.Last }} + <li> + <a href="{{ .URL }}" aria-label="Last"><span aria-hidden="true">»»</span></a> + </li> + {{ end }} +</ul> +{{ end }}`}, + {`schema.html`, `{{ with .Site.Social.GooglePlus }}<link rel="publisher" href="{{ . }}"/>{{ end }} +<meta itemprop="name" content="{{ .Title }}"> +<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"> - t.addInternalTemplate("", "twitter_cards.html", `{{- with $.Params.images -}} +{{if .IsPage}}{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}{{ if not .PublishDate.IsZero }} +<meta itemprop="datePublished" content="{{ .PublishDate.Format $ISO8601 | safeHTML }}" />{{ end }} +{{ if not .Date.IsZero }}<meta itemprop="dateModified" content="{{ .Date.Format $ISO8601 | safeHTML }}" />{{ end }} +<meta itemprop="wordCount" content="{{ .WordCount }}"> +{{ with .Params.images }}{{ range first 6 . }} + <meta itemprop="image" content="{{ . | absURL }}"> +{{ end }}{{ end }} + +<!-- Output all taxonomies as schema.org keywords --> +<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" /> +{{ end }}`}, + {`shortcodes/figure.html`, `<!-- image --> +<figure{{ with .Get "class" }} class="{{.}}"{{ end }}> + {{ if .Get "link"}}<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>{{ end }} + <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}{{ with .Get "height" }}height="{{.}}" {{ end }}/> + {{ if .Get "link"}}</a>{{ end }} + {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} + <figcaption>{{ if isset .Params "title" }} + <h4>{{ .Get "title" }}</h4>{{ end }} + {{ if or (.Get "caption") (.Get "attr")}}<p> + {{ .Get "caption" }} + {{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }} + {{ .Get "attr" }} + {{ if .Get "attrlink"}}</a> {{ end }} + </p> {{ end }} + </figcaption> + {{ end }} +</figure> +<!-- image -->`}, + {`shortcodes/gist.html`, `<script src="//gist.github.com/{{ index .Params 0 }}/{{ index .Params 1 }}.js{{if len .Params | eq 3 }}?file={{ index .Params 2 }}{{end}}"></script>`}, + {`shortcodes/highlight.html`, `{{ if len .Params | eq 2 }}{{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .Inner "\n\r") (.Get 0) "" }}{{ end }}`}, + {`shortcodes/instagram.html`, `{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }}`}, + {`shortcodes/ref.html`, `{{ if len .Params | eq 2 }}{{ ref .Page (.Get 0) (.Get 1) }}{{ else }}{{ ref .Page (.Get 0) }}{{ end }}`}, + {`shortcodes/relref.html`, `{{ if len .Params | eq 2 }}{{ relref .Page (.Get 0) (.Get 1) }}{{ else }}{{ relref .Page (.Get 0) }}{{ end }}`}, + {`shortcodes/speakerdeck.html`, `<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>`}, + {`shortcodes/tweet.html`, `{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}`}, + {`shortcodes/vimeo.html`, `{{ if .IsNamedParams }}<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> + <iframe src="//player.vimeo.com/video/{{ .Get "id" }}" {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> + </div>{{ else }} +<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> + <iframe src="//player.vimeo.com/video/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> + </div> +{{ end }}`}, + {`shortcodes/youtube.html`, `{{ if .IsNamedParams }} +<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> + <iframe src="//www.youtube.com/embed/{{ .Get "id" }}?{{ with .Get "autoplay" }}{{ if eq . "true" }}autoplay=1{{ end }}{{ end }}" + {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0" title="YouTube Video"></iframe> +</div>{{ else }} +<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> + <iframe src="//www.youtube.com/embed/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0" title="YouTube Video"></iframe> + </div> +{{ end }}`}, + {`twitter_cards.html`, `{{- with $.Params.images -}} <meta name="twitter:card" content="summary_large_image"/> <meta name="twitter:image" content="{{ index . 0 | absURL }}"/> {{ else -}} @@ -259,48 +287,5 @@ func (t *templateHandler) embedTemplates() { {{ with .twitter -}} <meta name="twitter:creator" content="@{{ . }}"/> {{ end -}} -{{ end -}}`) - - t.addInternalTemplate("", "google_news.html", `{{ if .IsPage }}{{ with .Params.news_keywords }} - <meta name="news_keywords" content="{{ range $i, $kw := first 10 . }}{{ if $i }},{{ end }}{{ $kw }}{{ end }}" /> -{{ end }}{{ end }}`) - - t.addInternalTemplate("", "schema.html", `{{ with .Site.Social.GooglePlus }}<link rel="publisher" href="{{ . }}"/>{{ end }} -<meta itemprop="name" content="{{ .Title }}"> -<meta itemprop="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"> - -{{if .IsPage}}{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}{{ if not .PublishDate.IsZero }} -<meta itemprop="datePublished" content="{{ .PublishDate.Format $ISO8601 | safeHTML }}" />{{ end }} -{{ if not .Date.IsZero }}<meta itemprop="dateModified" content="{{ .Date.Format $ISO8601 | safeHTML }}" />{{ end }} -<meta itemprop="wordCount" content="{{ .WordCount }}"> -{{ with .Params.images }}{{ range first 6 . }} - <meta itemprop="image" content="{{ . | absURL }}"> -{{ end }}{{ end }} - -<!-- Output all taxonomies as schema.org keywords --> -<meta itemprop="keywords" content="{{ if .IsPage}}{{ range $index, $tag := .Params.tags }}{{ $tag }},{{ end }}{{ else }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ printf "%s," $term }}{{ end }}{{ end }}{{ end }}" /> -{{ end }}`) - - t.addInternalTemplate("", "google_analytics.html", `{{ with .Site.GoogleAnalytics }} -<script> -(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ -(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), -m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - -ga('create', '{{ . }}', 'auto'); -ga('send', 'pageview'); -</script> -{{ end }}`) - - t.addInternalTemplate("", "google_analytics_async.html", `{{ with .Site.GoogleAnalytics }} -<script> -window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; -ga('create', '{{ . }}', 'auto'); -ga('send', 'pageview'); -</script> -<script async src='//www.google-analytics.com/analytics.js'></script> -{{ end }}`) - - t.addInternalTemplate("_default", "robots.txt", "User-agent: *") +{{ end -}}`}, } diff --git a/tpl/tplimpl/embedded/templates/README.md b/tpl/tplimpl/embedded/templates/README.md new file mode 100644 index 000000000..034c383d1 --- /dev/null +++ b/tpl/tplimpl/embedded/templates/README.md @@ -0,0 +1,5 @@ + + +## Build Templates + +If you add or modify any template in this folder, you also need to run `mage generate` to get the Go code in synch.
\ No newline at end of file diff --git a/tpl/tplimpl/embedded/templates/_default/robots.txt b/tpl/tplimpl/embedded/templates/_default/robots.txt new file mode 100755 index 000000000..4f9540ba3 --- /dev/null +++ b/tpl/tplimpl/embedded/templates/_default/robots.txt @@ -0,0 +1 @@ +User-agent: *
\ No newline at end of file |