This commit is contained in:
parent
b9d7553420
commit
4b530d332c
@ -10,4 +10,7 @@ services:
|
||||
path: src/
|
||||
- action: sync+restart
|
||||
path: html/
|
||||
target: /html
|
||||
target: html
|
||||
- action: sync
|
||||
path: static/
|
||||
target: static
|
||||
|
@ -4,6 +4,21 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Ange DUHAYON</title>
|
||||
<link rel="stylesheet" href="style.css"/>
|
||||
<script>
|
||||
function copyElem(id, r='') {
|
||||
navigator.clipboard.writeText(
|
||||
document.getElementById(id).innerText.replaceAll(r, ''),
|
||||
);
|
||||
}
|
||||
|
||||
function copyFile(id) {
|
||||
fetch(document.getElementById(id).childNodes[0].href).then(f => {
|
||||
f.text().then(t => {
|
||||
navigator.clipboard.writeText(t);
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
@ -36,13 +51,41 @@
|
||||
<div id="main">
|
||||
|
||||
<table>
|
||||
<tr id="matrix"><td>Matrix (Element)</td><td><a href="//app.element.io/#/user/@ange:gmoker.com">@ange:gmoker.com</a></td></tr>
|
||||
<tr id="discord"><td>Discord</td><td>@elrilio</td></tr>
|
||||
<tr id="phone"><td>Phone (France)</td><td><a href="tel:+33582951623">+33 5 82 95 16 23</a></td></tr>
|
||||
<tr id="email"><td>Email</td><td><a href="mailto:ange@yw5n.com">ange@yw5n.com</a></td></tr>
|
||||
<tr id="wa"><td>WhatsApp</td><td><a href="//wa.me/6285333559453">+62 853-3355-9453</a></td></tr>
|
||||
<tr id="pgp"><td>PGP</td><td><a href="/static/pgp.asc">pgp.asc</a></td></tr>
|
||||
<tr id="ssh"><td>SSH</td><td><a href="/static/ssh">ssh</a></td></tr>
|
||||
<tr>
|
||||
<td>Matrix (Element)</td>
|
||||
<td id="matrix"><a href="//app.element.io/#/user/@ange:gmoker.com">@ange:gmoker.com</a></td>
|
||||
<td><button onclick="copyElem('matrix')">Copy</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Discord</td>
|
||||
<td id="discord">@elrilio</td>
|
||||
<td><button onclick="copyElem('discord')">Copy</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Phone (France)</td>
|
||||
<td id="phone"><a href="tel:+33582951623">+33 5 82 95 16 23</a></td>
|
||||
<td><button onclick="copyElem('phone', / /g)">Copy</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Email</td>
|
||||
<td id="email"><a href="mailto:ange@yw5n.com">ange@yw5n.com</a></td>
|
||||
<td><button onclick="copyElem('email')">Copy</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WhatsApp</td>
|
||||
<td id="wa"><a href="//wa.me/6285333559453">+62 853-3355-9453</a></td>
|
||||
<td><button onclick="copyElem('wa', /[ |-]/g)">Copy</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PGP</td>
|
||||
<td id="pgp"><a href="/static/pgp.asc">pgp.asc</a></td>
|
||||
<td><button onclick="copyFile('pgp')">Copy</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SSH</td>
|
||||
<td id="ssh"><a href="/static/ssh">ssh</a></td>
|
||||
<td><button onclick="copyFile('ssh')">Copy</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", Route)
|
||||
http.HandleFunc("/", route)
|
||||
|
||||
err := http.ListenAndServe(":3000", nil)
|
||||
if err != nil {
|
||||
|
12
src/route.go
12
src/route.go
@ -15,17 +15,17 @@ var routes = []struct {
|
||||
regex *regexp.Regexp
|
||||
handler http.HandlerFunc
|
||||
}{
|
||||
{[]string{"GET"}, URL(""), Index},
|
||||
{[]string{"GET"}, URL("/style\\.css"), Style},
|
||||
{[]string{"GET"}, URL("/static/.+"), Static},
|
||||
{[]string{"GET"}, URL("/[^/]+"), HTML},
|
||||
{[]string{"GET"}, url(""), index},
|
||||
{[]string{"GET"}, url("/style\\.css"), style},
|
||||
{[]string{"GET"}, url("/static/.+"), static},
|
||||
{[]string{"GET"}, url("/[^/]+"), html},
|
||||
}
|
||||
|
||||
func URL(s string) *regexp.Regexp {
|
||||
func url(s string) *regexp.Regexp {
|
||||
return regexp.MustCompile("^" + s + "/?$")
|
||||
}
|
||||
|
||||
func Route(w http.ResponseWriter, r *http.Request) {
|
||||
func route(w http.ResponseWriter, r *http.Request) {
|
||||
for _, rt := range routes {
|
||||
matches := rt.regex.FindStringSubmatch(r.URL.Path)
|
||||
if len(matches) > 0 {
|
||||
|
@ -5,18 +5,18 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func Index(w http.ResponseWriter, r *http.Request) {
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, filepath.Join("html", "index.html"))
|
||||
}
|
||||
|
||||
func Style(w http.ResponseWriter, r *http.Request) {
|
||||
func style(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "/html/style.css")
|
||||
}
|
||||
|
||||
func Static(w http.ResponseWriter, r *http.Request) {
|
||||
func static(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, r.URL.Path)
|
||||
}
|
||||
|
||||
func HTML(w http.ResponseWriter, r *http.Request) {
|
||||
func html(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, filepath.Join("html", r.URL.Path + ".html"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user