Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local development instructions #8

Merged
merged 4 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ key

# config
*.conf
*.cfg
pricing.yaml

# Byte-compiled / optimized / DLL files
Expand Down
63 changes: 63 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Development

## BTCPay Server

You can pair with your existing production BTCPay Server, or [set one up locally](https://github.com/btcpayserver/btcpayserver-doc/blob/master/LocalDevelopment.md).

## Run development server

Clone the repository.

Install Python dependencies:

```sh
pip3 install flask flask_admin flask_apscheduler flask_login flask_principal flask_fileupload flask_bootstrap flask_migrate flask_ezmail
pip3 install gunicorn apscheduler sqlalchemy
pip3 install markdown python-slugify jwt psutil
pip3 install btcpay
pip3 install squareconnect
```

Configure database and settings path:

```sh
export ISSO_CONFIG_PATH=$PWD/isso.cfg
export COMMENTS_DB_PATH=$PWD/comments.db
```

Create or upgrade the database:

```sh
flask db upgrade
```

Start the server:

```sh
docker_boot.py & gunicorn patron:app
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check if docker_boot.py actually does anything.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker_boot.py makes continual GET requests to ensure that settings load. Certain settings won't load until an initial GET request is received.

```
## Run tests

Install Python dependencies:

```sh
pip3 install pytest
```

Configure database path:

```sh
export COMMENTS_DB_PATH_TEST=$PWD/comments-test.db
```

Create or upgrade the test database:


```sh
flask db upgrade
```

Run tests:
``sh
python3 -m pytest
```
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ That's it! You would replace `example.com` with the domain where you wish to hos

You only ever need to do that setup once, as from then on LibrePatron will update alongside BTCPay.

If you didn't use the LunaNode one-click install, the same instructions above apply so long as you're using the dockerized version of BTCPay.
If you didn't use the LunaNode one-click install, the same instructions above apply so long as you're using the dockerized version of BTCPay.

If you wish to install separately from BTCPay for whatever reason, see the alternate instructions in the 'alternate_install' directory.

Expand All @@ -66,7 +66,7 @@ IMPORTANT: Before advertising your site, see the section on post-install setup b

<h2>Post-Install Setup</h2>

The first visitor to the site will be prompted to register as administrator. The administrator is the user that posts updates, gets paid, etc. The administrator is the content creator.
The first visitor to the site will be prompted to register as administrator. The administrator is the user that posts updates, gets paid, etc. The administrator is the content creator.

Heading to the admin panel should be your first step after registering as the admin, as the site will not function properly until email and BTCPay Server settings are filled in. Square settings for accepting fiat are optional, as are the settings for Google Analytics and user comments. BTCPay pairing and email setup are mandatory, and your site will malfunction without them.

Expand All @@ -75,3 +75,7 @@ You'll need SMTP server info for the email section. Gmail, Yahoo, etc are not go
Your users will get a 5 hour subscription as soon as they pay their BTCPay invoice. That is bumped to 30 days as soon as BTCPay recognizes the payment as "confirmed". BTCPay settings determine how many confirmations are required to make a payment "confirmed."

If you decide to allow fiat payments, after setting up square, it is suggested that you run a [test charge by follwing these instructions](https://github.com/JeffVandrewJr/patron/blob/master/test-charge.md).

<h2>Development</h2>

See [DEVELOPMENT.md](DEVELOPMENT.md) for instructions on how to run a local development copy and how to contribute code.
4 changes: 2 additions & 2 deletions app/admin_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ def isso_config():
# isso requires a config file
# this function writes a config file in isso format
# file is saved in a Docker volume shared between lp and isso
file = '/var/lib/config/isso.cfg'
file = current_app.config['ISSO_CONFIG_PATH']
isso_pass = ThirdPartyServices.query.filter_by(
name='isso').first().code
isso_config = ConfigParser()
isso_config['general'] = {}
isso_config['general']['dbpath'] = '/var/lib/db/comments.db'
isso_config['general']['dbpath'] = current_app.config['COMMENTS_DB_PATH']
isso_config['general']['host'] = current_app.config['BLOGGING_SITEURL']
isso_config['admin'] = {}
isso_config['admin']['enabled'] = 'true'
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Config(object):
BLOGGING_ALLOW_FILE_UPLOAD = True
BLOGGING_ESCAPE_MARKDOWN = False
ISSO_CONFIG_PATH = os.environ.get('ISSO_CONFIG_PATH') or '/var/lib/config/isso.cfg'
COMMENTS_DB_PATH = os.environ.get('COMMENTS_DB_PATH') or '/var/lib/db/comments.db'
COMMENTS = False
COMMENTS_SUBURI = os.environ.get('COMMENTS_SUBURI') is not None
if COMMENTS_SUBURI:
Expand Down
1 change: 1 addition & 0 deletions tests/tconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Config(object):
BLOGGING_ALLOW_FILE_UPLOAD = True
BLOGGING_ESCAPE_MARKDOWN = False
ISSO_CONFIG_PATH = f'/tmp/{os.urandom(16)}'
COMMENTS_DB_PATH = os.environ.get('COMMENTS_DB_PATH_TEST') or '/var/lib/db/comments.db'
PREFERRED_URL_SCHEME = 'https'
SCHEDULER_BASE = datetime.now() + timedelta(minutes=1)
SCHEDULER_HOUR = SCHEDULER_BASE.hour
Expand Down