Support single-user WriteFreely instances

This removes the requirement to supply a username.
This commit is contained in:
Matt Baer 2021-01-19 11:47:19 -05:00
parent 2d916df166
commit a9cedbb4a0
2 changed files with 5 additions and 8 deletions

View File

@ -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 {

View File

@ -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