||4 weeks ago|
|LICENSES||3 months ago|
|docs||4 weeks ago|
|pkg||4 weeks ago|
|.gitignore||3 months ago|
|.gitignore.license||4 weeks ago|
|LICENSE.txt||1 year ago|
|Makefile||4 weeks ago|
|NOTICE.txt||3 months ago|
|NOTICE.txt.license||4 weeks ago|
|README.md||4 weeks ago|
|README.md.license||4 weeks ago|
|RELEASES.md||3 months ago|
|RELEASES.md.license||4 weeks ago|
|go.mod||1 year ago|
|go.mod.license||4 weeks ago|
|go.sum||1 year ago|
|go.sum.license||4 weeks ago|
|main.go||4 weeks ago|
...because your users shouldn't need to connect to someone else's server, just to display a few (static) badges in your README
Repository badges are a great visual cue you can use in your repository's README file to point your users to the most relevant information about your project.
Many badges that are out there are ready to use by just including an image tag into your README that dynamically loads the badge from the respective service's servers. Unless you use a proxy to access the badges (as GitHub does by default, unlike your average local markdown viewer), this implies that you have to point your users to the badge service's servers when they want to read your README. While that is very convenient for you as a developer, it is not optimal from a privacy and reliability point-of-view. That is because you now have to trust the badge service(s) to deal with your user's data responsibly and to run their servers reliably and safely. Also, if your users have cloned your repository, they now need Internet access to see your README the way you intended it to be.
To provide a decentralized and customizable alternative for those who don't want to go without repository badges, I have created ./badges. It is a collection of and generator for badges that you can copy to your repository and refer to locally.
Use pre-built badges
This project's Releases page
.zip files with a number of generic badges, like the ones you can see
at the top of this README.
You can download them and copy the badges you need into a subdirectory of your
repository (for example
./badges 🤓) and then refer to them in Markdown like
![API Reference](./badges/docs-apireference.svg) ![Apache License v2.0](./badges/license-apache20.svg) ...
Generate your own badges
You can also generate your own, custom badges using the ./badges generator, which you can download from this project's Releases page.
It is a single dependency-free executable that comes with templates, themes and fonts built-in.
If you want to build ./badges yourself, please refer to the Building ./badges section below.
To generate a single badge using the built-in standard template, run the following command:
./dot-slash-badges -template default -theme blue -p left=Foo -p right=Bar -o badge.svg
You can override nested parameters, such as theme parameters. For example:
./dot-slash-badges -template default -theme blue -p left=Foo -p right=Bar -p "theme.leftBgColor=#ff0000" -o custombadge.svg
You can load your own fonts. For example:
./dot-slash-badges -template default -theme blue -p left=Foo -p right=Bar -p "theme.leftFont=comic" -p "theme.rightFont=comicbd" -lf comic=comic.ttf -lf comicbd=comicbd.ttf -o custombadge.svg
The ./badges generator is fairly customizable. You can for example specify your own templates and themes that can be loaded from a file. For an overview of all available options, run
Parameters of the default template
The following parameters are supported in the default badge template:
|left||Hello||The text on the left of the badge|
|right||Hello||The text on the right of the badge|
|theme.fontSize||16||The size of the text on the badge|
|theme.height||25||The height of the badge|
|theme.leftBgColor||#2976B7||The background color of the left side of the badge|
|theme.leftFont||builtin-regular||The font family to be used for the left side of the badge. The font must be loaded explicitly first using the -lf parameter.|
|theme.leftTextColor||#FFFFFF||The text color of the left side of the badge|
|theme.rightBgColor||#A74168||The background color of the right side of the badge|
|theme.rightFont||builtin-black||The font family to be used for the right side of the badge. The font must be loaded explicitly first using the -lf parameter.|
|theme.rightTextColor||#FFFFFF||The text color of the right side of the badge|
Use ./badges web
The sister project
./badges web provides a webservice and corresponding
frontend for generating badges from the web.
Check it out at https://codeberg.org/lhinderberger/dot-slash-badges-web
Use ./badges as a library
The built-in templates and themes are literally built into ./badges, which you can in turn use as a batteries-included library in your own code.
This can be useful to create dynamic badges from your own server-side services.
./badges is a Go application that uses a Makefile for build automation.
To build it, you need:
- Go v1.16 or higher
- The REUSE linter (see https://reuse.software and https://reuse.readthedocs.io/) v1.0.0 or higher
- GNU make is recommended
For running the
release target of the makefile, you also need
Once you have the required software tools installed, run
build target of the Makefile will automatically
run the unit tests and the linter. If they pass, a binary for your current
system (or your current setup of
GOARCH environment variables)
will be built at the root of the source tree.
To just run the linter and unit tests, run
You can create your own templates for using with
./badges or use the template
To get started creating or adapting templates, you can have a look at the
built-in standard badge template, located at
the source tree of
Each template has its own directory, which contains:
template.tmplfile, which is a template in Go's text/template format
parameters.jsonfile that declares the template's parameters
themessubdirectory, containing one JSON file for each theme that you want to include with your template. Themes simply contain a set of template parameters that can be applied by specifying
./badgesto use the theme.
COPYING.txtfile describing Copyright restrictions on your template and its themes
- An optional
template.gofile, useful in case you want to compile your template into your application when using
./badgesas a library
template.tmpl file is written in Go's text/template
The template parameters are available via the dot notation, as described in the
text/template. For an example, have a look at the
template.tmpl file provided with the built-in standard badge template.
There are a number of functions available to
|Add||Adds two numbers|
|Div||Divides two numbers|
|FontMetrics||Calculates the metrics of the font with the given name. Results in a FontMetrics struct.|
|Mult||Multiplies two numbers|
|RenderText||Renders text to an SVG fragment. Parameters: Font name, text, font size, text color (in #rrggbb notation). Results in a RenderResult struct.|
|Sub||Subtracts two numbers|
Each template declares its parameters in its
parameters.json file is structured as a tree of Objects, with each node
either having a member called
parameter (to declare a parameter) or a member
subtree to recursively define a nested parameter specification.
Each parameter declaration consists of a
type, which is one of the types in
the table below, an optional
example value, the indicator
itself is optional) and - only for
string-type parameters - the optional hint
Supported parameter types:
- boolean (allows for the values "true" and "false")
- color (allows for color strings in #rrggbb notation)
- float (allows for single-precision floating point numbers)
- integer (allows for 24-bit signed integer values)
- string (allows for arbitrary strings)
Have a look at the
parameters.json file of the builtin standard badge template
./badges, located at
pkg/templates/standard-badge/parameters.json for an
./badges is a good solution for decentralizing badges that don't change
(such as licensing information or a link to the docs), it cannot provide you
with badges that change dynamically, for example a build status indicator.
You can, however, absolutely use ./badges to generate badges for your own, self-hosted (and most likely self-written 😉) dynamic batch services, that visually integrate nicely with the rest of the badges produced by ./badges. In fact, ./badges can be included as a Go library - and it comes with batteries included: The fonts, templates and themes of the ./badges generator are compiled into the library!
Feel free to contribute by posting issues on this project's Issue Tracker.
Please note that pull requests are only accepted if they are in line with the licensing of the rest of the project (see below).
Copyright and Licensing
The ./badges generator is (C) 2021-2022 Lucas Hinderberger firstname.lastname@example.org and Contributors
It is licensed under the Apache Licence Version 2.0.
The output of the ./badges generator using the built-in fonts, themes and templates is unencumbered by copyright restrictions (to the extent possible under law), due to the built-in fonts, themes and templates being released under CC0 1.0 Universal.
To the extent possible under law, the author has waived all copyright and related or neighboring rights to the pre-built badges originally distributed alongside ./badges, as described in CC0 1.0 Universal.
Author and Contact
./badges is authored by Lucas Hinderberger.
You can contact the author via email at email@example.com
The repository of ./badges can be found at https://codeberg.org/lhinderberger/dot-slash-badges
You're welcome to file bug reports, other issues and pull requests there.