btcp-digital-store/README.md

154 lines
5.2 KiB
Markdown
Raw Permalink Normal View History

2017-12-17 03:15:55 -08:00
# FileBazaar
2018-03-16 02:34:33 -07:00
[![npm release](https://img.shields.io/npm/v/filebazaar.svg)](https://www.npmjs.com/package/filebazaar)
2018-03-21 17:02:54 -07:00
[![MIT license](https://img.shields.io/github/license/elementsproject/filebazaar.svg)](https://github.com/elementsproject/filebazaar/blob/master/LICENSE)
2018-03-24 00:18:58 -07:00
[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
[![IRC](https://img.shields.io/badge/chat-on%20freenode-brightgreen.svg)](https://webchat.freenode.net/?channels=lightning-charge)
2018-03-16 02:34:33 -07:00
2018-03-21 17:02:54 -07:00
Sell digital files with Bitcoin & Lightning.
2017-12-17 03:15:55 -08:00
2018-03-21 17:02:54 -07:00
- Simple setup and minimal configuration, just put some files in a directory and start the server.
2017-12-17 03:15:55 -08:00
- Lightweight web browsing interface, works without JavaScript.
- Generates previews for images, videos, audio, pdf and text documents.
2018-03-21 17:02:54 -07:00
Powered by :zap: [Lightning Charge](https://github.com/ElementsProject/lightning-charge).
![FileBazaar demo](https://i.imgur.com/UhQD0Tg.gif)
2018-03-11 15:56:34 -07:00
2017-12-17 03:15:55 -08:00
## Quickstart
2017-12-29 11:34:57 -08:00
Setup [Lightning Charge](https://github.com/ElementsProject/lightning-charge), then:
2017-12-17 03:15:55 -08:00
```bash
# Install dependencies for EXIF extraction and preview generation
2018-03-21 17:02:54 -07:00
$ apt install exiftool ffmpeg graphicsmagick unoconv
2017-12-17 03:15:55 -08:00
2018-03-21 17:02:54 -07:00
# Install dependencies for node-canvas (see https://github.com/Automattic/node-canvas#installation)
$ apt install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
2017-12-17 03:15:55 -08:00
# Install filebazaar
$ npm install -g filebazaar
# Prepare a directory with the files you wish to sell and cd to it
$ mkdir ~/ForSale && cd ~/ForSale
2018-03-21 17:02:54 -07:00
# Initialize the `_filebazaar.yaml` config file
2017-12-17 03:15:55 -08:00
$ filebazaar init
2018-03-21 17:02:54 -07:00
# Edit the config file (`charge_token` is required, `token_secret` is auto-generated)
2018-03-11 15:56:34 -07:00
$ edit _filebazaar.yaml
2017-12-17 03:15:55 -08:00
# Start filebazaar!
$ filebazaar
```
## Configuration
FileBazaar's configuration options can be managed using the `_filebazaar.yaml` file or via environment variables.
2018-03-21 17:02:54 -07:00
All config options are optional and have sane defaults except for `charge_token` and `token_secret`, which are required.
See [`lib/config.js`](https://github.com/elementsproject/filebazaar/blob/master/src/lib/config.js) for more details.
2017-12-17 03:15:55 -08:00
Below is an example `_filebazaar.yaml` file:
```yaml
---
### Server settings
port: 9678
host: 127.0.0.1
env: production
url: http://my-public-url.com/
2017-12-29 11:34:57 -08:00
### Lightning Charge
2017-12-17 03:15:55 -08:00
2017-12-29 11:34:57 -08:00
charge_url: http://localhost:9112
charge_token: API_TOKEN_CONFIGURED_IN_CHARGE
2017-12-17 03:15:55 -08:00
### FileBazaar settings
# The directory containing the files for sale
# defaults to the directory containing the _filebazaar.yaml file
directory: /home/shesek/ForSale
# The default file price, can be overridden for individual files (see below)
default_price: 0.25 USD
# Expiry times
invoice_ttl: 3600 # lock-in exchange rate for 1 hour
download_ttl: 172800 # make download available for 2 days after payment
2017-12-17 03:15:55 -08:00
# Secret for generating HMAC access tokens (required)
token_secret: SOME_LONG_RANDOM_STRING
# Directory to keep cached preview files
# defaults to `{directory}/_filebazaar_cache`
cache_path: /path/to/filebazaar_cache
### Looks & feel
# See available themes on https://bootswatch.com
theme: yeti
# Add custom CSS
css: |
body { background: blue }
a { color: orange }
# Set custom views directory
views_dir: /path/to/custom/views
# Set custom static files directory
static_dir: /path/to/custom/static
### Files settings
files:
Books/Mastering-Bitcoin.pdf:
price: 5 USD
button: Buy this book
desc: >
Mastering Bitcoin is essential reading for everyone interested in learning about bitcoin.
This field **supports markdown** and will show up on the file's page.
# if you're only interested in setting the price, you can use:
Books/Mastering-Bitcoin.pdf: 5 USD
# if you want to configure multiple files inside the same directory, you can nest them:
Media/: # (note the trailing slash)
Books/Andreas/:
Mastering-Bitcoin.pdf: 5 USD # /Media/Books/Andreas/Mastering-Bitcoin.pdf
The-Internet-of-Money.pdf: 4 USD # /Media/Books/Andreas/The-Internet-of-Money.pdf
```
## CLI
2018-03-21 17:02:54 -07:00
#### Initializing `_filebazaar.yaml`
You can use `$ filebazaar init [directory]` to initialize a new `_filebazaar.yaml` config file.
A random `token_secret` will be added for you. If no `[directory]` is specified, the file will be created in the working directory.
#### Running FileBazaar
2017-12-17 03:15:55 -08:00
2018-03-21 17:02:54 -07:00
To start FileBazaar, run `$ filebazaar [path]`. You can either specify the path to the files directory or to the `_filebazaar.yaml` file.
If no `[path]` is specified, defaults to the working directory.
2017-12-17 03:15:55 -08:00
## File Preview
FileBazaar can currently generate previews for the following file types:
2018-03-21 17:02:54 -07:00
- Images: a preview image will be generated by pixelating the left half of the image and adding watermark text using [node-canvas](https://github.com/Automattic/node-canvas) and [graphicsmagick](http://www.graphicsmagick.org) (see [example image](https://i.imgur.com/OmrUysL.png)).
2017-12-17 03:15:55 -08:00
- Videos & audio: a preview will be generated by slicing off the first 30 seconds using [ffmpeg](http://ffmpeg.org).
- Documents: a preview image of the first page of the document will be generated using [unoconv](https://github.com/dagwieers/unoconv) (supports pdf, doc, docx, odt, and many others).
In addition, EXIF metadata will be extracted using [exiftool](https://www.sno.phy.queensu.ca/~phil/exiftool/) and displayed for all file types.
## License
MIT