Commit 9da55ffb authored by Xiaowu Zhang's avatar Xiaowu Zhang
Browse files

erp5_corporate_identity: add CI_web skin

parent 87b1f298
......@@ -19,8 +19,12 @@
<skin_folder>erp5_corporate_identity_slide</skin_folder>
<skin_selection>Slide</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>erp5_corporate_identity_web</skin_folder>
<skin_selection>CI_web</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>erp5_xhtml_style</skin_folder>
<skin_selection>Book,Leaflet,Letter,Release,Report,Slide</skin_selection>
<skin_selection>Book,CI_web,Leaflet,Letter,Release,Report,Slide</skin_selection>
</skin_folder_selection>
</registered_skin_selection>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_corporate_identity_web</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>404.error.page</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Not Found</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
line-height: 1.2;
margin: 0;
}
html {
color: #888;
display: table;
font-family: sans-serif;
height: 100%;
text-align: center;
width: 100%;
}
body {
display: table-cell;
vertical-align: middle;
margin: 2em auto;
}
h1 {
color: #555;
font-size: 2em;
font-weight: 400;
}
p {
margin: 0 auto;
width: 280px;
}
@media only screen and (max-width: 280px) {
body, p {
width: 95%;
}
h1 {
font-size: 1.5em;
margin: 0 0 0.3em;
}
}
</style>
</head>
<body>
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
</body>
</html>
<!-- IE needs 512+ bytes: https://blogs.msdn.microsoft.com/ieinternals/2010/08/18/friendly-http-error-pages/ -->
\ No newline at end of file
import re
from Products.PythonScripts.standard import html_quote
document = context
document_content = content
websection = document.getWebSectionValue()
document_url = html_quote(websection.getPermanentURL(context))
# table of content
# XXX we are back to adding TOC to all documents, which we don't want
# XXX fix this to be applied only if a page is viewed as chapter
document_header_list = re.findall("<h[1-6].*?</h[1-6]>", document_content or "")
if len(document_header_list) > 0:
header_current = 1
header_initial = None
table_of_content = ''
for header in document_header_list:
header_level = header[2]
header_initial = header_initial or header_level
header_reference = re.findall(">(.*)<", header)[0]
header_lowercase = header_reference.lower()
header_reference_prefix = header_lowercase.replace(" ", "-")
if header_level == header_current:
table_of_content += '</li>'
# start of a list
if header_level > header_current:
header_current = header_level
table_of_content += '<ul>'
# end of a list
if header_level < header_current:
iterations = (int(header_current) - int(header_level))
table_of_content += '</li></ul>' * iterations
header_current = header_level
# add anchor in content
snippet = ''.join(['>', header_reference])
named_snippet = ''.join([
'>',
'<a name="', html_quote(header_reference_prefix), '"></a>',
header_reference,
'<a class="custom-para" href="', document_url, '#', header_reference_prefix, '"><span style="font-size:.75em;line-height:1em;padding-left:.5em;">&para;</span></a>'
])
document_content = document_content.replace(snippet, named_snippet)
# create table of content entry
table_of_content += ''.join([
'<li><a href="#',
html_quote(header_reference_prefix),
'">',
html_quote(header_reference),
'</a>']
)
closer = int(header_current) * '</ul>'
insert = ''.join(['<p class="custom-table-of-contents">Table of Contents</p>', table_of_content, closer])
document_content = document_content.replace('${table_of_content}', insert)
return document_content
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>content=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebPage_enhanceHtmlContent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
================================================================================
Looks for <img /> with data-open-graph-image="true" from content
================================================================================
"""
import re
if item and item.getPortalType() == "Web Page":
content_image_list = re.findall("<img(.*?)/>", item.getTextContent() or "")
for image_candidate in content_image_list:
if "data-open-graph-image" in image_candidate:
match = re.search('src="([^"]+)"', image_candidate)
if match:
return match.group(1).split("?")[0]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>item=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebPage_getOpenGraphImage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
================================================================================
Get Lastest Documents of a certain Publication Section
================================================================================
"""
portal = language = validation_state = None
portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
language = portal.Localizer.get_selected_language()
validation_state = (
'released',
'released_alive',
'published',
'published_alive',
'shared',
'shared_alive',
'public',
'validated'
)
def getUid(publication_section):
publication_section_smallcaps = publication_section.lower()
return portal.portal_categories.publication_section[publication_section_smallcaps].getUid()
if len(publication_section_list) > 0:
publication_section_uid_list = map(lambda x:getUid(x), publication_section_list)
# beware of different dates: modificatio_date, creation_date, effective_date
if len(publication_section_uid_list) > 0:
return portal_catalog(
portal_type='Web Page',
publication_section_uid=[x for x in publication_section_uid_list],
validation_state=validation_state,
language=language,
sort_on=[('creation_date', 'descending')],
group_by=('reference',),
limit=[0, upper_limit]
)
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upper_limit=4, publication_section_list=[]</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getLastestDocumentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
================================================================================
Create A Webbook Layout Based on Websection Predicate and keywords
================================================================================
"""
from Products.PythonScripts.standard import html_quote
web_section = context
web_section_document_list = web_section.getDocumentValueList() or []
web_section_default_document = web_section.getDefaultDocumentValue() or None
web_section_default_document_content = ''
section_entry = '''<h%(digit)s class="ci-web-page-book-toc-group">%(title)s</h%(digit)s><ul>'''
group_entry = '''<li class="ci-web-page-book-toc-element"><a href="#%(reference)s">%(title)s</a></li>'''
section_close = '''</ul>'''
content_title_entry = '''<h%(digit)s class="ci-web-page-book-content-title">%(title)s</h%(digit)s><a id="%(reference)s">&para;</a>'''
if web_section_default_document is not None:
web_section_default_document_content = web_section_default_document.getTextContent()
if len(web_section_document_list) > 0:
book_toc = []
book_content = []
# First grouping order is by web_section keywords
web_section_keyword_list = web_section.getSubjectList() or ["ungrouped"]
if len(web_section_keyword_list) > 0:
web_section_keyword_dict = {
"rule": [],
"recommendation": [],
"crime": [],
"ungrouped": []
}
for web_section_keyword in web_section_keyword_list:
web_section_keyword_dict[web_section_keyword] = web_section_keyword_dict.get(web_section_keyword, [])
# get keywords of all pages
for page in web_section_document_list:
page_subject_list = page.getSubjectList() or []
if len(page_subject_list) > 0:
# find out which section keyword a page belongs to
page_subject_in_section_subject = None
for subject in page_subject_list:
if subject in web_section_keyword_list:
page_subject_in_section_subject = subject
page_subject_in_section_subject = page_subject_in_section_subject or "ungrouped"
page_dict = {}
page_dict["title"] = html_quote(page.getTitle())
page_dict["short_title"] = html_quote(page.getShortTitle())
page_dict["description"] = html_quote(page.getDescription())
page_dict["subject_list"] = page_subject_list
page_dict["reference"] = html_quote(page.getReference())
page_dict["text_content"] = page.getTextContent()
# now add all keywords and the page to this group
web_section_keyword_dict[page_subject_in_section_subject].append(page_dict)
# group_count
group_count = 0
for group in web_section_keyword_dict:
group_count += 1
for group in web_section_keyword_dict:
has_entry = None
group_page_list = web_section_keyword_dict[group]
group_keyword_list = []
if len(group_page_list) > 0:
if group == "ungrouped" and group_count == 1:
group_header_init = 0
else:
group_header_init = 1
if group == "ungrouped":
group_title = "additional rules"
else:
group_title = group
# initialize group header
book_toc.append(section_entry % {
"digit": group_header_init,
"title": group_title.title()
})
has_entry = True
# build list of keywords per page
for page in group_page_list:
for keyword in page.get("subject_list"):
if (keyword not in web_section_keyword_list):
if (keyword not in group_keyword_list):
group_keyword_list.append(keyword)
# add entries
group_keyword_list.sort()
for keyword in group_keyword_list:
group_title_dict = {
"digit": group_header_init + 1,
"reference": "reference-" + keyword.replace(" ", "_"),
"title": keyword.title()
}
book_toc.append(group_entry % group_title_dict)
book_content.append(content_title_entry % group_title_dict)
# XXX cumbersome - add all pages listed on this keyword
for page in group_page_list:
if keyword in page.get("subject_list"):
book_content.append(page.get("text_content"))
if has_entry is not None:
book_toc.append(section_close)
return web_section_default_document_content + ''.join(book_toc) + ''.join(book_content)
return web_section_default_document_content
#===============================================================================
# ======================================================================
# def pushDown(level):
# return ''.join(["h", str(level), ">"])
#
# def downgradeHeader(my_content, my_downgrade):
# if my_downgrade is None:
# my_downgrade = 1
#
# header_list = re.findall("<h[1-6].*</h[1-6]>", my_content or "")
# for header in header_list:
# header_tag = re.findall("<(h[1-6]>)", header)[0] #h2>
# header_key = header_tag[1]
# new_header = header.replace(header_tag, pushDown(int(header_key) + my_downgrade))
# my_content = my_content.replace(header, new_header)
#
# return my_content or ""
#
# web_section = document.getWebSectionValue()
# web_section_document_list = web_section.getDocumentValueList() or []
# page_keyword_ignore_list = ["rule", "crime", "recommendation"]
#
# book_anchor = '''<a name="reference-main-anchor"></a><br/><br/>'''
# section_placeholder = '''<span class="ci-web-page-book-toc-group"></span>'''
# section_start = '''<hr/><ul>'''
# section_entry = '''
# <h%(digit)s class="ci-web-page-book-toc-group">
# <a href="#%(reference)s">%(title)s</a>
# </h%(digit)s>'''
# section_pointer = '''
# <a name="%(reference)s"></a>
# <h%(digit)s class="ci-web-page-book-content-group">%(title)s</h%(digit)s>
# <span>
# [<a href="%(local_url)s#%(reference)s">&para;</a>]
# [<a href="%(local_url)s#reference-main-anchor">top</a>]
# </span>'''
# section_end = '''</ul><hr/>'''
# keyword_entry = '''
# <li class="ci-web-page-book-keyword-toc-element">
# <a href="%(url)s">%(title)s</a>&nbsp;
# [<a href="#%(reference)s">
# <span style="font-size:10px;">goto</span>
# </a>]&nbsp;-&nbsp;%(description)s
# </li>'''
# group_anchor = ''
# group_entry = '''
# <li class="ci-web-page-book-toc-element">
# <a href="#%(reference)s">%(title)s</a>&nbsp;(%(count)s)
# </li>'''
#
# content_title_entry = '''
# <a name="%(reference)s"></a>
# <h%(digit)s class="ci-web-page-book-content-title">%(title)s</h%(digit)s>
# <span>
# [<a href="%(local_url)s#%(reference)s">&para;</a>]
# [<a href="%(local_url)s#%(group_anchor)s">section</a>]
# </span>
# '''
#
# if len(web_section_document_list) > 0:
# book_toc = []
# book_content = []
# web_section_url = document.absolute_url()
#
# # group by websection keywords if specified
# web_section_keyword_list = web_section.getSubjectList() or []
# web_section_keyword_dict = {"ungrouped": []}
# #web_section_keyword_dict = {
# # "rule": [],
# # "crime": [],
# # "recommendation": []
# #}
# for web_section_keyword in web_section_keyword_list:
# web_section_keyword_dict[web_section_keyword] = web_section_keyword_dict.get(web_section_keyword, [])
#
# # add predicate pages by their keyword to web section keyword dict
# for page in web_section_document_list:
# page_subject_list = page.getSubjectList() or []
# #page_matched_to_websection_keyword = None
# page_dict = {}
# page_dict["title"] = html_quote(page.getTitle())
# page_dict["short_title"] = html_quote(page.getShortTitle())
# page_dict["description"] = html_quote(page.getDescription())
# page_dict["subject_list"] = page_subject_list
# page_dict["reference"] = html_quote(page.getReference())
# page_dict["text_content"] = page.getTextContent()
#
# if len(web_section_keyword_list) == 0:
# web_section_keyword_dict["ungrouped"].append(page_dict)
# else:
# if len(page_subject_list) > 0:
# for subject in page_subject_list:
# if web_section_keyword_dict.get(subject) is not None:
# #page_matched_to_websection_keyword = True
# web_section_keyword_dict[subject].append(page_dict)
#
# # no keywords set on page or keyword not matching websection keyword
# #if len(page_subject_list) == 0 or page_matched_to_websection_keyword is None:
# # web_section_keyword_dict["ungrouped"].append(page_dict)
#
#
# # all pages allocated to web section keywords, now split by page keyword
# # override for JP and split into rule recommendation and crime
# for group in web_section_keyword_dict:
# group_page_list = web_section_keyword_dict.get(group)
# group_has_header = None
# group_keyword_list = []
#
# if len(group_page_list) > 0:
#
# # web section keywords are first grouping order
# if len(web_section_keyword_list) > 0:
# if group == "ungrouped":
# group_title = "additional rules"
# else:
# group_title = group
# group_anchor = "anchor-" + group_title.replace(" ", "_")
# section_config = {
# "digit": 2,
# "title": group_title.title(),
# "reference": group_anchor,
# "local_url": web_section_url
# }
# book_toc.append(section_entry % section_config)
# book_content.append(section_pointer % section_config)
# group_has_header = True
# else:
# book_toc.append(section_placeholder)
#
# book_toc.append(section_start)
#
# # build list of keywords per group, exclude web section keywords
# for page_dict in group_page_list:
# for keyword in page_dict.get("subject_list"):
# if keyword not in web_section_keyword_list:
# if keyword not in page_keyword_ignore_list:
# if (keyword not in group_keyword_list):
# group_keyword_list.append(keyword)
#
# group_keyword_list.sort()
# for keyword in group_keyword_list:
# book_keyword_toc = []
# book_keyword_content = []
# keyword_page_count = 0
#
# group_title_dict = {
# "digit": 3 if group_has_header else 2,
# "reference": group_anchor + "_" + keyword.replace(" ", "_"),
# "title": keyword.title(),
# "local_url": web_section_url,
# "count": "",
# "group_anchor": group_anchor
# }
# book_keyword_toc.append(content_title_entry % group_title_dict)
# book_keyword_toc.append("<hr/><ul>")
#
# # XXX improve - match pages in the web section keyword to the page group keyword
# for page in group_page_list:
# page_reference = page.get("reference")
# page_anchor = group_anchor + "-" + page_reference.replace(" ", "_")
# page_url = "../" + page_reference
#
# if keyword in page.get("subject_list"):
# keyword_page_count += 1
# book_keyword_toc.append(keyword_entry % {
# "reference": "reference-" + page_anchor,
# "title": page.get("short_title"),
# "description": page.get("description"),
# "url": page_url
# })
# book_keyword_content.append(
# '<a name="reference-' + page_anchor + '"></a>' +
# downgradeHeader(page.get("text_content"), 3 if group_has_header else 2)
# )
# group_title_dict["count"] = keyword_page_count
# book_toc.append(group_entry % group_title_dict)
# book_keyword_toc.append("</ul><hr/>")
# book_content.append(''.join(book_keyword_toc) + ''.join(book_keyword_content))
# book_toc.append(section_end)
#
# document_content = document_content.replace(
# '${predicate_view_as_book}',
# book_anchor + ''.join(book_toc) + '<br/><br/>' + ''.join(book_content)
# )
#===============================================================================
#def generateBookByKeyword(complete_keyword_dict):
# keyword_list = complete_keyword_dict.keys()
# keyword_list.sort()
#
# return_value_list = []
# for keyword in keyword_list:
# return_value_list.append(list_start % (keyword.title()))
# for page in complete_keyword_dict[keyword]:
# return_value_list.append(
# list_item_template % (
# html_quote(page.getReference()),
# html_quote(page.getTitle()),
# html_quote(page.getShortTitle() or page.getTitle()),
# html_quote(page.getDescription())
# )
# )
# return_value_list.append(list_end)
#
# return ''.join(return_value_list)
#
#web_section = context
#web_section_document_list = web_section.getDocumentValueList() or []
#web_section_default_document = web_section.getDefaultDocumentValue() or None
#web_section_default_document_content = ''
#
#section_start = '''<h1 class="ci-web-page-content-section">%s</h1>'''
#list_start = '''<h2 class="ci-web-page-content-book">%s</h2><ul class="ci-web-page-content-book-list">'''
#list_item_template = '''<li><a href="%s" title="%s">%s</a>&nbsp;-&nbsp;%s</li>'''
#list_end = '</ul>'
#
#if web_section_default_document is not None:
# web_section_default_document_content = web_section_default_document.getTextContent()
#
#if len(web_section_document_list) > 0:
# book_content = []
#
# # First grouping order is by web_section keywords
# web_section_keyword_list = web_section.getSubjectList() or []
# if len(web_section_keyword_list) > 0:
# web_section_keyword_dict = {
# "rule": [],
# "recommendation": [],
# "crime": []
# }
# for web_section_keyword in web_section_keyword_list:
# web_section_keyword_dict[web_section_keyword] = web_section_keyword_dict.get(web_section_keyword, [])
#
# for page in web_section_document_list:
# page_subject_list = page.getSubjectList() or []
# if len(page_subject_list) > 0:
#
# # find correct section keyword to add page to
# for subject in page_subject_list:
# if subject in web_section_keyword_list:
# web_section_keyword_dict[subject].append(page)
#
# for group in web_section_keyword_dict:
# group_page_list = web_section_keyword_dict[group]
# if len(group_page_list) > 0:
# keyword_dict = {}
# for page in group_page_list:
# page_subject_list = page.getSubjectList() or []
# if len(page_subject_list) > 0:
# for subject in page_subject_list:
# key = subject
# if key not in web_section_keyword_list:
# page_list = keyword_dict[key] = keyword_dict.get(key, [])
# page_list.append(page)
# book_content.append(section_start % (group.title()))
# book_content.append(generateBookByKeyword(keyword_dict))
#
# book_content = ''.join(book_content)
#
# return web_section_default_document_content + book_content
#
# keyword_dict = {}
# for page in web_section_document_list:
# page_subject_list = page.getSubjectList() or []
#
# if len(page_subject_list):
# for subject in page_subject_list:
# key = subject
# # get or initialize a list for pages of this keyword
# page_list = keyword_dict[key] = keyword_dict.get(key, [])
# page_list.append(page)
#
# book_content = generateBookByKeyword(keyword_dict)
#
# return web_section_default_document_content + book_content
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_generateWebSectionBook</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
'''=============================================================================
Create WebSection based Navigation
============================================================================='''
from Products.PythonScripts.standard import html_quote
def buildItem(item, drill_down_depth):
return menu_item_template % (
#html_quote(item.getRelativeUrl()),
html_quote(item.getId()),
html_quote(item.getTitle()),
buildWebSectionMenu(getChildWebSectionList(item), drill_down_depth)
)
def getChildWebSectionList(element):
breadcrumb_list = element.getBreadcrumbItemList()
current_section = breadcrumb_list[-1]
return current_section[1].contentValues(portal_type='Web Section')
def buildWebSectionMenu(element_list, depth):
if depth < max_depth:
depth = depth + 1
display_list = []
display_items = ''
display_count = 0
for section in element_list:
is_accessible = section.getProperty('authorization_forced') is not True
is_visible = section.getProperty('visible') is 1
has_index = section.getProperty('int_index') is not None
if is_accessible and is_visible and has_index:
display_list.append(section)
if len(display_list):
display_list.sort(key=lambda x: x.getProperty('int_index'), reverse=False)
for menu_item in display_list:
if max_items is not None:
if display_count < max_items:
display_count = display_count + 1
display_items = display_items + buildItem(menu_item, depth)
else:
display_items = display_items + buildItem(menu_item, depth)
return menu_list_template % display_items
else:
return ''
else:
return ''
parent = context
parent_section_list = getChildWebSectionList(parent)
menu_list_template = '''<ul class="ci-web-sitemap-list">%s</ul>'''
menu_item_template = '''<li><a href="./%s"><span class="ci-web-sitemap-item-title">%s</span></a>%s</li>'''
depth = 0
max_depth = max_depth or 2
return buildWebSectionMenu(parent_section_list, depth)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>max_depth=None, max_items=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_generateWebSectionNavigation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
'''=============================================================================
List of CSS Files to load
============================================================================='''
if scope is not None:
if scope == "global":
return (
'roboto/roboto.css',
'roboto-condensed/roboto-condensed.css',
'heuristica/heuristica.css',
'ci_web_css/normalize.css',
'ci_web_css/ci_web.css',
)
return ()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>scope=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_getCssRelativeUrlList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
================================================================================
Return extendable default list of JavaScript files to load
================================================================================
"""
if scope is not None:
if scope == "global":
return [
"ci_web_js/ci_web.js"
]
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>scope=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_getJavaScriptRelativeUrlList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if parameter is not None and proxy is not None:
proxyHandler = getattr(context, 'Base_getProxyThemeBasedProperty', None)
prefixHandler = getattr(context, 'Base_getBasicThemeBasedProperty', None)
if proxyHandler is not None and proxy == True:
return proxyHandler(
parameter=parameter,
source_uid=source_uid,
is_site=True
)
if prefixHandler is not None and proxy == False:
return prefixHandler(
parameter=parameter
)
return "XXX could not retrieve %s" % (parameter or " undefined parameter")
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>parameter=None, proxy=None, source_uid=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_getThemeBasedProperty</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment