Skip to content

Commit

Permalink
Add README and documentation-like goodies
Browse files Browse the repository at this point in the history
  • Loading branch information
vifon committed Apr 11, 2019
1 parent 67cc982 commit bb75562
Show file tree
Hide file tree
Showing 7 changed files with 868 additions and 0 deletions.
623 changes: 623 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions README.md
@@ -0,0 +1,88 @@
# Ledger Web

Ledger Web was initially created to bridge the gap between a
smartphone and [Ledger CLI](https://ledger-cli.org/) by exposing a
HTTP API. Since then it evolved into a more general web UI for
Ledger.

## Screenshots

### Charts

[![](https://raw.githubusercontent.com/vifon/ledger-web/master/examples/Charts.png)](https://raw.githubusercontent.com/vifon/ledger-web/master/examples/Charts.png)

### API replacement rules

[![](https://raw.githubusercontent.com/vifon/ledger-web/master/examples/Rules.png)](https://raw.githubusercontent.com/vifon/ledger-web/master/examples/Rules.png)

### Ledger register

[![](https://raw.githubusercontent.com/vifon/ledger-web/master/examples/Register.png)](https://raw.githubusercontent.com/vifon/ledger-web/master/examples/Register.png)

## Installation

1. Clone the repository and install the dependencies:

git clone https://github.com/vifon/ledger-web
cd ledger-web
virtualenv .venv
. .venv/bin/activate
pip install -r requirements.txt

2. Set up the database.

./manage.py makemigrations
./manage.py migrate

3. Set the access credentials:

./manage.py createsuperuser
./manage.py runserver

Follow the instructions on screen and the enter
http://localhost:8000/admin

Add a new entry in the *Ledger paths* table for your user, pointing
it to your Ledger file.

If you want to use the HTTP API, add an access token too. A token
should be between 32 and 256 characters long. You'll need to
generate it yourself, for example with `pwgen 256 1`.

4. Customize `ledger/settings.py`, specifically you may be interested
in the last 3 options.

5. Check that everything works at http://localhost:8000/

6. Enable the production mode in `ledger/settings.py`:

- Set `DEBUG = False`.
- Generate a new `SECRET_KEY`, for example with [this snippet](https://gist.github.com/sandervm/2b15775012685553f0e2).
- Enter your domain and possibly a localhost in `ALLOWED_HOSTS`.
- Set `STATIC_ROOT`, for example `'/var/www/ledger' + STATIC_URL`
and run `./manage.py collectstatic`.

7. Set up a WSGI server (for example Gunicorn):

pip install gunicorn
gunicorn -w 4 -b 127.0.0.1:1234 ledger.wsgi
8. Set up a reverse proxy in a HTTP server, for example Nginx, a
config file included in `examples/ledger.nginx.conf`.

## Copyright

Copyright (C) 2019 Wojciech Siewierski

This program 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.

This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
Binary file added examples/Charts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/Register.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/Rules.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions examples/example.ledger
@@ -0,0 +1,99 @@
#!/usr/bin/ledger -f
; -*- mode: ledger; -*-

2018-12-01 Opening Balances
Assets:Bank $200000.00
Assets:Wallet $300.00
Equity:Opening Balances


2018-12-03 Gas Station
Expenses:Gas $100.00
Assets:Bank

2018-12-03 Walmart
Expenses:Food $20.00
Assets:Wallet

2018-12-04 Steam
Expenses:Entertainment $30.00
Assets:Bank

2018-12-13 Walmart
Expenses:Food $15.00
Assets:Wallet

2018-12-20 Awesome Company
Assets:Bank $6000.00
Income:Salary

2018-12-25 Rent
Expenses:Rent $1000.00
Assets:Bank


2019-01-03 Gas Station
Expenses:Gas $70.00
Assets:Bank

2019-01-03 Walmart
Expenses:Food $50.00
Assets:Wallet

2019-01-04 Steam
Expenses:Entertainment $5.00
Assets:Bank

2019-01-13 Newegg
Expenses:Hardware $4000.00
Assets::Bank

2019-01-20 Awesome Company
Assets:Bank $5500.00
Income:Salary


2019-02-03 Gas Station
Expenses:Gas $40.00
Assets:Bank

2019-02-03 Walmart
Expenses:Food $300.00
Assets:Wallet

2019-02-04 Steam
Expenses:Entertainment $15.00
Assets:Bank

2019-02-20 Awesome Company
Assets:Bank $4000.00
Income:Salary

2019-02-25 Rent
Expenses:Rent $1000.00
Assets:Bank


2019-03-03 Gas Station
Expenses:Gas $140.00
Assets:Bank

2019-03-03 Walmart
Expenses:Food $100.00
Assets:Wallet

2019-03-10 Walmart
Expenses:Food $50.00
Assets:Wallet

2019-03-17 Walmart
Expenses:Food $130.00
Assets:Wallet

2019-03-20 Awesome Company
Assets:Bank $7000.00
Income:Salary

2019-03-25 Rent
Expenses:Rent $1000.00
Assets:Bank
58 changes: 58 additions & 0 deletions examples/ledger.nginx.conf
@@ -0,0 +1,58 @@
# -*- conf -*-

server {
listen 80;
server_name example.com;

location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name example.com;
root /var/www/ledger;

ssl_certificate /etc/nginx/certs/example.com/fullchain;
ssl_certificate_key /etc/nginx/certs/example.com/key;
ssl_dhparam /etc/ssl/example.com/dhparam.pem;

add_header Strict-Transport-Security "max-age=31536000";

location / {
proxy_pass http://127.0.0.1:1234/;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /favicon.ico {
return 302 https://$host/static$request_uri;
}

location /static/ {
root /var/www/ledger;

gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml;

expires 1d;
add_header Cache-Control "public";
add_header Strict-Transport-Security "max-age=31536000";

location ~* \.(?:html)$ {
expires 1d;
}

location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
}
}
}

0 comments on commit bb75562

Please sign in to comment.