\ No newline at end of file
diff --git a/localhost:8080/about b/localhost:8080/about
new file mode 100644
index 0000000..c4c593f
--- /dev/null
+++ b/localhost:8080/about
@@ -0,0 +1 @@
+
site and this template are inspired by werc and XXIIVV. I found that these models of personal website organisations are well suited to lay out notes about varieties of subjects.
\ No newline at end of file
diff --git a/localhost:8080/docs/.view b/localhost:8080/docs/.view
new file mode 100644
index 0000000..d8c8fec
--- /dev/null
+++ b/localhost:8080/docs/.view
@@ -0,0 +1 @@
+
This directory holds a few notes about site concepts.
\ No newline at end of file
diff --git a/localhost:8080/docs/index b/localhost:8080/docs/index
new file mode 100644
index 0000000..30610a5
--- /dev/null
+++ b/localhost:8080/docs/index
@@ -0,0 +1,12 @@
+
.index is the template of children pages in the subtree
+
+
When a directory contains a file named .index, all files in children directories are going to use it as template.
+
+
An .index file is a normal html file, except that a few templates get replaced by the server generated content:
+
+
{{ post }} gets replaced by the content of the post resolved by the HTML path
+
{{ nav }} gets replaced by the server generated navbar, which is to be placed anywhere. This template places it next to the title
+
+
+
+
The role of .index is thus to structure and composite in a relatively minimalistic manner the componants that make up a page of the site.
\ No newline at end of file
diff --git a/localhost:8080/docs/view b/localhost:8080/docs/view
new file mode 100644
index 0000000..ced1356
--- /dev/null
+++ b/localhost:8080/docs/view
@@ -0,0 +1,3 @@
+
.view is the default page rendered in a directory
+
+
It can be used to provide a summary of what to expect in the subdirectories
\ No newline at end of file
diff --git a/site.go b/site.go
new file mode 100644
index 0000000..46e6cee
--- /dev/null
+++ b/site.go
@@ -0,0 +1,149 @@
+package main
+
+import (
+ "os"
+ "io/ioutil"
+ "net/http"
+ "path"
+ "path/filepath"
+ "strings"
+)
+
+const staticPrefix = "/static/"
+
+type NavTree struct {
+ name string
+ path string
+ children []NavTree
+ hasIndex bool
+ selected bool
+}
+
+func stripPath(caminho string) string {
+ caminho = path.Clean(caminho)
+ return "/" + path.Join(strings.Split(caminho, "/")[1:]...)
+}
+
+func rootTree(root string, goal string) (NavTree, string) {
+ nav := NavTree{}
+ nav.name = path.Base(root)
+ nav.path = root
+ nav.selected = false
+
+ index := ""
+
+ if !strings.HasPrefix(goal, root) {
+ return nav, index
+ }
+
+ nav.selected = true
+
+ filepath.Walk(root, func(current string, info os.FileInfo, err error) error {
+ if info.Name() == ".index" {
+ index = current
+ }
+
+ if current == root || info.Name()[0] == '.' {
+ return nil
+ }
+
+ rec, idx := rootTree(current, goal)
+ if idx != "" {
+ index = idx
+ }
+
+ nav.children = append(nav.children, rec)
+
+ if info.IsDir() {
+ return filepath.SkipDir
+ } else {
+ return nil
+ }
+ })
+
+ return nav, index
+}
+
+func RenderList(children []NavTree) string {
+ deleg := ""
+ ul := "
"
+ for _, s := range children {
+ u, d := s.Render()
+ ul += u
+ deleg += d
+ }
+ ul += "
"
+ ul += deleg
+ return ul
+}
+
+func (v *NavTree) Render() (string, string) {
+ li := "