diff --git a/addons/fastwq/query/common.py b/addons/fastwq/query/common.py index db48912..5e7f4c4 100644 --- a/addons/fastwq/query/common.py +++ b/addons/fastwq/query/common.py @@ -19,6 +19,7 @@ from collections import defaultdict import os +import io import shutil import unicodedata from PyQt4 import QtGui @@ -156,14 +157,24 @@ def add_to_tmpl(note, **kwargs): addings = js.strip() if addings not in afmt: if not addings.startswith(u''): - addings = u'\r\n'.format(addings) + addings = u'\n'.format(addings) afmt += addings if jsfile: - new_jsfile = u'_' + \ - jsfile if not jsfile.startswith(u'_') else jsfile - copy_static_file(jsfile, new_jsfile) - addings = u'\r\n'.format(new_jsfile) - afmt += addings + #new_jsfile = u'_' + \ + # jsfile if not jsfile.startswith(u'_') else jsfile + #copy_static_file(jsfile, new_jsfile) + #addings = u'\r\n'.format(new_jsfile) + jsfile = jsfile if isinstance(jsfile, list) else [jsfile] + addings = u'' + for fn in jsfile: + try: + f = io.open(fn, mode="r", encoding="utf-8") + addings += u'\n'.format(f.read()) + f.close() + except: + pass + if addings not in afmt: + afmt += addings note.model()['tmpls'][0]['afmt'] = afmt diff --git a/addons/fastwq/service/base.py b/addons/fastwq/service/base.py index 2b8e02d..f0f7665 100644 --- a/addons/fastwq/service/base.py +++ b/addons/fastwq/service/base.py @@ -572,8 +572,9 @@ class MdxService(LocalService): @export([u'默认', u'Default']) def fld_whole(self): html = self.get_default_html() - js = re.findall(r'.*?', html, re.DOTALL) - return QueryResult(result=html, js=u'\n'.join(js)) + js = re.findall(r'', html, re.DOTALL) + jsfile = re.findall(r''.format(addings) + addings = u'\n'.format(addings) afmt += addings if jsfile: - new_jsfile = u'_' + \ - jsfile if not jsfile.startswith(u'_') else jsfile - copy_static_file(jsfile, new_jsfile) - addings = u'\r\n'.format(new_jsfile) - afmt += addings + #new_jsfile = u'_' + \ + # jsfile if not jsfile.startswith(u'_') else jsfile + #copy_static_file(jsfile, new_jsfile) + #addings = u'\r\n'.format(new_jsfile) + #afmt += addings + jsfile = jsfile if isinstance(jsfile, list) else [jsfile] + addings = u'' + for fn in jsfile: + try: + with open(fn, 'r', encoding="utf-8") as f: + addings += u'\n'.format(f.read()) + f.close() + except: + pass + if addings not in afmt: + afmt += addings note.model()['tmpls'][0]['afmt'] = afmt diff --git a/addons21/fastwq/service/base.py b/addons21/fastwq/service/base.py index ff6456c..2073e96 100644 --- a/addons21/fastwq/service/base.py +++ b/addons21/fastwq/service/base.py @@ -578,8 +578,10 @@ class MdxService(LocalService): @export([u'默认', u'Default']) def fld_whole(self): html = self.get_default_html() - js = re.findall(r'.*?', html, re.DOTALL) - return QueryResult(result=html, js=u'\n'.join(js)) + js = re.findall(r'', html, re.DOTALL) + jsfile = re.findall(r'