-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
39 lines (31 loc) · 1.13 KB
/
main.go
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
package main
import (
"flag"
"fmt"
"github.com/polarpayne/wikix/page"
"github.com/polarpayne/wikix/render"
"github.com/polarpayne/wikix/static"
"github.com/spf13/afero"
)
var (
varUnsafe = flag.Bool("unsafe", false, "allow arbitary html in markdown")
varPathTemplate = flag.String("template", "template", "path to template directory")
varPathStatic = flag.String("static", "static", "path to static directory")
varPathPage = flag.String("page", "page", "path to page directory")
varRootPage = flag.String("root-page", "Welcome", "page that is used for the root path (homepage)")
varHost = flag.String("host", "localhost", "host that the application is started on")
varPort = flag.Int("port", 8080, "port that the application is started on")
)
func main() {
flag.Parse()
af := func(p string) afero.Fs {
return afero.NewReadOnlyFs(afero.NewBasePathFs(afero.NewOsFs(), p))
}
s := server{
render.NewTemplate(af(*varPathTemplate)),
page.NewFS(af(*varPathPage), af(*varPathPage), *varUnsafe),
static.NewFS(af(*varPathStatic)),
}
addr := fmt.Sprintf("%v:%v", *varHost, *varPort)
s.Run(addr)
}