Donations Box
Ask for donations in a pretty way.
About
donations-box is a widget for developers who want to list all their donation links, in a single place.
Features
- No Javascript required.
- No frames.
- Easy to use.
- Configurable.
- Minified already.
- Open Source.
Installation
- Via NPM:
npm i donations-box -g
. - Via YARN:
yarn global add donations-box
.
Usage
To add this widget to your site:
- Install it.
- Create a new file called
donations-box.config.js
, in the root of your project. - Set your donation links and your desired configurations. See here.
- Write
<!-- donations-box -->
where you want to include this widget. - Call the CLI or the JS version, during you build process.
And that's it!
If everything works as expected, you should see a new file in public/css
called donations-box.min.css
, and your files where you wrote <!-- donations-box -->
with the Donations Box's markup.
CLI
Run donations-box my-file
.
Where my-file
is where you want to add the widget to.
Options
If you need to change anything, try setting any of the following options:
donations-box <files...> [options]
Inject the donations box's markup in the given files.
Positionals:
files Files to inject the donations box's markup. (Globs supported).
Options:
--help Show help [boolean]
--version Show version number [boolean]
--config Path to your configuration file. See the Configure section in the
README file to know more.
[required] [default: "donations-box.config.js"]
--assetsDir Directory in which the assets for this project will be stored.
E.g: The css file. [default: "public"]
--token String to be replaced by the donations box's markup.
[default: "<!-- donations-box -->"]
JS
const donationsBox = require('donations-box');
(async () => {
try {
await donationsBox({
files: '',
config: '',
assetsDir: '',
token: ''
});
}
catch (
exception
) {
}
})();
Configuration
Configuration is done using a js
or a json
file, but a js
file is recommended.
The only requirement is that the js
file should export an object with your configurations.
Below are the supported configurations (remember that all the options are used for display purposes):
module.exports = {
'openInNewWindow': false,
'headline': '',
'disclaimer': '',
'open': true,
'maxColumns': 2,
'beneficiary': {
'alias': 'Donations Box',
'href': '/beneficiary.html',
'icon': {
'src': '/favicon.svg',
'alt': 'Donations Box icon',
'href': '/beneficiary.html?icon',
'html': null
}
},
'donations': {
'Stripe': [{
'type': 'one-off',
'href': '/donate.html',
'title': 'Buy me 1 coffee',
'amounts': [{
'href': '/donate.html',
'value': 3,
'periodicity': 'Daily',
'qr': {
'src': '/img/monero-qr.png',
'alt': 'Donations Box\'s Monero QR Code',
'srcset': '/img/monero-qr.png 2x',
'animate': false
},
'currency': {
'symbol': '$',
'name': 'Dollars',
'abbr': 'USD'
}
}]
}]
}
};
License
This project is under the MIT License, unless otherwise stated.