From a9cedbb4a0fe184fc0481cf64ce0d7d2e81ae6c1 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 19 Jan 2021 11:47:19 -0500 Subject: [PATCH] Support single-user WriteFreely instances This removes the requirement to supply a username. --- cmd/wfgraphic-cli/main.go | 8 +------- textpic.go | 5 ++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cmd/wfgraphic-cli/main.go b/cmd/wfgraphic-cli/main.go index f6cc525..8a15095 100644 --- a/cmd/wfgraphic-cli/main.go +++ b/cmd/wfgraphic-cli/main.go @@ -24,19 +24,13 @@ var ( outputFile = flag.String("o", "out.png", "Image output filename") font = flag.String("font", "serif", "Post font (options: \"serif\", \"sans\", \"mono\") - NOT IMPLEMENTED YET") instance = flag.String("i", "write.as", "WriteFreely instance hostname (e.g. pencil.writefree.ly)") - author = flag.String("u", "", "WriteFreely author username") + author = flag.String("u", "", "WriteFreely author username (for multi-user instances)") ) func main() { log.Info("Starting...") flag.Parse() - if *author == "" { - log.Info("Aborting. -u flag is required") - flag.Usage() - os.Exit(1) - } - log.Info("Reading input...") in, err := ioutil.ReadAll(os.Stdin) if err != nil { diff --git a/textpic.go b/textpic.go index 88ecb75..a5e2c9b 100644 --- a/textpic.go +++ b/textpic.go @@ -73,7 +73,10 @@ func GenerateImage(opt *ContentOptions, outputFilename string) error { } dc.SetColor(color.Black) - userPath := "/" + opt.Username + var userPath = "" + if opt.Username != "" { + userPath = "/" + opt.Username + } userTextWidth, _ := dc.MeasureString(userPath) // x = canvas halfway point - total text width halfway point x = wf/2 - (baseTextWidth+userTextWidth)/2