preview.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from .tool.func import *
  2. def preview_2(conn, name):
  3. curs = conn.cursor()
  4. if acl_check(name) == 1:
  5. return re_error('/ban')
  6. new_data = re.sub('^\r\n', '', flask.request.form.get('content', None))
  7. new_data = re.sub('\r\n$', '', new_data)
  8. end_data = render_set(
  9. title = name,
  10. data = new_data
  11. )
  12. if flask.request.args.get('section', None):
  13. action = '?section=' + flask.request.args.get('section', None)
  14. else:
  15. action = ''
  16. js_data = edit_help_button()
  17. return easy_minify(flask.render_template(skin_check(),
  18. imp = [name, wiki_set(), custom(), other2([' (' + load_lang('preview') + ')', 0])],
  19. data = '<a href="/edit_filter">(' + load_lang('edit_filter_rule') + ')</a>' + js_data[0] + '''
  20. <form method="post" action="/edit/''' + url_pas(name) + action + '''">
  21. ''' + js_data[1] + '''
  22. <textarea id="content" rows="25" name="content">''' + html.escape(flask.request.form.get('content', None)) + '''</textarea>
  23. <textarea style="display: none;" name="otent">''' + html.escape(flask.request.form.get('otent', None)) + '''</textarea>
  24. <hr class=\"main_hr\">
  25. <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
  26. <hr class=\"main_hr\">
  27. ''' + captcha_get() + '''
  28. <button id="save" type="submit">''' + load_lang('save') + '''</button>
  29. <button id="preview" type="submit" formaction="/preview/''' + url_pas(name) + action + '">' + load_lang('preview') + '''</button>
  30. </form>
  31. <hr class=\"main_hr\">
  32. ''' + end_data,
  33. menu = [['w/' + url_pas(name), load_lang('return')]]
  34. ))