Ignore:
Timestamp:
Sep 8, 2009 5:52:25 PM (15 years ago)
Author:
liebster
Message:

Added additional functionality for metatags using

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/views.py

    r1183 r1265  
    6767    def seo_customMetaTags( self ): 
    6868        """ 
    69            Return context's properties prefixed with qSEO_custom_ 
     69        """ 
     70        tags = self.seo_globalCustomMetaTags() 
     71        loc = self.seo_localCustomMetaTags() 
     72 
     73        names = [i['meta_name'] for i in tags] 
     74        add_tags = [] 
     75        for i in loc: 
     76            if i['meta_name'] in names: 
     77                for t in tags: 
     78                    if t['meta_name'] == i['meta_name']: 
     79                        t['meta_content'] = i['meta_content'] 
     80            else: 
     81                add_tags.append(i) 
     82        tags.extend(add_tags) 
     83        return tags 
     84 
     85    def seo_globalWithoutLocalCustomMetaTags( self ): 
     86        """ 
     87        """ 
     88        glob = self.seo_globalCustomMetaTags() 
     89        loc = self.seo_localCustomMetaTags() 
     90        names = [i['meta_name'] for i in loc] 
     91        tags = [] 
     92        for i in glob: 
     93            if i['meta_name'] not in names: 
     94                tags.append(i) 
     95        return tags 
     96 
     97    def seo_localCustomMetaTags( self ): 
     98        """ 
    7099        """ 
    71100        result = [] 
    72         added = [] 
    73101        property_prefix = 'qSEO_custom_' 
    74  
    75         context = aq_inner(self.context) 
    76  
     102        context = aq_inner(self.context) 
    77103        for property, value in context.propertyItems(): 
    78             idx = property.find(property_prefix) 
    79             if idx == 0 and len(property) > len(property_prefix): 
    80                 added.append(property[len(property_prefix):]) 
     104            if property.startswith(property_prefix) and property[len(property_prefix):]: 
    81105                result.append({'meta_name'    : property[len(property_prefix):], 
    82106                               'meta_content' : value}) 
    83  
     107        return result 
     108 
     109    def seo_globalCustomMetaTags( self ): 
     110        """ 
     111        """ 
     112        result = [] 
     113        context = aq_inner(self.context) 
    84114        site_properties = getToolByName(context, 'portal_properties') 
    85115        if hasattr(site_properties, 'seo_properties'): 
     
    87117            for tag in custom_meta_tags: 
    88118                name_value = tag.split(SEPERATOR) 
    89                 if name_value[0] and name_value[0] not in added: 
    90                     if len(name_value) == 1: 
    91                         result.append({'meta_name'    : name_value[0], 
    92                                        'meta_content' : ''}) 
    93                     else: 
    94                         result.append({'meta_name'    : name_value[0], 
    95                                        'meta_content' : name_value[1]}) 
     119                if name_value[0]: 
     120                    result.append({'meta_name'    : name_value[0], 
     121                                   'meta_content' : len(name_value) == 1 and '' or name_value[1]}) 
    96122        return result 
    97      
     123 
     124    def seo_nonEmptylocalMetaTags( self ): 
     125        """ 
     126        """ 
     127        return bool(self.seo_localCustomMetaTags()) 
     128 
    98129    def seo_html_comment( self ): 
    99130        """ 
Note: See TracChangeset for help on using the changeset viewer.