Browse Source
Remove docker, just us plain RQLite.
Also a number of small changes to get this all to work.
ansible-setup-and-deploy
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
8 changed files with
57 additions and
20 deletions
-
.gitignore
-
Makefile
-
README.md
-
xppl/app.py
-
xppl/config.py
-
xppl/cover.py
-
xppl/extractText.py
-
xppl/views.py
|
|
@ -1,6 +1,6 @@ |
|
|
|
*.pyc |
|
|
|
__pycache__/ |
|
|
|
rqlite* |
|
|
|
rqlite/ |
|
|
|
xppl/cover/** |
|
|
|
xppl/uploads/** |
|
|
|
.tox |
|
|
|
|
|
@ -0,0 +1,18 @@ |
|
|
|
RQLITE_DIR := rqlite |
|
|
|
RQLITE_TAR := rqlite-v4.3.0-linux-amd64.tar.gz |
|
|
|
RQLITE_UNTAR := rqlite-v4.3.0-linux-amd64 |
|
|
|
RQLITE_URL := https://github.com/rqlite/rqlite/releases/download/v4.3.0/rqlite-v4.3.0-linux-amd64.tar.gz |
|
|
|
|
|
|
|
install-rqlite: |
|
|
|
@mkdir -p $(RQLITE_DIR) |
|
|
|
@sudo apt update && sudo apt install -y curl |
|
|
|
@curl -L $(RQLITE_URL) -o $(RQLITE_DIR)/$(RQLITE_TAR) |
|
|
|
@tar xvfz $(RQLITE_DIR)/$(RQLITE_TAR) -C $(RQLITE_DIR) |
|
|
|
|
|
|
|
rqlited: |
|
|
|
@./$(RQLITE_DIR)/$(RQLITE_UNTAR)/rqlited $(RQLITE_DIR)/node.1 |
|
|
|
.PHONY: rqlited |
|
|
|
|
|
|
|
rqlite: |
|
|
|
@./$(RQLITE_DIR)/$(RQLITE_UNTAR)/rqlite |
|
|
|
.PHONY: rqlite |
|
|
@ -9,20 +9,29 @@ The [XPUB] library living at [Varia]. |
|
|
|
|
|
|
|
# Hack It |
|
|
|
|
|
|
|
You'll need to run an [RQLite] database first. It's easy with Docker: |
|
|
|
You'll need to run an [RQLite] database first: |
|
|
|
|
|
|
|
``` |
|
|
|
$ curl -sSL https://get.docker.com/ | sh |
|
|
|
$ docker run -p 4001:4001 -p 4002:4002 -d rqlite/rqlite |
|
|
|
$ apt update && apt install -y make |
|
|
|
$ make install-rqlite |
|
|
|
$ make rqlited |
|
|
|
``` |
|
|
|
|
|
|
|
Then get [Pipenv] and run the development server with: |
|
|
|
|
|
|
|
```bash |
|
|
|
$ pipenv install --dev --three |
|
|
|
$ pipenv run dev |
|
|
|
$ pipenv run devserver |
|
|
|
``` |
|
|
|
|
|
|
|
If you need to check the database contents, run: |
|
|
|
|
|
|
|
```bash |
|
|
|
$ make rqlite |
|
|
|
``` |
|
|
|
|
|
|
|
And then run `.help` for which commands are available. |
|
|
|
|
|
|
|
[Pipenv]: https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv |
|
|
|
[RQLite]: https://github.com/rqlite/rqlite |
|
|
|
|
|
|
|
|
|
@ -1,5 +1,8 @@ |
|
|
|
"""Main application factory.""" |
|
|
|
|
|
|
|
from os import makedirs |
|
|
|
from os.path import exists |
|
|
|
|
|
|
|
from dotenv import find_dotenv, load_dotenv |
|
|
|
from flask import Flask |
|
|
|
from sqlalchemy.dialects import registry |
|
|
@ -14,6 +17,7 @@ def create_app(config): |
|
|
|
configure_pyrqlite() |
|
|
|
configure_socketio(app) |
|
|
|
configure_sqlalchemy(app) |
|
|
|
configure_uploads(app) |
|
|
|
|
|
|
|
with app.app_context(): |
|
|
|
from xppl import views # noqa |
|
|
@ -55,3 +59,14 @@ def configure_socketio(app): |
|
|
|
from xppl.socketio import socketio |
|
|
|
|
|
|
|
socketio.init_app(app) |
|
|
|
|
|
|
|
|
|
|
|
def configure_uploads(app): |
|
|
|
"""Setup the uploads folder.""" |
|
|
|
upload_paths = [ |
|
|
|
app.config['UPLOAD_FOLDER'], |
|
|
|
app.config['UPLOAD_FOLDER_COVER'], |
|
|
|
] |
|
|
|
for path in upload_paths: |
|
|
|
if not exists(path): |
|
|
|
makedirs(path) |
|
|
|
|
|
@ -1,20 +1,15 @@ |
|
|
|
"""The Application settings.""" |
|
|
|
|
|
|
|
from os import environ, urandom |
|
|
|
from os import urandom |
|
|
|
from os.path import abspath, dirname, isdir, join |
|
|
|
|
|
|
|
BASEDIR = abspath(dirname(__file__)) |
|
|
|
|
|
|
|
|
|
|
|
class Base(): |
|
|
|
"""The base configuration.""" |
|
|
|
BASEDIR = abspath(dirname(__file__)) |
|
|
|
|
|
|
|
UPLOAD_FOLDER_COVER = join(BASEDIR, 'cover') |
|
|
|
UPLOAD_FOLDER = join(BASEDIR, 'uploads') |
|
|
|
LIGHT = isdir(UPLOAD_FOLDER) |
|
|
|
|
|
|
|
DEBUG = False |
|
|
|
TESTING = False |
|
|
|
|
|
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False |
|
|
|
SQLALCHEMY_DATABASE_URI = 'rqlite+pyrqlite://localhost:4001/' |
|
|
|
|
|
|
@ -31,7 +26,7 @@ class Development(Base): |
|
|
|
DEBUG = True |
|
|
|
TESTING = True |
|
|
|
DOMAIN = 'http://localhost' |
|
|
|
SECRET_KEY = environ.get( |
|
|
|
'XPPL_SECRET_KEY', |
|
|
|
urandom(24).hex() |
|
|
|
) |
|
|
|
SECRET_KEY = urandom(24).hex() |
|
|
|
UPLOAD_FOLDER_COVER = join(BASEDIR, 'cover') |
|
|
|
UPLOAD_FOLDER = join(BASEDIR, 'uploads') |
|
|
|
LIGHT = not isdir(UPLOAD_FOLDER) |
|
|
|
|
|
@ -52,7 +52,7 @@ def get_cover(file_path, filename): |
|
|
|
|
|
|
|
# Convert each page to a png image. |
|
|
|
for page in pages: |
|
|
|
big_filename = "app/cover/"+page["filename"] + "_cover.jpeg" |
|
|
|
big_filename = "xppl/cover/"+page["filename"] + "_cover.jpeg" |
|
|
|
|
|
|
|
img = pdf_page_to_png(src_pdf, pagenum=page["pagenum"], resolution=130) |
|
|
|
|
|
|
|
|
|
@ -3,7 +3,7 @@ import PyPDF2 |
|
|
|
|
|
|
|
def get_text(file_path, filename): |
|
|
|
read_pdf = file_path |
|
|
|
write_txt = "app/uploads/" + filename + '.txt' |
|
|
|
write_txt = "xppl/uploads/" + filename + '.txt' |
|
|
|
|
|
|
|
with open(read_pdf, 'rb') as pdf_file, open(write_txt, 'w') as text_file: |
|
|
|
read_pdf = PyPDF2.PdfFileReader(pdf_file) |
|
|
|
|
|
@ -467,7 +467,7 @@ def add_book(): |
|
|
|
pbooks=pbooks |
|
|
|
) |
|
|
|
html = HTML(string=html_string) |
|
|
|
html.write_pdf(target='app/uploads/potential.pdf') |
|
|
|
html.write_pdf(target='xppl/uploads/potential.pdf') |
|
|
|
|
|
|
|
book = Book( |
|
|
|
title, |
|
|
|