summaryrefslogtreecommitdiffstats
path: root/templates/page.html
blob: 0f89e2d5a7ccbedf482afee89838de3419bfd3c3 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<title>{{with .Doc.Title}}{{.}}{{else}}&nbsp;{{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&amp;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>