Skip to content

Commit

Permalink
Merge 1714819 into 50a4ea1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Stippel committed Oct 16, 2018
2 parents 50a4ea1 + 1714819 commit f2e340c
Show file tree
Hide file tree
Showing 16 changed files with 373 additions and 65 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Expand Up @@ -5,9 +5,16 @@ Changelog
1.0.0a1 (unreleased)
------------------

Added:

- Initial release.
[santonelli]

Changed:

- Improved sidebar styling and introduced a site-cover.
[jstippel]


Version (Date)
------------------
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Expand Up @@ -27,6 +27,7 @@ environment-vars =
eggs =
Plone
Pillow
Products.CMFPlone
collective.sidebar [test]


Expand Down
19 changes: 12 additions & 7 deletions src/collective/sidebar/browser/configure.zcml
Expand Up @@ -4,27 +4,32 @@
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="collective.sidebar">

<!-- Set overrides folder for Just-a-Bunch-Of-Templates product -->
<include package="z3c.jbot" file="meta.zcml" />

<browser:jbot
directory="overrides"
layer="collective.sidebar.interfaces.ICollectiveSidebarLayer"
/>

<!-- Publish static files -->
<plone:static
name="collective.sidebar"
type="plone"
<browser:resourceDirectory
directory="static"
name="collective.sidebar"
/>

<!-- Viewlets -->
<browser:viewlet
name="sidebar"
manager="plone.app.layout.viewlets.interfaces.IPortalTop"
manager="plone.app.layout.viewlets.interfaces.IMainNavigation"
layer="collective.sidebar.interfaces.ICollectiveSidebarLayer"
class=".sidebar.SidebarViewlet"
permission="zope2.View"
/>

<browser:viewlet
name="cover"
manager="plone.app.layout.viewlets.interfaces.IPortalTop"
layer="collective.sidebar.interfaces.ICollectiveSidebarLayer"
class=".sidebar.CoverViewlet"
permission="zope2.View"
/>

</configure>
@@ -0,0 +1,132 @@
<metal:page define-macro="master">

<tal:doctype tal:replace="structure string:&lt;!DOCTYPE html&gt;" />

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
tal:define="portal_state context/@@plone_portal_state;
context_state context/@@plone_context_state;
plone_view context/@@plone;
plone_layout context/@@plone_layout;
lang portal_state/language;
view nocall:view | nocall: plone_view;
dummy python: plone_layout.mark_view(view);
portal_url portal_state/portal_url;
checkPermission nocall: context/portal_membership/checkPermission;
site_properties context/portal_properties/site_properties;
ajax_include_head request/ajax_include_head | nothing;
ajax_load python:False;"
i18n:domain="plone"
tal:attributes="lang lang;">

<metal:cache tal:replace="structure provider:plone.httpheaders" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<div tal:replace="structure provider:plone.htmlhead" />
<metal:topslot define-slot="top_slot" />
<metal:headslot define-slot="head_slot" />
<metal:styleslot define-slot="style_slot" />
<div tal:replace="structure provider:plone.scripts" />
<metal:javascriptslot define-slot="javascript_head_slot" />
<link tal:replace="structure provider:plone.htmlhead.links" />
<meta name="generator" content="Plone - http://plone.com" />
</head>

<body tal:define="isRTL portal_state/is_rtl;
sl python:plone_layout.have_portlets('plone.leftcolumn', view);
sr python:plone_layout.have_portlets('plone.rightcolumn', view);
body_class python:plone_layout.bodyClass(template, view);
sidebar_locked python:view.request.cookies.get('sidebar-locked', '')"
data-with-sidebar="${python:'true' if sidebar_locked else ''}"
tal:attributes="class body_class;
dir python:isRTL and 'rtl' or 'ltr';
python:plone_view.patterns_settings()"
id="visual-portal-wrapper">

<tal:comment tal:replace="nothing">
<!-- This is removed to disable the default Plone toolbar -->
<div tal:replace="structure provider:plone.toolbar" />
</tal:comment>

<header id="portal-top" i18n:domain="plone">
<div tal:replace="structure provider:plone.portaltop" />
</header>

<div id="portal-mainnavigation" tal:content="structure provider:plone.mainnavigation"></div>

<aside id="global_statusmessage">
<tal:message tal:content="structure provider:plone.globalstatusmessage" />
<div metal:define-slot="global_statusmessage"></div>
</aside>

<div id="viewlet-above-content" tal:content="structure provider:plone.abovecontent" />

<article id="portal-column-content">

<metal:block define-slot="content">
<div metal:define-macro="content">
<metal:slot define-slot="body">

<article id="content">
<metal:bodytext define-slot="main">

<header>

<div id="viewlet-above-content-title" tal:content="structure provider:plone.abovecontenttitle" />

<metal:title define-slot="content-title">
<h1 class="documentFirstHeading" tal:define="title context/Title" tal:condition="title" tal:content="title"></h1>
</metal:title>

<div id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle" />

<metal:description define-slot="content-description">
<div class="documentDescription description" tal:define="description context/Description" tal:content="description" tal:condition="description">
</div>
</metal:description>

</header>

<div id="viewlet-above-content-body" tal:content="structure provider:plone.abovecontentbody" />

<div id="content-core">
<metal:text define-slot="content-core" tal:content="nothing"></metal:text>
</div>

<div id="viewlet-below-content-body" tal:content="structure provider:plone.belowcontentbody" />

</metal:bodytext>
</article>

</metal:slot>
</div>
</metal:block>

<div id="viewlet-below-content" tal:content="structure provider:plone.belowcontent" />

</article>

<aside id="portal-column-one" metal:define-slot="column_one_slot" tal:condition="sl">
<metal:portlets define-slot="portlets_one_slot">
<tal:block replace="structure provider:plone.leftcolumn" />
</metal:portlets>
</aside>

<aside id="portal-column-two" metal:define-slot="column_two_slot" tal:condition="sr">
<metal:portlets define-slot="portlets_two_slot">
<tal:block replace="structure provider:plone.rightcolumn" />
</metal:portlets>
</aside>

<footer id="portal-footer-wrapper" i18n:domain="plone">
<div tal:replace="structure provider:plone.portalfooter" />
</footer>

</body>

</html>

</metal:page>
@@ -0,0 +1,42 @@
<tal:sections xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
tal:define="portal_tabs view/portal_tabs"
tal:condition="portal_tabs"
i18n:domain="plone">

<p class="hiddenStructure" i18n:translate="heading_sections">Navigation</p>

<nav class="plone-navbar" id="portal-globalnav-wrapper">
<div class="container">

<div class="plone-navbar-header">
<button type="button" class="plone-navbar-toggle" data-toggle="collapse" data-target="#portal-globalnav-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>

<div class="plone-collapse plone-navbar-collapse" id="portal-globalnav-collapse">
<ul class="plone-nav plone-navbar-nav" id="portal-globalnav" tal:define="selected_tab python:view.selected_portal_tab">
<li>
<div id="portal-navigation-handle">
<i class="menu-item-icon glyphicon glyphicon-menu-hamburger" />
</div>
</li>
<tal:tabs tal:repeat="tab portal_tabs">
<li tal:define="tid tab/id" tal:attributes="id string:portaltab-${tid}; class python:selected_tab==tid and 'selected' or nothing">
<a href="" tal:content="tab/name" tal:attributes="href tab/url; title tab/description|nothing; target tab/link_target|nothing;">
Tab Name
</a>
</li>
</tal:tabs>
</ul>
</div>

</div>
</nav>

</tal:sections>
62 changes: 47 additions & 15 deletions src/collective/sidebar/browser/sidebar.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

from collective.sidebar.utils import crop
from collective.sidebar.utils import get_translated
from collective.sidebar.utils import get_user
Expand All @@ -13,18 +14,33 @@ class SidebarViewlet(ViewletBase):
index = ViewPageTemplateFile('templates/sidebar.pt')

def is_anonymous(self):
"""
Check if the user is anonymous.
"""
return api.user.is_anonymous()

def get_portal_url(self):
"""
Return the portal URL.
"""
return api.portal.get().absolute_url()

def get_user_profile_url(self):
return api.portal.get().absolute_url() + get_user()[2]
"""
Return URL for the user profile.
"""
portal_url = self.get_portal_url()
portal_user = get_user()[2]
return portal_url + portal_user

def get_search_path(self, query=False):
"""
Return a search URL using the SearchableText attribute.
"""
portal_url = self.get_portal_url()
if query:
return api.portal.get().absolute_url() + '/@@search?SearchableText=' # noqa :501
return api.portal.get().absolute_url() + '/@@search'
return '{0}/@@search?SearchableText='.format(portal_url)
return '{0}/@@search'.format(portal_url)

def get_navigation_root_url(self):
"""
Expand All @@ -34,6 +50,9 @@ def get_navigation_root_url(self):
return navigation_root.absolute_url()

def get_language(self):
"""
Return the current language.
"""
return api.portal.get_current_language()

def get_back(self):
Expand All @@ -45,21 +64,29 @@ def get_back(self):
return None
if self.context.portal_type == 'LRF':
return None
if hasattr(parent, 'default_page'):
try:
if parent.default_page == self.context.id:
if parent == api.portal.get_navigation_root(self.context):
return None
else:
return parent.aq_parent.absolute_url()
except AttributeError:
pass
return parent.absolute_url()

def can_edit(self):
"""
Check if the user can modify content.
"""
permission = 'cmf.ModifyPortalContent'
if api.user.has_permission(permission, obj=self.context):
return True
return False

def can_manage_portal(self):
"""
Check is user can manage the portal.
"""
permission = 'cmf.ManagePortal'
if api.user.has_permission(permission, obj=self.context):
return True
Expand All @@ -72,9 +99,11 @@ def check_item(self, item):
context = self.context
if item.exclude_from_nav:
return False
if hasattr(context, 'default_page'):
try:
if context.default_page == item.id:
return False
except AttributeError:
pass
return True

def get_items(self, root=False):
Expand Down Expand Up @@ -112,14 +141,8 @@ def get_addable_types(self):
parent = context.aq_parent
context_url = context.absolute_url()
parent_url = parent.absolute_url()
title_filter = [
'Collection',
'News Folder',
'Frontpage',
'Sponsors',
'Tracks',
'Events',
]
# Filter for Content-Types
title_filter = []
factories = api.content.get_view(
'plone.contentmenu.factories',
self.context,
Expand All @@ -133,9 +156,11 @@ def get_addable_types(self):
pass
else:
url = context_url
if hasattr(parent, 'default_page'):
try:
if parent.default_page == context.id:
url = parent_url
except AttributeError:
pass
url = '{0}/++add++{1}'.format(url, title)
data.append({'title': get_translated(title, self), 'url': url})
return data
Expand All @@ -148,10 +173,17 @@ def get_folder_contents_url(self):
parent = context.aq_parent
context_url = context.absolute_url() + '/folder_contents'
parent_url = parent.absolute_url() + '/folder_contents'
if hasattr(parent, 'default_page'):
try:
if parent.default_page == context.id:
return parent_url
except AttributeError:
pass
if IFolderish.providedBy(context):
return context_url
else:
return parent_url


class CoverViewlet(SidebarViewlet):

index = ViewPageTemplateFile('templates/cover.pt')

0 comments on commit f2e340c

Please sign in to comment.