diff --git a/files/requirements.txt b/files/requirements.txt index 4ec8b89..1ddf26f 100644 --- a/files/requirements.txt +++ b/files/requirements.txt @@ -20,4 +20,5 @@ requests==2.26.0 discord-webhook pyyaml pycryptodome -telepot-mod \ No newline at end of file +telepot-mod +Flask-Dropzone \ No newline at end of file diff --git a/lib/framework/init_main.py b/lib/framework/init_main.py index 175238b..f56030e 100644 --- a/lib/framework/init_main.py +++ b/lib/framework/init_main.py @@ -90,7 +90,16 @@ class Framework: self.celery = self.__init_celery() - + from flask_dropzone import Dropzone + self.app.config.update( + DROPZONE_MAX_FILE_SIZE = 102400, + DROPZONE_TIMEOUT = 5*60*1000, + #DROPZONE_ALLOWED_FILE_CUSTOM = True, + #DROPZONE_ALLOWED_FILE_TYPE = 'default, image, audio, video, text, app, *.*', + ) + self.dropzone = Dropzone(self.app) + + def __init_celery(self): try: from celery import Celery @@ -190,7 +199,7 @@ class Framework: self.__make_default_logger() self.logger.info('### LAST') - self.logger.info(f"### PORT: {self.config['port']}") + self.logger.info(f"### PORT: {self.config.get('port')}") self.logger.info('### Now you can access App by webbrowser!!') diff --git a/lib/framework/init_route.py b/lib/framework/init_route.py index 4f7f236..b8ccbf0 100644 --- a/lib/framework/init_route.py +++ b/lib/framework/init_route.py @@ -35,9 +35,11 @@ def global_ajax(sub): # globalEditBtn try: import flaskcode - return jsonify(True) + from flaskcode.setup import P as PP + ret = {'ret':True, 'target':PP.ModelSetting.get('setting_open_target')} + return jsonify(ret) except: - return jsonify(False) + return jsonify({'ret':False}) @@ -92,7 +94,7 @@ def file2(path): -@F.app.route("/up", methods=['GET', 'POST']) +@F.app.route("/upload", methods=['GET', 'POST']) def upload(): # curl -F file=@downloader_video.tar https://dev.soju6jan.com/up # @@ -100,9 +102,9 @@ def upload(): if request.method == 'POST': f = request.files['file'] from werkzeug import secure_filename - tmp = secure_filename(f.filename) - F.logger.debug('upload : %s', tmp) - f.save(os.path.join(F.path_data, 'upload', tmp)) + upload_path = F.SystemModelSetting.get('path_upload') + os.makedirs(upload_path, exist_ok=True) + f.save(os.path.join(upload_path, secure_filename(f.filename))) return jsonify('success') except Exception as exception: F.logger.error('Exception:%s', exception) diff --git a/lib/framework/init_web.py b/lib/framework/init_web.py index ee43859..12ba665 100644 --- a/lib/framework/init_web.py +++ b/lib/framework/init_web.py @@ -49,6 +49,7 @@ def jinja_initialize(app): app.jinja_env.globals.update(get_theme=get_theme) app.jinja_env.globals.update(get_menu_map=MenuManager.get_menu_map) app.jinja_env.globals.update(get_web_title=get_web_title) + app.jinja_env.globals.update(dropzone=F.dropzone) app.jinja_env.filters['get_menu'] = get_menu app.jinja_env.filters['get_theme'] = get_theme diff --git a/lib/framework/static/js/ff_global1.js b/lib/framework/static/js/ff_global1.js index 50a77c1..e4e866e 100644 --- a/lib/framework/static/js/ff_global1.js +++ b/lib/framework/static/js/ff_global1.js @@ -112,8 +112,8 @@ $("body").on('click', '#globalEditBtn', function(e) { data: {}, dataType: "json", success: function (ret) { - if (ret) { - window.location.href = '/flaskcode?open=' + file; + if (ret.ret) { + window.open('/flaskcode?open=' + file, ret.target); } else { notify('편집기 플러그인을 설치해야 합니다.', 'warning'); } @@ -160,11 +160,11 @@ function shutdown_confirm() { var select_local_file_modal_callback = null; -function selectLocalFile(title, init_path, func) { +function globalSelectLocalFile(title, init_path, func) { _selectLocalFileModal(title, init_path, false, func); } -function selectLocalFolder(title, init_path, func) { +function globalSelectLocalFolder(title, init_path, func) { _selectLocalFileModal(title, init_path, true, func); } diff --git a/lib/framework/templates/macro_menu.html b/lib/framework/templates/macro_menu.html index 60fd0a7..fc7a5fa 100644 --- a/lib/framework/templates/macro_menu.html +++ b/lib/framework/templates/macro_menu.html @@ -46,7 +46,11 @@ {% if category_child['uri'] == menu[0] %} {{ category_child['name'] }} {% else %} - {{ category_child['name'] }} + {% if category_child['target'] == '__blank' %} + {{ category_child['name'] }} + {% else %} + {{ category_child['name'] }} + {% endif %} {% endif %} {% endif %} {% endfor %} @@ -85,9 +89,17 @@ {% endif %} {% else %} {% if current_menu[1] == module['uri'] or (current_menu[2] is not none and current_menu[1] + "/" + current_menu[2] == module['uri']) %} -