added rendering of index
This commit is contained in:
parent
fbc1dfd85a
commit
3010118695
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>NewTab</title>
|
||||
<title>{{ .PageTitle }}</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="assets/style.css">
|
||||
</head>
|
||||
@ -11,7 +11,7 @@
|
||||
<form class="search-grid" action="https://duckduckgo.com/">
|
||||
<div class="search-logo">
|
||||
<img als="girl_juice" src="assets/girl_juice.png" />
|
||||
<h2 class="phrases">GirlJuice.Inject()</h2>
|
||||
<h2 class="phrases"></h2>
|
||||
<img als="girl_juice" src="assets/girl_juice.png" />
|
||||
</div>
|
||||
<input name="q" type="text" class="grid-item" class="search" placeholder="Search DuckDuckGo :3 :3 :3" />
|
||||
@ -28,7 +28,7 @@
|
||||
]
|
||||
|
||||
Array.from(document.querySelectorAll(".phrases")).forEach(element => {
|
||||
element.textContent = phrases[Math.floor(Math.random()*phrases.length)];
|
||||
// element.textContent = phrases[Math.floor(Math.random()*phrases.length)];
|
||||
})
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
13
go.mod
13
go.mod
@ -1,3 +1,16 @@
|
||||
module gitea.elara.ws/Hazel/transfem-startpage
|
||||
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
github.com/labstack/echo/v4 v4.13.4 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
golang.org/x/crypto v0.38.0 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
)
|
||||
|
21
go.sum
Normal file
21
go.sum
Normal file
@ -0,0 +1,21 @@
|
||||
github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA=
|
||||
github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ=
|
||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
19
internal/rendering/template.go
Normal file
19
internal/rendering/template.go
Normal file
@ -0,0 +1,19 @@
|
||||
package rendering
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func getFileContent() string {
|
||||
content, err := os.ReadFile("frontend/index.html")
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return string(content)
|
||||
}
|
||||
|
||||
var IndexTemplate = template.Must(template.New("index").Parse(getFileContent()))
|
26
main.go
26
main.go
@ -1,21 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"gitea.elara.ws/Hazel/transfem-startpage/internal/diyhrt"
|
||||
"gitea.elara.ws/Hazel/transfem-startpage/internal/rendering"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
var CurrentRenderingConfig = rendering.DefaultRenderingConfig()
|
||||
|
||||
func getIndex(c echo.Context) error {
|
||||
var tpl bytes.Buffer
|
||||
rendering.IndexTemplate.Execute(&tpl, CurrentRenderingConfig)
|
||||
|
||||
return c.HTML(http.StatusOK, tpl.String())
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("running transfem startpage")
|
||||
|
||||
listings, err := diyhrt.GetListings()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
e := echo.New()
|
||||
e.Static("/assets", "frontend/assets")
|
||||
e.GET("/", getIndex)
|
||||
|
||||
for _, l := range listings {
|
||||
fmt.Println(l)
|
||||
}
|
||||
e.Logger.Fatal(e.Start(":5500"))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user