Permalink
Browse files

Added configuration option to hide addthis button (with upgrade step)…

…. Fixed javascript bug which broke javascripts if content didn't have IBelowContent provider. Added style fix to hide bottom border from addthis buttons.
  • Loading branch information...
1 parent 367ddf0 commit 0c23080591be1e8c441c1e39fb89f2e052c40c49 Jukka Ojaniemi committed Feb 4, 2012
@@ -1,9 +1,13 @@
<!-- AddThis Button BEGIN -->
<tal:block tal:condition="view/available">
-<div class="addthis_toolbox addthis_default_style" id="socialtools" i18n:domain="collective.addthis">
- <a href="#" class="addthis_button_compact" tal:attributes="href view/getAddThisURL" i18n:translate="">Share</a>
- <span class="addthis_separator">|</span>
- <tal:chicklet-block repeat="chicklet view/chicklets">
+<div class="addthis_toolbox addthis_default_style" id="socialtools"
+ i18n:domain="collective.addthis" tal:define="chicklets view/chicklets">
+ <tal:addthis-button tal:condition="view/addthis_button_visible">
+ <a href="#" class="addthis_button_compact"
+ tal:attributes="href view/getAddThisURL" i18n:translate="">Share</a>
+ <span class="addthis_separator">|</span>
+ </tal:addthis-button>
+ <tal:chicklet-block repeat="chicklet chicklets">
<tal:comment replace="nothing">
The closing the a tag below is important. If it is not closed this way,
illegitimate chicklets randomly show up on the page.
@@ -12,6 +16,8 @@
</tal:chicklet-block>
</div>
<!-- AddThis Button END -->
-<script type="text/javascript" tal:content="view/addthis_config_javascript"></script>
-<script type="text/javascript" tal:attributes="src view/javascript_url"></script>
+<script type="text/javascript" tal:content="view/addthis_config_javascript">
+</script>
+<script type="text/javascript" tal:attributes="src view/javascript_url">
+</script>
</tal:block>
@@ -43,6 +43,13 @@ def chicklets(self):
results[chicklet_names.index(chick.value)] = chick
return results
+ @property
+ def addthis_button_visible(self):
+ try:
+ return self._settings.addthis_button_visible
+ except KeyError:
+ return True
+
def getAddThisURL(self):
"""
Returns URL to AddThis service. If that isn't specified we'll return
@@ -76,6 +76,10 @@ class IAddThisSettings(Interface):
"content via links shared with AddThis."),
default=False,)
+ addthis_button_visible = schema.Bool(
+ title=_(u"Show AddThis button before social media items."),
+ default=True,)
+
class ISocialMedia(Interface):
"""A source of listing of social media supported by the addthis service."""
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<object name="portal_css" meta_type="Stylesheets Registry">
- <stylesheet title="" cacheable="True" compression="safe" cookable="True"
+ <stylesheet title="" cacheable="True" compression="full" cookable="True"
enabled="1" expression="" id="++resource++collective.addthis/addthis.css"
- media="screen" rel="stylesheet" rendering="import"/>
+ media="screen" rel="stylesheet" rendering="link"/>
</object>
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<object name="portal_javascripts" meta_type="JavaScripts Registry">
- <javascript authenticated="False" cacheable="True" compression="none"
+ <javascript authenticated="False" cacheable="True" compression="full"
conditionalcomment="" cookable="True" enabled="True" expression=""
id="++resource++collective.addthis/addthis.js" inline="False"
insert-after="++resource++plone.app.jquerytools.form.js" />
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
- <version>1001</version>
+ <version>1002</version>
<dependencies>
<dependency>profile-plone.app.registry:default</dependency>
</dependencies>
@@ -1,3 +1,7 @@
-#socialtools {
+div#socialtools {
float: right;
-}
+}
+
+div#socialtools a:link {
+ border-bottom: none;
+}
@@ -1,3 +1,9 @@
$(document).ready(function() {
- addthis.init();
+ try{
+ addthis.init();
+ }
+ catch(e){
+ console.warn('It seems this page is missing viewlet which provides ' +
+ 'addthis scripts.');
+ }
});
@@ -9,7 +9,6 @@
from zope.component import getMultiAdapter, queryUtility
from zope.interface import directlyProvides
-#from plone.testing.z2 import Browser
from plone.registry.interfaces import IRegistry
from plone.registry import Registry
from Products.CMFCore.utils import getToolByName
@@ -61,7 +60,7 @@ def test_registry_default_values(self):
self.assertEqual(rec[BASE % 'addthis_chicklets'].value, [])
self.assertFalse(rec[BASE % 'addthis_data_track_clickback'].value)
self.assertFalse(rec[BASE % 'addthis_data_track_addressbar'].value)
-
+ self.assertTrue(rec[BASE % 'addthis_button_visible'].value)
class FunctionalTest(unittest.TestCase):
@@ -88,6 +87,5 @@ def test_registry_event_listener(self):
self.assertFalse(addthis.getEnabled())
-
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)
@@ -55,4 +55,15 @@
</gs:upgradeSteps>
+ <gs:upgradeDepends
+ title="Upgrade collective.addthis GS profile from 1001 to 1002."
+ description="Adds new configuration option to hide addthis button."
+ source="1001"
+ destination="1002"
+ profile="collective.addthis:default"
+ import_steps="plone.app.registry"
+ purge="False"
+ run_deps="False"
+ />
+
</configure>
View
@@ -1,6 +1,15 @@
Changelog
=========
+1.3 (2012-02-04)
+----------------
+
+- Added configuration option to hide AddThis button.
+- Fixed bug where addthis broke javascripts when watching content
+ without IBelowContentBody provider.
+- Fixed styles to not display border-bottom for link (from Sunbursts
+ public.css).
+
1.2 (2012-01-31)
----------------
View
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os
-version = '1.2'
+version = '1.3'
setup(name='collective.addthis',
version=version,

0 comments on commit 0c23080

Please sign in to comment.