2014-01-09 17:33:20 -05:00
|
|
|
// Copyright © 2013 Steve Francia <spf@spf13.com>.
|
|
|
|
//
|
|
|
|
// Licensed under the Simple Public 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://opensource.org/licenses/Simple-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.
|
|
|
|
|
2014-04-23 02:52:01 -04:00
|
|
|
package hugolib
|
2014-01-09 17:33:20 -05:00
|
|
|
|
|
|
|
type Tmpl struct {
|
2014-01-29 17:50:31 -05:00
|
|
|
Name string
|
|
|
|
Data string
|
2014-01-09 17:33:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *GoHtmlTemplate) EmbedShortcodes() {
|
2014-02-25 23:57:31 -05:00
|
|
|
t.AddInternalShortcode("highlight.html", `{{ .Get 0 | highlight .Inner }}`)
|
|
|
|
t.AddInternalShortcode("test.html", `This is a simple Test`)
|
|
|
|
t.AddInternalShortcode("figure.html", `<!-- image -->
|
|
|
|
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
|
|
|
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
|
2014-10-08 10:54:50 -04:00
|
|
|
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }}{{ with .Get "width" }}width="{{.}}"{{ end }} />
|
2014-02-25 23:57:31 -05:00
|
|
|
{{ if .Get "link"}}</a>{{ end }}
|
|
|
|
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
|
2014-01-09 17:33:20 -05:00
|
|
|
<figcaption>{{ if isset .Params "title" }}
|
2014-02-25 23:57:31 -05:00
|
|
|
<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 }}
|
2014-01-09 17:33:20 -05:00
|
|
|
</p> {{ end }}
|
|
|
|
</figcaption>
|
|
|
|
{{ end }}
|
|
|
|
</figure>
|
|
|
|
<!-- image -->`)
|
|
|
|
}
|
2014-04-09 17:45:34 -04:00
|
|
|
|
|
|
|
func (t *GoHtmlTemplate) EmbedTemplates() {
|
|
|
|
|
|
|
|
t.AddInternalTemplate("_default", "rss.xml", `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
|
|
<channel>
|
|
|
|
<title>{{ .Title }} on {{ .Site.Title }} </title>
|
2014-09-27 03:35:42 -04:00
|
|
|
<generator uri="https://gohugo.io">Hugo</generator>
|
2014-04-09 17:45:34 -04:00
|
|
|
<link>{{ .Permalink }}</link>
|
|
|
|
{{ with .Site.LanguageCode }}<language>{{.}}</language>{{end}}
|
2014-04-23 02:52:01 -04:00
|
|
|
{{ with .Site.Author.name }}<author>{{.}}</author>{{end}}
|
2014-04-09 17:45:34 -04:00
|
|
|
{{ with .Site.Copyright }}<copyright>{{.}}</copyright>{{end}}
|
|
|
|
<updated>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</updated>
|
|
|
|
{{ range first 15 .Data.Pages }}
|
|
|
|
<item>
|
|
|
|
<title>{{ .Title }}</title>
|
|
|
|
<link>{{ .Permalink }}</link>
|
|
|
|
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</pubDate>
|
2014-04-23 02:52:01 -04:00
|
|
|
{{with .Site.Author.name}}<author>{{.}}</author>{{end}}
|
2014-04-09 17:45:34 -04:00
|
|
|
<guid>{{ .Permalink }}</guid>
|
|
|
|
<description>{{ .Content | html }}</description>
|
|
|
|
</item>
|
|
|
|
{{ end }}
|
|
|
|
</channel>
|
|
|
|
</rss>`)
|
|
|
|
|
2014-05-06 06:50:23 -04:00
|
|
|
t.AddInternalTemplate("_default", "sitemap.xml", `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
|
|
{{ range .Data.Pages }}
|
|
|
|
<url>
|
|
|
|
<loc>{{ .Permalink }}</loc>
|
|
|
|
<lastmod>{{ safeHtml ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ with .Sitemap.ChangeFreq }}
|
2014-05-06 11:02:56 -04:00
|
|
|
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
|
|
|
|
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}
|
2014-05-06 06:50:23 -04:00
|
|
|
</url>
|
|
|
|
{{ end }}
|
|
|
|
</urlset>`)
|
|
|
|
|
2014-04-23 02:52:01 -04:00
|
|
|
t.AddInternalTemplate("", "disqus.html", `{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var disqus_shortname = '{{ .Site.DisqusShortname }}';
|
|
|
|
var disqus_identifier = '{{with .GetParam "disqus_identifier" }}{{ . }}{{ else }}{{ .Permalink }}{{end}}';
|
|
|
|
var disqus_title = '{{with .GetParam "disqus_title" }}{{ . }}{{ else }}{{ .Title }}{{end}}';
|
|
|
|
var disqus_url = '{{with .GetParam "disqus_url" }}{{ . | html }}{{ else }}{{ .Permalink }}{{end}}';
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
|
|
|
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
|
|
|
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
|
|
|
})();
|
|
|
|
</script>
|
|
|
|
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
|
|
|
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>{{end}}`)
|
|
|
|
|
2014-04-09 17:45:34 -04:00
|
|
|
}
|