Skip to content

Commit

Permalink
Allow to customize title via config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Feb 11, 2020
1 parent 838e045 commit 0c8adff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions config-example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"max-concurrent-indexers" : 2,
"dbpath" : "data",
"title" : "Hound",
"health-check-uri" : "/healthz",
"repos" : {
"SomeGitRepo" : {
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (r *Repo) PushUpdatesEnabled() bool {

type Config struct {
DbPath string `json:"dbpath"`
Title string `json:"title"`
Repos map[string]*Repo `json:"repos"`
MaxConcurrentIndexers int `json:"max-concurrent-indexers"`
HealthCheckURI string `json:"health-check-uri"`
Expand Down
2 changes: 1 addition & 1 deletion ui/assets/index.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Hound</title>
<title>{{ .Title }}</title>
<link rel="stylesheet" href="css/octicons/octicons.css">
<link rel="stylesheet" href="css/hound.css">
<link rel="search" href="//{{ .Host }}/open_search.xml"
Expand Down
2 changes: 1 addition & 1 deletion ui/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func renderForDev(w io.Writer, root string, c *content, cfg *config.Config, r *h
"ReactVersion": ReactVersion,
"jQueryVersion": JQueryVersion,
"ReposAsJson": json,
"Title": cfg.Title,
"Source": html_template.HTML(buf.String()),
"Host": r.Host,
})
Expand Down Expand Up @@ -128,7 +129,7 @@ func (h *prdHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ct := h.content[p]
if ct != nil {
// if so, render it
if err := renderForPrd(w, ct, h.cfgJson, r); err != nil {
if err := renderForPrd(w, ct, h.cfg, h.cfgJson, r); err != nil {
log.Panic(err)
}
return
Expand All @@ -142,7 +143,7 @@ func (h *prdHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// Renders a templated asset in prd-mode. This strategy will embed
// the sources directly in a script tag on the templated page.
func renderForPrd(w io.Writer, c *content, cfgJson string, r *http.Request) error {
func renderForPrd(w io.Writer, c *content, cfg *config.Config, cfgJson string, r *http.Request) error {
var buf bytes.Buffer
buf.WriteString("<script>")
for _, src := range c.sources {
Expand All @@ -158,6 +159,7 @@ func renderForPrd(w io.Writer, c *content, cfgJson string, r *http.Request) erro
"ReactVersion": ReactVersion,
"jQueryVersion": JQueryVersion,
"ReposAsJson": cfgJson,
"Title": cfg.Title,
"Source": html_template.HTML(buf.String()),
"Host": r.Host,
})
Expand Down

0 comments on commit 0c8adff

Please sign in to comment.