This commit is contained in:
flaskfarm
2022-10-07 15:11:05 +09:00
parent cde69d4d8a
commit 863ca3058d
12 changed files with 125 additions and 133 deletions

View File

@@ -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!!')

View File

@@ -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)

View File

@@ -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

View File

@@ -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);
}

View File

@@ -46,7 +46,11 @@
{% if category_child['uri'] == menu[0] %}
<a class="dropdown-item active" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold">{{ category_child['name'] }}</a>
{% else %}
<a class="dropdown-item" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold">{{ category_child['name'] }}</a>
{% if category_child['target'] == '__blank' %}
<a class="dropdown-item" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold">{{ category_child['name'] }}</a>
{% else %}
<a class="dropdown-item" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold" target="__blank">{{ category_child['name'] }}</a>
{% 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']) %}
<li class="nav-item"><a class="nav-link active" href="/{{current_menu[0]}}/{{module['uri']}}">{{module['name']}}</a></li>
{% if 'target' in module and module['target'] == '_blank' %}
<li class="nav-item"><a class="nav-link active" href="/{{current_menu[0]}}/{{module['uri']}}" target="_blank">{{module['name']}}</a></li>
{% else %}
<li class="nav-item"><a class="nav-link active" href="/{{current_menu[0]}}/{{module['uri']}}">{{module['name']}}</a></li>
{% endif %}
{% else %}
<li class="nav-item"><a class="nav-link" href="/{{current_menu[0]}}/{{module['uri']}}">{{module['name']}}</a></li>
{% if 'target' in module and module['target'] == '_blank' %}
<li class="nav-item"><a class="nav-link" href="/{{current_menu[0]}}/{{module['uri']}}" target="_blank">{{module['name']}}</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="/{{current_menu[0]}}/{{module['uri']}}">{{module['name']}}</a></li>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}