Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

style_settings.py 1.7 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import webnotes
  5. no_sitemap = 1
  6. base_template_path = "templates/pages/style_settings.css"
  7. def get_context(context):
  8. """returns web style"""
  9. doc = webnotes.doc("Style Settings", "Style Settings")
  10. prepare(doc)
  11. return { "doc": doc.fields }
  12. def prepare(doc):
  13. from webnotes.utils import cint, cstr
  14. # set default colours
  15. default_colours = {
  16. "background_color": "FFFFFF",
  17. "page_background": "FFFFFF",
  18. "top_bar_background": "FFFFFF",
  19. "top_bar_foreground": "444444",
  20. "page_headings": "222222",
  21. "page_text": "000000"
  22. }
  23. for d in default_colours:
  24. if not doc.fields.get(d):
  25. doc.fields[d] = default_colours[d]
  26. if not doc.font_size:
  27. doc.font_size = "13px"
  28. doc.small_font_size = cstr(cint(doc.font_size[:-2])-2) + 'px'
  29. doc.page_border = cint(doc.page_border)
  30. fonts = []
  31. if doc.google_web_font_for_heading:
  32. fonts.append(doc.google_web_font_for_heading)
  33. if doc.google_web_font_for_text:
  34. fonts.append(doc.google_web_font_for_text)
  35. fonts = list(set(fonts))
  36. if doc.heading_text_as:
  37. doc.heading_text_style = {
  38. "UPPERCASE": "uppercase",
  39. "Title Case":"capitalize",
  40. "lowercase": "lowercase"
  41. }.get(doc.heading_text_as) or ""
  42. doc.at_import = ""
  43. for f in fonts:
  44. doc.at_import += "\n@import url(https://fonts.googleapis.com/css?family=%s:400,700);" % f.replace(" ", "+")
  45. # move @import from add_css field to the top of the css file
  46. if doc.add_css and "@import url" in doc.add_css:
  47. import re
  48. at_imports = list(set(re.findall("@import url\([^\(\)]*\);", doc.add_css)))
  49. doc.at_import += "\n" + "\n".join(at_imports)
  50. for imp in at_imports:
  51. doc.add_css = doc.add_css.replace(imp, "")