From a3270f399d54fffd9619c2af9e3e5617ebe20056 Mon Sep 17 00:00:00 2001 From: ston1th Date: Thu, 6 Apr 2017 21:14:48 +0200 Subject: [PATCH] copyright messgae and verbose mode --- context.go | 2 ++ dump.go | 12 ++++++++++-- engine.go | 2 ++ handler.go | 2 ++ logger.go | 2 ++ main.go | 4 ++++ render.go | 2 ++ routes.go | 2 ++ sri.sh | 2 ++ templates.go | 10 ++++++---- templates.sh | 4 ++++ userdb.go | 2 ++ 12 files changed, 40 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index 9b7cde7..0513111 100644 --- a/context.go +++ b/context.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( diff --git a/dump.go b/dump.go index 83b0b44..4cea771 100644 --- a/dump.go +++ b/dump.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( @@ -17,6 +19,12 @@ type DumpArticle struct { Public bool `json:"public"` } +func verboseLog(prefix, title string) { + if verbose { + fmt.Fprintln(os.Stderr, prefix, title) + } +} + func dumpWiki() error { index, err := bleve.OpenUsing(bleveStore, map[string]interface{}{"read_only": true}) if err != nil { @@ -38,7 +46,7 @@ func dumpWiki() error { if err != nil { return err } - fmt.Fprintln(os.Stderr, "dump:", art.Title) + verboseLog("dump:", art.Title) arts = append(arts, DumpArticle{ Title: art.Title, LinkTitle: art.LinkTitle, @@ -68,7 +76,7 @@ func restoreWiki() (err error) { return } for _, art := range arts { - fmt.Fprintln(os.Stderr, "restore:", art.Title) + verboseLog("restore:", art.Title) err = engine.Restore(art) if err != nil { return diff --git a/engine.go b/engine.go index 44c0b7e..0e50af9 100644 --- a/engine.go +++ b/engine.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( diff --git a/handler.go b/handler.go index 30cac26..5165955 100644 --- a/handler.go +++ b/handler.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( diff --git a/logger.go b/logger.go index bdb85f7..75efbf0 100644 --- a/logger.go +++ b/logger.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( diff --git a/main.go b/main.go index cc7357f..7b9d41c 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + //go:generate ./templates.sh package main @@ -48,6 +50,7 @@ var ( dump bool restore bool + verbose bool ) func main() { @@ -59,6 +62,7 @@ func main() { 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(&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() err := os.Chdir(datadir) diff --git a/render.go b/render.go index 2cd1e27..1636cc5 100644 --- a/render.go +++ b/render.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( diff --git a/routes.go b/routes.go index 2504774..d6426fe 100644 --- a/routes.go +++ b/routes.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import ( diff --git a/sri.sh b/sri.sh index a0c7988..7add35f 100755 --- a/sri.sh +++ b/sri.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (C) 2017 Marius Schellenberger + HASH="sha256" DIR="templates" FILES="*.css *.js *.ico" diff --git a/templates.go b/templates.go index f738cf4..73efdc1 100644 --- a/templates.go +++ b/templates.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + // This file is auto-generated by build/templates.sh // using the contents of the templates directory @@ -321,7 +323,7 @@ const ( {{if .Admin}}
{{end}} @@ -347,11 +349,11 @@ const ( no {{end}} {{if $admin}} - Edit  - Delete + Edit  + Delete {{else}} {{if eq $item.Username $user}} - Edit + Edit {{else}} {{end}} diff --git a/templates.sh b/templates.sh index d6df51e..4a14391 100755 --- a/templates.sh +++ b/templates.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (C) 2017 Marius Schellenberger + # this file generates Go source code for the gowiki # it contains html and css and uses the contents # of the templates directory @@ -12,6 +14,8 @@ if [ ! -d templates ]; then fi cat << EOF > ${templates_go} +// Copyright (C) 2017 Marius Schellenberger + // This file is auto-generated by build/templates.sh // using the contents of the templates directory diff --git a/userdb.go b/userdb.go index 94d95a0..c5b9182 100644 --- a/userdb.go +++ b/userdb.go @@ -1,3 +1,5 @@ +// Copyright (C) 2017 Marius Schellenberger + package main import (