link list displayed
This commit is contained in:
parent
9defacc932
commit
d1bd9c37b6
124
cmd/web/app-links.go
Normal file
124
cmd/web/app-links.go
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
type AppLink struct {
|
||||||
|
Title string
|
||||||
|
Url string
|
||||||
|
Image string
|
||||||
|
Description string
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAppLinks(tier, baseUri string) []AppLink {
|
||||||
|
if tier == "enterprise" {
|
||||||
|
return getEnterpriseLinks(baseUri)
|
||||||
|
} else if tier == "creator" {
|
||||||
|
return getCreatorLinks(baseUri)
|
||||||
|
} else if tier == "teams" {
|
||||||
|
return getTeamsLinks(baseUri)
|
||||||
|
}
|
||||||
|
|
||||||
|
return getStarterLinks(baseUri)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getStarterLinks(baseUri string) []AppLink {
|
||||||
|
return []AppLink {
|
||||||
|
{
|
||||||
|
Title: "User Management",
|
||||||
|
Description: "Create users and manage their access",
|
||||||
|
Image: "/img/panel.jpg",
|
||||||
|
Url: "https://panel." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Nextcloud",
|
||||||
|
Description: "Email, Files, Documents",
|
||||||
|
Image: "/img/nextcloud.jpg",
|
||||||
|
Url: "https://nextcloud." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Vaultwarden",
|
||||||
|
Description: "Password Management",
|
||||||
|
Image: "/img/vaultwarden.jpg",
|
||||||
|
Url: "https://vaultwarden." + baseUri,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCreatorLinks(baseUri string) []AppLink {
|
||||||
|
creatorLinks := []AppLink {
|
||||||
|
{
|
||||||
|
Title: "Element and Matrix",
|
||||||
|
Description: "Team Chat",
|
||||||
|
Image: "/img/element.jpg",
|
||||||
|
Url: "https://element." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Wordpress",
|
||||||
|
Description: "Your website",
|
||||||
|
Image: "/img/wordpress.jpg",
|
||||||
|
Url: "https://" + baseUri,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return append(creatorLinks, getStarterLinks(baseUri)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTeamsLinks(baseUri string) []AppLink {
|
||||||
|
teamsLinks := []AppLink {
|
||||||
|
{
|
||||||
|
Title: "Espo CRM",
|
||||||
|
Description: "Customer relationship manager",
|
||||||
|
Image: "/img/espo.jpg",
|
||||||
|
Url: "https://espocrm." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "FreeScout",
|
||||||
|
Description: "Customer Help Desk",
|
||||||
|
Image: "/img/freescout.jpg",
|
||||||
|
Url: "https://freescout." + baseUri,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return append(teamsLinks, getCreatorLinks(baseUri)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getEnterpriseLinks(baseUri string) []AppLink {
|
||||||
|
enterpriseLinks := []AppLink{
|
||||||
|
{
|
||||||
|
Title: "Jitsi",
|
||||||
|
Description: "Video Chat",
|
||||||
|
Image: "/img/jitsi.jpg",
|
||||||
|
Url: "https://jitsi." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Listmonk",
|
||||||
|
Description: "Email Marketing",
|
||||||
|
Image: "/img/listmonk.jpg",
|
||||||
|
Url: "https://listmonk." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Baserow",
|
||||||
|
Description: "Visual Databases",
|
||||||
|
Image: "/img/baserow.jpg",
|
||||||
|
Url: "https://baserow." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Bookstack",
|
||||||
|
Description: "Wiki Knowledgebase",
|
||||||
|
Image: "/img/bookstack.jpg",
|
||||||
|
Url: "https://bookstack." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Gitea",
|
||||||
|
Description: "GIT Source Control",
|
||||||
|
Image: "/img/gitea.jpg",
|
||||||
|
Url: "https://gitea." + baseUri,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Title: "Castopod",
|
||||||
|
Description: "Podcast Distribution",
|
||||||
|
Image: "/img/castopod.jpg",
|
||||||
|
Url: "https://castopod." + baseUri,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return append(enterpriseLinks, getTeamsLinks(baseUri)...)
|
||||||
|
}
|
@ -1,7 +1,25 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func (app *application) home(writer http.ResponseWriter, request *http.Request) {
|
func (app *application) home(writer http.ResponseWriter, request *http.Request) {
|
||||||
app.render(writer, request, http.StatusOK, "home.tmpl.html", templateData{})
|
domain := request.Host
|
||||||
|
domainPieces := strings.Split(domain, ".")
|
||||||
|
var baseURI string
|
||||||
|
if len(domainPieces) > 1 {
|
||||||
|
baseURI = domainPieces[len(domainPieces) - 2] + domainPieces[len(domainPieces) - 1]
|
||||||
|
} else {
|
||||||
|
baseURI = domain
|
||||||
|
}
|
||||||
|
|
||||||
|
data := templateData{
|
||||||
|
AppLinks: getAppLinks(app.tier, baseURI),
|
||||||
|
Tier: app.tier,
|
||||||
|
BaseUri: baseURI,
|
||||||
|
}
|
||||||
|
|
||||||
|
app.render(writer, request, http.StatusOK, "home.tmpl.html", data)
|
||||||
}
|
}
|
@ -11,11 +11,14 @@ import (
|
|||||||
type application struct {
|
type application struct {
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
templateCache map[string]*template.Template
|
templateCache map[string]*template.Template
|
||||||
|
tier string
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//Get env variables
|
//Get env variables
|
||||||
addr := flag.String("addr", ":4000", "HTTP network address")
|
addr := flag.String("addr", ":4000", "HTTP network address")
|
||||||
|
tier := flag.String("tier", "starter", "tier the core is on")
|
||||||
|
flag.Parse()
|
||||||
//Set up logger
|
//Set up logger
|
||||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||||
AddSource: true,
|
AddSource: true,
|
||||||
@ -30,6 +33,7 @@ func main() {
|
|||||||
app := application {
|
app := application {
|
||||||
logger: logger,
|
logger: logger,
|
||||||
templateCache: templateCache,
|
templateCache: templateCache,
|
||||||
|
tier: *tier,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = http.ListenAndServe(*addr, app.routes())
|
err = http.ListenAndServe(*addr, app.routes())
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
BaseUri string
|
BaseUri string
|
||||||
|
AppLinks []AppLink
|
||||||
|
Tier string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTemplateCache() (map[string]*template.Template, error) {
|
func newTemplateCache() (map[string]*template.Template, error) {
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
{{define "title"}}Home{{end}}
|
{{define "title"}}Home{{end}}
|
||||||
|
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
yo
|
<section class="app-links">
|
||||||
|
<h2 class="app-links-title">Apps for {{.BaseUri}} on the {{.Tier}} tier.</h2>
|
||||||
|
<div class="app-links-container">
|
||||||
|
<!-- LOOP HERE -->
|
||||||
|
{{range .AppLinks}}
|
||||||
|
<a href="{{.Url}}" class="app-link-card-link">
|
||||||
|
<div class="app-link-card">
|
||||||
|
<h3 class="app-link-card__title">{{.Title}}</h3>
|
||||||
|
<p class="app-link-card__description">{{.Description}}</p>
|
||||||
|
<img src="{{.Image}}" alt="" class="app-link-card__image">
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
{{end}}
|
{{end}}
|
@ -1,5 +1,7 @@
|
|||||||
{{define "nav"}}
|
{{define "nav"}}
|
||||||
<nav>
|
<nav class="nav">
|
||||||
<a href="/">Home</a>
|
<a href="/" class="nav-link">Home</a>
|
||||||
|
<a href="/" class="nav-link">Login</a>
|
||||||
|
<a href="/" class="nav-link">VPN</a>
|
||||||
</nav>
|
</nav>
|
||||||
{{end}}
|
{{end}}
|
Loading…
Reference in New Issue
Block a user