From d260e3a65bdec981fd98db8a2352caa9bef9ae55 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 26 Sep 2020 15:30:15 +0200 Subject: finalizing fixing refactor!! --- cli/app/server/web.py | 8 ++------ cli/app/settings/app_cfg.py | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'cli') diff --git a/cli/app/server/web.py b/cli/app/server/web.py index 0436cd4..1a3b064 100644 --- a/cli/app/server/web.py +++ b/cli/app/server/web.py @@ -12,7 +12,7 @@ handler.setFormatter(formatter) logger.addHandler(handler) logging.getLogger().addHandler(logging.StreamHandler()) -from flask import Flask, Blueprint, send_from_directory, request +from flask import Flask, send_from_directory, request from app.sql.common import db, connection_url from app.settings import app_cfg @@ -25,8 +25,7 @@ def create_app(script_info=None): """ functional pattern for creating the flask app """ - logging.debug("Starting Flask app...") - + logging.debug("Starting Swimmer server...") app = Flask(__name__, static_folder=app_cfg.DIR_STATIC, static_url_path='/static') app.config['SQLALCHEMY_DATABASE_URI'] = connection_url app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False @@ -45,9 +44,6 @@ def create_app(script_info=None): @app.errorhandler(404) def page_not_found(e): return app.send_static_file(index_html), 200 - # path = os.path.join(os.path.dirname(__file__), './static/index.html') - # with open(path, "r") as f: - # return f.read(), 200 @app.route('/', methods=['GET']) def index(): diff --git a/cli/app/settings/app_cfg.py b/cli/app/settings/app_cfg.py index 0d724c7..5fc4982 100644 --- a/cli/app/settings/app_cfg.py +++ b/cli/app/settings/app_cfg.py @@ -58,10 +58,7 @@ URL_MEDIA = join(URL_DATA, 'media') URL_UPLOADS = join(URL_DATA, 'uploads') URL_EXPORTS = join(URL_DATA, 'exports') -if 'cli' in os.getcwd(): - DIR_STATIC = os.path.abspath('../static') -else: - DIR_STATIC = os.path.abspath('static') +DIR_STATIC = join(DIR_APP, 'static') HASH_TREE_DEPTH = 3 # for sha256 subdirs HASH_BRANCH_SIZE = 3 # for sha256 subdirs -- cgit v1.2.3-70-g09d2 From 85bfb949fea4e69dabc5b7544ce70d26d3d11393 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 26 Dec 2020 21:56:56 +0100 Subject: add support for unsafe inline scripts --- cli/commands/site/export.py | 2 +- frontend/app/site/app.js | 2 ++ frontend/app/site/site/site.actions.js | 2 +- frontend/app/views/page/components/tile.form.js | 35 ++++++++++++++++++++++- frontend/app/views/page/components/tile.handle.js | 7 +++++ webpack.config.site.js | 4 +-- 6 files changed, 46 insertions(+), 6 deletions(-) (limited to 'cli') diff --git a/cli/commands/site/export.py b/cli/commands/site/export.py index 5f4636a..0ba6a62 100644 --- a/cli/commands/site/export.py +++ b/cli/commands/site/export.py @@ -30,7 +30,7 @@ def cli(ctx, opt_graph_path, opt_output_dir): return # build everything here - graph_dir = join(opt_output_dir, graph.path) + graph_dir = os.path.abspath(join(opt_output_dir, graph.path)) # load site index index_html = load_text(join(app_cfg.DIR_STATIC, 'site.html'), split=False) diff --git a/frontend/app/site/app.js b/frontend/app/site/app.js index cf52460..389e5b5 100644 --- a/frontend/app/site/app.js +++ b/frontend/app/site/app.js @@ -31,3 +31,5 @@ export default class App extends Component { ) } } +/* +*/ diff --git a/frontend/app/site/site/site.actions.js b/frontend/app/site/site/site.actions.js index 2eea442..79e4573 100644 --- a/frontend/app/site/site/site.actions.js +++ b/frontend/app/site/site/site.actions.js @@ -1,4 +1,4 @@ -import * as types from 'app/types' +import * as types from '../types' import { api } from 'app/utils' export const setSiteTitle = title => dispatch => { diff --git a/frontend/app/views/page/components/tile.form.js b/frontend/app/views/page/components/tile.form.js index 5b25f13..3f43dd0 100644 --- a/frontend/app/views/page/components/tile.form.js +++ b/frontend/app/views/page/components/tile.form.js @@ -15,7 +15,7 @@ import { preloadImage } from 'app/utils' import * as tileActions from '../../tile/tile.actions' const SELECT_TYPES = [ - "image", "text", "link" + "image", "text", "link", "script", ].map(s => ({ name: s, label: s })) const ALIGNMENTS = [ @@ -33,6 +33,7 @@ const REQUIRED_KEYS = { image: ['url'], text: ['content'], link: [], + script: [], } const IMAGE_TILE_STYLES = [ @@ -109,6 +110,14 @@ const newLink = (data) => ({ ...data, }) +const newScript = (data) => ({ + settings: { + ...newPosition({ width: 100, height: 100, }), + }, + type: 'script', + ...data, +}) + const newPosition = (data) => ({ x: 0, y: 0, width: 0, height: 0, @@ -122,6 +131,7 @@ const TYPE_CONSTRUCTORS = { image: newImage, text: newText, link: newLink, + script: newScript, } class TileForm extends Component { @@ -356,6 +366,8 @@ class TileForm extends Component { ? this.renderTextForm() : temporaryTile.type === 'link' ? this.renderLinkForm() + : temporaryTile.type === 'script' + ? this.renderScriptForm() : ""} {this.renderHyperlinkForm()} @@ -555,6 +567,27 @@ class TileForm extends Component { ) } + renderScriptForm() { + const { temporaryTile } = this.props + const { errorFields } = this.state + return ( +
+