This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
storage.go
58 lines (44 loc) · 1.59 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2014 Daniel Kertesz <daniel@spatof.org>
// All rights reserved. This program comes with ABSOLUTELY NO WARRANTY.
// See the file LICENSE for details.
package spock
// Abstract interface to a VCS used as a wiki storage.
import (
"time"
)
// Valid page extensions.
var PAGE_EXTENSIONS = []string{"md", "rst", "org", "txt"}
// This is the interface to the version control system used as a backend.
type Storage interface {
JoinPath(relpath string) (string, error)
// Lookup a single Page
LookupPage(pagepath string) (*Page, bool, error)
// CRUD
RenamePage(origPath, destPath string, signature *CommitSignature, message string) (RevID, error)
DeletePage(path string, signature *CommitSignature, message string) (RevID, error)
SavePage(page *Page, sig *CommitSignature, message string) error
// Get the commit logs for a Page.
LogsForPage(path string) ([]CommitLog, error)
// Get the last commit for a single Page. (deprecate?)
GetLastCommit(path string) (*CommitLog, error)
// List all the pages inside this Storage.
ListPages() ([]string, error)
// Returns a diff between the current page content and another revision. (rewrite?)
DiffPage(page *Page, revA, revB string) ([]string, error)
}
// The struct used to pack all informations regarding a single VCS commit.
type CommitLog struct {
Id string
Message string
Name string
Email string
When time.Time
}
// The struct used when creating a new commit
type CommitSignature struct {
Name string
Email string
When time.Time
}
// RevID represents a revision id; with git is the SHA hash of a commit.
type RevID string