- Lua 100%
|
Christophe Delord
7c1a0c4ac4
simplified configuration
- the blur filter is hardcoded - only the outer rectangle is rounded |
||
|---|---|---|
| badges | simplified configuration | |
| .gitignore | Initial commit | |
| badges.lua | simplified configuration | |
| badges.toml | simplified configuration | |
| build.lua | simplified configuration | |
| LICENSE | LICENSE | |
| README.md | more examples | |
Badges
Badges Installation Usage Examples License Version
Lots of GitHub repositories use badges. They are visually nice, but they are also images dynamically built and loaded from third-party servers.
badges generates actually static badges as SVG images hosted on the same server.
It simply scans files, searches for things that look like a badge filename and generates badges as SVG images.
A badge file is a file in a directory named badges (or a subdirectory).
The filename describes the badge content, color and size.
- Badges with a single text
text-width-color.svgtext: text displayed in the badgewidth: width in pixels of the badgecolor: background color of the badge (e.g.:green,123,123456)
- Badges with two texts
text1-text2-width1-width2-color.svgtext1: first text displayed in the badgetext2: second text displayed in the badgewidth1: width in pixels of the first textwidth2: width in pixels of the second textcolor: background color of the second text (e.g.:green,123,123456)
The default color of the first text is white on grey.
badges makes some substitutions in the text fields:
_is replaced width (space)@xyzis replaced with the value of thexyzvariable (variablestable in the configuration file or-DCLI option)
Special characters in text fields can be escaped:
@@becomes@__becomes_(underscore)--becomes-(dash)
To insert characters that are invalid in a filename, you must use variables.
Installation
badges requires LuaX.
# install badges in ~/.local/bin and ~/.local/lib
$ git clone https://codeberg.org/cdsoft/badges
$ cd badges
$ bang && ninja install
or set $PREFIX to install badges to a custom directory ($PREFIX/bin and $PREFIX/lib):
$ export PREFIX=/path # install badges to /path/bin and /path/lib
$ git clone https://codeberg.org/cdsoft/badges
$ cd badges
$ bang && ninja install
This will install 2 files in $PREFIX/bin:
$PREFIX/bin/badges:badgescommand line utility compiled with LuaX. It can be run without any dependency.$PREFIX/bin/badges.lua:badges.luacommand line utility bundled with LuaX as a standalone Lua script. It requires a Lua 5.4 or 5.5 interpreter (e.g.: lua).
In case precompiled binaries are needed (GNU/Linux, MacOS, Windows),
some can be found at cdelord.fr/pub.
These archives contain badges as well as some other softwares more or less related to LuaX.
Usage
Usage: .build/badges [-h] [-v] [-c file.toml] [--init] [-D NAME=VALUE]
[<input>] ...
Arguments:
input files or directories to scan
Options:
-h, --help Show this help message and exit.
-v, --version Show badges version
-c file.toml Configuration file (default: badges.toml)
--init Print the default configuration
-D NAME=VALUE Define a variable
badges- Scans for files in the current directory and generates badges.
badges file.md dir1 dir2- Generate badges found in
file1.mdand in all files indir1anddir2. badges -c file.toml ...- Overloads the default configuration with a user configuration file.
badges -D V=42 ...- Defines a variable that can be used in textual fields (e.g.:
@Vis replaced with42). badges --init- Prints the default configuration.
The default configuration is badges.toml.
Examples
| Filename | Badge |
|---|---|
badges/License-GPL3-75-45-blue.svg |
|
badges/License-GPL3-75-45-057.svg |
|
badges/Linux-🐧-75-45-771077.svg |
|
badges/3_..._2_..._1-GO-75-45-003500.svg |
|
badges/Badges-75-blue.svg |
Badges |
badges/✅-45-grey.svg |
|
badges/Version-@VERSION-75-45-green.svg |
|
badges/text--with--dashes-and_@@arobases-150-120-28c.svg |
|
badges/__and__underscores__-150-gold.svg |
License
badges is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
badges is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with badges. If not, see <https://www.gnu.org/licenses/>.
For further information about badges you can visit
https://codeberg.org/cdsoft/badges