Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

70 righe
1.8 KiB

  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. from webnotes.webutils import get_hex_shade
  10. doc = webnotes.doc("Style Settings", "Style Settings")
  11. prepare(doc)
  12. return {
  13. "doc": doc,
  14. "get_hex_shade": get_hex_shade
  15. }
  16. def prepare(doc):
  17. from webnotes.utils import cint, cstr
  18. # set default colours
  19. default_colours = {
  20. "background_color": "FFFFFF",
  21. "page_background": "FFFFFF",
  22. "top_bar_background": "FFFFFF",
  23. "top_bar_foreground": "444444",
  24. "page_headings": "222222",
  25. "page_text": "000000"
  26. }
  27. for d in default_colours:
  28. if not doc.fields.get(d):
  29. doc.fields[d] = default_colours[d]
  30. if not doc.font_size:
  31. doc.font_size = "13px"
  32. doc.small_font_size = cstr(cint(doc.font_size[:-2])-2) + 'px'
  33. doc.page_border = cint(doc.page_border)
  34. fonts = []
  35. if doc.google_web_font_for_heading:
  36. fonts.append(doc.google_web_font_for_heading)
  37. if doc.google_web_font_for_text:
  38. fonts.append(doc.google_web_font_for_text)
  39. fonts = list(set(fonts))
  40. if doc.heading_text_as:
  41. doc.heading_text_style = {
  42. "UPPERCASE": "uppercase",
  43. "Title Case":"capitalize",
  44. "lowercase": "lowercase"
  45. }.get(doc.heading_text_as) or ""
  46. doc.at_import = ""
  47. for f in fonts:
  48. doc.at_import += "\n@import url(https://fonts.googleapis.com/css?family=%s:400,700);" % f.replace(" ", "+")
  49. # move @import from add_css field to the top of the css file
  50. if doc.add_css and "@import url" in doc.add_css:
  51. import re
  52. at_imports = list(set(re.findall("@import url\([^\(\)]*\);", doc.add_css)))
  53. doc.at_import += "\n" + "\n".join(at_imports)
  54. for imp in at_imports:
  55. doc.add_css = doc.add_css.replace(imp, "")