mark.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from set_mark.start import start
  2. import re
  3. import html
  4. import sqlite3
  5. from urllib import parse
  6. import time
  7. import threading
  8. def send_p(d):
  9. d = html.escape(d)
  10. js_p = re.compile('javascript:', re.I)
  11. d = js_p.sub('', d)
  12. d = re.sub('&lt;a href="(?:[^"]*)"&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + url_pas('\g<in>') + '">\g<in></a>', d)
  13. return d
  14. def url_pas(data):
  15. return parse.quote(data).replace('/','%2F')
  16. def plusing(conn, name, link, backtype):
  17. curs = conn.cursor()
  18. curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
  19. if not curs.fetchall():
  20. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  21. def namumark(conn, title, data, num, in_c, toc_y):
  22. data = start(conn, data, title)
  23. data += '<script>function folding(num, test = 0) { var fol = document.getElementById(\'folding_\' + num); if(fol.style.display == \'inline-block\' || fol.style.display == \'block\') { fol.style.display = \'none\'; } else { if(num % 3 == 0 && test != 1) { fol.style.display = \'block\'; } else { fol.style.display = \'inline-block\'; } } } </script>'
  24. # if num == 1:
  25. # for d4 in backlink:
  26. # t = threading.Thread(target = plusing, args = [conn, d4[0], d4[1], d4[2]])
  27. # t.start()
  28. # t.join()
  29. #
  30. # conn.commit()
  31. return data