Skip to content

Commit 7c688cc

Browse files
committed
chore: publish badgelib
1 parent 1e9e264 commit 7c688cc

File tree

8 files changed

+53
-31
lines changed

8 files changed

+53
-31
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
username: ${{ github.actor }}
4444
password: ${{ secrets.GITHUB_TOKEN }}
4545

46-
- name: build & push (main)
46+
- name: Build & push (dev)
4747
if: ${{ github.ref == 'refs/heads/main' }}
4848
uses: docker/build-push-action@v6
4949
with:
@@ -54,7 +54,7 @@ jobs:
5454
tags: |
5555
ghcr.io/${{ github.repository }}:dev
5656
57-
- name: build & push (tag)
57+
- name: Build & push (tag)
5858
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
5959
uses: docker/build-push-action@v6
6060
with:
@@ -71,3 +71,13 @@ jobs:
7171
uses: softprops/action-gh-release@v2
7272
env:
7373
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
publish:
76+
runs-on: ubuntu-latest
77+
needs: build
78+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
79+
steps:
80+
- name: Publish to crates.io
81+
run: cargo publish --manifest-path badgelib/Cargo.toml
82+
env:
83+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ docker-run: docker-build
3434
docker rm --force $(tag) || true
3535
docker run -p 8080:8080 --name $(tag) $(tag)
3636

37+
publish:
38+
cargo publish --manifest-path badgelib/Cargo.toml
39+
3740
bench:
3841
@# wrk -t4 -c400 -d30s http://localhost:8080/health
3942
wrk -t4 -c400 -d30s 'http://localhost:8080/badge/?icon=github&label=GitHub&value=badges'

app/assets/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ html { scroll-behavior: smooth; }
1111
.flex-col { display: flex; flex-direction: column; }
1212
.flex-wrap { flex-wrap: wrap; }
1313
.items-center { align-items: center; }
14+
.justify-center { justify-content: center; }
15+
.justify-between { justify-content: space-between; }
1416
.w-1\/2 { width: 50%; }
1517
.w-1\/4 { width: 25%; }
1618
.gap-2 { gap: 0.5rem; }
1719
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
20+
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
21+
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
1822
.pr-2 { padding-right: 0.5rem; }
1923
.text-center { text-align: center; }
2024
.text-right { text-align: right; }

app/src/apis/gems.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ async fn get_data(name: String) -> Res<GemData> {
3535
Ok(GemData { version, license, dlt, ruby_ver })
3636
}
3737

38+
fn norm_min_ver(v: &String) -> String {
39+
v.replace(">=", "≥").replace("<=", "≤")
40+
}
41+
3842
#[derive(Debug, Deserialize, Serialize, strum::EnumIter, strum::Display)]
3943
pub(crate) enum Kind {
4044
#[serde(rename = "v", alias = "version")]
@@ -56,6 +60,6 @@ pub async fn handler(
5660
Kind::Version => Ok(badge.for_version("gem", &rs.version)),
5761
Kind::License => Ok(badge.for_license(&rs.license)),
5862
Kind::DlTotal => Ok(badge.for_downloads(Period::Total, rs.dlt)),
59-
Kind::Ruby => Ok(badge.label("ruby").value(&rs.ruby_ver)),
63+
Kind::Ruby => Ok(badge.label("ruby").value(&norm_min_ver(&rs.ruby_ver))),
6064
}
6165
}

app/src/pages.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,21 @@ fn layout(title: Option<&str>, node: Markup) -> Markup {
9898
title { (title) }
9999
meta name="title" content=(title) {}
100100
meta name="description" content=(descr) {}
101+
link rel="icon" type="image/svg+xml" href="/assets/logo.svg" {}
102+
// link rel="icon" type="image/png" href="/assets/favicon.png" {}
103+
// link rel="apple-touch-icon" href="/assets/apple-touch-icon.png" {}
101104

102105
// Open Graph / X Meta Tags
103106
meta property="og:type" content="website" {}
104107
meta property="og:url" content="https://badges.ws/" {}
105108
meta property="og:title" content=(title) {}
106109
meta property="og:description" content=(descr) {}
107-
meta property="og:image" content="/assets/social-preview.png" {}
110+
// meta property="og:image" content="/assets/social-preview.png" {}
108111
meta property="twitter:card" content="summary_large_image" {}
109112
meta property="twitter:url" content="https://badges.ws/" {}
110113
meta property="twitter:title" content=(title) {}
111114
meta property="twitter:description" content=(descr) {}
112-
meta property="twitter:image" content="/assets/social-preview.png" {}
113-
link rel="icon" type="image/svg+xml" href="/assets/logo.svg" {}
114-
// link rel="icon" type="image/png" href="/assets/favicon.png" {}
115-
// link rel="apple-touch-icon" href="/assets/apple-touch-icon.png" {}
115+
// meta property="twitter:image" content="/assets/social-preview.png" {}
116116

117117
// Additional Meta Tags
118118
meta name="theme-color" content="#ffffff" {}
@@ -148,8 +148,6 @@ fn layout(title: Option<&str>, node: Markup) -> Markup {
148148
a href="/privacy" class="contrast" { "Privacy Policy" }
149149
}
150150

151-
152-
153151
li {
154152
a href="https://github.com/vladkens/badges" class="contrast flex-row items-center" target="_blank" {
155153
"View on GitHub"
@@ -1170,12 +1168,13 @@ pub async fn index() -> AnyRep<impl IntoResponse> {
11701168
(sec_options)
11711169

11721170
section {
1173-
(heading(3, "Badges"))
1171+
(heading(3, "Dynamic badges"))
11741172
(render_tbox("Static", static_examples))
11751173
}
11761174

11771175
section {
1178-
(heading(3, "Languages & Packages"))
1176+
(heading(3, "Integrations"))
1177+
// Languages & Packages
11791178
(render_enum::<apis::npm::Kind>("NPM", "/npm/{}/apigen-ts"))
11801179
(render_enum::<apis::pypi::Kind>("PyPI", "/pypi/{}/twscrape"))
11811180
(render_enum::<apis::crates::Kind>("Crates.io", "/crates/{}/tokio"))
@@ -1190,27 +1189,18 @@ pub async fn index() -> AnyRep<impl IntoResponse> {
11901189
(render_enum::<apis::cocoapods::Kind>("CocoaPods", "/cocoapods/{}/SwiftyJSON"))
11911190
(render_enum::<apis::puppetforge::Kind>("Puppet Forge", "/puppetforge/{}/puppetlabs/puppetdb"))
11921191
(render_enum::<apis::cpan::Kind>("CPAN", "/cpan/{}/PerlPowerTools"))
1193-
}
1194-
1195-
section {
1196-
(heading(3, "Marketplaces"))
1192+
// Marketplaces
11971193
(render_enum::<apis::homebrew::Kind>("Homebrew", "/homebrew/{}/macmon"))
11981194
(render_enum::<apis::homebrew::Kind>("Homebrew Cask", "/homebrew/{}/cask/firefox"))
11991195
(render_enum::<apis::vscode::Kind>("VS Code", "/vscode/{}/esbenp.prettier-vscode"))
12001196
(render_enum::<apis::amo::Kind>("Mozilla Add-ons", "/amo/{}/privacy-badger17"))
12011197
(render_enum::<apis::cws::Kind>("Chrome Web Store", "/cws/{}/epcnnfbjfcgphgdmggkamkmgojdagdnn"))
12021198
(render_enum::<apis::jetbrains::Kind>("JetBrains Plugin", "/jetbrains/{}/22282"))
1203-
}
1204-
1205-
section {
1206-
(heading(3, "Services & CI/CD"))
1199+
// Services & CI/CD
12071200
(render_enum::<apis::github::Kind>("GitHub", "/github/{}/vladkens/macmon"))
12081201
(render_enum::<apis::docker::Kind>("Docker", "/docker/{}/grafana/grafana"))
12091202
(render_enum::<apis::readthedocs::Kind>("Read the Docs", "/readthedocs/{}/pip"))
1210-
}
1211-
1212-
section {
1213-
(heading(3, "Community"))
1203+
// Community
12141204
(render_enum::<apis::discord::Kind>("Discord", "/discord/{}/793890238267260958"))
12151205
(render_enum::<apis::youtube::KindChannel>("YouTube Channel", "/youtube/channel/{}/UC8ENHE5xdFSwx71u3fDH5Xw"))
12161206
(render_enum::<apis::youtube::KindVideo>("YouTube Video", "/youtube/{}/dQw4w9WgXcQ"))

badgelib/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
name = "badgelib"
33
version = "0.1.0"
44
edition = "2024"
5+
license = "MIT"
6+
description = "A library for generating badges in Rust"
7+
homepage = "https://badges.ws"
8+
repository = "https://github.com/vladkens/badges/"
9+
keywords = ["badge", "badges", "shields"]
10+
categories = ["development-tools"]
511

612
[features]
713
default = []

badgelib/readme.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ A Rust library for generating customizable SVG badges, similar to shields.io.
1919

2020
## Installation
2121

22-
Add this to your `Cargo.toml`:
22+
Add **badgelib** to your project using the following `cargo` command:
2323

24-
```toml
25-
[dependencies]
26-
badgelib = "0.1.0"
24+
```sh
25+
cargo add badgelib
2726
```
2827

29-
To enable Axum integration, add the `axum` feature:
28+
To enable Axum integration, use:
3029

31-
```toml
32-
badgelib = { version = "0.1.0", features = ["axum"] }
30+
```sh
31+
cargo add badgelib --features axum
3332
```
3433

3534
## Usage

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ docker run -d -p 8080:80 ghcr.io/vladkens/badges:latest
8484

8585
*(⏳ = Coming Soon)*
8686

87+
## Use as a Rust Crate
88+
89+
The core library powering Badges.ws, **badgelib**, can also be used as a standalone Rust crate for generating customizable SVG badges programmatically.
90+
91+
For more details and examples, check out the [badgelib README](badgelib/readme.md).
92+
8793
## Contribute
8894

8995
**Missing an integration?** Request or contribute — let’s build the ultimate badge toolkit together!

0 commit comments

Comments
 (0)