Example #1
0
    def get_logo(self):
        BLANK_IMAGE = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='

        if self.secure_login_view.scrub_backend():
            return BLANK_IMAGE
        else:
            return getSiteLogo()
Example #2
0
def get_site_logo(site=None):
    """Return the custom logo or Plone's default."""
    if not PLONE_4:
        try:
            from Products.CMFPlone.utils import getSiteLogo
        except ImportError:
            return None
        else:
            return getSiteLogo(site=site)

    from spirit.plone.theming.interfaces import IPloneThemeSettings
    from plone.formwidget.namedfile.converter import b64decode_file

    if site is None:
        site = api.portal.get()

    registry = getUtility(IRegistry)
    settings = registry.forInterface(IPloneThemeSettings, check=False)  # noqa
    site_url = site.absolute_url()

    if getattr(settings, 'site_logo', False):
        filename, data = b64decode_file(settings.site_logo)
        return '{0}/@@site-logo-plone4/{1}'.format(site_url, filename)
    else:
        return '{0}/logo.png'.format(site_url)
    def test_getSiteLogo_with_setting(self):
        from Products.CMFPlone.utils import getSiteLogo
        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISiteSchema, prefix='plone')
        settings.site_logo = SITE_LOGO_BASE64

        self.assertTrue(
            'http://nohost/plone/@@site-logo/pixel.png' in getSiteLogo())
Example #4
0
 def update(self):
     super(PortalHeader, self).update()
     if api.portal.get_registry_record('plone.site_logo'):
         self.logo_url = utils.getSiteLogo()
     else:
         self.logo_url = '{0}/++plone++plonetheme.tokyo/{1}'.format(
             api.portal.get().absolute_url(), 'plone_logow.svg')
     self.logo_title = api.portal.get_registry_record('plone.site_title')
    def update(self):

        super(LogoViewlet, self).update()
        self.site_title = api.portal.get_registry_record('plone.site_title')

        self.navigation_root_title = self.site_title
        self.logo_title = self.site_title
        self.img_src = getSiteLogo()
Example #6
0
    def update(self):

        super(LogoViewlet, self).update()
        self.site_title = api.portal.get_registry_record('plone.site_title', )

        # TODO: should this be changed to settings.site_title?
        self.navigation_root_title = self.site_title
        self.logo_title = self.site_title
        self.img_src = getSiteLogo()
    def test_getSiteLogo_with_setting(self):
        from Products.CMFPlone.utils import getSiteLogo
        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISiteSchema, prefix='plone')
        settings.site_logo = SITE_LOGO_BASE64

        self.assertTrue(
            'http://nohost/plone/@@site-logo/pixel.png'
            in getSiteLogo())
Example #8
0
    def update(self):
        super(LogoViewlet, self).update()

        site_title = api.portal.get_registry_record('plone.site_title')
        self.logo_title = site_title

        self.logo_src = getSiteLogo()
        self.site_description = api.portal.get_registry_record(
            'plonetheme.persona.site_description')
        self.site_title = site_title
Example #9
0
    def update(self):
        super(LogoViewlet, self).update()

        site_title = api.portal.get_registry_record('plone.site_title')
        self.logo_title = site_title

        self.logo_src = getSiteLogo()
        self.site_description = api.portal.get_registry_record(
            'plonetheme.persona.site_description'
        )
        self.site_title = site_title
Example #10
0
 def update(self):
     super(PortalHeader, self).update()
     registry = getUtility(IRegistry)
     settings = registry.forInterface(
         ISiteSchema,
         prefix='plone',
         check=False,
     )
     self.logo = None
     if getattr(settings, 'site_logo', False):
         self.logo = utils.getSiteLogo()
     self.logo_title = settings.site_title
Example #11
0
    def update(self):
        super(LogoViewlet, self).update()

        # TODO: should this be changed to settings.site_title?
        self.navigation_root_title = self.portal_state.navigation_root_title()

        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISiteSchema,
                                         prefix="plone",
                                         check=False)
        self.logo_title = settings.site_title
        self.img_src = getSiteLogo()
Example #12
0
    def update(self):
        super(LogoViewlet, self).update()

        # TODO: should this be changed to settings.site_title?
        self.navigation_root_title = self.portal_state.navigation_root_title()

        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISiteSchema,
                                         prefix="plone",
                                         check=False)
        self.logo_title = settings.site_title
        self.img_src = getSiteLogo()
Example #13
0
    def default_image(self, image):
        if image is not None:
            portal_state = getMultiAdapter(
                 (self.context, self.request), name=u'plone_portal_state')
            site_root_url = portal_state.navigation_root_url()
            image_url = '%s%s' % (site_root_url, image)
        else:
            image_url = getSiteLogo()

        twitter_tag = {}
        twitter_tag['twitter:image'] = image_url
        og_tag = {}
        og_tag['og:image'] = image_url
        return [twitter_tag, og_tag]
Example #14
0
 def getData(self):
     survey_settings = getUtility(IRegistry).forInterface(ICastleSurvey, check=False)
     survey_data = {
         'url': survey_settings.survey_api_url,
         'id': self.data.get('survey_id'),
         'custom_url': self.data.get('survey_url'),
         'rule': self.data.get('rule', 'always'),
         'cookie': self.data.get('use_cookie', 'show_once'),
         'display': self.data.get('display', 'here'),
         'duration': self.data.get('duration', 20),
         'count': self.data.get('page_count', 5),
         'logo': getSiteLogo()
     }
     return b64encode(json.dumps(survey_data))
Example #15
0
    def __call__(self):
        portal = api.portal.get()
        self.cover = api.content.find(context=portal['index_html'], depth=0)[0]
        self.youtubeList = api.content.find(context=portal['index_html'],
                                            depth=1)
        self.fax = api.portal.get_registry_record('fax', interface=IInform)
        self.address = api.portal.get_registry_record('address',
                                                      interface=IInform)
        self.cellphone = api.portal.get_registry_record('cellphone',
                                                        interface=IInform)
        self.email = api.portal.get_registry_record('email', interface=IInform)
        self.logo = getSiteLogo()

        return self.template()
Example #16
0
 def get_logo(self):
     return getSiteLogo()
Example #17
0
 def logo(self):
     return getSiteLogo(self.site)
Example #18
0
 def logo(self):
     return getSiteLogo(self.site)
Example #19
0
    def _get_tags(self):
        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISocialMediaSchema, prefix="plone",
                                         check=False)

        if not settings.share_social_data:
            return []

        tags = [
            dict(itemprop="name", content=self.page_title),
            dict(name="twitter:card", content="summary"),
            dict(name="twitter:title", content=self.page_title),
            dict(property="og:site_name", content=self.site_title_setting),
            dict(property="og:title", content=self.page_title),
            dict(property="og:type", content="website"),
        ]
        if settings.twitter_username:
            tags.append(dict(name="twitter:site",
                             content="@" + settings.twitter_username))
        if settings.facebook_app_id:
            tags.append(dict(property="fb:app_id",
                             content=settings.facebook_app_id))
        if settings.facebook_username:
            tags.append(
                dict(property="og:article:publisher",
                     content="https://www.facebook.com/" +
                     settings.facebook_username))

        # reuse syndication since that packages the data
        # the way we'd prefer likely
        site = getSite()
        feed = FolderFeed(site)
        item = queryMultiAdapter((self.context, feed), IFeedItem, default=None)
        if item is None:
            item = BaseItem(self.context, feed)

        tags.extend([
            dict(itemprop="description", content=item.description),
            dict(itemprop="url", content=item.link),
            dict(name="twitter:description", content=item.description),
            dict(name="twitter:url", content=item.link),
            dict(property="og:description", content=item.description),
            dict(property="og:url", content=item.link),
        ])

        found_image = False
        if item.has_enclosure and item.file_length > 0:
            if item.file_type.startswith('image'):
                found_image = True
                tags.extend([
                    dict(name="twitter:image", content=item.file_url),
                    dict(property="og:image", content=item.file_url),
                    dict(itemprop="image", content=item.file_url),
                    dict(property="og:image:type", content=item.file_type)
                ])
            elif (item.file_type.startswith('video') or
                    item.file_type == "application/x-shockwave-flash"):
                tags.extend([
                    dict(property="og:video", content=item.file_url),
                    dict(property="og:video:type", content=item.file_type)
                ])
            elif item.file_type.startswith('audio'):
                tags.extend([
                    dict(property="og:audio", content=item.file_url),
                    dict(property="og:audio:type", content=item.file_type)
                ])

        if not found_image:
            url = getSiteLogo()
            tags.extend([
                dict(name="twitter:image", content=url),
                dict(property="og:image", content=url),
                dict(itemprop="image", content=url),
                dict(property="og:image:type", content='image/png')
            ])
        return tags
Example #20
0
 def getSiteLogo(self):
     return getSiteLogo()
Example #21
0
 def img_src(self):
     return getSiteLogo()
Example #22
0
 def update(self):
     context = self.context
     self.logo = getSiteLogo()
Example #23
0
    def update(self):
        super(SocialTagsViewlet, self).update()
        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISocialMediaSchema,
                                         prefix="plone",
                                         check=False)

        if not settings.share_social_data:
            self.tags = []
            return

        self.tags = [
            dict(name="twitter:card", content="summary"),
            dict(name="twitter:title", content=self.page_title),
            dict(property="og:title", content=self.page_title),
            dict(itemprop="name", content=self.page_title),
            dict(property="og:type", content="website"),
            dict(property="og:site_name", content=self.site_title_setting),
        ]
        if settings.twitter_username:
            self.tags.append(
                dict(name="twitter:site",
                     content="@" + settings.twitter_username))
        if settings.facebook_app_id:
            self.tags.append(
                dict(property="fb:app_id", content=settings.facebook_app_id))
        if settings.facebook_username:
            self.tags.append(
                dict(property="og:article:publisher",
                     content="https://www.facebook.com/" +
                     settings.facebook_username))

        # reuse syndication since that packages the data
        # the way we'd prefer likely
        site = getSite()
        feed = FolderFeed(site)
        item = queryMultiAdapter((self.context, feed), IFeedItem, default=None)
        if item is None:
            item = BaseItem(self.context, feed)

        self.tags.extend([
            dict(name="twitter:description", content=item.description),
            dict(property="og:description", content=item.description),
            dict(itemprop="description", content=item.description),
            dict(name="twitter:url", content=item.link),
            dict(property="og:url", content=item.link),
        ])

        found_image = False
        if item.has_enclosure and item.file_length > 0:
            if item.file_type.startswith('image'):
                found_image = True
                self.tags.extend([
                    dict(name="twitter:image", content=item.file_url),
                    dict(property="og:image", content=item.file_url),
                    dict(itemprop="image", content=item.file_url),
                    dict(property="og:image:type", content=item.file_type)
                ])
            elif (item.file_type.startswith('video')
                  or item.file_type == "application/x-shockwave-flash"):
                self.tags.extend([
                    dict(property="og:video", content=item.file_url),
                    dict(property="og:video:type", content=item.file_type)
                ])
            elif item.file_type.startswith('audio'):
                self.tags.extend([
                    dict(property="og:audio", content=item.file_url),
                    dict(property="og:audio:type", content=item.file_type)
                ])

        if not found_image:
            url = getSiteLogo()
            self.tags.extend([
                dict(name="twitter:image", content=url),
                dict(property="og:image", content=url),
                dict(itemprop="image", content=url),
                dict(property="og:image:type", content='image/png')
            ])
Example #24
0
 def update(self):
     super(PortalHeader, self).update()
     self.logo = None
     if api.portal.get_registry_record('plone.site_logo'):
         self.logo = utils.getSiteLogo()
     self.logo_title = api.portal.get_registry_record('plone.site_title')
 def test_getSiteLogo_with_no_setting(self):
     from Products.CMFPlone.utils import getSiteLogo
     self.assertTrue(
         'http://nohost/plone/logo.png'
         in getSiteLogo())
 def test_getSiteLogo_with_no_setting(self):
     from Products.CMFPlone.utils import getSiteLogo
     self.assertTrue('http://nohost/plone/logo.png' in getSiteLogo())
Example #27
0
    def get_data(self):
        registry = getUtility(IRegistry)
        btype = registry.get('castle.business_type', None)
        bname = registry.get('castle.business_name', None)
        utils = Utils(self.context, getRequest())

        if not btype and bname:
            # return subset that uses site name, org type
            registry = getUtility(IRegistry)
            site_settings = registry.forInterface(ISiteSchema,
                                                  prefix="plone",
                                                  check=False)
            return {
                "@context": "http://schema.org",
                "@type": 'Organization',
                "name": site_settings.site_title,
                "url": utils.get_public_url(),
                "logo": {
                    "@type": "ImageObject",
                    "url": getSiteLogo()
                }
            }

        data = {
            "@context": "http://schema.org",
            "@type": btype,
            "name": bname,
            "url": utils.get_public_url(),
            'telephone': registry.get('castle.business_telephone', ''),
            "logo": {
                "@type": "ImageObject",
                "url": getSiteLogo()
            }
        }
        address = registry.get('castle.business_address', None)
        if address:
            data['address'] = {
                '@type': 'PostalAddress',
                'streetAddress': address,
                'addressLocality': registry.get('castle.business_city', ''),
                'addressRegion': registry.get('castle.business_state', ''),
                'postalCode': registry.get('castle.business_postal_code', ''),
                'addressCountry': registry.get('castle.business_country', '')
            }
        coordinates = registry.get('castle.business_coordinates', '')
        if coordinates:
            try:
                coordinates = json.loads(coordinates)
            except Exception:
                coordinates = None
            if coordinates:
                data['geo'] = {
                    '@type': 'GeoCoordinates',
                    'latitude': coordinates.get('lat', ''),
                    'longitude': coordinates.get('lng', '')
                }
        days = registry.get('castle.business_days_of_week', [])
        hours = []
        if days:
            hours.append({
                '@type': "OpeningHoursSpecification",
                'dayOfWeek': days,
                'opens': registry.get('castle.business_opens', ''),
                'closes': registry.get('castle.business_closes', ''),
            })
        for special in registry.get('castle.business_special_hours', []) or []:
            if special.count('|') != 2:
                continue
            day, opens, closes = special.split('|')
            hours.append({
                '@type': "OpeningHoursSpecification",
                'dayOfWeek': day,
                'opens': opens,
                'closes': closes
            })
        if hours:
            data['openingHoursSpecification'] = hours
        menu = registry.get('castle.business_menu_link', None)
        if menu:
            data["menu"] = menu
        if registry.get('castle.business_accepts_reservations', False):
            data["acceptsReservations"] = "True"

        try:
            data.update(json.loads(
                registry.get(
                    'castle.business_additional_configuration', '{}')))
        except Exception:
            pass
        return data