Moved plugin web files to be in the plugin folder to reduce staticfiles blueprint coupling

master
Kevin Froman 2020-09-01 22:41:59 +00:00
parent 14f2d03ebf
commit 37e5dbab4b
23 changed files with 37 additions and 40 deletions

View File

@ -43,31 +43,6 @@ def onboard_files(path):
return send_from_directory(f'{root}onboarding/', path) return send_from_directory(f'{root}onboarding/', path)
@static_files_bp.route('/chat/', endpoint='chatIndex')
def chat_index():
return send_from_directory(root + 'chat/', "index.html")
@static_files_bp.route('/chat/<path:path>', endpoint='chat')
def load_chat(path):
return send_from_directory(root + 'chat/', path)
@static_files_bp.route('/board/', endpoint='board')
def loadBoard():
return send_from_directory(root + 'board/', "index.html")
@static_files_bp.route('/mail/<path:path>', endpoint='mail')
def loadMail(path):
return send_from_directory(root + 'mail/', path)
@static_files_bp.route('/mail/', endpoint='mailindex')
def loadMailIndex():
return send_from_directory(root + 'mail/', 'index.html')
@static_files_bp.route('/friends/<path:path>', endpoint='friends') @static_files_bp.route('/friends/<path:path>', endpoint='friends')
def loadContacts(path): def loadContacts(path):
return send_from_directory(root + 'friends/', path) return send_from_directory(root + 'friends/', path)
@ -88,10 +63,6 @@ def loadContacts():
return send_from_directory(root + 'profiles/', 'index.html') return send_from_directory(root + 'profiles/', 'index.html')
@static_files_bp.route('/board/<path:path>', endpoint='boardContent')
def boardContent(path):
return send_from_directory(root + 'board/', path)
@static_files_bp.route('/shared/<path:path>', endpoint='sharedContent') @static_files_bp.route('/shared/<path:path>', endpoint='sharedContent')
def sharedContent(path): def sharedContent(path):

View File

@ -8,6 +8,7 @@ import os
import ujson as json import ujson as json
from flask import Response, Blueprint from flask import Response, Blueprint
from flask import send_from_directory
from deadsimplekv import DeadSimpleKV from deadsimplekv import DeadSimpleKV
from utils import identifyhome from utils import identifyhome
@ -28,6 +29,9 @@ from utils import identifyhome
flask_blueprint = Blueprint('circles', __name__) flask_blueprint = Blueprint('circles', __name__)
root = os.path.dirname(os.path.realpath(__file__))
with open( with open(
os.path.dirname( os.path.dirname(
os.path.realpath(__file__)) + '/info.json', 'r') as info_file: os.path.realpath(__file__)) + '/info.json', 'r') as info_file:
@ -41,6 +45,15 @@ read_only_cache = DeadSimpleKV(
flush_on_exit=False, flush_on_exit=False,
refresh_seconds=30) refresh_seconds=30)
@flask_blueprint.route('/board/<path:path>', endpoint='circlesstatic')
def load_mail(path):
return send_from_directory(root + '/web/', path)
@flask_blueprint.route('/board/', endpoint='circlesindex')
def load_mail_index():
return send_from_directory(root + '/web/', 'index.html')
@flask_blueprint.route('/circles/getpostsbyboard/<board>') @flask_blueprint.route('/circles/getpostsbyboard/<board>')
def get_post_by_board(board): def get_post_by_board(board):

View File

@ -36,7 +36,7 @@ import flowapi # noqa
""" """
flask_blueprint = flowapi.flask_blueprint flask_blueprint = flowapi.flask_blueprint
security_whitelist = ['staticfiles.boardContent', 'staticfiles.board'] security_whitelist = ['circles.circlesstatic', 'circles.circlesindex']
plugin_name = 'circles' plugin_name = 'circles'
PLUGIN_VERSION = '0.1.0' PLUGIN_VERSION = '0.1.0'

View File

@ -7,6 +7,7 @@ import os
import ujson as json import ujson as json
from flask import Response, request, redirect, Blueprint, abort from flask import Response, request, redirect, Blueprint, abort
from flask import send_from_directory
import deadsimplekv as simplekv import deadsimplekv as simplekv
from onionrusers import contactmanager from onionrusers import contactmanager
@ -32,6 +33,18 @@ import sentboxdb
""" """
flask_blueprint = Blueprint('mail', __name__) flask_blueprint = Blueprint('mail', __name__)
kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat') kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat')
root = os.path.dirname(os.path.realpath(__file__))
@flask_blueprint.route('/mail/<path:path>', endpoint='mailstatic')
def load_mail(path):
return send_from_directory(root + '/web/', path)
@flask_blueprint.route('/mail/', endpoint='mailindex')
def load_mail_index():
return send_from_directory(root + '/web/', 'index.html')
@flask_blueprint.route('/mail/ping') @flask_blueprint.route('/mail/ping')
def mail_ping(): def mail_ping():

View File

@ -38,7 +38,7 @@ import sentboxdb, mailapi, loadinbox # import after path insert
from onblacklist import on_blacklist_add from onblacklist import on_blacklist_add
flask_blueprint = mailapi.flask_blueprint flask_blueprint = mailapi.flask_blueprint
security_whitelist = ['staticfiles.mail', 'staticfiles.mailindex'] security_whitelist = ['mail.mailstatic', 'mail.mailindex']
def add_deleted(keyStore, b_hash): def add_deleted(keyStore, b_hash):

View File

@ -8,16 +8,16 @@
"general": { "general": {
"allow_public_api_dns_rebinding": false, "allow_public_api_dns_rebinding": false,
"announce_node": true, "announce_node": true,
"dev_mode": false, "dev_mode": true,
"display_header": true, "display_header": true,
"ephemeral_tunnels": false, "ephemeral_tunnels": false,
"hide_created_blocks": true, "hide_created_blocks": true,
"insert_deniable_blocks": true, "insert_deniable_blocks": false,
"max_block_age": 2678400, "max_block_age": 2678400,
"minimum_block_pow": 5, "minimum_block_pow": 1,
"minimum_send_pow": 5, "minimum_send_pow": 1,
"public_key": "", "public_key": "",
"random_bind_ip": true, "random_bind_ip": false,
"security_level": 0, "security_level": 0,
"show_notifications": true, "show_notifications": true,
"store_plaintext_blocks": true, "store_plaintext_blocks": true,
@ -31,12 +31,12 @@
}, },
"file": { "file": {
"output": true, "output": true,
"remove_on_exit": true "remove_on_exit": false
}, },
"verbosity": "default" "verbosity": "default"
}, },
"onboarding": { "onboarding": {
"done": false "done": true
}, },
"peers": { "peers": {
"max_connect": 1000, "max_connect": 1000,
@ -69,10 +69,10 @@
"transports": { "transports": {
"lan": true, "lan": true,
"sneakernet": true, "sneakernet": true,
"tor": true "tor": false
}, },
"ui": { "ui": {
"animated_background": true, "animated_background": false,
"theme": "dark" "theme": "dark"
} }
} }