|
|
@@ -7,39 +7,40 @@ def api_w_2(conn, name):
|
|
|
curs.execute(db_change("select title from data where title = ?"), [name])
|
|
|
if curs.fetchall():
|
|
|
return flask.jsonify({ "exist" : "1" })
|
|
|
- else:
|
|
|
- return flask.jsonify({})
|
|
|
else:
|
|
|
if acl_check(name, 'render') != 1:
|
|
|
if flask.request.method == 'POST':
|
|
|
- g_data = render_set(title = name, data = flask.request.form.get('data', ''), num = 2)
|
|
|
+ g_data = flask.request.form.get('data', '')
|
|
|
+ g_data = render_set(title = name, data = g_data, num = 2)
|
|
|
|
|
|
return flask.jsonify({ "title" : name, "data" : g_data[0], "js_data" : g_data[1] })
|
|
|
else:
|
|
|
curs.execute(db_change("select data from data where title = ?"), [name])
|
|
|
data = curs.fetchall()
|
|
|
if data:
|
|
|
- if flask.request.args.get('include', 'include_1'):
|
|
|
- json_data = data[0][0]
|
|
|
-
|
|
|
- get_all_change_1 = [('@' + i[0] + '@', i[1]) for i in re.findall(r'@([^=]+)=([^@]+)@', json_data)]
|
|
|
- json_data = re.sub(r'@(?P<in>[^=]+)=([^@]+)@', '@\g<in>@', json_data)
|
|
|
+ json_data = data[0][0]
|
|
|
+ include_data = flask.request.args.get('include', None)
|
|
|
+ if include_data:
|
|
|
+ get_all_change_1 = []
|
|
|
+ find_replace_moment = re.findall(r'(@([^=@]+)=([^=@]+)@|@([^=@]+)@)', json_data)
|
|
|
+ for i in find_replace_moment:
|
|
|
+ if i[1] != '':
|
|
|
+ get_all_change_1 += [['@' + i[1] + '@', i[2]]]
|
|
|
+
|
|
|
+ json_data = json_data.replace(i[0], '@' + i[1] + '@', 1)
|
|
|
+ else:
|
|
|
+ json_data = json_data.replace(i[0], '@' + i[3] + '@', 1)
|
|
|
|
|
|
get_all_change_2 = re.findall(r'(@(?:[^@]*)@),([^,]*),', flask.request.args.get('change', '')) + get_all_change_1
|
|
|
for i in get_all_change_2:
|
|
|
json_data = json_data.replace(
|
|
|
i[0].replace('<amp>', '&'),
|
|
|
- i[1].replace('<amp>', '&').replace('<comma>', ',')
|
|
|
+ i[1].replace('<amp>', '&').replace('<comma>', ','),
|
|
|
+ 1
|
|
|
)
|
|
|
-
|
|
|
- g_data = render_set(title = name, data = json_data, num = 2, include = flask.request.args.get('include', 'include_1'))
|
|
|
- else:
|
|
|
- json_data = g_data[0]
|
|
|
-
|
|
|
- g_data = render_set(title = name, data = json_data, num = 2)
|
|
|
+
|
|
|
+ g_data = render_set(title = name, data = json_data, num = 2, include = include_data)
|
|
|
|
|
|
return flask.jsonify({ "title" : name, "data" : g_data[0], "js_data" : g_data[1] })
|
|
|
- else:
|
|
|
- return flask.jsonify({})
|
|
|
- else:
|
|
|
- return flask.jsonify({})
|
|
|
+
|
|
|
+ return flask.jsonify({})
|