diff options
| Commit | ad823cc4d72edbab10f0dadf99b30df91c3f7c50 (patch) | |
|---|---|---|
| Author | 2020-08-16 08:38:04 +0300 | |
| Committer | 2020-08-16 08:38:04 +0300 | |
| Files | 6666a19acc2316d6ad5ad00291066d6d6fd42a5b /layouts | |
| IPL-ad823cc4d72edbab10f0dadf99b30df91c3f7c50.tar IPL-ad823cc4d72edbab10f0dadf99b30df91c3f7c50.tar.gz IPL-ad823cc4d72edbab10f0dadf99b30df91c3f7c50.zip | ||
Squashed 'website/themes/reveal-hugo/' content from commit ff9f389
git-subtree-dir: website/themes/reveal-hugo
git-subtree-split: ff9f389743ae2fe5c5cc6101455db0616e8548e2
18 files changed, 265 insertions, 0 deletions
| -rw-r--r-- | layouts/_default/baseof.reveal.html | 36 | ||||
| -rw-r--r-- | layouts/_default/bundle.reveal.html | 4 | ||||
| -rw-r--r-- | layouts/_default/index.reveal.html | 4 | ||||
| -rw-r--r-- | layouts/_default/list.reveal.html | 4 | ||||
| -rw-r--r-- | layouts/_default/single.reveal.html | 0 | ||||
| -rw-r--r-- | layouts/partials/layout/head.html | 7 | ||||
| -rw-r--r-- | layouts/partials/layout/javascript.html | 63 | ||||
| -rw-r--r-- | layouts/partials/layout/theme.html | 28 | ||||
| -rw-r--r-- | layouts/partials/reveal-hugo/body.html | 1 | ||||
| -rw-r--r-- | layouts/partials/reveal-hugo/end.html | 1 | ||||
| -rw-r--r-- | layouts/partials/reveal-hugo/head.html | 1 | ||||
| -rw-r--r-- | layouts/partials/reveal-hugo/slides.html | 26 | ||||
| -rw-r--r-- | layouts/shortcodes/frag.html | 4 | ||||
| -rw-r--r-- | layouts/shortcodes/fragment.html | 6 | ||||
| -rw-r--r-- | layouts/shortcodes/markdown.html | 8 | ||||
| -rw-r--r-- | layouts/shortcodes/note.html | 4 | ||||
| -rw-r--r-- | layouts/shortcodes/section.html | 5 | ||||
| -rw-r--r-- | layouts/shortcodes/slide.html | 63 |
diff --git a/layouts/_default/baseof.reveal.html b/layouts/_default/baseof.reveal.html new file mode 100644 index 0000000..a25a4d7 --- /dev/null +++ b/layouts/_default/baseof.reveal.html @@ -0,0 +1,36 @@ +<!doctype html> +<html lang="en"> + <head> + {{ partial "layout/head" . }} + {{ partial "layout/theme" . }} + <!-- To insert markup before the closing head tag for all presentations, + create layouts/partials/reveal-hugo/head.html --> + {{- partial "reveal-hugo/head" . -}} + <!-- To insert markup at the end of the head tag for a specific presentation, + create layouts/partials/{section}/reveal-hugo/head.html --> + {{- $sectionHeadPartial := printf "%s/reveal-hugo/head" (.Page.Section | default "home") -}} + {{- if fileExists (printf "layouts/partials/%s.html" $sectionHeadPartial) -}}{{ partial $sectionHeadPartial . }}{{- end }} + </head> + <body> + <div class="reveal"> + <div class="slides"> + {{- block "main" . -}}{{- end -}} + </div> + <!-- To insert markup at the end of the .reveal tag for all presentations, + create layouts/partials/reveal-hugo/end.html --> + {{- partial "reveal-hugo/end" . -}} + <!-- To insert markup at the end of the .reveal tag for a specific presentation, + create layouts/partials/{section}/reveal-hugo/end.html --> + {{- $sectionHeadPartial := printf "%s/reveal-hugo/end" (.Page.Section | default "home") -}} + {{- if fileExists (printf "layouts/partials/%s.html" $sectionHeadPartial) -}}{{ partial $sectionHeadPartial . }}{{- end }} + </div> + {{- partial "layout/javascript" . }} + <!-- To insert markup before the closing body tag for all presentations, + create layouts/partials/reveal-hugo/body.html --> + {{- partial "reveal-hugo/body" . }} + <!-- To insert markup at the end of the head tag for a specific presentation, + create layouts/partials/{section}/reveal-hugo/body.html --> + {{- $sectionBodyPartial := printf "%s/reveal-hugo/body" (.Page.Section | default "home") -}} + {{- if fileExists (printf "layouts/partials/%s.html" $sectionBodyPartial) -}}{{ partial $sectionBodyPartial . }}{{- end }} + </body> +</html> diff --git a/layouts/_default/bundle.reveal.html b/layouts/_default/bundle.reveal.html new file mode 100644 index 0000000..62fb5c8 --- /dev/null +++ b/layouts/_default/bundle.reveal.html @@ -0,0 +1,4 @@ +{{ define "main" }} + {{ partial "reveal-hugo/slides" (slice .Page) }} + {{ partial "reveal-hugo/slides" (.Resources.ByType "page") }} +{{ end }} diff --git a/layouts/_default/index.reveal.html b/layouts/_default/index.reveal.html new file mode 100644 index 0000000..1b4b67c --- /dev/null +++ b/layouts/_default/index.reveal.html @@ -0,0 +1,4 @@ +{{ define "main" }} + {{ partial "reveal-hugo/slides" (slice .Page) }} + {{ partial "reveal-hugo/slides" (where .Site.RegularPages "Type" "home") }} +{{ end }} diff --git a/layouts/_default/list.reveal.html b/layouts/_default/list.reveal.html new file mode 100644 index 0000000..63e4b9d --- /dev/null +++ b/layouts/_default/list.reveal.html @@ -0,0 +1,4 @@ +{{ define "main" }} + {{ partial "reveal-hugo/slides" (slice .Page) }} + {{ partial "reveal-hugo/slides" (where .Pages "Kind" "page") }} +{{ end }} diff --git a/layouts/_default/single.reveal.html b/layouts/_default/single.reveal.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/_default/single.reveal.html diff --git a/layouts/partials/layout/head.html b/layouts/partials/layout/head.html new file mode 100644 index 0000000..085923a --- /dev/null +++ b/layouts/partials/layout/head.html @@ -0,0 +1,7 @@ +<meta charset="utf-8"> +<title>{{ or .Page.Title .Site.Title }}</title> +{{ with $.Param "description" }}<meta name="description" content="{{ . }}">{{ end }} +{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }} +<meta name="apple-mobile-web-app-capable" content="yes"> +<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> +<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
\ No newline at end of file diff --git a/layouts/partials/layout/javascript.html b/layouts/partials/layout/javascript.html new file mode 100644 index 0000000..fe99cb9 --- /dev/null +++ b/layouts/partials/layout/javascript.html @@ -0,0 +1,63 @@ +<!-- polyfill needed for IE11 and below --> +<script type="text/javascript" src={{ "reveal-hugo/object-assign.js" | relURL }}></script> +<!-- Printing and PDF exports --> +<!-- use Hugo to create the right path for the print stylesheet, then conditionally include it --> +{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}} +<a href="{{ printf "%s/css/print/" $reveal_location | relURL }}" id="print-location" style="display: none;"></a> +<script type="text/javascript"> + var printLocationElement = document.getElementById('print-location'); + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = printLocationElement.href + (window.location.search.match(/print-pdf/gi) ? 'pdf.css' : 'paper.css'); + document.getElementsByTagName('head')[0].appendChild(link); +</script> +<!-- output Hugo parameters into JavaScript to be used when initializing Reveal.js --> +<script type="application/json" id="reveal-hugo-site-params">{{ jsonify .Site.Params.reveal_hugo | safeJS }}</script> +<script type="application/json" id="reveal-hugo-page-params">{{ jsonify .Page.Params.reveal_hugo | safeJS }}</script> +<!-- load Reveal.js javascripts --> +<script src="{{ printf "%s/js/reveal.js" $reveal_location | relURL }}"></script> +<!-- load Reveal.js plugins --> +<script type="text/javascript"> + // Hugo lowercases all params and Reveal.js needs camelcase + // So params in Hugo must be stored in snakecase and we camelize them here + function camelize(map) { + if (map) { + Object.keys(map).forEach(function(k) { + newK = k.replace(/(\_\w)/g, function(m) { return m[1].toUpperCase() }); + if (newK != k) { + map[newK] = map[k]; + delete map[k]; + } + }); + } + return map; + } + // pattern inspired by https://github.com/RealOrangeOne/hugo-theme-revealjs + var revealHugoDefaults = { center: true, controls: true, history: true, progress: true, transition: "slide" }; + var revealHugoSiteParams = JSON.parse(document.getElementById('reveal-hugo-site-params').innerHTML); + var revealHugoPageParams = JSON.parse(document.getElementById('reveal-hugo-page-params').innerHTML); + // See all options - https://github.com/hakimel/reveal.js#configuration + var options = Object.assign({}, + camelize(revealHugoDefaults), + camelize(revealHugoSiteParams), + camelize(revealHugoPageParams)); + Reveal.initialize(options); +</script> +<!-- load Reveal.js plugins after Reveal.js is initialized --> +{{ if $.Param "reveal_hugo.load_default_plugins" | default true }} + {{ $default_plugins := slice "plugin/markdown/marked.js" "plugin/markdown/markdown.js" "plugin/highlight/highlight.js" "plugin/zoom-js/zoom.js" }} + {{ range $default_plugins }} + <script type="text/javascript" src="{{ printf "%s/%s" $reveal_location . | relURL }}"></script> + {{ end }} + <!-- always use local version of the notes plugin since HTML file it requires isn't on CDN --> + <script type="text/javascript" src="{{ "reveal-js/plugin/notes/notes.js" | relURL }}"></script> +{{ end }} +<!-- load custom plugins locally only (not CDN since many plugins won't exist there) --> +{{ range $.Param "reveal_hugo.plugins" }} +<script type="text/javascript" src="{{ . | relURL }}"></script> +{{ end }} +{{- $custom_js := $.Param "reveal_hugo.custom_js" -}} +{{- if $custom_js -}} +<script type="text/javascript" src="{{ $custom_js | relURL }}"></script> +{{- end -}} diff --git a/layouts/partials/layout/theme.html b/layouts/partials/layout/theme.html new file mode 100644 index 0000000..a4f7c86 --- /dev/null +++ b/layouts/partials/layout/theme.html @@ -0,0 +1,28 @@ +<!-- Theme used for presentation --> +{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}} +{{- $highlight_location := $.Param "reveal_hugo.highlight_cdn" | default "highlight-js" -}} +{{- $custom_theme := $.Param "reveal_hugo.custom_theme" -}} +<link rel="stylesheet" href="{{ printf "%s/css/reset.css" $reveal_location | relURL }}"> +<link rel="stylesheet" href="{{ printf "%s/css/reveal.css" $reveal_location | relURL }}"> +{{- $custom_theme := $.Param "reveal_hugo.custom_theme" -}} +{{- if $custom_theme -}} + {{- $custom_theme_options := $.Param "reveal_hugo.custom_theme_options" | default dict -}} + {{- if $.Param "reveal_hugo.custom_theme_compile" -}} + {{ $asset := resources.Get $custom_theme | resources.ExecuteAsTemplate "_.scss" . | toCSS $custom_theme_options | minify | fingerprint }} + <link rel="stylesheet" href="{{ $asset.Permalink | relURL }}" id="theme"> + {{- else -}} + <link rel="stylesheet" href="{{ $custom_theme | relURL }}" id="theme"> + {{- end -}} +{{ else -}} + {{- $theme := $.Param "reveal_hugo.theme" | default "black" -}} + <link rel="stylesheet" href="{{ printf "%s/css/theme/%s.css" $reveal_location $theme | relURL }}" id="theme"> +{{ end -}} +{{ if $.Param "reveal_hugo.load_default_plugins" | default true -}} + <!-- Theme used for syntax highlighting of code --> + {{- $highlight_theme := $.Param "reveal_hugo.highlight_theme" | default "default" -}} + <link rel="stylesheet" href="{{ printf "%s/%s.min.css" $highlight_location $highlight_theme | relURL }}"> +{{- end }} +{{- $custom_css := $.Param "reveal_hugo.custom_css" -}} +{{- if $custom_css -}} +<link rel="stylesheet" href="{{ $custom_css | relURL }}" id="custom_css"> +{{- end -}} diff --git a/layouts/partials/reveal-hugo/body.html b/layouts/partials/reveal-hugo/body.html new file mode 100644 index 0000000..f2dd4bf --- /dev/null +++ b/layouts/partials/reveal-hugo/body.html @@ -0,0 +1 @@ +<!-- override this partial to add content before the body tag closes -->
\ No newline at end of file diff --git a/layouts/partials/reveal-hugo/end.html b/layouts/partials/reveal-hugo/end.html new file mode 100644 index 0000000..1ca9f46 --- /dev/null +++ b/layouts/partials/reveal-hugo/end.html @@ -0,0 +1 @@ +<!-- override this partial to add content before the .reveal tag closes --> diff --git a/layouts/partials/reveal-hugo/head.html b/layouts/partials/reveal-hugo/head.html new file mode 100644 index 0000000..ed1e892 --- /dev/null +++ b/layouts/partials/reveal-hugo/head.html @@ -0,0 +1 @@ +<!-- override this partial to add content before the head tag closes -->
\ No newline at end of file diff --git a/layouts/partials/reveal-hugo/slides.html b/layouts/partials/reveal-hugo/slides.html new file mode 100644 index 0000000..0bed8a9 --- /dev/null +++ b/layouts/partials/reveal-hugo/slides.html @@ -0,0 +1,26 @@ +<!-- Use the array of pages passed as a param --> +{{ range . -}} +<!-- Don't process empty content files --> + {{- if ne (len .Content) 0 -}} + <!-- Remove the <hr /> tag generated by blackfriday for footnotes --> + {{- $content := replace .Content "<div class=\"footnotes\">\n\n<hr />" "<div class=\"footnotes\">" -}} + <!-- <code> blocks processed by Hugo's highlighter have a data-lang attribute. For those, we disable --> + <!-- highlight.js by changing the language class to "nohighlight", and adding "data-noescape". --> + {{- $content := replaceRE `<code class="language-\w+"\s+data-lang="\w+"` `<code class="nohighlight" data-noescape` $content -}} + <!-- enable Highlight.js line numbers when the markdown code block language selection is followed by "{}" e.g. ```js{} --> + {{- $content := replaceRE `(<code class="language-\w+){}(">)` `$1" data-line-numbers>` $content -}} + <!-- enable Highlight.js line highlights when the language selection is followed by "{<line numbers>}" e.g. ```js{1,5-7} --> + {{- $content := replaceRE `(<code class="language-\w+){(\S+)}(">)` `$1" data-line-numbers="$2">` $content -}} + <!-- Support both <hr /> (blackfriday) and <hr> (mmark) --> + {{- $content := replace $content "<hr>" "<hr />" -}} + <!-- Split the processed content by <hr /> tag --> + {{- range (split $content "<hr />") -}} + <!-- Only wrap in <section> tag if not already wrapped by shortcode --> + {{- if not (in . "data-noprocess") -}} +<section> + {{- end -}} + {{- . | safeHTML -}} +</section> + {{- end -}} + {{- end -}} +{{- end }} diff --git a/layouts/shortcodes/frag.html b/layouts/shortcodes/frag.html new file mode 100644 index 0000000..c1de8c8 --- /dev/null +++ b/layouts/shortcodes/frag.html @@ -0,0 +1,4 @@ +<span class='fragment {{ .Get "class" }}' + {{ with .Get "index" }}data-fragment-index='{{ . }}'{{ end }}> + {{ .Get "c" }} +</span>
\ No newline at end of file diff --git a/layouts/shortcodes/fragment.html b/layouts/shortcodes/fragment.html new file mode 100644 index 0000000..bcd5627 --- /dev/null +++ b/layouts/shortcodes/fragment.html @@ -0,0 +1,6 @@ +{{/* Render .Inner before processing the shortcode. */}} +{{ $_hugo_config := `{ "version": 1 }` }} +<span class='fragment {{ .Get "class" }}' + {{ with .Get "index" }}data-fragment-index='{{ . }}'{{ end }}> + {{ .Inner }} +</span>
\ No newline at end of file diff --git a/layouts/shortcodes/markdown.html b/layouts/shortcodes/markdown.html new file mode 100644 index 0000000..f5effbc --- /dev/null +++ b/layouts/shortcodes/markdown.html @@ -0,0 +1,8 @@ +<section data-noprocess data-markdown + data-separator="^\r?\n---\r?\n$" + data-separator-vertical="^\r?\n------\r?\n$" + data-separator-notes="notes?:"> + <script type="text/template"> + {{ .Inner }} + </script> +</section>
\ No newline at end of file diff --git a/layouts/shortcodes/note.html b/layouts/shortcodes/note.html new file mode 100644 index 0000000..f5ee55e --- /dev/null +++ b/layouts/shortcodes/note.html @@ -0,0 +1,4 @@ +{{/* Markdown is not rendered inside <aside> tags! So we use the following */}} +{{/* config which causes .Inner to be rendered before processing the shortcode. */}} +{{ $_hugo_config := `{ "version": 1 }` }} +<aside class="notes">{{ .Inner }}</aside>
\ No newline at end of file diff --git a/layouts/shortcodes/section.html b/layouts/shortcodes/section.html new file mode 100644 index 0000000..7a2c9d0 --- /dev/null +++ b/layouts/shortcodes/section.html @@ -0,0 +1,5 @@ +{{/* Render .Inner before processing the shortcode. */}} +{{ $_hugo_config := `{ "version": 1 }` }} +<section data-shortcode-section> +{{ .Inner }} +</section>
\ No newline at end of file diff --git a/layouts/shortcodes/slide.html b/layouts/shortcodes/slide.html new file mode 100644 index 0000000..0016326 --- /dev/null +++ b/layouts/shortcodes/slide.html @@ -0,0 +1,63 @@ +{{- $scratch := .Scratch -}} +{{- $scratch.Set "slides" slice -}} +{{- $content := .Get "content" -}} +{{- if $content -}} + {{- $lookup := split $content "." }} + {{ $markdownContent := .Page.Site.Data }} + {{- range $dataPath := $lookup -}} + {{- $markdownContent = index $markdownContent $dataPath -}} + {{- end -}} + {{- $html := $markdownContent | markdownify -}} + {{- $html := replace $html "<hr>" "<hr />" -}} + {{- $slides := split $html "<hr />" -}} + {{- range $slides -}} + {{- $scratch.Add "slides" . -}} + {{- end -}} +{{- else -}} + {{- $scratch.Add "slides" "" -}} +{{- end -}} +{{- $params := . -}} +{{- $noPrefix := slice "id" "class" -}} +{{- $noOutput := slice "content" "template" -}} +{{- $template := $params.Get "template" -}} +{{- if $template -}} + {{- $scratch.Add "templateParams" slice -}} + {{- with $.Site.Params.reveal_hugo.templates -}} + {{- $scratch.Add "templateParams" . -}} + {{- end -}} + {{- if ne $.Page.File.LogicalName "_index.md" -}} + {{- $scratch.Add "templateParams" ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates -}} + {{- end -}} + {{- with $.Page.Params.reveal_hugo.templates -}} + {{- $scratch.Add "templateParams" . -}} + {{- end -}} + {{- $scratch.Add "templateParams" (slice $.Page.Params.reveal_hugo.templates) -}} + {{- $templateParams := $scratch.Get "templateParams" }} + {{- range $templateParams -}} + {{- if (ne . nil) -}} + {{- range $key, $value := (index . $template) -}} + {{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} +{{- range $sindex, $svalue := $scratch.Get "slides" }} +<section data-noprocess data-shortcode-slide +{{- if $template -}} + {{- range $key, $value := ($scratch.Get "template") }} + {{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }} + {{ $attrName | safeHTMLAttr }}="{{ $value }}" + {{- end }} + data-template="{{ $template }}" +{{- end -}} + {{- range $key, $value := $.Params -}} + {{- if not (in $noOutput $key) -}} + {{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }} + {{ $attrName | safeHTMLAttr }}="{{ $value }}" + {{- end -}} + {{- end -}}> + {{ $svalue | safeHTML }} +{{- if ne $sindex (sub (len ($scratch.Get "slides")) 1) -}} +</section> +{{- end -}} +{{- end -}} |
