您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

110 行
3.0 KiB

  1. """
  2. Generate index.cgi html
  3. Loads index.html from the template with:
  4. 1. bootinfo
  5. 2. static html of home / if _escaped_fragment_ is given
  6. 3. top menus and bottom menus
  7. """
  8. import webnotes
  9. body_html = """
  10. <header></header>
  11. <div id="startup_div" style="padding: 8px;
  12. font-size: 12px; font-family: Arial !important; line-height: 1.6em;">
  13. Loading...
  14. </div>
  15. <!-- Main Starts -->
  16. <div id="body_div">
  17. </div>
  18. <div class="no_script" style="display: none;">
  19. %s
  20. </div>
  21. <footer></footer>
  22. <div id="dialog_back"></div>
  23. """
  24. def get():
  25. """get index html"""
  26. import webnotes
  27. from jinja2 import Template
  28. with open('lib/conf/index.html', 'r') as f:
  29. template = Template(f.read())
  30. # google crawler
  31. if '_escaped_fragment_' in webnotes.form:
  32. page = webnotes.form_dict['_escaped_fragment_']
  33. if not page:
  34. page = webnotes.user.get_home_page()
  35. return template.render(bootinfo = '', style_tag='', version='0', \
  36. script_tag = '', body_html=html_snapshot(page), ajax_meta_tag = '')
  37. # home page
  38. else:
  39. import webnotes.session_cache
  40. from build.project import get_version
  41. import json
  42. bootinfo = webnotes.session_cache.get()
  43. bootinfo = """var wn = {}; wn.boot = %s;""" % json.dumps(bootinfo)
  44. if webnotes.session['user'] == 'Guest':
  45. script_tag = '<script type="text/javascript" src="js/all-web.js"></script>'
  46. style_tag = '<link type="text/css" rel="stylesheet" href="css/all-web.css">'
  47. else:
  48. script_tag = '<script type="text/javascript" src="js/all-app.js"></script>'
  49. style_tag = '<link type="text/css" rel="stylesheet" href="css/all-app.css">'
  50. return template.render(bootinfo = bootinfo, version = get_version(), \
  51. script_tag = script_tag, style_tag = style_tag, body_html=body_html % '', \
  52. ajax_meta_tag = '<meta name="fragment" content="!">')
  53. def html_snapshot(page):
  54. """get html snapshot for search bot"""
  55. from webnotes.widgets.page import get_page_html
  56. from webnotes.model.doc import Document
  57. doc = Document('Website Settings', 'Website Settings')
  58. doc.content = get_page_html(page)
  59. doc.header_menu = doc.footer_menu = ''
  60. doc.page_name = page
  61. for m in webnotes.conn.sql("""select parentfield, label, url, custom_page
  62. from `tabTop Bar Item` where parent='Top Bar Settings' order by idx""", as_dict=1):
  63. m['std_page'] = m.get('url') or m('custom_page')
  64. if m['parentfield']=='top_bar_items':
  65. doc.header_menu += '<li><a href="index.cgi#!%(std_page)s">%(label)s</a></li>' % m
  66. else:
  67. doc.footer_menu += '<li><a href="index.cgi#!%(std_page)s">%(label)s</a></li>' % m
  68. return """
  69. <header>
  70. <h3>%(brand_html)s</h3>
  71. <ul>
  72. %(header_menu)s
  73. </ul>
  74. </header>
  75. %(content)s
  76. <footer>
  77. <ul>
  78. %(footer_menu)s
  79. </ul>
  80. <div>Address: %(address)s</div>
  81. <div>&copy; %(copyright)s</div>
  82. <div>Powered by <a href="https://erpnext.com">erpnext.com</a></div>
  83. <div style="background-color: #ffc; padding: 7px">
  84. This page is for search engines, for standard browsers click
  85. <a href="index.cgi#!%(page_name)s">here</a>
  86. </div>
  87. </footer>
  88. """ % doc.fields