db: automatically populate first article in blank databases
This commit is contained in:
parent
53e5e0cfae
commit
c263decdfe
@ -1,6 +1,7 @@
|
||||
package yatwiki3
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
@ -28,6 +29,14 @@ func NewWikiServer(opts *ServerOptions) (*WikiServer, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tr, err := wdb.TotalRevisions()
|
||||
if (err == nil && tr == 0) || err == sql.ErrNoRows {
|
||||
err := wdb.SaveArticle(opts.DefaultPage, `YATWiki3`, "", 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
tmpl, err := template.New("yatwiki/page").Parse(pageTemplate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user