Changeset 1052 in products


Ignore:
Timestamp:
May 19, 2009 9:43:04 AM (12 years ago)
Author:
piv
Message:

fix page title in case it equals portal title, add appropriate test, update documentation, ready for tagging

Location:
quintagroup.seoptimizer/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/docs/HISTORY.txt

    r962 r1052  
    33 
    44 
    5 2.0.6 (unreleased) 
     52.0.6 (2009-05-19) 
    66------------------ 
    77 
    8 - Nothing changed yet. 
     8- Fix page title tag, now it is not duplicated in case 
     9  site and current page have equal titles 
     10  [piv] 
    911 
    1012 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/viewlets.py

    r957 r1052  
     1from cgi import escape 
    12from zope.component import getMultiAdapter 
    23from zope.viewlet.interfaces import IViewlet 
     
    2122        self.override_comments = self.context.hasProperty('qSEO_html_comment') 
    2223 
     24    def std_title(self): 
     25        portal_title = safe_unicode(self.portal_title()) 
     26        page_title = safe_unicode(self.page_title()) 
     27        if page_title == portal_title: 
     28            return u"<title>%s</title>" % (escape(portal_title)) 
     29        else: 
     30            return u"<title>%s &mdash; %s</title>" % ( 
     31                escape(safe_unicode(page_title)), 
     32                escape(safe_unicode(portal_title))) 
     33 
    2334    def render(self): 
    24         std_title = u"<title>%s &mdash; %s</title>" % ( safe_unicode(self.page_title()), 
    25                                                         safe_unicode(self.portal_title()) 
    26                                                       ) 
     35        std_title = self.std_title() 
    2736        seo_context = getMultiAdapter((self.context, self.request), name='seo_context') 
    2837        if not self.override_title: 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testQSEOptimizer.py

    r959 r1052  
    185185        self.html = self.publish(abs_path, self.basic_auth).getBody() 
    186186 
     187        # now setup page with title equal to plone site's title 
     188        my_doc2 = self.portal.invokeFactory('Document', id='my_doc2') 
     189        my_doc2 = self.portal['my_doc2'] 
     190        my_doc2.update(title=self.portal.Title()) 
     191        wf_tool.doActionFor(my_doc2, 'publish') 
     192        abs_path2 = "/%s" % my_doc2.absolute_url(1) 
     193        self.html2 = self.publish(abs_path2, self.basic_auth).getBody() 
     194 
    187195    def testTitle(self): 
    188196        m = re.match('.*<title>\\s*hello world\\s*</title>', self.html, re.S|re.M) 
    189197        self.assert_(m, 'Title not set in') 
     198 
     199    def testTitleDuplication(self): 
     200        """If we are not overriding page title and current page title equals title of the plone site 
     201        then there should be no concatenation of both titles. Only one should be displayed. 
     202        """ 
     203        m = re.match('.*<title>\\s*%s\\s*</title>' % self.portal.Title(), self.html2, re.S|re.M) 
     204        self.assert_(m, 'Title is not set correctly, perhaps it is duplicated with plone site title') 
    190205 
    191206    def testDescription(self): 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/version.txt

    r962 r1052  
    1 2.0.6 dev 
     12.0.6 
Note: See TracChangeset for help on using the changeset viewer.