Changeset 1931 in products
- Timestamp:
- Mar 17, 2010 6:46:02 PM (15 years ago)
- Location:
- quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/browser/viewlets.py
r1909 r1931 206 206 """ Simple viewlet for canonical url link rendering. 207 207 """ 208 209 208 def render( self ): 210 seo _context = getMultiAdapter((self.context, self.request), name='seo_context')211 return """<link rel="canonical" href="%s" />""" % seo _context['seo_canonical']209 seoc = getMultiAdapter((self.context, self.request), name=u'seo_context') 210 return """<link rel="canonical" href="%s" />""" % seoc['seo_canonical'] -
quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/browser/views.py
r1918 r1931 13 13 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile 14 14 from Products.CMFPlone import PloneMessageFactory as pmf 15 16 from quintagroup.canonicalpath.interfaces import ICanonicalLink 17 from quintagroup.canonicalpath.adapters import PROPERTY_LINK as CANONICAL_PROPERTY 15 18 16 19 from quintagroup.seoptimizer import interfaces … … 55 58 "meta_keywords": self.getSEOProperty('qSEO_keywords', 'Subject', ()), 56 59 "seo_keywords": self.getSEOProperty('qSEO_keywords', default=()), 57 "seo_canonical": self.seo_canonical(),60 "seo_canonical": ICanonicalLink(self.context).canonical_link, 58 61 # Add test properties 59 62 "has_seo_title": self.context.hasProperty('qSEO_title'), … … 63 66 "has_html_comment": self.context.hasProperty('qSEO_html_comment'), 64 67 "has_seo_keywords": self.context.hasProperty('qSEO_keywords'), 65 "has_seo_canonical": self.context.hasProperty( 'qSEO_canonical'),68 "has_seo_canonical": self.context.hasProperty(CANONICAL_PROPERTY), 66 69 } 67 70 #seotags["seo_nonEmptylocalMetaTags"] = bool(seotags["seo_localCustomMetaTags"]) … … 135 138 return result 136 139 137 def seo_canonical( self ):138 """ Generate canonical URL from SEO properties.139 """140 canpath = queryAdapter(self.context, interfaces.ISEOCanonicalPath)141 return self.pps.portal_url() + canpath.canonical_path()142 143 140 144 141 class SEOContextPropertiesView( BrowserView ): … … 159 156 return condition and first or second 160 157 161 def getMainDomain(self, url):162 """ Get a main domain.163 """164 url = url.split('//')[-1]165 dompath = url.split(':')[0]166 dom = dompath.split('/')[0]167 return '.'.join(dom.split('.')[-2:])168 169 158 def validateSEOProperty(self, property, value): 170 159 """ Validate a seo property. 171 160 """ 172 purl = getToolByName(self.context, 'portal_url')() 173 state = '' 174 if property == PROP_PREFIX+'canonical': 175 # validate seo canonical url property 176 pdomain = self.getMainDomain(purl) 177 if not pdomain == self.getMainDomain(value): 178 state = _('canonical_msg', default=u'Canonical URL mast be in ${pdomain} domain.', mapping={'pdomain': pdomain}) 179 return state 161 return '' 180 162 181 163 def setProperty(self, property, value, type='string'): … … 208 190 if seo_key == 'custommetatags': 209 191 self.manageSEOCustomMetaTagsProperties(**kw) 192 elif seo_key == 'canonical': 193 canonical = seo_items[seo_key] 194 try: 195 ICanonicalLink(self.context).canonical_link = canonical 196 except InvalidValue, e: 197 return str(e) 210 198 else: 211 199 if seo_key in seo_overrides_keys and seo_items.get(seo_key+SUFFIX):
Note: See TracChangeset
for help on using the changeset viewer.