Changeset 988 in products for qSEOptimizer/trunk/adapters.py


Ignore:
Timestamp:
Oct 1, 2007 2:52:49 PM (17 years ago)
Author:
crchemist
Message:

Merged with /qSEOptimizer/branches/additional-keywords branch

File:
1 copied

Legend:

Unmodified
Added
Removed
  • qSEOptimizer/trunk/adapters.py

    r987 r988  
     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) 
Note: See TracChangeset for help on using the changeset viewer.