]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/main.go
telnet:// is used in practice
[sgblog.git] / cmd / sgblog / main.go
index 2173580bc2ebdc2bad162d61614c5edd1b5c5c75..9162a88b0ffb830c468d8886830a69de9c06b7dc 100644 (file)
@@ -64,6 +64,7 @@ var (
                "gopher": struct{}{},
                "http":   struct{}{},
                "https":  struct{}{},
+               "telnet": struct{}{},
        }
 )
 
@@ -77,11 +78,11 @@ type Cfg struct {
        Branch  string
        Title   string
 
-       BaseURL   string
        URLPrefix string
 
-       AtomId     string
-       AtomAuthor string
+       AtomBaseURL string
+       AtomId      string
+       AtomAuthor  string
 
        CSS       string
        Webmaster string
@@ -262,8 +263,8 @@ func main() {
        etagHash.Write([]byte(cfg.GitPath))
        etagHash.Write([]byte(cfg.Branch))
        etagHash.Write([]byte(cfg.Title))
-       etagHash.Write([]byte(cfg.BaseURL))
        etagHash.Write([]byte(cfg.URLPrefix))
+       etagHash.Write([]byte(cfg.AtomBaseURL))
        etagHash.Write([]byte(cfg.AtomId))
        etagHash.Write([]byte(cfg.AtomAuthor))
 
@@ -291,7 +292,7 @@ func main() {
        }
 
        defaultLinks = append(defaultLinks, `<link rel="top" href="`+cfg.URLPrefix+`/" title="top">`)
-       atomURL := cfg.BaseURL + cfg.URLPrefix + "/" + AtomFeed
+       atomURL := cfg.AtomBaseURL + cfg.URLPrefix + "/" + AtomFeed
        defaultLinks = append(defaultLinks, `<link rel="alternate" title="Atom feed" href="`+atomURL+`" type="application/atom+xml">`)
 
        repo, err = git.PlainOpen(cfg.GitPath)
@@ -380,12 +381,13 @@ func main() {
 
                var table bytes.Buffer
                table.WriteString(
-                       "<table border=1>\n<tr>" +
+                       "<table border=1>\n" +
+                               "<caption>Comments</caption>\n<tr>" +
                                "<th>N</th>" +
                                "<th>When</th>" +
                                "<th>Title</th>" +
-                               "<th size=\"5%\">L</th>" +
-                               "<th size=\"5%\">C</th>" +
+                               `<th size="5%"><a title="Lines">L</a></th>` +
+                               `<th size="5%"><a title="Comments">C</a></th>` +
                                "<th>Linked to</th></tr>\n")
                for _, entry := range entries {
                        commentN++
@@ -428,12 +430,12 @@ func main() {
                                href = cfg.URLPrefix + "/"
                        }
                        links = append(links, `<link rel="prev" href="`+href+`" title="newer">`)
-                       refs.WriteString(makeA(href, "&nbsp;[prev]"))
+                       refs.WriteString("\n" + makeA(href, "[prev]"))
                }
                if !logEnded {
                        href = cfg.URLPrefix + "/?offset=" + strconv.Itoa(offset+PageEntries)
                        links = append(links, `<link rel="next" href="`+href+`" title="older">`)
-                       refs.WriteString(makeA(href, "&nbsp;[next]"))
+                       refs.WriteString("\n" + makeA(href, "[next]"))
                }
 
                os.Stdout.Write([]byte(startHeader(etagHash, gzipWriter != nil)))
@@ -494,7 +496,7 @@ func main() {
                                ID:    "urn:uuid:" + feedId,
                                Link: []atom.Link{{
                                        Rel:  "alternate",
-                                       Href: cfg.BaseURL + cfg.URLPrefix + "/" + commit.Hash.String(),
+                                       Href: cfg.AtomBaseURL + cfg.URLPrefix + "/" + commit.Hash.String(),
                                }},
                                Published: atom.Time(commit.Author.When),
                                Updated:   atom.Time(commit.Author.When),
@@ -549,16 +551,19 @@ func main() {
                }
                out.Write([]byte(startHTML(fmt.Sprintf("%s (%s)", title, when), links)))
                if cfg.AboutURL != "" {
-                       out.Write([]byte(fmt.Sprintf("[%s]&nbsp;", makeA(cfg.AboutURL, "about"))))
+                       out.Write([]byte(fmt.Sprintf("[%s]\n", makeA(cfg.AboutURL, "about"))))
                }
+               out.Write([]byte(fmt.Sprintf("[%s]\n", makeA(cfg.URLPrefix+"/", "index"))))
                if parent != "" {
                        out.Write([]byte(fmt.Sprintf(
-                               "[%s]&nbsp;",
+                               "[%s]\n",
                                makeA(cfg.URLPrefix+"/"+parent, "older"),
                        )))
                }
                out.Write([]byte(fmt.Sprintf(
-                       "[<tt>%s</tt>]&nbsp;[<tt>%s</tt>]<hr/>\n<h2>%s</h2>\n<pre>\n",
+                       "[<tt><a title=\"When\">%s</a></tt>]\n"+
+                               "[<tt><a title=\"Hash\">%s</a></tt>]\n"+
+                               "<hr/>\n<h2>%s</h2>\n<pre>\n",
                        when, commit.Hash.String(), title,
                )))
                for _, line := range lines[2:] {