Add site description
0e7bd0ba2e26c28b990c217b40b3c0ff53a78191
1 parent
f0281f35
handler.go
+14 -12
| 7 | 7 | "strconv" |
|
| 8 | 8 | "strings" |
|
| 9 | 9 | ) |
|
| 10 | 10 | ||
| 11 | 11 | type pageData struct { |
|
| 12 | - | SiteTitle string |
|
| 13 | - | BaseURL string |
|
| 14 | - | Repo string |
|
| 15 | - | Description string |
|
| 16 | - | Section string |
|
| 17 | - | Ref string |
|
| 18 | - | CommitHash string |
|
| 19 | - | Data any |
|
| 12 | + | SiteTitle string |
|
| 13 | + | SiteDescription string |
|
| 14 | + | BaseURL string |
|
| 15 | + | Repo string |
|
| 16 | + | Description string |
|
| 17 | + | Section string |
|
| 18 | + | Ref string |
|
| 19 | + | CommitHash string |
|
| 20 | + | Data any |
|
| 20 | 21 | } |
|
| 21 | 22 | ||
| 22 | 23 | func (s *server) newPageData(repo *RepoInfo, section, ref string) pageData { |
|
| 23 | 24 | pd := pageData{ |
|
| 24 | - | SiteTitle: s.title, |
|
| 25 | - | BaseURL: s.baseURL, |
|
| 26 | - | Section: section, |
|
| 27 | - | Ref: ref, |
|
| 25 | + | SiteTitle: s.title, |
|
| 26 | + | SiteDescription: s.description, |
|
| 27 | + | BaseURL: s.baseURL, |
|
| 28 | + | Section: section, |
|
| 29 | + | Ref: ref, |
|
| 28 | 30 | } |
|
| 29 | 31 | if repo != nil { |
|
| 30 | 32 | pd.Repo = repo.Name |
|
| 31 | 33 | pd.Description = repo.Description |
|
| 32 | 34 | } |
main.go
+19 -16
| 10 | 10 | "sort" |
|
| 11 | 11 | "strings" |
|
| 12 | 12 | ) |
|
| 13 | 13 | ||
| 14 | 14 | type server struct { |
|
| 15 | - | repos map[string]*RepoInfo |
|
| 16 | - | sorted []string |
|
| 17 | - | tmpl *templateSet |
|
| 18 | - | title string |
|
| 19 | - | baseURL string |
|
| 20 | - | scanPath string |
|
| 21 | - | username string |
|
| 22 | - | password string |
|
| 15 | + | repos map[string]*RepoInfo |
|
| 16 | + | sorted []string |
|
| 17 | + | tmpl *templateSet |
|
| 18 | + | title string |
|
| 19 | + | description string |
|
| 20 | + | baseURL string |
|
| 21 | + | scanPath string |
|
| 22 | + | username string |
|
| 23 | + | password string |
|
| 23 | 24 | } |
|
| 24 | 25 | ||
| 25 | 26 | func main() { |
|
| 26 | 27 | listen := flag.String("listen", ":8080", "listen address") |
|
| 27 | 28 | scanPath := flag.String("scan-path", ".", "path to scan for git repos") |
|
| 28 | 29 | title := flag.String("title", "radiant code repositories", "site title") |
|
| 30 | + | description := flag.String("description", "", "site description shown on the index page") |
|
| 29 | 31 | baseURL := flag.String("base-url", "", "base URL prefix (e.g. /git)") |
|
| 30 | 32 | nonBare := flag.Bool("non-bare", false, "also scan for non-bare repos (dirs containing .git)") |
|
| 31 | 33 | username := flag.String("username", "", "HTTP basic auth username (requires -password)") |
|
| 32 | 34 | password := flag.String("password", "", "HTTP basic auth password (requires -username)") |
|
| 33 | 35 | flag.Parse() |
| 58 | 60 | if err != nil { |
|
| 59 | 61 | log.Fatalf("load templates: %v", err) |
|
| 60 | 62 | } |
|
| 61 | 63 | ||
| 62 | 64 | srv := &server{ |
|
| 63 | - | repos: repos, |
|
| 64 | - | sorted: sorted, |
|
| 65 | - | tmpl: tmpl, |
|
| 66 | - | title: *title, |
|
| 67 | - | baseURL: strings.TrimRight(*baseURL, "/"), |
|
| 68 | - | scanPath: abs, |
|
| 69 | - | username: *username, |
|
| 70 | - | password: *password, |
|
| 65 | + | repos: repos, |
|
| 66 | + | sorted: sorted, |
|
| 67 | + | tmpl: tmpl, |
|
| 68 | + | title: *title, |
|
| 69 | + | description: *description, |
|
| 70 | + | baseURL: strings.TrimRight(*baseURL, "/"), |
|
| 71 | + | scanPath: abs, |
|
| 72 | + | username: *username, |
|
| 73 | + | password: *password, |
|
| 71 | 74 | } |
|
| 72 | 75 | ||
| 73 | 76 | mux := http.NewServeMux() |
|
| 74 | 77 | mux.HandleFunc("/style.css", srv.serveCSS) |
|
| 75 | 78 | mux.HandleFunc("/radiant.svg", srv.serveLogo) |
static/js/hirad.js
+1 -1
| 11 | 11 | 'continue', 'return', 'true', 'false', 'loop', 'extern', 'panic', |
|
| 12 | 12 | 'device', 'register', 'bit', 'catch', 'throw', 'throws', 'test', |
|
| 13 | 13 | 'at', 'mut', 'nil', 'undefined', 'static', 'in', 'is', 'where', |
|
| 14 | 14 | 'as', 'and', 'or', 'xor', 'not', 'try', 'atomic', 'select' |
|
| 15 | 15 | ]; |
|
| 16 | - | const types = ['bool', 'u8', 'u16', 'u32', 'i8', 'i16', 'i32', 'f32', 'void', 'opaque']; |
|
| 16 | + | const types = ['bool', 'u8', 'u16', 'u32', 'u64', 'i8', 'i16', 'i32', 'i64', 'f32', 'void', 'opaque']; |
|
| 17 | 17 | ||
| 18 | 18 | // Syntax definition. |
|
| 19 | 19 | // |
|
| 20 | 20 | // The key becomes the class name of the span around the matched block of code. |
|
| 21 | 21 | const syntax = [ |
templates/layout.html
+1 -1
| 8 | 8 | </head> |
|
| 9 | 9 | <body> |
|
| 10 | 10 | <div class="container"> |
|
| 11 | 11 | {{if not .Repo}} |
|
| 12 | 12 | <nav class="repo-nav"> |
|
| 13 | - | <span class="repo-name"><a href="{{.BaseURL}}/" class="logo-link"><img class="logo" src="{{.BaseURL}}/radiant.svg" alt="" width="16" height="16"></a><a href="{{.BaseURL}}/">{{.SiteTitle}}</a></span> |
|
| 13 | + | <span class="repo-name"><a href="{{.BaseURL}}/" class="logo-link"><img class="logo" src="{{.BaseURL}}/radiant.svg" alt="" width="16" height="16"></a><a href="{{.BaseURL}}/">{{.SiteTitle}}</a>{{if .SiteDescription}}<span class="repo-desc">{{.SiteDescription}}</span>{{end}}</span> |
|
| 14 | 14 | </nav> |
|
| 15 | 15 | {{end}} |
|
| 16 | 16 | {{if .Repo}} |
|
| 17 | 17 | <nav class="repo-nav"> |
|
| 18 | 18 | <span class="repo-name"><a href="{{.BaseURL}}/" class="logo-link"><img class="logo" src="{{.BaseURL}}/radiant.svg" alt="" width="16" height="16"></a><a href="{{.BaseURL}}/{{.Repo}}/">{{.Repo}}</a>{{if .Description}}<span class="repo-desc">{{.Description}}</span>{{end}}</span> |
watch
+1 -1
| 1 | 1 | #!/bin/sh |
|
| 2 | 2 | # Rebuild and restart on source changes. |
|
| 3 | 3 | # Requires `entr(1)`. |
|
| 4 | 4 | find . -name '*.go' -o -name '*.html' -o -name '*.css' \ |
|
| 5 | - | | entr -r go run . -scan-path ~/src/radiant -non-bare "$@" |
|
| 5 | + | | entr -r go run . -scan-path ~/src/radiant -non-bare -description "Radiant computer repositories" "$@" |