mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-12-09 01:48:08 +00:00
Move config-related stuff to its own module
This commit is contained in:
@@ -3,6 +3,7 @@ package history
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"html"
|
||||
"log"
|
||||
"os/exec"
|
||||
@@ -167,7 +168,7 @@ func (rev *Revision) bestLink() string {
|
||||
func gitsh(args ...string) (out bytes.Buffer, err error) {
|
||||
fmt.Printf("$ %v\n", args)
|
||||
cmd := exec.Command(gitpath, args...)
|
||||
cmd.Dir = util.WikiDir
|
||||
cmd.Dir = cfg.WikiDir
|
||||
|
||||
b, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
@@ -179,7 +180,7 @@ func gitsh(args ...string) (out bytes.Buffer, err error) {
|
||||
// silentGitsh is like gitsh, except it writes less to the stdout.
|
||||
func silentGitsh(args ...string) (out bytes.Buffer, err error) {
|
||||
cmd := exec.Command(gitpath, args...)
|
||||
cmd.Dir = util.WikiDir
|
||||
cmd.Dir = cfg.WikiDir
|
||||
|
||||
b, err := cmd.CombinedOutput()
|
||||
return *bytes.NewBuffer(b), err
|
||||
|
||||
@@ -4,20 +4,20 @@ package history
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"log"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"github.com/gorilla/feeds"
|
||||
)
|
||||
|
||||
func recentChangesFeed() *feeds.Feed {
|
||||
feed := &feeds.Feed{
|
||||
Title: "Recent changes",
|
||||
Link: &feeds.Link{Href: util.URL},
|
||||
Link: &feeds.Link{Href: cfg.URL},
|
||||
Description: "List of 30 recent changes on the wiki",
|
||||
Author: &feeds.Author{Name: "Wikimind", Email: "wikimind@mycorrhiza"},
|
||||
Updated: time.Now(),
|
||||
@@ -44,7 +44,7 @@ func recentChangesFeed() *feeds.Feed {
|
||||
Description: rev.descriptionForFeed(),
|
||||
Created: rev.Time,
|
||||
Updated: rev.Time,
|
||||
Link: &feeds.Link{Href: util.URL + rev.bestLink()},
|
||||
Link: &feeds.Link{Href: cfg.URL + rev.bestLink()},
|
||||
})
|
||||
}
|
||||
return feed
|
||||
@@ -141,7 +141,7 @@ func (rev *Revision) asHistoryEntry(hyphaName string) (html string) {
|
||||
author := ""
|
||||
if rev.Username != "anon" {
|
||||
author = fmt.Sprintf(`
|
||||
<span class="history-entry__author">by <a href="/page/%[1]s/%[2]s" rel="author">%[2]s</span>`, util.UserHypha, rev.Username)
|
||||
<span class="history-entry__author">by <a href="/page/%[1]s/%[2]s" rel="author">%[2]s</span>`, cfg.UserHypha, rev.Username)
|
||||
}
|
||||
return fmt.Sprintf(`
|
||||
<li class="history__entry">
|
||||
@@ -176,7 +176,7 @@ func parseRevisionLine(line string) Revision {
|
||||
|
||||
// See how the file with `filepath` looked at commit with `hash`.
|
||||
func FileAtRevision(filepath, hash string) (string, error) {
|
||||
out, err := gitsh("show", hash+":"+strings.TrimPrefix(filepath, util.WikiDir+"/"))
|
||||
out, err := gitsh("show", hash+":"+strings.TrimPrefix(filepath, cfg.WikiDir+"/"))
|
||||
return out.String(), err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user