Пример #1
0
    def __init__(self, context, request):
        super(PluginView, self).__init__(context, request)
        pp = getToolByName(context, 'portal_properties')

        self.context = context
        self.title = context.title
        self.description = context.Description()
        self.request = request
        self.portal_state = getMultiAdapter((self.context, self.request),
                                            name=u'plone_portal_state')
        self.portal = self.portal_state.portal()
        self.site_url = self.portal_state.portal_url()
        self.portal_title = self.portal_state.portal_title()
        self.url = context.absolute_url()
        self.language = facebook_language(get_language(context), self.language)
        self.sheet = getattr(pp, 'sc_social_likes_properties', None)
        self.image = get_content_image(context, width=1200, height=630)
        if self.sheet:
            self.fbaction = self.sheet.getProperty('fbaction', '')
            self.fbapp_id = self.sheet.getProperty('fbapp_id', '')
            self.fbadmins = self.sheet.getProperty('fbadmins', '')
            self.fbshow_like = 'Like' in self.sheet.getProperty(
                'fbbuttons', [])
            self.fbshow_share = 'Share' in self.sheet.getProperty(
                'fbbuttons', [])
            self.button = self.typebutton
Пример #2
0
    def __init__(self, context, request):
        super(PluginView, self).__init__(context, request)
        pp = getToolByName(context, 'portal_properties')

        self.context = context
        self.title = context.title
        self.description = context.Description()
        self.request = request
        self.portal_state = getMultiAdapter((self.context, self.request),
                                            name=u'plone_portal_state')
        self.portal = self.portal_state.portal()
        self.site_url = self.portal_state.portal_url()
        self.portal_title = self.portal_state.portal_title()
        self.url = context.absolute_url()
        self.language = facebook_language(get_language(context), self.language)
        self.sheet = getattr(pp, 'sc_social_likes_properties', None)
        self.image = get_content_image(context, width=1200, height=630)
        if self.sheet:
            self.fbaction = self.sheet.getProperty("fbaction", "")
            self.fbapp_id = self.sheet.getProperty("fbapp_id", "")
            self.fbadmins = self.sheet.getProperty("fbadmins", "")
            self.button = self.typebutton
            if self.fbaction == 'share':
                self.fbclass = 'fb-share-button'
            else:
                self.fbclass = 'fb-like'
Пример #3
0
 def update(self):
     registry = getUtility(IRegistry)
     self.settings = registry.forInterface(ISocialLikeSettings, check=False)
     self.helper = getMultiAdapter((self.context, self.request), name=u'sl_helper')
     self.title = self.context.Title()
     self.description = self.context.Description()
     portal = api.portal.get()
     self.site_name = portal.Title()
     self.language = facebook_language(get_language(self.context), 'en_US')
     self.image = get_content_image(self.context)
Пример #4
0
 def update(self):
     registry = getUtility(IRegistry)
     self.settings = registry.forInterface(ISocialLikeSettings, check=False)
     self.helper = getMultiAdapter((self.context, self.request), name=u'sl_helper')
     self.title = self.context.Title()
     self.description = self.context.Description()
     portal = api.portal.get()
     self.site_name = portal.Title()
     self.language = facebook_language(get_language(self.context), 'en_US')
     self.image = get_content_image(self.context)
 def test_facebook_language(self):
     default = 'en_US'
     self.assertEqual(facebook_language(['pt-br', 'pt'], default), 'pt_BR')
     self.assertEqual(facebook_language(['de'], default), 'de_DE')
     self.assertEqual(facebook_language(['it'], default), 'it_IT')
     self.assertEqual(facebook_language(['fi', 'en'], default), 'fi_FI')
     self.assertEqual(facebook_language(['ga'], default), 'ga_IE')
     self.assertEqual(facebook_language(['ji'], default), default)
     self.assertEqual(facebook_language([], default), default)
Пример #6
0
 def test_facebook_language(self):
     default = 'en_US'
     self.assertEqual(facebook_language(['pt-br', 'pt'], default), 'pt_BR')
     self.assertEqual(facebook_language(['de', ], default), 'de_DE')
     self.assertEqual(facebook_language(['it', ], default), 'it_IT')
     self.assertEqual(facebook_language(['fi', 'en'], default), 'fi_FI')
     self.assertEqual(facebook_language(['ga', ], default), 'ga_IE')
     self.assertEqual(facebook_language(['ji', ], default), default)
     self.assertEqual(facebook_language([], default), default)
Пример #7
0
 def fbjs(self):
     language = facebook_language(get_language(self.context), 'en_US')
     return """
 (function() {{
     var po = document.createElement('script');
     po.async = true;
     po.src = document.location.protocol + '//connect.facebook.net/{0}/all.js#xfbml=1';
     var head = document.getElementsByTagName('head')[0];
     head.appendChild(po);
 }}());
 """.format(language)
Пример #8
0
 def fbjs(self):
     language = facebook_language(get_language(self.context), 'en_US')
     return """
 (function() {{
     var po = document.createElement('script');
     po.async = true;
     po.src = document.location.protocol + '//connect.facebook.net/{0}/all.js#xfbml=1';
     var head = document.getElementsByTagName('head')[0];
     head.appendChild(po);
 }}());
 """.format(language)
Пример #9
0
 def __init__(self, context, request):
     self.context = context
     self.request = request
     # FIXME: the following could rise unexpected exceptions
     #        move it to a new setup() method
     #        see: http://docs.plone.org/develop/plone/views/browserviews.html#creating-a-view
     self.title = context.title
     self.description = context.Description()
     self.portal_state = getMultiAdapter((self.context, self.request),
                                         name=u'plone_portal_state')
     self.portal = self.portal_state.portal()
     self.site_url = self.portal_state.portal_url()
     self.portal_title = self.portal_state.portal_title()
     self.url = context.absolute_url()
     self.language = facebook_language(get_language(context), self.language)
     self.image = get_content_image(context, width=1200, height=630)
     self.typebutton  # XXX: needed to initialize self.width
Пример #10
0
    def __init__(self, context, request):
        super(PluginView, self).__init__(context, request)
        pp = getToolByName(context, 'portal_properties')

        self.context = context
        self.title = context.title
        self.description = context.Description()
        self.request = request
        self.portal_state = getMultiAdapter((self.context, self.request),
                                            name=u'plone_portal_state')
        self.portal = self.portal_state.portal()
        self.site_url = self.portal_state.portal_url()
        self.portal_title = self.portal_state.portal_title()
        self.url = context.absolute_url()
        languages = self.request.get('HTTP_ACCEPT_LANGUAGE',
                                     '').split(';')[0].split(',')
        self.language = facebook_language(languages, self.language)
        self.sheet = getattr(pp, 'sc_social_likes_properties', None)
        self.image = get_content_image(context, width=200, height=200)
        if self.sheet:
            self.fbaction = self.sheet.getProperty("fbaction", "")
            self.fbapp_id = self.sheet.getProperty("fbapp_id", "")
            self.fbadmins = self.sheet.getProperty("fbadmins", "")
            self.button = self.typebutton