copyright messgae and verbose mode

This commit is contained in:
ston1th 2017-04-06 21:14:48 +02:00
commit a3270f399d
12 changed files with 40 additions and 6 deletions

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (

12
dump.go
View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (
@ -17,6 +19,12 @@ type DumpArticle struct {
Public bool `json:"public"` Public bool `json:"public"`
} }
func verboseLog(prefix, title string) {
if verbose {
fmt.Fprintln(os.Stderr, prefix, title)
}
}
func dumpWiki() error { func dumpWiki() error {
index, err := bleve.OpenUsing(bleveStore, map[string]interface{}{"read_only": true}) index, err := bleve.OpenUsing(bleveStore, map[string]interface{}{"read_only": true})
if err != nil { if err != nil {
@ -38,7 +46,7 @@ func dumpWiki() error {
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintln(os.Stderr, "dump:", art.Title) verboseLog("dump:", art.Title)
arts = append(arts, DumpArticle{ arts = append(arts, DumpArticle{
Title: art.Title, Title: art.Title,
LinkTitle: art.LinkTitle, LinkTitle: art.LinkTitle,
@ -68,7 +76,7 @@ func restoreWiki() (err error) {
return return
} }
for _, art := range arts { for _, art := range arts {
fmt.Fprintln(os.Stderr, "restore:", art.Title) verboseLog("restore:", art.Title)
err = engine.Restore(art) err = engine.Restore(art)
if err != nil { if err != nil {
return return

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
//go:generate ./templates.sh //go:generate ./templates.sh
package main package main
@ -48,6 +50,7 @@ var (
dump bool dump bool
restore bool restore bool
verbose bool
) )
func main() { func main() {
@ -59,6 +62,7 @@ func main() {
flag.BoolVar(&secureCookie, "s", false, "enable secure cookie") flag.BoolVar(&secureCookie, "s", false, "enable secure cookie")
flag.BoolVar(&dump, "dump", false, "create a json dump of all articles in the data directory (dump is written to stdout)") flag.BoolVar(&dump, "dump", false, "create a json dump of all articles in the data directory (dump is written to stdout)")
flag.BoolVar(&restore, "restore", false, "restore a json dump to the data directory (dump is read from stdin)") flag.BoolVar(&restore, "restore", false, "restore a json dump to the data directory (dump is read from stdin)")
flag.BoolVar(&verbose, "v", false, "enable verbose dump/restore mode")
flag.Parse() flag.Parse()
err := os.Chdir(datadir) err := os.Chdir(datadir)

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (

2
sri.sh
View file

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# Copyright (C) 2017 Marius Schellenberger
HASH="sha256" HASH="sha256"
DIR="templates" DIR="templates"
FILES="*.css *.js *.ico" FILES="*.css *.js *.ico"

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
// This file is auto-generated by build/templates.sh // This file is auto-generated by build/templates.sh
// using the contents of the templates directory // using the contents of the templates directory
@ -321,7 +323,7 @@ const (
{{if .Admin}} {{if .Admin}}
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<a href="/user/new"><b>New User</b></a> <a class="btn btn-sm btn-primary" href="/user/new"><b>New User</b></a>
</div> </div>
</div> </div>
{{end}} {{end}}
@ -347,11 +349,11 @@ const (
<td>no</td> <td>no</td>
{{end}} {{end}}
{{if $admin}} {{if $admin}}
<td><a href="/user/edit/{{$item.Username}}">Edit</a>&nbsp; <td><a class="btn btn-xs btn-primary" href="/user/edit/{{$item.Username}}">Edit</a>&nbsp;
<a href="/user/del/{{$item.Username}}">Delete</a></td> <a class="btn btn-xs btn-danger" href="/user/del/{{$item.Username}}">Delete</a></td>
{{else}} {{else}}
{{if eq $item.Username $user}} {{if eq $item.Username $user}}
<td><a href="/user/edit/{{$item.Username}}">Edit</a></td> <td><a class="btn btn-xs btn-primary" href="/user/edit/{{$item.Username}}">Edit</a></td>
{{else}} {{else}}
<td></td> <td></td>
{{end}} {{end}}

View file

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# Copyright (C) 2017 Marius Schellenberger
# this file generates Go source code for the gowiki # this file generates Go source code for the gowiki
# it contains html and css and uses the contents # it contains html and css and uses the contents
# of the templates directory # of the templates directory
@ -12,6 +14,8 @@ if [ ! -d templates ]; then
fi fi
cat << EOF > ${templates_go} cat << EOF > ${templates_go}
// Copyright (C) 2017 Marius Schellenberger
// This file is auto-generated by build/templates.sh // This file is auto-generated by build/templates.sh
// using the contents of the templates directory // using the contents of the templates directory

View file

@ -1,3 +1,5 @@
// Copyright (C) 2017 Marius Schellenberger
package main package main
import ( import (