Compare commits
22 Commits
8406a230ab
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
1098e39ca0
|
|||
|
73684451b8
|
|||
|
1f6d647e93
|
|||
|
bdd8ceef96
|
|||
|
a4875f0d57
|
|||
|
cf61021c67
|
|||
|
09aa419694
|
|||
|
710fa11b07
|
|||
|
3e59c99b5d
|
|||
|
9b4c53778d
|
|||
|
13f38313ac
|
|||
|
050ff9060e
|
|||
|
79769661cd
|
|||
|
afc4c9f1c9
|
|||
|
70292286a8
|
|||
|
ef72171568
|
|||
|
31c2a592ea
|
|||
| 082b43094a | |||
| 5e2907147a | |||
| b569db1582 | |||
| 17ea2ac9ea | |||
| 4c367dbdcc |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build/
|
||||||
11
Makefile
11
Makefile
@@ -2,10 +2,9 @@ BINARY=kisurun
|
|||||||
BUILD_DIR=build
|
BUILD_DIR=build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@echo "Building $(BINARY)..."
|
|
||||||
go build -o $(BUILD_DIR)/$(BINARY) .
|
go build -o $(BUILD_DIR)/$(BINARY) .
|
||||||
@echo "Copying templates and static..."
|
cp -r templates $(BUILD_DIR)
|
||||||
mkdir -p $(BUILD_DIR)/templates
|
cp -r pages $(BUILD_DIR)
|
||||||
mkdir -p $(BUILD_DIR)/static
|
cp -r static $(BUILD_DIR)
|
||||||
cp -r templates/* $(BUILD_DIR)/templates/
|
clean:
|
||||||
cp -r static/* $(BUILD_DIR)/static/
|
rm -rf $(BUILD_DIR)
|
||||||
|
|||||||
47
main.go
47
main.go
@@ -4,59 +4,30 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func getTemplateDir() string {
|
|
||||||
exePath, err := os.Executable()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
exeDir := filepath.Dir(exePath)
|
|
||||||
|
|
||||||
testPath := filepath.Join(exeDir, "templates")
|
|
||||||
if _, err := os.Stat(testPath); err == nil {
|
|
||||||
return testPath
|
|
||||||
}
|
|
||||||
// if running using: go run use wd
|
|
||||||
wd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
return filepath.Join(wd, "templates")
|
|
||||||
}
|
|
||||||
|
|
||||||
func pageHandler(w http.ResponseWriter, r *http.Request) {
|
func pageHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
path := strings.Trim(r.URL.Path, "/")
|
path := r.URL.Path
|
||||||
if path == "" {
|
if path == "/" {
|
||||||
path = "home"
|
path = "/home"
|
||||||
}
|
}
|
||||||
|
t, err := template.Must(template.ParseGlob("templates/*.html")).Clone()
|
||||||
|
|
||||||
templateDir := getTemplateDir()
|
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(
|
|
||||||
filepath.Join(templateDir, "layout.html"),
|
|
||||||
filepath.Join(templateDir, "header.html"),
|
|
||||||
filepath.Join(templateDir, "footer.html"),
|
|
||||||
filepath.Join(templateDir, path+".html"),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if _, err := t.ParseFiles(filepath.Join("pages", path+".html")); err != nil {
|
||||||
err = tmpl.ExecuteTemplate(w, "layout", nil)
|
http.NotFound(w, r)
|
||||||
if err != nil {
|
return
|
||||||
|
}
|
||||||
|
if err := t.ExecuteTemplate(w, "layout", nil); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", pageHandler)
|
http.HandleFunc("/", pageHandler)
|
||||||
|
|
||||||
log.Println("Server running at http://localhost:14888")
|
log.Println("Server running at http://localhost:14888")
|
||||||
log.Fatal(http.ListenAndServe(":14888", nil))
|
log.Fatal(http.ListenAndServe(":14888", nil))
|
||||||
}
|
}
|
||||||
|
|||||||
11
pages/home.html
Normal file
11
pages/home.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{{define "content"}}
|
||||||
|
<h2>
|
||||||
|
My super duper epic site
|
||||||
|
<p class="submissivetext">(contains nothing dont roast me again notbob im just a babeh)</p>
|
||||||
|
</h2>
|
||||||
|
<p>services i host</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://git.kisukalat.xyz/">git server</a></li>
|
||||||
|
<li><a href="https://xmr.kisukalat.xyz/">xmr explorer</a></li>
|
||||||
|
</ul>
|
||||||
|
{{end}}
|
||||||
@@ -13,8 +13,6 @@ body {
|
|||||||
border-width: 5px;
|
border-width: 5px;
|
||||||
border-color: #123;
|
border-color: #123;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
padding: 1em ;
|
padding: 1em ;
|
||||||
}
|
}
|
||||||
@@ -88,7 +86,12 @@ aside {
|
|||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
text-align: center ;
|
text-align: center;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
@@ -106,4 +109,9 @@ header {
|
|||||||
display: block ;
|
display: block ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.submissivetext {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
color: #666;
|
||||||
|
margin-top: -5px;
|
||||||
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<ul>
|
<ul style="padding-left: 0;">
|
||||||
<li>
|
<li>
|
||||||
Monero XMR: <code>44KiSSaf5h7MGd3GqAaNZc45DdwC7q9BmCtsZ9knfsCNj7PyipHfBvBUZVHiBUU8dMJJ82MfPBZdzVugUs7BnANT6SUyDsN</code>
|
Monero XMR: <code>44KiSSaf5h7MGd3GqAaNZc45DdwC7q9BmCtsZ9knfsCNj7PyipHfBvBUZVHiBUU8dMJJ82MfPBZdzVugUs7BnANT6SUyDsN</code>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{{define "content"}}
|
|
||||||
<h1>Kisu's homepage</h1>
|
|
||||||
<p>Resist Resist Resist</p>
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
<title>{{block "title" .}}Kisukalat.xyz{{end}}</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="/static/style.css">
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user