Welcome to mirror list, hosted at ThFree Co, Russian Federation.

slides.html « partials « layouts - github.com/RCJacH/hugo-webslides.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 563464a356de02f71370ec21c2ec6022117da7c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{{ $.Scratch.Set "slideIDGlobal" 1 }}
<!-- Use the array of pages passed as a param -->
{{ range .Pages -}}
  {{ $.Scratch.Delete "slideClassGlobal" }}
  {{ $.Scratch.Set "slideClassGlobal" .Params.bg }}
<!-- 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\">" -}}
    <!-- Split the processed content by <hr /> tag -->
    {{- range $elem_val := split $content "<hr />" -}}
      <!-- Initialize Scratch Content -->
      {{- $.Scratch.Delete "contentClass" -}}
      {{- $.Scratch.Delete "secondaryClass" -}}
      {{- $.Scratch.Delete "slideID" -}}
      {{- $.Scratch.Delete "bgi" -}}
      {{- $.Scratch.Delete "bgPos" -}}
      {{- $.Scratch.Delete "bgImage" -}}
      {{- $.Scratch.Delete "bgType" -}}
      {{- $.Scratch.Delete "slideClass" -}}
      {{- $.Scratch.Delete "gridClass" -}}
      
      <!-- Get slide properties from first line with HTML comment -->
      {{- $first := index (findRE "<!--[ ]?: (.+) -->" $elem_val 1) 0 -}}
      {{- with $first -}}
        {{- $.Scratch.Set "contentClass" (replace (delimit (findRE " [.][^. ]+" $first) " ") " ." "") -}}
        {{- $.Scratch.Set "secondaryClass" (replace (delimit (findRE " [.][.][^. ]+" $first) " ") " .." "") -}}
        {{- $.Scratch.Set "slideID" (replace (delimit (findRE " #[^ ]+" $first) "-") " #" "") -}}
        {{- $.Scratch.Set "bgi" (replace (index (findRE " bgimage=[^ ]+" $first) 0) " bgimage=" "") -}}
        {{- $.Scratch.Set "bgPos" (replace (index (findRE " bgpos=[^ ]+" $first) 0) " bgpos=" "") -}}
        {{- if in ($.Scratch.Get "bgi") "|" -}}
          {{- $.Scratch.Set "bgImage" (index (split ($.Scratch.Get "bgi") "|") 1) -}}
          {{- $.Scratch.Set "bgType" (index (split ($.Scratch.Get "bgi") "|") 0) -}}
        {{- else -}}
          {{- $.Scratch.Set "bgImage" ($.Scratch.Get "bgi") -}}
        {{- end -}}
        {{- $.Scratch.Set "slideClass" (replace (delimit (findRE " bg=[^ ]+" $first) " ") " bg=" "") -}}
      {{- end -}}
      {{- $elem_val := replace $elem_val $first "" -}}

      <!-- Block class -->
      {{- $elem_val := replaceRE "<([^>]+)><!--[ ]?: [.](.+) -->" "<$1 class=\"$2\">" $elem_val -}}
      <!-- List class -->
      {{- $elem_val := replaceRE "<!--[ ]?: [.](.+) -->[\n]*<([uo]l)>" "<$2 class=\"$1\">" $elem_val }}
      <!-- Grid class -->
      {{- with index (findRE "<p>[|]{3,}[vsm]+" $elem_val) 0 -}}
        {{- if in . "v" -}}
          {{- $.Scratch.Set "gridClass" "vertical-align" -}}
        {{- else if in . "sms" -}}
          {{- $.Scratch.Set "gridClass" "sms" -}}
        {{- else if in . "ms" -}}
          {{- $.Scratch.Set "gridClass" "ms" -}}
        {{- else if in . "sm" -}}
          {{- $.Scratch.Set "gridClass" "sm" -}}
        {{- end -}}
      {{- end -}}
      {{- $elem_val := replaceRE "<p>[|]{3,}[vsm]+" "<p>|||" $elem_val -}}
      <!-- hr with two dashes -->
      {{- $elem_val := replaceRE "[\n]*<p>&ndash;</p>[\n]*" "<hr />" $elem_val }}

      <section id="{{- if $.Scratch.Get "slideID" }}{{ $.Scratch.Get "slideID" }}{{ else -}}slide{{- $.Scratch.Get "slideIDGlobal" -}}{{- end -}}"{{- with (or ($.Scratch.Get "slideClass") ($.Scratch.Get "slideClassGlobal")) }} class="{{- . -}}"{{- end -}}>
        {{- with $.Scratch.Get "bgImage" }}
        <span class="background{{- with $.Scratch.Get "bgPos" -}}-{{- . -}}{{- end -}}
        {{- if in ($.Scratch.Get "bgType") "d"}} dark{{- end -}}
        {{- if in ($.Scratch.Get "bgType") "l"}} light{{- end -}}" style="background-image:url('{{ . }}')"></span>
          {{- if in ($.Scratch.Get "bgType") "f" }}
        <span class="background frame"></span>
          {{- end -}}
        {{- end }}
        <div{{ with $.Scratch.Get "contentClass" }} class="{{ . }}"{{ end }}>
        {{- with $.Scratch.Get "secondaryClass" }}
          <div class="{{ . }}">
        {{- end -}}
        {{- $grid := split $elem_val "<p>|||</p>" -}}
        {{- $.Scratch.Set "grid" 0 -}}
        {{- range $grid_index, $grid_val := $grid -}}
          {{- if eq $grid_index 0 -}}
            {{ . | safeHTML }}
          {{- else -}}
            {{- if eq ($.Scratch.Get "grid") 0 }}
          <div class="grid{{- with $.Scratch.Get "gridClass"}} {{ . -}}{{- end -}}">
              {{- $.Scratch.Set "grid" 1 -}}
            {{- end }}
            <div class="column">{{ . | safeHTML}}</div>
            {{- if eq (add $grid_index 1) (len $grid) }}
          </div>
            {{- end -}}
          {{- end -}} <!-- grid_index -->
        {{- end }} <!-- range grid -->
        {{- with $.Scratch.Get "secondaryClass" }}
          </div>
        {{- end -}}
        </div>
      </section>
      {{- $.Scratch.Set "slideIDGlobal" (add ($.Scratch.Get "slideIDGlobal") 1) -}}
    {{- end -}} <!-- range content -->
  {{- end -}} <!-- if content -->
{{- end }} <!-- range .Pages -->