This commit is contained in:
parent
ab48932ad5
commit
d8ecbef86e
@ -1,4 +1,4 @@
|
|||||||
FROM docker.io/golang:1.23 AS build
|
FROM docker.io/golang:1.24 AS build
|
||||||
WORKDIR /build/
|
WORKDIR /build/
|
||||||
COPY go.mod go.sum .
|
COPY go.mod go.sum .
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
@ -11,5 +11,6 @@ COPY html/ html/
|
|||||||
COPY css/ css/
|
COPY css/ css/
|
||||||
COPY static/ static/
|
COPY static/ static/
|
||||||
COPY tmpl/ tmpl/
|
COPY tmpl/ tmpl/
|
||||||
|
COPY aliases.txt aliases.txt
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["./app"]
|
CMD ["./app"]
|
||||||
|
5
aliases.txt
Normal file
5
aliases.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ssh /static/ssh
|
||||||
|
pgp /static/pgp.asc
|
||||||
|
termux.sh https://git.gmoker.com/ange/termux/raw/branch/main/install.sh
|
||||||
|
dotfiles.sh
|
||||||
|
archinstall.sh
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
{{template "head.tmpl" .}}
|
{{template "head.tmpl" .}}
|
||||||
<script src="static/copy.js"></script>
|
<script src="copy.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{template "header.tmpl" .}}
|
{{template "header.tmpl" .}}
|
||||||
|
25
src/aliases.go
Normal file
25
src/aliases.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ALIASES map[string]string
|
||||||
|
|
||||||
|
func generateAliases() {
|
||||||
|
f, err := os.Open("aliases.txt")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
sc := bufio.NewScanner(f)
|
||||||
|
|
||||||
|
ALIASES = make(map[string]string)
|
||||||
|
for sc.Scan() {
|
||||||
|
sp := strings.Fields(sc.Text())
|
||||||
|
|
||||||
|
ALIASES[sp[0]] = sp[1]
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", route)
|
http.HandleFunc("/", route)
|
||||||
|
generateAliases()
|
||||||
generateTmpl()
|
generateTmpl()
|
||||||
if err := http.ListenAndServe(":3000", nil); err != nil {
|
if err := http.ListenAndServe(":3000", nil); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -17,7 +17,7 @@ var routes = []struct {
|
|||||||
}{
|
}{
|
||||||
{[]string{"GET"}, url(""), index},
|
{[]string{"GET"}, url(""), index},
|
||||||
{[]string{"GET"}, url("/static/.+"), static},
|
{[]string{"GET"}, url("/static/.+"), static},
|
||||||
{[]string{"GET"}, url("/(.+\\.css)"), css},
|
{[]string{"GET"}, url("/(.+\\.(css|js))"), file},
|
||||||
{[]string{"GET"}, url("/([^/]+)"), html},
|
{[]string{"GET"}, url("/([^/]+)"), html},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/views.go
10
src/views.go
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func index(w http.ResponseWriter, r *http.Request) {
|
func index(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -13,12 +13,14 @@ func static(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.ServeFile(w, r, r.URL.Path)
|
http.ServeFile(w, r, r.URL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func css(w http.ResponseWriter, r *http.Request) {
|
func file(w http.ResponseWriter, r *http.Request) {
|
||||||
http.ServeFile(w, r, filepath.Join("css", getParam(r, 0)))
|
http.ServeFile(w, r, filepath.Join(getParam(r, 1), getParam(r, 0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func html(w http.ResponseWriter, r *http.Request) {
|
func html(w http.ResponseWriter, r *http.Request) {
|
||||||
if t, found := TMPL[getParam(r, 0)]; found {
|
if a, found := ALIASES[getParam(r, 0)]; found {
|
||||||
|
http.Redirect(w, r, a, http.StatusFound)
|
||||||
|
} else if t, found := TMPL[getParam(r, 0)]; found {
|
||||||
w.Write(t)
|
w.Write(t)
|
||||||
} else {
|
} else {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div id="header">
|
<div id="header">
|
||||||
<a id="headerLink" href="/">Ange DUHAYON</a>
|
<a id="headerLink" href="/">Ange DUHAYON</a>
|
||||||
<span id="headerSubtitle">AAAAAAAAAAAAAAAAAAAAAAAAAAAA</span>
|
<span id="headerSubtitle">DevOps Engineer</span>
|
||||||
<span id="credits" class="right" style="font-size: .4em;">Website heavily inspired from <a href="//suckless.org/" target="_blank" rel="noreferrer noopener">suckless.org</a></span>
|
<span id="credits" class="right" style="font-size: .4em;">Website heavily inspired from <a href="//suckless.org/" target="_blank" rel="noreferrer noopener">suckless.org</a></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
|
Loading…
Reference in New Issue
Block a user