snd

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 1 Imported by: 0

README

Discord GitHub Discussions GitHub release (latest by date)

Sales & Dungeons — Thermal Printer as D&D Utility.

With Sales & Dungeons you can create highly customizable handouts, quick reference and much more for your Dungeons and Dragons (or other PnP) Sessions. Most Thermal Printer are small in size and can be taken with you and kept right at the gaming table. Use-cases range from printing out magic items, spells or a letter that the group found to little character sheets of your players to use as DM note. The possibilities are nearly endless!

Warning: This is still rough and early version. If you want to get this working the best way is to jump on the Discord and ask for help.

Screenshot

Features

  • Works on Windows, Mac and Linux
  • Extensive templating system through Nunjucks
  • Various connection methods
    • Windows Direct Printing
    • Raw USB Printing
    • CUPS
    • Serial
  • Import & Export templates and data sources
  • Fast access to external data sources like Open5e (instant access to SRD monsters, spells and more)
  • Edit templates in your favorite editor (e.g. Visual Studio Code) and get live preview

Printer Requirements

At the moment Sales & Dungeons only supports the ESC/POS (Epson Standard Code) control codes, which is still one of the most used control code set. Check if a thermal printer you are interested in mentions ESC/POS or Epson in the description or manual.

In general the rule of thumb is:

  • Most cheap chinese thermal printer found on Amazon or AliExpress support it
  • Most epson thermal printer obviously support it
  • A lot of older Serial printer (like Metapace T-1) also support it

More specific information about tested printers can be found in the wiki: Printer-Settings

How It Works

Templates: Templates are created in HTML (and CSS) in combination with the Nunjucks templating language. You can imagine the templates as little websites. That makes it possible to use all the nice and convenient layout options that HTML and CSS has to offer and even include any common framework you might need (e.g. Fontawesome for Icons).

Rendered HTML: After creating a template you can create entries with the data you want and print them. Nunjucks will create the rendered HTML from the data you want to print.

Rendered Image: Then this HTML get's converted to a image. Currently this conversion is done by Chrome via the Chrome Debug Protocol. Although Chrome seems like a huge overkill for just HTML-To-Image conversion it's the standard solution at the moment because it supports most of the modern HTML and CSS features.

ESC / POS Commands: The last step before our awesome template hits the Printer is the conversion from the rendered image to the "draw image" command of the printer.

Printer: The generated command will then be sent to the printer and printed. Now your template is ready to be used!

🎉 🎉 🎉

Pre-Build Binaries

Check our github release page: https://github.com/BigJk/snd/releases

Printers, Templating & Building

If you want to see what printers were already tested, which settings they need, how the templates work or how you can build Sales & Dungeons yourself please visit the wiki.

Credits

Icons used in the Sales & Dungeons Logo were made by Smashicons, Good Ware from www.flaticon.com

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildTime string
View Source
var GitBranch string
View Source
var GitCommitHash string

Functions

This section is empty.

Types

type DataSource

type DataSource struct {
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Author      string `json:"author"`
	Description string `json:"description"`
	Version     string `json:"version"`
}

DataSource represents a data source in S&D.

func (DataSource) ID

func (ds DataSource) ID() string

type Entry

type Entry struct {
	ID   string                 `json:"id"`
	Name string                 `json:"name"`
	Data map[string]interface{} `json:"data"`
}

Entry represents one data entry in a template or data source.

type Settings

type Settings struct {
	PrinterType     string `json:"printerType"`
	PrinterEndpoint string `json:"printerEndpoint"`
	PrinterWidth    int    `json:"printerWidth"`
	Commands        struct {
		ExplicitInit      bool `json:"explicitInit"`
		Cut               bool `json:"cut"`
		ForceStandardMode bool `json:"forceStandardMode"`
		LinesBefore       int  `json:"linesBefore"`
		LinesAfter        int  `json:"linesAfter"`
	} `json:"commands"`
	Stylesheets []string `json:"stylesheets"`
}

Settings represents the basic settings for S&D.

type Template

type Template struct {
	Name          string                 `json:"name"`
	Slug          string                 `json:"slug"`
	Author        string                 `json:"author"`
	Description   string                 `json:"description"`
	PrintTemplate string                 `json:"printTemplate"`
	ListTemplate  string                 `json:"listTemplate"`
	SkeletonData  map[string]interface{} `json:"skeletonData"`
	Images        map[string]string      `json:"images"`
	DataSources   []string               `json:"dataSources"`
	Version       string                 `json:"version"`
}

Template represents one S&D template.

func (Template) ID

func (t Template) ID() string

Directories

Path Synopsis
cmd
app
Package database represents the data layer of S&D.
Package database represents the data layer of S&D.
Package imexport provides functions to import and export S&D templates and data sources.
Package imexport provides functions to import and export S&D templates and data sources.
Package log provides logging utilities for S&D and makes it possible to hook into the logging to save the logs somewhere else.
Package log provides logging utilities for S&D and makes it possible to hook into the logging to save the logs somewhere else.
cups
Package cups provides printing for Sales & Dungeons via cups.
Package cups provides printing for Sales & Dungeons via cups.
remote
Package remote provides printing for Sales & Dungeons via a remote endpoint.
Package remote provides printing for Sales & Dungeons via a remote endpoint.
usb
Package usb provides printing for Sales & Dungeons via USB.
Package usb provides printing for Sales & Dungeons via USB.
windows
Package windows provides printing for Sales & Dungeons via direct printing on windows.
Package windows provides printing for Sales & Dungeons via direct printing on windows.
Package rendering provides a function to render HTML to images.
Package rendering provides a function to render HTML to images.
Package server represents the webserver that powers S&D.
Package server represents the webserver that powers S&D.
thermalprinter
epson
Package epson implements the protocol used by most thermal printer, also commonly referred to as ESC or POS commands.
Package epson implements the protocol used by most thermal printer, also commonly referred to as ESC or POS commands.

Jump to

Keyboard shortcuts

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