split into packages

This commit is contained in:
ston1th 2018-02-09 22:38:47 +01:00
commit c5d41b0965
26 changed files with 328 additions and 449 deletions

42
pkg/db/page.go Normal file
View file

@ -0,0 +1,42 @@
package db
type Article struct {
Title string `json:"title"`
LinkTitle string `json:"-"`
Search string `json:"search"`
Index template.HTML `json:"index"`
Text template.HTML `json:"text"`
MD string `json:"md"`
Created string `json:"created"`
Updated string `json:"updated"`
Public bool `json:"public"`
}
type Permission int
const (
Public Permission = iota
Internal
Private
)
type Page struct {
Title string `json:"title"`
Markdown string `json:"markdown"`
Index template.HTML `json:"index"`
Text template.HTML `json:"text"`
Created string `json:"created"`
Updated string `json:"updated"`
Perm Permission `json:"perm"`
}
func (bs *BoltStore) GetPage(title string) (p Page, err error) {
err = bs.db.View(func(tx *bolt.Tx) error {
v := tx.Bucket([]byte(pageTable)).Get([]byte(username))
if v == nil {
return errUserNotExists
}
return bs.Unmarshal(v, &u)
})
return
}