some tests and major cleanup
This commit is contained in:
parent
8ef2a2547c
commit
16671b3406
30 changed files with 192057 additions and 202431 deletions
13
pkg/db/db.go
13
pkg/db/db.go
|
|
@ -3,13 +3,13 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/cache"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/index"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/render"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/store"
|
||||
"io"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -24,24 +24,19 @@ You can customize it how you like.`
|
|||
|
||||
const blevePath = "bleve"
|
||||
|
||||
func dbErr(i interface{}) error {
|
||||
return fmt.Errorf("db: %s", i)
|
||||
}
|
||||
|
||||
type DB struct {
|
||||
store store.Store
|
||||
cache *cache.Cache
|
||||
Index *index.Index
|
||||
}
|
||||
|
||||
func New(datadir string) (db *DB, err error) {
|
||||
func New(dir string) (db *DB, err error) {
|
||||
db = &DB{cache: cache.NewCache()}
|
||||
db.Index, err = index.NewIndex(datadir + "/" + blevePath)
|
||||
db.store, err = store.NewBoltStore(filepath.Join(dir, storeFile), nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
db.store, err = store.NewBoltStore(storeFile, nil)
|
||||
db.Index, err = index.NewIndex(filepath.Join(dir, blevePath))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/render"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/store"
|
||||
|
|
@ -13,10 +14,10 @@ const pagePrefix = "page/"
|
|||
|
||||
var (
|
||||
errPageNotFound = store.ErrKeyNotFound
|
||||
errPermissionDenied = dbErr("permission denied")
|
||||
errInvalidPermission = dbErr("invalid permission")
|
||||
errPrivateWikiPage = dbErr("private wiki pages are not allowed")
|
||||
errDeleteIndexPage = dbErr("index page can not be deleted")
|
||||
errPermissionDenied = errors.New("db: permission denied")
|
||||
errInvalidPermission = errors.New("db: invalid permission")
|
||||
errPrivateWikiPage = errors.New("db: private wiki pages are not allowed")
|
||||
errDeleteIndexPage = errors.New("db: index page can not be deleted")
|
||||
)
|
||||
|
||||
func (db *DB) GetAllPages(username string) (pages core.Pages) {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ import (
|
|||
const userPrefix = "user/"
|
||||
|
||||
var (
|
||||
errUserNotFound = dbErr("user not found")
|
||||
errUserExists = dbErr("user already exist")
|
||||
errUserReserved = dbErr("username is reserved")
|
||||
errUserNotFound = errors.New("db: user not found")
|
||||
errUserExists = errors.New("db: user already exist")
|
||||
errUserReserved = errors.New("db: username is reserved")
|
||||
|
||||
userRe = regexp.MustCompile("[^a-zA-Z0-9]+")
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue