Compare commits

..

17 Commits

Author SHA1 Message Date
9d549d0db0 Update 'xppl/getannot.py' 2020-02-05 12:10:02 +01:00
1e56afc8c4 Update 'xppl/getannot.py' 2020-02-05 12:06:32 +01:00
59be37d9a4 Update 'xppl/getannot.py' 2019-01-30 21:18:44 +01:00
80845b4429 Update 'xppl/getannot.py' 2019-01-30 20:58:35 +01:00
ccl
fef16a1680 Update 'xppl/templates/show_stack_detail.html' 2019-01-30 20:55:49 +01:00
cbeeffb6fb Update 'xppl/templates/annotations.html' 2019-01-30 20:49:31 +01:00
b944572399 Update 'xppl/getannot.py' 2019-01-30 20:26:43 +01:00
ca367e8aab Update 'xppl/getannot.py' 2019-01-30 20:23:41 +01:00
ea25fbcd10 Update 'xppl/getannot.py' 2019-01-30 20:19:00 +01:00
e30b59d6a5
Fix link to YAML and an Ansible link. 2018-12-15 11:47:13 +00:00
2210f82833
Fix formatting. Include the parenthetic comment. 2018-12-15 11:46:21 +00:00
ea1d1f8123
Add some links. 2018-12-15 11:45:39 +00:00
3551631642
Ansible fixups. Just make it sure it works for real. 2018-12-15 11:39:39 +00:00
b98146fd34
Shorten that one. 2018-12-15 11:26:36 +00:00
e85b7a7611
Make it clear what these instructions are for. 2018-12-15 11:22:50 +00:00
fc393a3d5f
Separate Ansible world into setup and deployment.
This makes it possible to run a deployment as opposed to a 'setup' play
where all the necessary prerequisites are arranged on the server. We
don't need to do that each time.

Closes decentral1se/xppl#4.

Might help decentral1se/xppl#2.
2018-12-15 00:03:27 +00:00
decentral1se
1d044b5dbc Merge branch 'add-change-log' of decentral1se/xppl into master 2018-12-15 00:25:20 +01:00
9 changed files with 67 additions and 25 deletions

View File

@ -26,8 +26,7 @@ Deployed on:
* Bootstrap the application via [xppl/app.py](xppl/app.py). * Bootstrap the application via [xppl/app.py](xppl/app.py).
* Added [Makefile](Makefile) targets for installing [RQLite](https://github.com/rqlite/rqlite). * Added [Makefile](Makefile) targets for installing [RQLite](https://github.com/rqlite/rqlite).
* Run [isort](https://isort.readthedocs.io/en/latest/) and [pylava](https://github.com/pylava/pylava) * Run [isort](https://isort.readthedocs.io/en/latest/) and [pylava](https://github.com/pylava/pylava)
code audit tools over the source to use PEP 8 style, catch any erroneous code audit tools over the source.
imports, unused variables etc. with some basic static analysis.
* Use a new [Hypothesis](https://web.hypothes.is/) API key. * Use a new [Hypothesis](https://web.hypothes.is/) API key.
### Fixed ### Fixed

View File

@ -7,7 +7,7 @@ The [XPUB] library living at [Varia].
[XPUB]: http://xpub.nl/ [XPUB]: http://xpub.nl/
[Varia]: https://varia.zone/ [Varia]: https://varia.zone/
# Change It # Run It Locally
Please note, the following instructions have only been tested on the Debian Stretch OS. Please note, the following instructions have only been tested on the Debian Stretch OS.
@ -26,6 +26,8 @@ $ pipenv install --dev --three
$ pipenv run devserver $ pipenv run devserver
``` ```
The local development web server will now be available.
If you need to check the database contents, run: If you need to check the database contents, run:
```bash ```bash
@ -56,10 +58,11 @@ The XPPL is made up of a few parts:
* The [Flask] application and it's dependencies. * The [Flask] application and it's dependencies.
* The [RQLite] database. * The [RQLite] database.
* The [Syncthing] integration for uploads. * The [Syncthing] integration for uploads.
* The Nginx reverse proxy. * The [Nginx reverse proxy].
* The Let's Encrypt web certificates. * The [Let's Encrypt web certificates].
If you know [Ansible] (it's just YAML), you can just [read the entire configuration]. If you know [Ansible](https://www.ansible.com/overview/how-ansible-works) (it's
just YAML), you can just [read the entire configuration].
On the varia.zone machine, you can check the running services with: On the varia.zone machine, you can check the running services with:
@ -85,6 +88,7 @@ No backups are configured right now.
[Flask]: http://flask.pocoo.org/ [Flask]: http://flask.pocoo.org/
[RQLite]: https://github.com/rqlite/rqlite [RQLite]: https://github.com/rqlite/rqlite
[Syncthing]: https://docs.syncthing.net/ [Syncthing]: https://docs.syncthing.net/
[Nginx reverse proxy]: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
[Let's Encrypt web certificates]: https://certbot.eff.org/
[Syncthing UI]: https://vvvvvvaria.org/st/ [Syncthing UI]: https://vvvvvvaria.org/st/
[read the entire configuration]: ansible/plays/main.yml [read the entire configuration]: ansible/plays/setup.yml
[Ansible]: https://www.ansible.com/overview/how-ansible-works

View File

@ -1,14 +1,27 @@
# XPPL Ansible Automation # XPPL Ansible Automation
An automated deployment for the XPPL. An automated deployment for the XPPL. If you're running these scripts, you'll
need SSH access and Sudo permissions on the machines. It is already running
deployments for:
## Run It * [books.vvvvvvaria.org](https://books.vvvvvvaria.org/)
You'll need to have SSH and Sudo access to [varia.zone] first. ## Prerequisites
You'll need to install [Ansible](https://docs.ansible.com).
```bash ```bash
$ sudo apt install -y ansible $ sudo apt install -y ansible
$ ansible-playbook --ask-become-pass plays/main.yml
``` ```
[varia.zone]: https://varia.zone/ ## Setup a New XPPL
```bash
$ ansible-playbook --limit varia.zone --ask-become-pass plays/setup.yml
```
## Deploy a New XPPL Version
```bash
$ ansible-playbook --limit varia.zone --ask-become-pass plays/deploy.yml
```

View File

@ -1,2 +1,2 @@
[varia-zone] [all]
varia.zone ansible_ssh_port=12345 varia.zone ansible_ssh_port=12345

23
ansible/plays/deploy.yml Normal file
View File

@ -0,0 +1,23 @@
---
# Just deploy a new version of the the XPPL.
# Depends on setup.yml being ran first to set things up.
- hosts: all
pre_tasks:
- name: Shutdown the running XPPL for the deployment.
become: true
supervisorctl:
name: 'xppl:'
state: stopped
roles:
- role: git # Clone the project source
- role: pipenv # Install Python dependencies
- role: env # Configure the application environment
- role: nginx # Setup the Nginx configuration
post_tasks:
- name: Start back up the XPPL after the deployment.
become: true
supervisorctl:
name: 'xppl:'
state: started

View File

@ -1,11 +1,14 @@
--- ---
- hosts: varia-zone # Setup all necessary infrastructure for the project.
# Install the project and get it running under supervisor.
- hosts: all
roles: roles:
- role: perms # Setup users and groups - role: perms # Setup users and groups
- role: git # Clone the project source - role: git # Clone the project source
- role: pipenv # Install Python dependencies - role: pipenv # Install Python dependencies
- role: env # Configure application environment - role: env # Configure the application environment
- role: rqlite # Install RQLite - role: rqlite # Install RQLite
- role: supervisor # Setup managed processes - role: supervisor # Setup managed processes
- role: nginx # Setup Nginx configuration - role: nginx # Setup the Nginx configuration

View File

@ -6,7 +6,7 @@ from flask import request
def get_annotations(): def get_annotations():
# TODO(decentral1se): remove this from the source # TODO(decentral1se): remove this from the source
KEY = "6879-H5GbA2KyFIeEUM1BubjVTLP8yM3GMyHgOAjjNe_GBxY" KEY = "6879-n8AksBoSB7kYoQ3eEwzpEr3nFQEmSp3XN-0PcKL_Sik"
# a dictionary containing necessary http headers # a dictionary containing necessary http headers
headers = { headers = {
@ -15,7 +15,7 @@ def get_annotations():
"Authorization": "Bearer %s" % KEY "Authorization": "Bearer %s" % KEY
} }
base_url = "https://hypothes.is/api/search?user=varia_annotator@hypothes.is" base_url = "https://hypothes.is/api/search?user=xpub@hypothes.is"
search_url = "".join([base_url]) search_url = "".join([base_url])
@ -45,7 +45,7 @@ def get_annot_results(annot, name):
data = { data = {
'text': item['text'], 'text': item['text'],
'extract': item['target'][0]['selector'][2]['exact'], 'extract': item['target'][0]['selector'][2]['exact'],
'title': item['document']['title'], 'url': item['uri'] 'title': item['uri'][37:], 'url': item['uri']
} }
res.append(data) res.append(data)
else: else:
@ -54,7 +54,7 @@ def get_annot_results(annot, name):
data = { data = {
'text': item['text'], 'text': item['text'],
'extract': item['target'][0]['selector'][1]['exact'], 'extract': item['target'][0]['selector'][1]['exact'],
'title': item['document']['title'], 'url': item['uri'] 'title': item['uri'][37:], 'url': item['uri']
} }
res.append(data) res.append(data)
return res return res
@ -71,7 +71,7 @@ def get_annot_book(annot, name):
data = { data = {
'text': item['text'], 'text': item['text'],
'extract': item['target'][0]['selector'][2]['exact'], 'extract': item['target'][0]['selector'][2]['exact'],
'title': item['document']['title'], 'url': item['uri'] 'title': item['uri'][37:], 'url': item['uri']
} }
res.append(data) res.append(data)
else: else:
@ -80,7 +80,7 @@ def get_annot_book(annot, name):
data = { data = {
'text': item['text'], 'text': item['text'],
'extract': item['target'][0]['selector'][1]['exact'], 'extract': item['target'][0]['selector'][1]['exact'],
'title': item['document']['title'], 'url': item['uri'] 'title': item['uri'][37:], 'url': item['uri']
} }
res.append(data) res.append(data)
return res return res

View File

@ -11,7 +11,7 @@
{%for book in books%} {%for book in books%}
{%if book.file == row.uri%} {%if book.file == row.uri%}
<p align="right" style="font-family:archivo narrow;font-size:10px;">Book</p> <p align="right" style="font-family:archivo narrow;font-size:10px;">Book</p>
<a href="books/{{book.id}}"><p align="right" style="font-family:archivo narrow;font-size:18px;">{{book.title}}</p></a><br> <a href="books/{{book.id}}"><p align="right" style="font-family:archivo narrow;font-size:18px;">{{book.file}}</p></a><br>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@ -19,7 +19,7 @@
{% for book in stack.books %} {% for book in stack.books %}
{% if loop.length >= 5 %} {% if loop.length >= 5 %}
{% if loop.index == 6 %} {% if loop.index == 6 %}
<p style='color:red;'>Your stack is getting a little too big. Are these next books really relevant?</p> <p style='color:red;'>Your stack is getting a little big. Proceed.</p>
<br> <br>
<br> <br>
{% endif %} {% endif %}