Changeset 1647 in products


Ignore:
Timestamp:
Feb 4, 2010 5:31:50 PM (10 years ago)
Author:
liebster
Message:

Added Filter keywords by content and tests

Location:
quintagroup.seoptimizer/trunk/quintagroup/seoptimizer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/adapters.py

    r1645 r1647  
    2424        seo_context = queryMultiAdapter((self.context, request), name='seo_context') 
    2525        if seo_context: 
    26             usage_keywords_in_metatags = seo_props.getProperty('usage_keywords_in_metatags', None) 
     26            filter_keywords_by_content = seo_props.getProperty('filter_keywords_by_content', None) 
    2727            meta_keywords = list(seo_context.meta_keywords()) 
    2828            is_test = self.context.REQUEST.get('without_metatag_keywords', None) 
    29             if usage_keywords_in_metatags and meta_keywords and is_test is None: 
     29            if filter_keywords_by_content and meta_keywords and is_test is None: 
    3030                # extract words from url page using lynx browser (test page randered without metatag keywords) 
    3131                text = commands.getoutput('lynx --dump --nolist %s?without_metatag_keywords=1' % self.context.absolute_url()).lower() 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/templates/seo_controlpanel.pt

    r1645 r1647  
    8080          <div class="field"> 
    8181            <input type="checkbox" 
    82                    id="usageKeywordsInMetatags" 
    83                    name="usageKeywordsInMetatags" 
    84                    tal:attributes="checked view/getUsageKeywordsInMetatags"/> 
    85             <label for="usageKeywordsInMetatags" i18n:translate="label_usage_keywords_in_metatags"> 
    86                 Usage of keywords, found on the page, in metatags. 
     82                   id="filterKeywordsByContent" 
     83                   name="filterKeywordsByContent" 
     84                   tal:attributes="checked view/getFilterKeywordsByContent"/> 
     85            <label for="filterKeywordsByContent" i18n:translate="label_filter_keywords_by_content"> 
     86                Filter keywords by content. 
    8787            </label> 
    88             <div class="formHelp" i18n:translate="help_usage_keywords_in_metatags"> 
    89                 Usage of keywords, found on the page, in metatags. 
     88            <div class="formHelp" i18n:translate="help_filter_keywords_by_content"> 
     89                Usage metatags keywords, which present in content. 
    9090              </div> 
    9191          </div> 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/views.py

    r1645 r1647  
    278278        return seo.getProperty('additional_keywords') 
    279279 
    280     def getUsageKeywordsInMetatags( self ): 
    281         """ Get values from usage_keywords_in_metatags property in seo_properties. 
     280    def getFilterKeywordsByContent( self ): 
     281        """ Get values from filter_keywords_by_content property in seo_properties. 
    282282        """ 
    283283        seo = self.portal_properties.seo_properties 
    284         return seo.getProperty('usage_keywords_in_metatags') 
     284        return seo.getProperty('filter_keywords_by_content') 
    285285 
    286286    def createMultiColumnList( self ): 
     
    305305        default_custom_metatags = request.get('default_custom_metatags', []) 
    306306        metatags_order = request.get('metatags_order', []) 
    307         usageKeywordsInMetatags = request.get('usageKeywordsInMetatags', None) 
     307        filterKeywordsByContent = request.get('filterKeywordsByContent', None) 
    308308        settingsUseKeywordsSG = int(request.get('settingsUseKeywordsSG', 1)) 
    309309        settingsUseKeywordsLG = int(request.get('settingsUseKeywordsLG', 1)) 
     
    321321            seo_props.manage_changeProperties(metatags_order=metatags_order) 
    322322            seo_props.manage_changeProperties(content_types_seoprops_enabled=content_types_seoprops_enabled) 
    323             seo_props.manage_changeProperties(usage_keywords_in_metatags=usageKeywordsInMetatags) 
     323            seo_props.manage_changeProperties(filter_keywords_by_content=filterKeywordsByContent) 
    324324            seo_props.manage_changeProperties(settings_use_keywords_sg=settingsUseKeywordsSG) 
    325325            seo_props.manage_changeProperties(settings_use_keywords_lg=settingsUseKeywordsLG) 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/profiles/default/propertiestool.xml

    r1645 r1647  
    8787   <element value="distribution seo_distribution"/> 
    8888  </property> 
    89   <property name="usage_keywords_in_metatags" type="boolean">True</property> 
     89  <property name="filter_keywords_by_content" type="boolean">True</property> 
    9090 </object> 
    9191 <object name="site_properties" meta_type="Plone Property Sheet"> 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/profiles/reinstall/propertiestool.xml

    r1645 r1647  
    2121   <element value="distribution seo_distribution"/> 
    2222  </property> 
    23   <property name="usage_keywords_in_metatags" type="boolean">True</property> 
     23  <property name="filter_keywords_by_content" type="boolean">True</property> 
    2424  <property name="settings_use_keywords_sg" type="int">1</property> 
    2525  <property name="settings_use_keywords_lg" type="int">1</property> 
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testQSEOptimizerUsageKeywords.py

    r1646 r1647  
    8888        self.assert_(m, "No 'foo, bar' keyword find") 
    8989 
    90     def setup_testing_render_keywords(self): 
    91         self.my_doc.setText('<p>global local subject</p>') 
     90    def setup_testing_render_keywords(self, html='<p>global local subject</p>'): 
     91        self.my_doc.setText(html) 
    9292        self.sp.additional_keywords = (('global',)) 
    9393        self.my_doc.manage_addProperty('qSEO_keywords', ('local'), 'lines') 
     
    136136        self.assert_(m, "No 'subject, global, local' keywords find") 
    137137 
     138    def test_default_values_filter_keywords_by_content_in_configlet(self): 
     139        self.assertEqual(self.sp.getProperty('filter_keywords_by_content', None), True) 
     140 
     141    def test_changes_filter_keywords_by_content_in_configlet(self): 
     142        path = self.portal.id+'/@@seo-controlpanel?filter_keywords_by_content=False&form.submitted=1' 
     143        self.publish(path, self.basic_auth) 
     144        self.assertEqual(self.sp.getProperty('filter_keywords_by_content', 0), None) 
     145 
     146    def test_filter_keywords_by_content_true(self): 
     147        # Usage metatags keywords, which present in content (filter_keywords_by_content=True) 
     148        self.sp.manage_changeProperties(settings_use_keywords_sg=3, settings_use_keywords_lg=2, filter_keywords_by_content=True) 
     149        self.html = self.setup_testing_render_keywords(html='<p>subject global</p>') 
     150        m = re.match('.*(<meta\s+(?:(?:name="keywords"\s*)|(?:content="(?:subject|global),\s*(?:subject|global)"\s*)){2}/>)', 
     151                    self.html, re.S|re.M) 
     152        self.assert_(m, "In metatags keywords not finded \"subject, global\". Checkbox filter_keywords_by_content in configlet is not working.") 
     153 
     154    def test_filter_keywords_by_content_false(self): 
     155        # Usage metatags keywords, without taking into consideration presece in content (filter_keywords_by_content=False) 
     156        self.sp.manage_changeProperties(settings_use_keywords_sg=3, settings_use_keywords_lg=2, filter_keywords_by_content=False) 
     157        self.html = self.setup_testing_render_keywords(html='<p>subject global</p>') 
     158        m = re.match('.*(<meta\s+(?:(?:name="keywords"\s*)|(?:content="(?:subject|global|local),\s*(?:subject|global|local),\s*(?:subject|global|local)"\s*)){2}/>)', 
     159                    self.html, re.S|re.M) 
     160        self.assert_(m, "In metatags keywords not finded \"subject, global, locals\". Checkbox filter_keywords_by_content in configlet is not working.") 
    138161 
    139162def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.