Help us shape the future of Go! Take the 2026 Go Developer Survey

verzettler

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 8 Imported by: 0

README

Verzettler

Verzettler turns key-value pairs provided in the JSON format into flash cards ready for duplex printing.

Zettelserver

Run it:

$ go run server/zettelserver.go

Then browse localhost:3771/index.html.

Alternatively, use curl or the like:

$ curl -X POST -F pairs=@pairs.json -F cols=3 -F rows=5 -F size=14 \
  "http://localhost:3771/zettel" --output flashcards.pdf

Command Line Tool

Build the program:

$ go build cmd/verzettler.go

Copy any TTF font into the working directory and call the file font.ttf. Then run the program:

$ ./verzettler pairs.json

The output flashcards.pdf will be written to the current working directory.

Get help on the command line options:

$ ./verzettler -h

Use a special font:

$ ./verzettler -font /usr/share/fonts/TTF/DejaVuSans.ttf pairs.json

Use a bigger font size:

$ ./verzettler -size 18 pairs.json

Use a different row/column layout in the output:

$ ./verzettler -rows 5 -cols 3 pairs.json

Use a different output path:

$ ./verzettler -out vocabulary.pdf pairs.json

Documentation

Overview

verzettler converts a JSON file of key-value pairs into PDF flash cards.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFlashCardsPDF

func BuildFlashCardsPDF(params FlashCardParams) error

BuildFlashCardsPDF takes a map of word pairs, a path to store the resulting PDF, the path to a font file (TTF), and renders a PDF of flash cards.

func DistributeWords

func DistributeWords(pdf *gopdf.GoPdf, page Page)

DistributeWords renders the given page's words on a PDF.

func DrawGrid

func DrawGrid(pdf *gopdf.GoPdf, page Page)

DrawGrid renders a grid on the PDF according to the page's rows and cols.

func Fail

func Fail(msg string, args ...interface{})

Types

type FlashCardParams

type FlashCardParams struct {
	Rows       int
	Cols       int
	FontSize   int
	FontPath   string
	InputPath  string
	OutputPath string
}

FlashCardParams contains all the meta parameters needed to generate a flash cards PDF from a JSON input file.

func ParseCommandLineArguments

func ParseCommandLineArguments(cmdName string) FlashCardParams

type Page

type Page struct {
	Items []string
	Rows  int
	Cols  int
}

Page represents a set of items and a grid of Rows and Cols.

func NewPage

func NewPage(rows, cols int) Page

NewPage creats a Page with an empty Items slice of size Rows*Cols.

type Sheet

type Sheet struct {
	Front Page
	Back  Page
}

Sheet represents a physical sheet of paper with a Front and a Back page.

func Distribute

func Distribute(pairs map[string]string, rows, cols int) []Sheet

Distribute distributes the string pairs over a sheet. The order on the front and back page are reversed within a row, so that a pair is correctly placed on a duplex printout on the resulting sheets.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL