Changeset 1019

Show
Ignore:
Timestamp:
12/05/07 09:24:22
Author:
piv
Message:

version 1.4.0

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qSEOptimizer/trunk/HISTORY.txt

    r1017 r1019  
     11.4.0 
     2 
     3    * added layer for plone 2.5.4 version 
     4     
     5    * refactored additional keywords adapter (now lynx is required) 
     6     
     7    * fixed sorting of keywords in keywords meta tag 
     8 
    191.3.0 
    210 
  • qSEOptimizer/trunk/TODO.txt

    r988 r1019  
    11Future 
    22 
     3  * 3 tests failures (lynx require running of a real host) 
     4 
    35  * Generic Setup integration for skin layers 
  • qSEOptimizer/trunk/adapters.py

    r988 r1019  
     1import re, commands 
    12from zope.interface import implements 
    23from Products.CMFCore.utils import getToolByName 
     
    1314        portal_props = getToolByName(self.context, 'portal_properties') 
    1415        seo_props = getToolByName(portal_props, 'seo_properties') 
    15         original = set(self.context.qSEO_Keywords()) 
    16         additional = set(seo_props.additional_keywords) 
    17         text = set(self.context.SearchableText().split()) 
    18         keywords = list(additional.intersection(text).union(original)) 
     16 
     17        # now set type is not using because of it unordered behaviour 
     18        #original = set(self.context.qSEO_Keywords()) 
     19        #additional = set(seo_props.additional_keywords) 
     20        #text = set(self.context.SearchableText().split()) 
     21        #keywords = list(additional.intersection(text).union(original)) 
     22 
     23        keywords = list(self.context.qSEO_Keywords()) 
     24        lower_keywords = map(lambda x: x.lower(), keywords) 
     25        additional = seo_props.additional_keywords 
     26 
     27        is_test = self.context.REQUEST.get('qseo_without_additional_keywords', None) 
     28 
     29        if additional and is_test is None: 
     30            # extract words from url page using lynx browser 
     31            text = commands.getoutput('lynx --dump --nolist %s?qseo_without_additional_keywords=1' % self.context.absolute_url()).lower() 
     32            if text and text != 'sh: lynx: command not found': 
     33                for keyword in additional: 
     34                    if keyword.lower() not in lower_keywords and re.compile(r'\b%s\b' % keyword, re.I).search(text): 
     35                        keywords.append(keyword) 
     36 
    1937        return ', '.join(keywords) 
  • qSEOptimizer/trunk/browser/keywords.py

    r1016 r1019  
    1818 
    1919        # extract keywords from text 
     20        if not text.strip(): 
     21            return _(u'Keywords list is empty!') 
     22 
    2023        keywords = map(lambda x: x.strip(), text.lower().split('\n')) 
    2124        if not keywords: 
     
    2326 
    2427        # request html page of context object 
    25         url = self.context.absolute_url() 
     28        url = '%s?qseo_without_additional_keywords=1' % self.context.absolute_url() 
    2629        #try: 
    2730            #page = urllib.urlopen(url) 
     
    5861 
    5962        # extract words from url page using lynx browser 
    60         page_text = commands.getoutput('lynx --dump --nolist %s' % url) 
     63        page_text = commands.getoutput('lynx --dump --nolist %s' % url).lower() 
    6164        if page_text and page_text != 'sh: lynx: command not found': 
    6265            #page_words = page_text.lower().split() 
    63             page_text = page_text.lower() 
     66            page_text = page_text 
    6467        else: 
    6568            return _(u'Could not find lynx browser!') 
     
    6972        added = {} 
    7073        for keyword in keywords: 
    71             pattern = re.compile(r'\b%s\b' % keyword, re.I) 
    72             if not (pattern.search(page_text) or keyword in added.keys()): 
     74            if keyword not in added.keys() and not re.compile(r'\b%s\b' % keyword, re.I).search(page_text): 
    7375                missing.append(keyword) 
    7476                added[keyword] = 1 
  • qSEOptimizer/trunk/tests/testQSEOptimizer.py

    r1009 r1019  
    198198 
    199199    def testDescription(self): 
    200         m = re.match('.*<meta content="it is description" name="description" />', self.html, re.S|re.M) 
     200        m = re.match('.*<meta name="description" content="it is description" />', self.html, re.S|re.M) 
    201201        self.assert_(m, 'Description not set in') 
    202202 
    203203    def testKeywords(self): 
    204         m = re.match('.*<meta content="my1|key2" name="keywords" />', self.html, re.S|re.M) 
     204        m = re.match('.*<meta name="keywords" content="my1|key2" />', self.html, re.S|re.M) 
    205205        self.assert_(m, 'Keywords not set in') 
    206206 
    207207    def testRobots(self): 
    208         m = re.match('.*<meta content="ALL" name="robots" />', self.html, re.S|re.M) 
     208        m = re.match('.*<meta name="robots" content="ALL" />', self.html, re.S|re.M) 
    209209        self.assert_(m, 'Robots not set in') 
    210210 
    211211    def testDistribution(self): 
    212         m = re.match('.*<meta content="Global" name="distribution" />', self.html, re.S|re.M) 
     212        m = re.match('.*<meta name="distribution" content="Global" />', self.html, re.S|re.M) 
    213213        self.assert_(m, 'Distribution not set in') 
    214214 
     
    223223    def testCustomMetaTags(self): 
    224224        for tag in custom_metatags: 
    225             m = re.search('<meta content="%(meta_content)s" name="%(meta_name)s" />' % tag, self.html, re.S|re.M) 
     225            m = re.search('<meta name="%(meta_name)s" content="%(meta_content)s" />' % tag, self.html, re.S|re.M) 
    226226            self.assert_(m, "Custom meta tag %s not applied." % tag['meta_name']) 
    227227 
     
    342342        self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 
    343343 
    344         m = re.match('.*<meta content=".*?" name="DC.format" />', self.html, re.S|re.M) and re.match('.*<meta content=".*?" name="DC.distribution" />', self.html, re.S|re.M) 
     344        m = re.match('.*<meta name="DC.format" content=".*?" />', self.html, re.S|re.M) and re.match('.*<meta name="DC.distribution" content=".*?" />', self.html, re.S|re.M) 
    345345 
    346346        self.assert_(m, 'DC meta tags not avaliable when createManager=True') 
  • qSEOptimizer/trunk/version.txt

    r1017 r1019  
    1 1.3.0 
     11.4.0