diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/content.html | 97 | ||||
-rw-r--r-- | templates/page.html | 112 |
2 files changed, 209 insertions, 0 deletions
diff --git a/templates/content.html b/templates/content.html new file mode 100644 index 0000000..73f18c7 --- /dev/null +++ b/templates/content.html @@ -0,0 +1,97 @@ +{{- if eq .Name "section" "content" -}} +{{- if .Title}} +<section class="cnm-section"><details open> + {{- inc .Title -}} + <summary> + {{- with .Title -}} + {{- if $l := lanchor -}} + <h{{depth}}>{{.}}<a class="sec-link" id="/{{$l}}" href="#/{{$l}}">ΒΆ</a> + {{- if $s := sanchor}}{{if ne $s $l}}<a id="#{{$s}}"></a>{{end}}{{end -}} + </h{{depth}}> + {{- end -}} + {{- end -}} + </summary> + {{- range .Children -}} + {{- template "content.html" . -}} + {{- end -}} + {{- dec -}} +</details></section> +{{else -}} +{{- range .Children -}} + {{- template "content.html" . -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{- if eq .Name "list" -}} +{{if .Ordered}}<ol{{else}}<ul{{end}} class="cnm-list"> + {{- range .Children -}} + {{- if eq .Name "list" -}} + {{- template "content.html" . -}} + {{- else -}} + <li>{{- template "content.html" . -}}</li> + {{- end -}} + {{- end -}} +{{- if .Ordered}}</ol>{{else}}</ul>{{end -}} +{{- end -}} + +{{- if eq .Name "table" -}} +<table class="cnm-table"> + {{- range .Rows -}} + {{- template "content.html" . -}} + {{- end -}} +</table> +{{- end -}} + +{{- if eq .Name "header" -}} +<tr class="cnm-header"> + {{- range .Children -}} + <th>{{template "content.html" .}}</th> + {{- end -}} +</tr> +{{- end -}} + +{{- if eq .Name "row" -}} +<tr class="cnm-row"> + {{- range .Children -}} + <td>{{template "content.html" .}}</td> + {{- end -}} +</tr> +{{- end -}} + +{{- if eq .Name "embed" -}} +<figure class="cnm-embed"> + {{- if eq .Type "image/png" "image/jpeg" "image/webp" "image/*" -}} + <a href="{{tourl .URL}}"><img src="{{tourl .URL}}" alt="{{with .Description}}{{.}}{{else}}embedded {{.Type}}{{end}}" {{with .Description}}title="{{.}}" {{end}}/></a> + {{- end -}} + {{- if eq .Type "video/mp4" "video/webm" "video/*" -}} + <video src="{{tourl .URL}}" controls{{with .Description}} title="{{.}}"{{end}}> + Video content: <a href="{{tourl .URL}}">{{.URL}}</a> + </video> + {{- end -}} + {{- if not (eq .Type "image/png" "image/jpeg" "image/webp" "image/*" "video/mp4" "video/webm" "video/*") -}} + <p> + Embedded <code>{{.Type}}</code> content: <a href="{{tourl .URL}}"{{with .Description}} title="{{.}}"{{end}}>{{.URL}}</a> + </p> + {{- end -}} + {{- with .Description}}<figcaption>{{.}}</figcaption>{{end -}} +</figure> +{{- end -}} + +{{- if eq .Name "text" -}} + {{- if eq .Format "" "plain"}}{{range .Contents.Paragraphs -}} +<p class="cnm-text">{{.}}</p> + {{- end}}{{end -}} + {{- if eq .Format "fmt" -}} + {{- range .Contents.Paragraphs -}} + {{- cnmfmt . -}} + {{- end -}} + {{- end -}} + {{- if not (eq .Format "" "plain" "fmt") -}} +<pre class="cnm-text cnm-text-pre">{{.Contents.Text}}</pre> + {{- end -}} +{{- end -}} + +{{- if eq .Name "raw" -}} +<pre class="cnm-raw"><code class="cnm-raw-{{lang .Syntax}}">{{.Contents}}</code></pre> +{{- end -}} diff --git a/templates/page.html b/templates/page.html new file mode 100644 index 0000000..0f89e2d --- /dev/null +++ b/templates/page.html @@ -0,0 +1,112 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>{{with .Doc.Title}}{{.}}{{else}} {{end}}</title> + <link rel="stylesheet" href="/static/style.css" /> + <style>main p,main summary,h1,h2,h3,h4,h5,h6{white-space: pre-wrap;}</style> + <script async src="/static/script.js"></script> + {{if .Highlight}}<link rel="stylesheet" href="/static/highlight/style.css" />{{end}} + </head> + <body> + <header> + {{if .Browser -}} + <form id="browser" action="/" method="post"> + <input type="text" name="url" placeholder="cnp://example.com/" value="{{if ne .URL "cnp:///"}}{{.URL}}{{end}}" /> + <input type="submit" value="Go" /> + </form> + {{- end}} + + {{with .Doc.Title}}<h1>{{.}}</h1>{{end -}} + + {{with .Doc.Links -}} + <nav> + <details open> + <summary><b>Links</b></summary> + <ul> + {{- range .}} + <li><a href="{{tourl .URL}}"{{with .Description}} title="{{.}}"{{end}}>{{with .Name}}{{.}}{{else}}{{.URL}}{{end}}</a></li> + {{- end}} + </ul> + </details> + </nav> + {{- end -}} + + {{with .Site -}} + <nav> + <details> + <summary><b>Sitemap</b></summary> + {{- block "site" . -}} + <ul> + {{- range . -}} + <li> + <a href="{{tourl .Path}}">{{.Name}}</a> + {{- template "site" .Children -}} + </li> + {{- end -}} + </ul> + {{- end -}} + </details> + </nav> + {{- end -}} + + {{if .Toc.Children -}} + <nav> + <details> + <summary><b>Table of Contents</b></summary> + <ul> + {{- range .Toc.Children -}} + {{- block "toc" . -}} + {{- inc .Title -}} + <li> + <a href="#/{{anchor}}">{{.Title}}</a> + {{- with .Children -}} + <ul> + {{- range . -}} + {{- template "toc" . -}} + {{- end -}} + </ul> + {{- end -}} + </li> + {{- dec -}} + {{- end -}} + {{- end -}} + </ul> + </details> + </nav> + {{- end}} + </header> + + <main> + {{- with .Doc.Content}} + {{- range .Children}} + {{- template "content.html" .}} + {{- end}}{{end}} + </main> + + <footer> + <p>This is a <a href="https://contnet.org/">ContNet</a> <code>text/cnm</code> page retrieved over CNP from <a {{href .URL}}>{{.URL}}</a> + - + <a href="?req&resp">See request/response</a> + - + <a href="?raw">Raw CNM document</a> + </p> + <details> + <summary>CNP request header (<a href="?req">try</a>)</summary> + <pre><code class="lang-{{lang "text/cnp"}}">{{.Req}}</code></pre> + </details> + <details> + <summary>CNP response header (<a href="?hdr">try</a>)</summary> + <pre><code class="lang-{{lang "text/cnp"}}">{{.Resp}}</code></pre> + </details> + <details> + <summary>Try with <a href="https://en.wikipedia.org/wiki/Netcat">Netcat</a></summary> + <pre><code class="lang-{{lang "application/x-sh"}}">{{.Netcat}}</code></pre> + </details> + </footer> + + {{if .Highlight}}<script src="/static/highlight/highlight.pack.js"></script> + <script src="/static/hlraw.js"></script>{{end}} + </body> +</html> |