first working version
This commit is contained in:
parent
14e0611f06
commit
85f93bae69
32 changed files with 863 additions and 571 deletions
26
pkg/db/db.go
26
pkg/db/db.go
|
|
@ -8,7 +8,6 @@ import (
|
|||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/index"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/store"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -17,11 +16,9 @@ const (
|
|||
usersFile = "users.db"
|
||||
pagesFile = "pages.db"
|
||||
bcryptCost = 13
|
||||
indexName = "Index"
|
||||
welcome = `# Welcome to GoWiki
|
||||
This is the [Index](/wiki/Index) page.
|
||||
You can customize it how you like.`
|
||||
wikiSection = "wiki"
|
||||
)
|
||||
|
||||
/*const (
|
||||
|
|
@ -40,12 +37,13 @@ type DB struct {
|
|||
Index *index.Index
|
||||
}
|
||||
|
||||
func NewDB(indexPath string) (db *DB, err error) {
|
||||
func New(indexPath string) (db *DB, err error) {
|
||||
db = &DB{cache: cache.NewCache()}
|
||||
db.Index, err = index.NewIndex(indexPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
//TODO
|
||||
//db.Index, err = index.NewIndex(indexPath)
|
||||
//if err != nil {
|
||||
// return
|
||||
//}
|
||||
|
||||
db.users, err = store.NewBoltStore(usersFile, nil)
|
||||
if err != nil {
|
||||
|
|
@ -66,11 +64,9 @@ func NewDB(indexPath string) (db *DB, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
if _, err = db.pageExists(util.StoreTitle(wikiSection, indexName), defUser); err != nil {
|
||||
_, err = db.CreatePage(indexName, wikiSection, welcome, defUser, core.Public)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = db.CreatePage(core.IndexPage, core.WikiSection, welcome, defUser, core.Public)
|
||||
if err != nil && err != store.ErrKeyNotFound {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -84,5 +80,7 @@ func (db *DB) Close() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return db.Index.Close()
|
||||
return nil
|
||||
//TODO
|
||||
//return db.Index.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue