Amio 6 years ago
parent
commit
1e15505169
  1. 10
      README.md
  2. 8
      libs/index.md
  3. 7
      libs/live-fns/crates.js
  4. 3
      libs/live-fns/pypi.js
  5. 31
      libs/serve-index.js

10
README.md

@ -29,13 +29,17 @@ We are using [StandardJS][standard-href] style, make sure you have ESLint/Standa
### Add live badge
If a service you wish to have is still missing here, we welcome new contirbutions. Check out [live-fns/crates.js](libs/live-fns/crates.js) and [live-fns/_index.js](libs/live-fns/_index.js) to get a quick impression. Basically, you need to add a file in `libs/live-fns/[name-of-service].js` and that's it.
If a service you wish to have is still missing here, we welcome new contirbutions. Basically, you need to add a file in `libs/live-fns/[name-of-service].js` and that's it. Take [crates](https://badgen.net/#crates) as an example:
- [libs/live-fns/crates.js](libs/live-fns/crates.js) - the main function for [crates.io](https://crates.io)
- [libs/live-fns/_index.js](libs/live-fns/_index.js) - the list of all live-badges
- [libs/index.md](libs/index.md) - the `index.md` holds examples
To ensure that your addition is working correctly start the development server with `npm run dev`.
### Deploy your own Badgen
### Deploy to Now Cloud
Badgen generate badges on the fly, which means it's stateless (not rely on any db service). Deploy your own Badgen instance to [Now Cloud](https://zeit.co/now) with one single command:
Badgen generate badges on the fly, which means it's stateless (not rely on any db service). Deploy your own Badgen Service to [Now Cloud](https://zeit.co/now) with one single command:
```
now amio/badgen-service
```

8
libs/index.md

@ -178,14 +178,6 @@ Available icons:
}
</script>
## About
Made with ❤️ by [Amio](https://github.com/amio)
<span style="float:right; color: #AAA">
<a href="https://github.com/amio/badgen-service">GitHub</a> |
<a href="https://twitter.com/badgen_net">Twitter</a>
</span>
<script>
// Update usage url for 'flat.badgen.net'
if (window.location.hostname === 'flat.badgen.net') {

7
libs/live-fns/crates.js

@ -1,8 +1,9 @@
const axios = require('../axios.js')
const millify = require('millify')
const semColor = require('../utils/sem-color.js')
module.exports = async function (topic, ...args) {
const endpoint = `https://crates.io/api/v1/crates/${args[0]}`
module.exports = async function (topic, pkg) {
const endpoint = `https://crates.io/api/v1/crates/${pkg}`
const { crate } = await axios.get(endpoint).then(res => res.data)
switch (topic) {
@ -10,7 +11,7 @@ module.exports = async function (topic, ...args) {
return {
subject: 'crates.io',
status: 'v' + crate.max_version,
color: crate.max_version[0] === '0' ? 'orange' : 'blue'
color: semColor(crate.max_version)
}
case 'd':
return {

3
libs/live-fns/pypi.js

@ -1,4 +1,5 @@
const axios = require('../axios.js')
const semColor = require('../utils/sem-color.js')
module.exports = async function (method, project) {
const endpoint = `https://pypi.org/pypi/${project}/json`
@ -9,7 +10,7 @@ module.exports = async function (method, project) {
return {
subject: 'pypi',
status: 'v' + info.version,
color: info.version[0] === '0' ? 'orange' : 'blue'
color: semColor(info.version)
}
default:
return {

31
libs/serve-index.js

@ -4,7 +4,8 @@ module.exports = serveMarked('libs/index.md', {
title: 'Badgen - Fast badge generating service',
preset: 'merri',
inlineCSS: `
body { max-width: 950px; padding: 0 1.6em 1em }
body { max-width: inherit }
body > * { width: 950px; margin-left: auto; margin-right: auto }
h1 + p { letter-spacing: 0.1px }
h1 + p a { display: inline-block; margin-top: 1em; padding: 4px; height: 20px }
h1 + p img { height: 20px }
@ -28,7 +29,35 @@ module.exports = serveMarked('libs/index.md', {
dd b { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif }
dd b { display: inline-block; min-width: 15em; text-align: right; font-weight: 300; color: #999 }
dd i { display: inline-block; min-width: 13.5em }
#footer { width: 100vw; margin: 5rem -1rem 0; background-color: #333; color: #CCC }
#foo-content { width: 950px; margin: 0 auto; padding: 2rem 1rem; letter-spacing: 0.5px }
#foo-content { display: grid; grid-template-columns: 1fr 1fr }
#foo-content h3 { font-weight: 300 }
#foo-content p { line-height: 2em; font-weight: 300 }
#foo-content a { color: #FFF }
#foo-content aside { padding: 1rem 1rem; display: flex; justify-content: flex-end; align-items: flex-end }
#foo-content aside a { line-height: 2em; margin-left: 1rem }
`,
beforeHeadEnd: `<link rel="icon" type="image/svg+xml" href="/favicon.svg">`,
beforeBodyEnd: `
<div id="footer">
<div id="foo-content">
<segment>
<h3>Badgen Service</h3>
<p>
built with <br/>
by <a href="https://github.com/amio">Amio</a>
and awesome <a href="https://github.com/amio/badgen-service/graphs/contributors">contributors</a><br/>
hosted on <a href="#">Now Cloud</a>
</p>
</segment>
<aside>
<a href="https://github.com/amio/badgen-service">GitHub</a>
<a href="https://twitter.com/badgen_net">Twitter</a>
</aside>
</div>
</div>
`,
trackingGA: 'UA-4646421-14'
})

Loading…
Cancel
Save