mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-06 10:00:26 +00:00
Do nothing in particular
This commit is contained in:
parent
171e9e2bac
commit
b4dd2dcfad
@ -1,9 +1,9 @@
|
||||
// Package history provides a git wrapper.
|
||||
package history
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"html"
|
||||
"log"
|
||||
"os/exec"
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
@ -21,10 +22,10 @@ var gitpath string
|
||||
var renameMsgPattern = regexp.MustCompile(`^Rename ‘(.*)’ to ‘.*’`)
|
||||
|
||||
// Start finds git and initializes git credentials.
|
||||
func Start(wikiDir string) {
|
||||
func Start() {
|
||||
path, err := exec.LookPath("git")
|
||||
if err != nil {
|
||||
log.Fatal("Cound not find the git executable. Check your $PATH.")
|
||||
log.Fatal("Could not find the git executable. Check your $PATH.")
|
||||
}
|
||||
gitpath = path
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// information.go
|
||||
// Things related to gathering existing information.
|
||||
package history
|
||||
|
||||
// information.go
|
||||
// Things related to gathering existing information.
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
@ -174,13 +174,20 @@ func parseRevisionLine(line string) Revision {
|
||||
}
|
||||
}
|
||||
|
||||
// See how the file with `filepath` looked at commit with `hash`.
|
||||
// FileAtRevision shows how the file with the given file path looked at the commit with the hash. It may return an error if git fails.
|
||||
func FileAtRevision(filepath, hash string) (string, error) {
|
||||
out, err := gitsh("show", hash+":"+strings.TrimPrefix(filepath, cfg.WikiDir+"/"))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return out.String(), err
|
||||
}
|
||||
|
||||
// PrimitiveDiffAtRevision generates a plain-text diff for the given filepath at the commit with the given hash. It may return an error if git fails.
|
||||
func PrimitiveDiffAtRevision(filepath, hash string) (string, error) {
|
||||
out, err := silentGitsh("diff", "--unified=1", "--no-color", hash+"~", hash, "--", filepath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return out.String(), err
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// history/operations.go
|
||||
// Things related to writing history.
|
||||
package history
|
||||
|
||||
// history/operations.go
|
||||
// Things related to writing history.
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
@ -84,7 +84,10 @@ func (hop *HistoryOp) WithFilesRemoved(paths ...string) *HistoryOp {
|
||||
func (hop *HistoryOp) WithFilesRenamed(pairs map[string]string) *HistoryOp {
|
||||
for from, to := range pairs {
|
||||
if from != "" {
|
||||
os.MkdirAll(filepath.Dir(to), 0777)
|
||||
if err := os.MkdirAll(filepath.Dir(to), 0777); err != nil {
|
||||
hop.Errs = append(hop.Errs, err)
|
||||
continue
|
||||
}
|
||||
if err := Rename(from, to); err != nil {
|
||||
hop.Errs = append(hop.Errs, err)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// The `hyphae` package is for the Hypha type, hypha storage and stuff like that. It shall not depend on mycorrhiza modules other than util.
|
||||
// Package hyphae is for the Hypha type, hypha storage and stuff like that. It shall not depend on mycorrhiza modules other than util.
|
||||
package hyphae
|
||||
|
||||
import (
|
||||
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// HyphaPattern is a pattern which all hyphae must match.
|
||||
var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"\'&%{}]+`)
|
||||
var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}]+`)
|
||||
|
||||
type Hypha struct {
|
||||
sync.RWMutex
|
||||
|
2
main.go
2
main.go
@ -37,7 +37,7 @@ func main() {
|
||||
// Init the subsystems:
|
||||
hyphae.Index(cfg.WikiDir)
|
||||
user.InitUserDatabase()
|
||||
history.Start(cfg.WikiDir)
|
||||
history.Start()
|
||||
shroom.SetHeaderLinks()
|
||||
|
||||
// Network:
|
||||
|
@ -3,7 +3,6 @@ package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@ -43,7 +42,7 @@ func (md *MycoDoc) Lex(recursionLevel int) *MycoDoc {
|
||||
return md
|
||||
}
|
||||
|
||||
// AsHtml returns an html representation of the document
|
||||
// AsHTML returns an html representation of the document
|
||||
func (md *MycoDoc) AsHTML() string {
|
||||
md.html = Parse(md.Lex(0).ast, 0, 0, 0)
|
||||
return md.html
|
||||
@ -97,76 +96,3 @@ func (md *MycoDoc) ogFillVars() *MycoDoc {
|
||||
func ogTag(property, content string) string {
|
||||
return fmt.Sprintf(`<meta property="og:%s" content="%s"/>`, property, content)
|
||||
}
|
||||
|
||||
/* The rest of this file is currently unused. TODO: use it I guess */
|
||||
|
||||
type BlockType int
|
||||
|
||||
const (
|
||||
BlockH1 = iota
|
||||
BlockH2
|
||||
BlockH3
|
||||
BlockH4
|
||||
BlockH5
|
||||
BlockH6
|
||||
BlockRocket
|
||||
BlockPre
|
||||
BlockQuote
|
||||
BlockPara
|
||||
)
|
||||
|
||||
type CrawlWhere int
|
||||
|
||||
const (
|
||||
inSomewhere = iota
|
||||
inPre
|
||||
inEnd
|
||||
)
|
||||
|
||||
func crawl(name, content string) []string {
|
||||
stateStack := []CrawlWhere{inSomewhere}
|
||||
|
||||
startsWith := func(token string) bool {
|
||||
return strings.HasPrefix(content, token)
|
||||
}
|
||||
|
||||
pop := func() {
|
||||
stateStack = stateStack[:len(stateStack)-1]
|
||||
}
|
||||
|
||||
push := func(s CrawlWhere) {
|
||||
stateStack = append(stateStack, s)
|
||||
}
|
||||
|
||||
readln := func(c string) (string, string) {
|
||||
parts := strings.SplitN(c, "\n", 1)
|
||||
return parts[0], parts[1]
|
||||
}
|
||||
|
||||
preAcc := ""
|
||||
line := ""
|
||||
|
||||
for {
|
||||
switch stateStack[0] {
|
||||
case inSomewhere:
|
||||
switch {
|
||||
case startsWith("```"):
|
||||
push(inPre)
|
||||
_, content = readln(content)
|
||||
default:
|
||||
}
|
||||
case inPre:
|
||||
switch {
|
||||
case startsWith("```"):
|
||||
pop()
|
||||
_, content = readln(content)
|
||||
default:
|
||||
line, content = readln(content)
|
||||
preAcc += html.EscapeString(line)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return []string{}
|
||||
}
|
||||
|
@ -10,14 +10,3 @@ func remover(prefix string) func(string) string {
|
||||
return strings.TrimSpace(strings.TrimPrefix(l, prefix))
|
||||
}
|
||||
}
|
||||
|
||||
// Remove #, ## or ### from beginning of `line`.
|
||||
func removeHeadingOctothorps(line string) string {
|
||||
f := remover("#")
|
||||
return f(f(f(line)))
|
||||
}
|
||||
|
||||
// Return a canonical representation of a hypha `name`.
|
||||
func canonicalName(name string) string {
|
||||
return strings.ToLower(strings.ReplaceAll(strings.TrimSpace(name), " ", "_"))
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -67,11 +68,11 @@ func parseTransclusion(line, hyphaName string) (xclusion Transclusion) {
|
||||
func xclCanonicalName(hyphaName, xclName string) string {
|
||||
switch {
|
||||
case strings.HasPrefix(xclName, "./"):
|
||||
return canonicalName(path.Join(hyphaName, strings.TrimPrefix(xclName, "./")))
|
||||
return util.CanonicalName(path.Join(hyphaName, strings.TrimPrefix(xclName, "./")))
|
||||
case strings.HasPrefix(xclName, "../"):
|
||||
return canonicalName(path.Join(path.Dir(hyphaName), strings.TrimPrefix(xclName, "../")))
|
||||
return util.CanonicalName(path.Join(path.Dir(hyphaName), strings.TrimPrefix(xclName, "../")))
|
||||
default:
|
||||
return canonicalName(xclName)
|
||||
return util.CanonicalName(xclName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,6 @@ package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/assets"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@ -16,7 +13,10 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/assets"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"github.com/bouncepaw/mycorrhiza/user"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"github.com/bouncepaw/mycorrhiza/views"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user