From 363ed5061569bda5c1a8c5d781306985acee478d Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Wed, 15 May 2019 01:49:50 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/cms/__init__.py | 2 ++ app/api/cms/file.py | 21 +++++++++++++++++++++ app/extensions/file/config.py | 1 + app/extensions/file/local_uploader.py | 27 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 app/api/cms/file.py create mode 100644 app/extensions/file/config.py create mode 100644 app/extensions/file/local_uploader.py diff --git a/app/api/cms/__init__.py b/app/api/cms/__init__.py index 559d701..af09b63 100644 --- a/app/api/cms/__init__.py +++ b/app/api/cms/__init__.py @@ -13,9 +13,11 @@ def create_cms(): from .admin import admin_api from .user import user_api from .log import log_api + from .file import file_api from .test import test_api admin_api.register(cms) user_api.register(cms) log_api.register(cms) + file_api.register(cms) test_api.register(cms) return cms diff --git a/app/api/cms/file.py b/app/api/cms/file.py new file mode 100644 index 0000000..9791628 --- /dev/null +++ b/app/api/cms/file.py @@ -0,0 +1,21 @@ +""" + :copyright: © 2019 by the Lin team. + :license: MIT, see LICENSE for more details. +""" +from flask import request +from lin import login_required +from lin.exception import Success +from lin.redprint import Redprint + +from app.extensions.file.local_uploader import LocalUploader + +file_api = Redprint('file') + + +@file_api.route('/', methods=['POST']) +@login_required +def post_file(): + files = request.files + uploader = LocalUploader(files) + uploader.upload() + return Success() diff --git a/app/extensions/file/config.py b/app/extensions/file/config.py new file mode 100644 index 0000000..0a0423b --- /dev/null +++ b/app/extensions/file/config.py @@ -0,0 +1 @@ +# 文件相关配置 diff --git a/app/extensions/file/local_uploader.py b/app/extensions/file/local_uploader.py new file mode 100644 index 0000000..3bb92b7 --- /dev/null +++ b/app/extensions/file/local_uploader.py @@ -0,0 +1,27 @@ +import os + +from werkzeug.utils import secure_filename + +from lin.core import File +from lin.file import Uploader + + +class LocalUploader(Uploader): + + def upload(self, **kwargs): + ret = dict(file_storage=self._file_storage, file=[]) + for single in self._file_storage: + secure_filename(single.filename) + name = self._generate_uuid() + self._get_ext(single) + full_path = os.path.join(self._store_dir, name) + single.save(full_path) + file = File.create_file( + name=name, + path=full_path, + _type=1, + extension=self._get_ext(single), + size=self._get_size(single), + commit=True + ) + ret['file'].append(file) + return ret From 468651bdb018bbabbb4e55e2c0fe0da263336f20 Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Sun, 19 May 2019 22:06:18 +0800 Subject: [PATCH 02/13] =?UTF-8?q?feat:=20=E6=94=B9=E5=BB=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/cms/file.py | 7 ++-- app/api/cms/user.py | 17 ++++++++-- app/app.py | 2 +- app/extensions/file/local_uploader.py | 46 +++++++++++++++++---------- app/validators/forms.py | 6 ++++ 5 files changed, 55 insertions(+), 23 deletions(-) diff --git a/app/api/cms/file.py b/app/api/cms/file.py index 9791628..ff91447 100644 --- a/app/api/cms/file.py +++ b/app/api/cms/file.py @@ -2,9 +2,8 @@ :copyright: © 2019 by the Lin team. :license: MIT, see LICENSE for more details. """ -from flask import request +from flask import request, jsonify from lin import login_required -from lin.exception import Success from lin.redprint import Redprint from app.extensions.file.local_uploader import LocalUploader @@ -17,5 +16,5 @@ def post_file(): files = request.files uploader = LocalUploader(files) - uploader.upload() - return Success() + ret = uploader.upload() + return jsonify(ret) diff --git a/app/api/cms/user.py b/app/api/cms/user.py index 32b3f71..5be1d7b 100644 --- a/app/api/cms/user.py +++ b/app/api/cms/user.py @@ -4,9 +4,10 @@ :copyright: © 2019 by the Lin team. :license: MIT, see LICENSE for more details. """ +from collections import namedtuple from operator import and_ -from flask import jsonify +from flask import jsonify, request, url_for from flask_jwt_extended import create_access_token, get_jwt_identity, get_current_user, \ create_refresh_token, verify_jwt_refresh_token_in_request from lin.core import manager, route_meta, Log @@ -16,8 +17,10 @@ from lin.log import Logger from lin.redprint import Redprint +from app.extensions.file.local_uploader import LocalUploader from app.libs.error_code import RefreshException -from app.validators.forms import LoginForm, RegisterForm, ChangePasswordForm, UpdateInfoForm +from app.validators.forms import LoginForm, RegisterForm, ChangePasswordForm, UpdateInfoForm, \ + AvatarUpdateForm user_api = Redprint('user') @@ -136,6 +139,16 @@ def get_allowed_apis(): return jsonify(user) +@user_api.route('/avatar', methods=['PUT']) +@login_required +def set_avatar(): + form = AvatarUpdateForm().validate_for_api() + user = get_current_user() + with db.auto_commit(): + user.avatar = form.avatar.data + return Success(msg='操作成功') + + def _register_user(form: RegisterForm): with db.auto_commit(): # 注意:此处使用挂载到manager上的user_model,不可使用默认的User diff --git a/app/app.py b/app/app.py index 56ccbd1..d985b35 100644 --- a/app/app.py +++ b/app/app.py @@ -26,7 +26,7 @@ def create_tables(app): def create_app(register_all=True): - app = Flask(__name__) + app = Flask(__name__, static_folder='./assets') app.config.from_object('app.config.setting') app.config.from_object('app.config.secure') if register_all: diff --git a/app/extensions/file/local_uploader.py b/app/extensions/file/local_uploader.py index 3bb92b7..c9725c5 100644 --- a/app/extensions/file/local_uploader.py +++ b/app/extensions/file/local_uploader.py @@ -1,5 +1,4 @@ -import os - +from flask import current_app from werkzeug.utils import secure_filename from lin.core import File @@ -9,19 +8,34 @@ class LocalUploader(Uploader): def upload(self, **kwargs): - ret = dict(file_storage=self._file_storage, file=[]) + ret = [] + site_domain = current_app.config.get('SITE_DOMAIN')\ + if current_app.config.get('SITE_DOMAIN') else '127.0.0.1:5000' for single in self._file_storage: - secure_filename(single.filename) - name = self._generate_uuid() + self._get_ext(single) - full_path = os.path.join(self._store_dir, name) - single.save(full_path) - file = File.create_file( - name=name, - path=full_path, - _type=1, - extension=self._get_ext(single), - size=self._get_size(single), - commit=True - ) - ret['file'].append(file) + file_md5 = self._generate_md5(single.read()) + single.seek(0) + exists = File.query.filter_by(md5=file_md5).first() + if exists: + ret.append({ + "key": single.filename, + "id": exists.id, + "url": site_domain + '/assets/' + exists.path + }) + else: + absolute_path, relative_path, real_name = self._get_store_path(single.filename) + secure_filename(single.filename) + single.save(absolute_path) + file = File.create_file( + name=real_name, + path=relative_path, + extension=self._get_ext(single.filename), + size=self._get_size(single), + md5=file_md5, + commit=True + ) + ret.append({ + "key": single.filename, + "id": file.id, + "url": site_domain + '/assets/' + file.path + }) return ret diff --git a/app/validators/forms.py b/app/validators/forms.py index 2ef9359..a1f8328 100644 --- a/app/validators/forms.py +++ b/app/validators/forms.py @@ -141,6 +141,12 @@ class UpdateUserInfoForm(Form): ]) +class AvatarUpdateForm(Form): + avatar = StringField('头像', validators=[ + DataRequired(message='请输入头像url') + ]) + + class BookSearchForm(Form): q = StringField(validators=[DataRequired(message='必须传入搜索关键字')]) # 前端的请求参数中必须携带`q` From 3a4903ecd45c317624ff35462dbd37f148f003a5 Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Sun, 19 May 2019 23:46:24 +0800 Subject: [PATCH 03/13] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E6=A8=A1=E5=9D=97=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/cms/user.py | 6 ++---- app/extensions/file/local_uploader.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/api/cms/user.py b/app/api/cms/user.py index 5be1d7b..7c1b061 100644 --- a/app/api/cms/user.py +++ b/app/api/cms/user.py @@ -4,10 +4,9 @@ :copyright: © 2019 by the Lin team. :license: MIT, see LICENSE for more details. """ -from collections import namedtuple from operator import and_ -from flask import jsonify, request, url_for +from flask import jsonify from flask_jwt_extended import create_access_token, get_jwt_identity, get_current_user, \ create_refresh_token, verify_jwt_refresh_token_in_request from lin.core import manager, route_meta, Log @@ -17,7 +16,6 @@ from lin.log import Logger from lin.redprint import Redprint -from app.extensions.file.local_uploader import LocalUploader from app.libs.error_code import RefreshException from app.validators.forms import LoginForm, RegisterForm, ChangePasswordForm, UpdateInfoForm, \ AvatarUpdateForm @@ -146,7 +144,7 @@ def set_avatar(): user = get_current_user() with db.auto_commit(): user.avatar = form.avatar.data - return Success(msg='操作成功') + return Success(msg='更新头像成功') def _register_user(form: RegisterForm): diff --git a/app/extensions/file/local_uploader.py b/app/extensions/file/local_uploader.py index c9725c5..ef3dd2b 100644 --- a/app/extensions/file/local_uploader.py +++ b/app/extensions/file/local_uploader.py @@ -10,7 +10,7 @@ class LocalUploader(Uploader): def upload(self, **kwargs): ret = [] site_domain = current_app.config.get('SITE_DOMAIN')\ - if current_app.config.get('SITE_DOMAIN') else '127.0.0.1:5000' + if current_app.config.get('SITE_DOMAIN') else 'http://127.0.0.1:5000' for single in self._file_storage: file_md5 = self._generate_md5(single.read()) single.seek(0) From 3b89b981cb4e5b305652756aafddbd95bb98bae5 Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Wed, 22 May 2019 17:58:57 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E8=BF=94=E5=9B=9E=E7=9A=84key?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/extensions/file/local_uploader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/extensions/file/local_uploader.py b/app/extensions/file/local_uploader.py index ef3dd2b..36fc853 100644 --- a/app/extensions/file/local_uploader.py +++ b/app/extensions/file/local_uploader.py @@ -17,7 +17,7 @@ def upload(self, **kwargs): exists = File.query.filter_by(md5=file_md5).first() if exists: ret.append({ - "key": single.filename, + "key": single.name, "id": exists.id, "url": site_domain + '/assets/' + exists.path }) @@ -34,7 +34,7 @@ def upload(self, **kwargs): commit=True ) ret.append({ - "key": single.filename, + "key": single.name, "id": file.id, "url": site_domain + '/assets/' + file.path }) From 5e968959f94685de61143a3d215d80ee05a963b9 Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Sun, 2 Jun 2019 11:27:07 +0800 Subject: [PATCH 05/13] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/extensions/file/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/extensions/file/config.py b/app/extensions/file/config.py index 0a0423b..420e194 100644 --- a/app/extensions/file/config.py +++ b/app/extensions/file/config.py @@ -1 +1,9 @@ # 文件相关配置 +FILE = { + "STORE_DIR": 'app/assets', + "SINGLE_LIMIT": 1024 * 1024 * 2, + "TOTAL_LIMIT": 1024 * 1024 * 20, + "NUMS": 10, + "INCLUDE": set([]), + "EXCLUDE": set([]) +} From 7011b757258c817f2bcf5ae6b7169c67c1dc48df Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Mon, 3 Jun 2019 12:32:42 +0800 Subject: [PATCH 06/13] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E5=BA=93=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pipfile | 2 +- README.md | 6 +++--- code.md | 6 ++++++ requirements.txt | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Pipfile b/Pipfile index eef60d5..ceda59a 100644 --- a/Pipfile +++ b/Pipfile @@ -12,7 +12,7 @@ Flask = "==1.0.2" Flask-SQLAlchemy = "==2.3.2" Flask-WTF = "==0.14.2" Flask-Cors = "==2.1.0" -Lin-CMS = "==0.1.1b1" +Lin-CMS = "==0.1.1b3" [dev-packages] pytest = "*" diff --git a/README.md b/README.md index 6c68274..541afdb 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ Lin-CMS 是林间有风团队经过大量项目实践所提炼出的一套**内 ## 最新版本 -核心库:0.1.1b1 +核心库:0.1.1b3 -示例工程:0.1.0-beta.1 +示例工程:0.1.0-beta.2 ### 文档地址 @@ -165,4 +165,4 @@ pipenv shell ## 下个版本开发计划 -- [ ] 调整 jwt 机制,增强灵活性 +- [ ] 系统访问日志、错误日志 diff --git a/code.md b/code.md index 7b8bcd9..8df5be1 100644 --- a/code.md +++ b/code.md @@ -26,6 +26,12 @@ 10100 refresh token 获取失败 +10110 文件体积过大 + +10120 文件数量过多 + +10130 文件扩展名不符合规范 + 20000 werkzeug 中的HTTP EXCEPTION,error_code统一为1007,前端应读取msg ## 项目使用的状态码 diff --git a/requirements.txt b/requirements.txt index a4a5391..fc8cd9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ Flask-WTF==0.14.2 idna==2.6 itsdangerous==1.1.0 Jinja2==2.10 -Lin-CMS==0.1.1b1 +Lin-CMS==0.1.1b3 MarkupSafe==1.1.1 pipfile==0.0.2 PyJWT==1.7.1 From f7eaabfb230eb92e2a8f77113cc2836485e6fe9c Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Mon, 3 Jun 2019 12:33:40 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwin=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=9C=A8cmd=E4=B8=8B=E6=89=A7=E8=A1=8C=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=8F=92=E4=BB=B6=E8=84=9A=E6=9C=AC=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin_init.py b/plugin_init.py index c135439..53478ea 100644 --- a/plugin_init.py +++ b/plugin_init.py @@ -144,12 +144,12 @@ def __update_setting(self, new_setting): sub_str = 'PLUGIN_PATH = ' + self.__format_setting(final_setting) setting_path = self.app.config.root_path + '/config/setting.py' - with open(setting_path, 'r') as f: + with open(setting_path, 'r', encoding='UTF-8') as f: content = f.read() pattern = 'PLUGIN_PATH = \{([\s\S]*)\}+.*?' result = re.sub(pattern, sub_str, content) - with open(setting_path, 'w+') as f: + with open(setting_path, 'w+', encoding='UTF-8') as f: f.write(result) def __get_all_plugins(self): @@ -255,7 +255,7 @@ def __generate_plugin_graph(self): '.', '/').replace('app', '') requirements_path = self.app.config.root_path + \ plugin_path + '/requirements.txt' - with open(requirements_path, 'r') as f: + with open(requirements_path, 'r', encoding='UTF-8') as f: while True: # 正则匹配requirements的每一行的信息 From 337c8b1072d4f69ea0847c066afb2e47cbd36cc4 Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Mon, 3 Jun 2019 19:41:30 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4LocalUpload?= =?UTF-8?q?=E4=B8=8Bupload=E7=9A=84=E5=A4=9A=E4=BD=99=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/extensions/file/local_uploader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/extensions/file/local_uploader.py b/app/extensions/file/local_uploader.py index 36fc853..b80637c 100644 --- a/app/extensions/file/local_uploader.py +++ b/app/extensions/file/local_uploader.py @@ -7,7 +7,7 @@ class LocalUploader(Uploader): - def upload(self, **kwargs): + def upload(self): ret = [] site_domain = current_app.config.get('SITE_DOMAIN')\ if current_app.config.get('SITE_DOMAIN') else 'http://127.0.0.1:5000' From 5e58bcb913d2e0050007fd3ea2bd7ecb7718860c Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Wed, 12 Jun 2019 17:26:25 +0800 Subject: [PATCH 09/13] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=97=A5=E5=BF=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.py | 42 +++++++++++++++++++++++++++++++++++++++++- app/config/log.py | 11 +++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 app/config/log.py diff --git a/app/app.py b/app/app.py index d985b35..73c3141 100644 --- a/app/app.py +++ b/app/app.py @@ -2,8 +2,10 @@ :copyright: © 2019 by the Lin team. :license: MIT, see LICENSE for more details. """ +import json +import time -from flask import Flask +from flask import Flask, request, g from flask_cors import CORS from lin import Lin @@ -25,14 +27,52 @@ def create_tables(app): db.create_all() +def register_before_request(app): + @app.before_request + def request_cost_time(): + g.request_start_time = time.time() + g.request_time = lambda: "%.5f" % (time.time() - g.request_start_time) + + +def register_after_request(app): + @app.after_request + def log_response(resp): + log_config = app.config.get('LOG') + if not log_config['REQUEST_LOG']: + return resp + message = '[%s]->[%s] from:%s costs:%.3f ms' % ( + request.method, + request.path, + request.remote_addr, + float(g.request_time()) * 1000 + ) + if log_config['LEVEL'] == 'INFO': + app.logger.info(message) + elif log_config['LEVEL'] == 'DEBUG': + req_body = '{}' + try: + req_body = request.get_json() + except: + pass + message += ' data:{param:%s, body:%s} ' % ( + json.dumps(request.args, ensure_ascii=False), + req_body + ) + app.logger.debug(message) + return resp + + def create_app(register_all=True): app = Flask(__name__, static_folder='./assets') app.config.from_object('app.config.setting') app.config.from_object('app.config.secure') + app.config.from_object('app.config.log') if register_all: register_blueprints(app) Lin(app) apply_cors(app) # 创建所有表格 create_tables(app) + register_before_request(app) + register_after_request(app) return app diff --git a/app/config/log.py b/app/config/log.py new file mode 100644 index 0000000..d65b299 --- /dev/null +++ b/app/config/log.py @@ -0,0 +1,11 @@ +""" + :copyright: © 2019 by the Lin team. + :license: MIT, see LICENSE for more details. +""" + +LOG = { + 'LEVEL': 'DEBUG', + 'DIR': 'logs', + 'SIZE_LIMIT': 1024 * 1024 * 5, + 'REQUEST_LOG': True +} From ee8080a51f5fd5f8b161acba8ba9dd0b0c2113b5 Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Sat, 15 Jun 2019 13:35:00 +0800 Subject: [PATCH 10/13] =?UTF-8?q?refactor:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index 73c3141..d5f4360 100644 --- a/app/app.py +++ b/app/app.py @@ -40,7 +40,7 @@ def log_response(resp): log_config = app.config.get('LOG') if not log_config['REQUEST_LOG']: return resp - message = '[%s]->[%s] from:%s costs:%.3f ms' % ( + message = '[%s] -> [%s] from:%s costs:%.3f ms' % ( request.method, request.path, request.remote_addr, @@ -54,7 +54,7 @@ def log_response(resp): req_body = request.get_json() except: pass - message += ' data:{param:%s, body:%s} ' % ( + message += " data:{\n\tparam: %s, \n\tbody: %s\n} " % ( json.dumps(request.args, ensure_ascii=False), req_body ) @@ -70,9 +70,10 @@ def create_app(register_all=True): if register_all: register_blueprints(app) Lin(app) + register_before_request(app) + register_after_request(app) apply_cors(app) # 创建所有表格 create_tables(app) - register_before_request(app) - register_after_request(app) + return app From ba0efeda2a11273146d8477ac307bebab971a16f Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Mon, 17 Jun 2019 22:12:33 +0800 Subject: [PATCH 11/13] =?UTF-8?q?chroe:=20=E4=BF=AE=E6=94=B9=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E5=BA=93=E4=BE=9D=E8=B5=96=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pipfile | 2 +- app/app.py | 2 +- app/config/log.py | 4 ++-- requirements.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Pipfile b/Pipfile index ceda59a..1f7e95f 100644 --- a/Pipfile +++ b/Pipfile @@ -12,7 +12,7 @@ Flask = "==1.0.2" Flask-SQLAlchemy = "==2.3.2" Flask-WTF = "==0.14.2" Flask-Cors = "==2.1.0" -Lin-CMS = "==0.1.1b3" +Lin-CMS = "==0.1.1b4" [dev-packages] pytest = "*" diff --git a/app/app.py b/app/app.py index d5f4360..43d2ffa 100644 --- a/app/app.py +++ b/app/app.py @@ -51,7 +51,7 @@ def log_response(resp): elif log_config['LEVEL'] == 'DEBUG': req_body = '{}' try: - req_body = request.get_json() + req_body = request.get_json() if request.get_json() else {} except: pass message += " data:{\n\tparam: %s, \n\tbody: %s\n} " % ( diff --git a/app/config/log.py b/app/config/log.py index d65b299..9de678a 100644 --- a/app/config/log.py +++ b/app/config/log.py @@ -2,10 +2,10 @@ :copyright: © 2019 by the Lin team. :license: MIT, see LICENSE for more details. """ - LOG = { 'LEVEL': 'DEBUG', 'DIR': 'logs', 'SIZE_LIMIT': 1024 * 1024 * 5, - 'REQUEST_LOG': True + 'REQUEST_LOG': True, + 'FILE': True } diff --git a/requirements.txt b/requirements.txt index fc8cd9b..d85fe5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ Flask-WTF==0.14.2 idna==2.6 itsdangerous==1.1.0 Jinja2==2.10 -Lin-CMS==0.1.1b3 +Lin-CMS==0.1.1b4 MarkupSafe==1.1.1 pipfile==0.0.2 PyJWT==1.7.1 From 22377a083f8a9cf9f42dbe90edb8409e288448da Mon Sep 17 00:00:00 2001 From: fujiale33 Date: Mon, 17 Jun 2019 22:14:22 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6=E5=88=B0=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=BE=9D=E7=84=B6=E4=BC=9A=E5=9C=A8?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=88=9B=E5=BB=BA=E7=9B=AE=E5=BD=95=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/extensions/file/local_uploader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/extensions/file/local_uploader.py b/app/extensions/file/local_uploader.py index b80637c..07aa8bb 100644 --- a/app/extensions/file/local_uploader.py +++ b/app/extensions/file/local_uploader.py @@ -9,6 +9,7 @@ class LocalUploader(Uploader): def upload(self): ret = [] + self.mkdir_if_not_exists() site_domain = current_app.config.get('SITE_DOMAIN')\ if current_app.config.get('SITE_DOMAIN') else 'http://127.0.0.1:5000' for single in self._file_storage: From e3e9d5f478b12db9a6b299635adf2c5c105fae8c Mon Sep 17 00:00:00 2001 From: Colorful Date: Tue, 18 Jun 2019 10:05:06 +0800 Subject: [PATCH 13/13] Update readme (#65) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update README.md * 新增系统日志 (#63) * feat: 新增文件上传API * feat: 改建文件上传 * fix: 删除多余的模块导入 * fix: 修改文件上传返回的key值 * feat: 增加文件上传默认配置 * chore: 更新核心库版本 * fix: 修复win系统在cmd下执行初始化插件脚本的编码问题 * fix: 删除LocalUpload下upload的多余参数 * feat: 新增系统日志功能 * refactor: 格式化日志记录格式 * chroe: 修改核心库依赖版本号 * fix: 修复上传文件到第三方服务器依然会在本地创建目录的bug * Update README.md * Update README.md --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 541afdb..4a67bcd 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ Lin-CMS 是林间有风团队经过大量项目实践所提炼出的一套**内 ## 最新版本 -核心库:0.1.1b3 +核心库:0.1.1b4 -示例工程:0.1.0-beta.2 +示例工程:0.1.0-beta.3 ### 文档地址 @@ -48,6 +48,18 @@ Lin-CMS 是林间有风团队经过大量项目实践所提炼出的一套**内 [http://face.cms.7yue.pro/](http://face.cms.7yue.pro/) +### QQ 交流群 + +QQ 群号:643205479 + + + +### 微信公众号 + +微信搜索:林间有风 + + + ### Lin CMS 的特点 Lin CMS 的构筑思想是有其自身特点的。下面我们阐述一些 Lin 的主要特点。 @@ -162,7 +174,3 @@ pipenv shell “心上无垢,林间有风" 这证明你已经成功的将 Lin 运行起来了,Congratulations! - -## 下个版本开发计划 - -- [ ] 系统访问日志、错误日志