From 37e5dbab4b662c34d88373581aeca2028e353ea6 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 1 Sep 2020 22:41:59 +0000 Subject: [PATCH] Moved plugin web files to be in the plugin folder to reduce staticfiles blueprint coupling --- src/httpapi/miscclientapi/staticfiles.py | 29 ------------------- .../default-plugins/circles/flowapi.py | 13 +++++++++ static-data/default-plugins/circles/main.py | 2 +- .../circles/web}/autorefresh.js | 0 .../circles/web}/board.js | 0 .../circles/web}/default-circle-picker.js | 0 .../circles/web}/detect-plaintext-storage.js | 0 .../circles/web}/index.html | 0 .../circles/web}/popular.js | 0 .../circles/web}/sethumanreadable.js | 0 .../circles/web}/sort-posts.js | 0 .../circles/web}/theme.css | 0 static-data/default-plugins/pms/mailapi.py | 13 +++++++++ static-data/default-plugins/pms/main.py | 2 +- .../pms/web}/closesettings.js | 0 .../pms/web}/index.html | 0 .../pms/web}/loadsettings.js | 0 .../mail => default-plugins/pms/web}/mail.css | 0 .../mail => default-plugins/pms/web}/mail.js | 0 .../pms/web}/sendmail.js | 0 .../pms/web}/sethumanreadable.js | 0 .../pms/web}/settings.js | 0 static-data/default_config.json | 18 ++++++------ 23 files changed, 37 insertions(+), 40 deletions(-) rename static-data/{www/board => default-plugins/circles/web}/autorefresh.js (100%) rename static-data/{www/board => default-plugins/circles/web}/board.js (100%) rename static-data/{www/board => default-plugins/circles/web}/default-circle-picker.js (100%) rename static-data/{www/board => default-plugins/circles/web}/detect-plaintext-storage.js (100%) rename static-data/{www/board => default-plugins/circles/web}/index.html (100%) rename static-data/{www/board => default-plugins/circles/web}/popular.js (100%) rename static-data/{www/board => default-plugins/circles/web}/sethumanreadable.js (100%) rename static-data/{www/board => default-plugins/circles/web}/sort-posts.js (100%) rename static-data/{www/board => default-plugins/circles/web}/theme.css (100%) rename static-data/{www/mail => default-plugins/pms/web}/closesettings.js (100%) rename static-data/{www/mail => default-plugins/pms/web}/index.html (100%) rename static-data/{www/mail => default-plugins/pms/web}/loadsettings.js (100%) rename static-data/{www/mail => default-plugins/pms/web}/mail.css (100%) rename static-data/{www/mail => default-plugins/pms/web}/mail.js (100%) rename static-data/{www/mail => default-plugins/pms/web}/sendmail.js (100%) rename static-data/{www/mail => default-plugins/pms/web}/sethumanreadable.js (100%) rename static-data/{www/mail => default-plugins/pms/web}/settings.js (100%) diff --git a/src/httpapi/miscclientapi/staticfiles.py b/src/httpapi/miscclientapi/staticfiles.py index 644274aa..6beef97e 100644 --- a/src/httpapi/miscclientapi/staticfiles.py +++ b/src/httpapi/miscclientapi/staticfiles.py @@ -43,31 +43,6 @@ def onboard_files(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/', 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/', 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/', endpoint='friends') def loadContacts(path): return send_from_directory(root + 'friends/', path) @@ -88,10 +63,6 @@ def loadContacts(): return send_from_directory(root + 'profiles/', 'index.html') -@static_files_bp.route('/board/', endpoint='boardContent') -def boardContent(path): - return send_from_directory(root + 'board/', path) - @static_files_bp.route('/shared/', endpoint='sharedContent') def sharedContent(path): diff --git a/static-data/default-plugins/circles/flowapi.py b/static-data/default-plugins/circles/flowapi.py index e1cd5ad8..8121c079 100755 --- a/static-data/default-plugins/circles/flowapi.py +++ b/static-data/default-plugins/circles/flowapi.py @@ -8,6 +8,7 @@ import os import ujson as json from flask import Response, Blueprint +from flask import send_from_directory from deadsimplekv import DeadSimpleKV from utils import identifyhome @@ -28,6 +29,9 @@ from utils import identifyhome flask_blueprint = Blueprint('circles', __name__) +root = os.path.dirname(os.path.realpath(__file__)) + + with open( os.path.dirname( os.path.realpath(__file__)) + '/info.json', 'r') as info_file: @@ -41,6 +45,15 @@ read_only_cache = DeadSimpleKV( flush_on_exit=False, refresh_seconds=30) +@flask_blueprint.route('/board/', 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/') def get_post_by_board(board): diff --git a/static-data/default-plugins/circles/main.py b/static-data/default-plugins/circles/main.py index 66178a8c..07348ba4 100755 --- a/static-data/default-plugins/circles/main.py +++ b/static-data/default-plugins/circles/main.py @@ -36,7 +36,7 @@ import flowapi # noqa """ flask_blueprint = flowapi.flask_blueprint -security_whitelist = ['staticfiles.boardContent', 'staticfiles.board'] +security_whitelist = ['circles.circlesstatic', 'circles.circlesindex'] plugin_name = 'circles' PLUGIN_VERSION = '0.1.0' diff --git a/static-data/www/board/autorefresh.js b/static-data/default-plugins/circles/web/autorefresh.js similarity index 100% rename from static-data/www/board/autorefresh.js rename to static-data/default-plugins/circles/web/autorefresh.js diff --git a/static-data/www/board/board.js b/static-data/default-plugins/circles/web/board.js similarity index 100% rename from static-data/www/board/board.js rename to static-data/default-plugins/circles/web/board.js diff --git a/static-data/www/board/default-circle-picker.js b/static-data/default-plugins/circles/web/default-circle-picker.js similarity index 100% rename from static-data/www/board/default-circle-picker.js rename to static-data/default-plugins/circles/web/default-circle-picker.js diff --git a/static-data/www/board/detect-plaintext-storage.js b/static-data/default-plugins/circles/web/detect-plaintext-storage.js similarity index 100% rename from static-data/www/board/detect-plaintext-storage.js rename to static-data/default-plugins/circles/web/detect-plaintext-storage.js diff --git a/static-data/www/board/index.html b/static-data/default-plugins/circles/web/index.html similarity index 100% rename from static-data/www/board/index.html rename to static-data/default-plugins/circles/web/index.html diff --git a/static-data/www/board/popular.js b/static-data/default-plugins/circles/web/popular.js similarity index 100% rename from static-data/www/board/popular.js rename to static-data/default-plugins/circles/web/popular.js diff --git a/static-data/www/board/sethumanreadable.js b/static-data/default-plugins/circles/web/sethumanreadable.js similarity index 100% rename from static-data/www/board/sethumanreadable.js rename to static-data/default-plugins/circles/web/sethumanreadable.js diff --git a/static-data/www/board/sort-posts.js b/static-data/default-plugins/circles/web/sort-posts.js similarity index 100% rename from static-data/www/board/sort-posts.js rename to static-data/default-plugins/circles/web/sort-posts.js diff --git a/static-data/www/board/theme.css b/static-data/default-plugins/circles/web/theme.css similarity index 100% rename from static-data/www/board/theme.css rename to static-data/default-plugins/circles/web/theme.css diff --git a/static-data/default-plugins/pms/mailapi.py b/static-data/default-plugins/pms/mailapi.py index 81c5a127..fde35956 100755 --- a/static-data/default-plugins/pms/mailapi.py +++ b/static-data/default-plugins/pms/mailapi.py @@ -7,6 +7,7 @@ import os import ujson as json from flask import Response, request, redirect, Blueprint, abort +from flask import send_from_directory import deadsimplekv as simplekv from onionrusers import contactmanager @@ -32,6 +33,18 @@ import sentboxdb """ flask_blueprint = Blueprint('mail', __name__) kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat') +root = os.path.dirname(os.path.realpath(__file__)) + + +@flask_blueprint.route('/mail/', 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') def mail_ping(): diff --git a/static-data/default-plugins/pms/main.py b/static-data/default-plugins/pms/main.py index 7ff46150..c9a80a92 100755 --- a/static-data/default-plugins/pms/main.py +++ b/static-data/default-plugins/pms/main.py @@ -38,7 +38,7 @@ import sentboxdb, mailapi, loadinbox # import after path insert from onblacklist import on_blacklist_add flask_blueprint = mailapi.flask_blueprint -security_whitelist = ['staticfiles.mail', 'staticfiles.mailindex'] +security_whitelist = ['mail.mailstatic', 'mail.mailindex'] def add_deleted(keyStore, b_hash): diff --git a/static-data/www/mail/closesettings.js b/static-data/default-plugins/pms/web/closesettings.js similarity index 100% rename from static-data/www/mail/closesettings.js rename to static-data/default-plugins/pms/web/closesettings.js diff --git a/static-data/www/mail/index.html b/static-data/default-plugins/pms/web/index.html similarity index 100% rename from static-data/www/mail/index.html rename to static-data/default-plugins/pms/web/index.html diff --git a/static-data/www/mail/loadsettings.js b/static-data/default-plugins/pms/web/loadsettings.js similarity index 100% rename from static-data/www/mail/loadsettings.js rename to static-data/default-plugins/pms/web/loadsettings.js diff --git a/static-data/www/mail/mail.css b/static-data/default-plugins/pms/web/mail.css similarity index 100% rename from static-data/www/mail/mail.css rename to static-data/default-plugins/pms/web/mail.css diff --git a/static-data/www/mail/mail.js b/static-data/default-plugins/pms/web/mail.js similarity index 100% rename from static-data/www/mail/mail.js rename to static-data/default-plugins/pms/web/mail.js diff --git a/static-data/www/mail/sendmail.js b/static-data/default-plugins/pms/web/sendmail.js similarity index 100% rename from static-data/www/mail/sendmail.js rename to static-data/default-plugins/pms/web/sendmail.js diff --git a/static-data/www/mail/sethumanreadable.js b/static-data/default-plugins/pms/web/sethumanreadable.js similarity index 100% rename from static-data/www/mail/sethumanreadable.js rename to static-data/default-plugins/pms/web/sethumanreadable.js diff --git a/static-data/www/mail/settings.js b/static-data/default-plugins/pms/web/settings.js similarity index 100% rename from static-data/www/mail/settings.js rename to static-data/default-plugins/pms/web/settings.js diff --git a/static-data/default_config.json b/static-data/default_config.json index 4846991a..a65588ca 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -8,16 +8,16 @@ "general": { "allow_public_api_dns_rebinding": false, "announce_node": true, - "dev_mode": false, + "dev_mode": true, "display_header": true, "ephemeral_tunnels": false, "hide_created_blocks": true, - "insert_deniable_blocks": true, + "insert_deniable_blocks": false, "max_block_age": 2678400, - "minimum_block_pow": 5, - "minimum_send_pow": 5, + "minimum_block_pow": 1, + "minimum_send_pow": 1, "public_key": "", - "random_bind_ip": true, + "random_bind_ip": false, "security_level": 0, "show_notifications": true, "store_plaintext_blocks": true, @@ -31,12 +31,12 @@ }, "file": { "output": true, - "remove_on_exit": true + "remove_on_exit": false }, "verbosity": "default" }, "onboarding": { - "done": false + "done": true }, "peers": { "max_connect": 1000, @@ -69,10 +69,10 @@ "transports": { "lan": true, "sneakernet": true, - "tor": true + "tor": false }, "ui": { - "animated_background": true, + "animated_background": false, "theme": "dark" } } \ No newline at end of file