Skip to content

Commit

Permalink
Merge pull request #100 from plone/thet_site_url
Browse files Browse the repository at this point in the history
Use ``getSite()`` instead of portal url
  • Loading branch information
jensens committed Mar 14, 2016
2 parents c9fc53c + 2d36d66 commit a075790
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Incompatibilities:

New:

- *add item here*
- For the theming controlpanel, change base URLs from portal URL to what getSite returns, but don't change the controlpanels context binding.
This allows for more flexibility when configuring it to be allowed on a sub site with a local registry.
[thet]

Fixes:

Expand Down
13 changes: 7 additions & 6 deletions src/plone/app/theming/browser/controlpanel.pt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
view nocall:view | nocall: plone_view;
portal_url portal_state/portal_url;
ajax_load python:False;
dummy python: request.set('disable_toolbar', True);"
dummy python: request.set('disable_toolbar', True);
site_url view/site_url"
tal:attributes="lang lang;">

<metal:cache tal:replace="structure provider:plone.httpheaders" />
Expand Down Expand Up @@ -72,9 +73,9 @@
i18n:translate="heading_theme_settings">Theme settings</h1>

<a id="setup-link" class="link-parent"
tal:attributes="href string:${context/portal_url}/@@overview-controlpanel"
i18n:translate="label_up_to_plone_setup">
Up to Site Setup
tal:attributes="href string:$site_url/@@overview-controlpanel"
i18n:translate="">
Site Setup
</a>
</header>

Expand All @@ -100,12 +101,12 @@
data-pat-plone-modal="width: 80%"
i18n:translate="">Upload Zip file</a>

<a tal:attributes="href string:${context/portal_url}/test_rendering#top"
<a tal:attributes="href string:$site_url/test_rendering#top"
class="plone-btn plone-btn-large plone-btn-primary"
target="_blank"
i18n:translate="">Test Styles</a>

<a tal:attributes="href string:${context/portal_url}/@@theming-controlpanel-help"
<a tal:attributes="href string:$site_url/@@theming-controlpanel-help"
class="plone-btn plone-btn-large plone-btn-primary pat-plone-modal"
data-pat-plone-modal="
width: 85%;
Expand Down
28 changes: 14 additions & 14 deletions src/plone/app/theming/browser/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from plone.resource.utils import queryResourceDirectory
from zope.component import getMultiAdapter
from zope.component import getUtility
from zope.component.hooks import getSite
from zope.publisher.browser import BrowserView
from zope.schema.interfaces import IVocabularyFactory
import logging
Expand All @@ -40,6 +41,13 @@ def authorize(context, request):

class ThemingControlpanel(BrowserView):

@property
def site_url(self):
"""Return the absolute URL to the current site, which is likely not
necessarily the portal root.
"""
return getSite().absolute_url()

def __call__(self):
self.pskin = getToolByName(self.context, 'portal_skins')

Expand Down Expand Up @@ -102,10 +110,7 @@ def update(self):

if 'form.button.Cancel' in form:
IStatusMessage(self.request).add(_(u"Changes cancelled"))

portalUrl = getToolByName(self.context, 'portal_url')()
self.redirect("{0:s}/@@overview-controlpanel".format(portalUrl))

self.redirect("{0}/@@overview-controlpanel".format(self.site_url))
return False

if 'form.button.Enable' in form:
Expand Down Expand Up @@ -310,10 +315,9 @@ def update(self):
self.theme_settings.enabled = True

if not self.errors:
portalUrl = getToolByName(self.context, 'portal_url')()
self.redirect(
"{0}/++theme++{1}/@@theming-controlpanel-mapper".format(
portalUrl,
self.site_url,
themeData.__name__
)
)
Expand Down Expand Up @@ -366,10 +370,9 @@ def update(self):
applyTheme(themeData)
self.theme_settings.enabled = True

portalUrl = getToolByName(self.context, 'portal_url')()
self.redirect(
"{0}/++theme++{1}/@@theming-controlpanel-mapper".format(
portalUrl,
self.site_url,
name
)
)
Expand Down Expand Up @@ -414,9 +417,7 @@ def themeList(self):
themes = []
zodbNames = [t.__name__ for t in self.zodbThemes]

portalUrl = getToolByName(self.context, 'portal_url')()

complete = [];
complete = []
active_theme = None

for theme in self.availableThemes:
Expand Down Expand Up @@ -448,7 +449,7 @@ def themeList(self):
'description': theme.description,
'override': override,
'editable': theme.__name__ in zodbNames,
'preview': "{0}/{1}".format(portalUrl, previewUrl),
'preview': "{0}/{1}".format(self.site_url, previewUrl),
'selected': theme.__name__ == self.selectedTheme,
}
if theme.__name__ == self.selectedTheme:
Expand All @@ -465,10 +466,9 @@ def themeList(self):
return themes

def redirectToFieldset(self, fieldset):
portalUrl = getToolByName(self.context, 'portal_url')()
self.redirect(
"{0}/{1}#fieldsetlegend-{2}".format(
portalUrl,
self.site_url,
self.__name__,
fieldset
)
Expand Down

0 comments on commit a075790

Please sign in to comment.