Initial commit
This commit is contained in:
commit
ca00ee623d
8 changed files with 205 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
doksie
|
4
Makefile
Normal file
4
Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
run:
|
||||
go run main.go
|
||||
build:
|
||||
go build -v -ldflags "-s -w"
|
7
content/index.md
Normal file
7
content/index.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
Doksie
|
||||
=======
|
||||
|
||||
- Will have plain MD files
|
||||
- Git backup
|
||||
- Webhook initiated pulling
|
||||
- Multiple location backings (git-repos)
|
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
|||
module jakest.us/doksie
|
||||
|
||||
go 1.22.9
|
||||
|
||||
require github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62
|
2
go.sum
Normal file
2
go.sum
Normal file
|
@ -0,0 +1,2 @@
|
|||
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62 h1:pbAFUZisjG4s6sxvRJvf2N7vhpCvx2Oxb3PmS6pDO1g=
|
||||
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
69
main.go
Normal file
69
main.go
Normal file
|
@ -0,0 +1,69 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/gomarkdown/markdown"
|
||||
"github.com/gomarkdown/markdown/html"
|
||||
"github.com/gomarkdown/markdown/parser"
|
||||
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Page struct {
|
||||
Title string
|
||||
MarkDown []byte
|
||||
HTML string
|
||||
Navigation string
|
||||
}
|
||||
|
||||
const port = 6900
|
||||
|
||||
func mdToHTML(md []byte) []byte {
|
||||
// create markdown parser with extensions
|
||||
extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock
|
||||
p := parser.NewWithExtensions(extensions)
|
||||
doc := p.Parse(md)
|
||||
|
||||
// create HTML renderer with extensions
|
||||
htmlFlags := html.CommonFlags | html.HrefTargetBlank
|
||||
opts := html.RendererOptions{Flags: htmlFlags}
|
||||
renderer := html.NewRenderer(opts)
|
||||
|
||||
return markdown.Render(doc, renderer)
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Starting listener on :%v", port)
|
||||
http.Handle("/static/", http.FileServer(http.Dir("./")))
|
||||
http.HandleFunc("/", httpRootHandler)
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", port), nil))
|
||||
}
|
||||
|
||||
func loadPage(fileUrl string) ([]byte, error) {
|
||||
var fileContents, err = os.ReadFile(fileUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fileContents, nil
|
||||
}
|
||||
func httpRootHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var p Page
|
||||
t, _ := template.ParseFiles("page.html")
|
||||
markdown, err := loadPage("content/index.md")
|
||||
p.MarkDown = markdown
|
||||
if err != nil {
|
||||
log.Fatal("Can't open file")
|
||||
}
|
||||
p.HTML = string(mdToHTML(p.MarkDown))
|
||||
p.Navigation = buildNav()
|
||||
t.Execute(w, p)
|
||||
}
|
||||
|
||||
func buildNav() string {
|
||||
|
||||
return "<a href=\"http://google.com\">Google.com</a>"
|
||||
}
|
17
page.html
Normal file
17
page.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="/static/style.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{{.Title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="nav">
|
||||
{{.Navigation}}
|
||||
</div>
|
||||
<div id="content">
|
||||
{{.HTML}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
100
static/style.css
Normal file
100
static/style.css
Normal file
|
@ -0,0 +1,100 @@
|
|||
body {
|
||||
font-family: Tahoma, Verdana, sans-serif;
|
||||
background-color: #000000;
|
||||
color: #ffc000;
|
||||
}
|
||||
|
||||
hr {
|
||||
border-color: #584200;
|
||||
}
|
||||
|
||||
|
||||
#flexout {
|
||||
display: flex;
|
||||
max-width: 75rem;
|
||||
margin: auto;
|
||||
justify-content: center;
|
||||
}
|
||||
#lpanel {
|
||||
order: 0;
|
||||
}
|
||||
#rpanel {
|
||||
order: 2;
|
||||
}
|
||||
#rpanel, #lpanel, .flexpanel {
|
||||
width: 15rem;
|
||||
border-radius: 1rem;
|
||||
padding: .5rem;
|
||||
background-color: #271d00;
|
||||
}
|
||||
|
||||
#loginform {
|
||||
text-align: center;
|
||||
}
|
||||
#titlebox {
|
||||
font-size: 5em;
|
||||
text-align: center;
|
||||
}
|
||||
#titlebox > img {
|
||||
height: 1.25em;
|
||||
vertical-align: sub;
|
||||
}
|
||||
#centerbox {
|
||||
margin-left: 1rem;
|
||||
margin-right: 1rem;
|
||||
background-color: #271d00;
|
||||
border-radius: 1rem;
|
||||
padding: .5rem;
|
||||
flex-grow: 1;
|
||||
order: 1;
|
||||
}
|
||||
#postform {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
#postformtextarea {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
#postformactionrow {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.post {
|
||||
position: relative;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
padding: 1rem;
|
||||
margin-top: 3rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
.postinfo {
|
||||
position: absolute;
|
||||
left: -1px;
|
||||
top: -2em;
|
||||
height: 3rem;
|
||||
min-width: 15rem;
|
||||
background-color: #ffc000;
|
||||
color: #000000;
|
||||
border-radius: 3rem;
|
||||
border-bottom-left-radius: 0;
|
||||
padding: .25rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
.postactions {
|
||||
/*float: right;*/
|
||||
position: absolute;
|
||||
background-color: #ffc000;
|
||||
padding: .25rem;
|
||||
border-radius: 2rem;
|
||||
border-top-right-radius: 0;
|
||||
right: -1px;
|
||||
bottom: -1rem;
|
||||
}
|
||||
.reactionaction {
|
||||
height: 2rem;
|
||||
vertical-align: bottom;
|
||||
}
|
Loading…
Add table
Reference in a new issue