Changeset 3127 for trunk


Ignore:
Timestamp:
01/04/11 18:13:43 (9 years ago)
Author:
jukka
Message:

Cleaned a bit.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LeMillCatalogTool.py

    r3126 r3127  
    437437        return 'search' 
    438438 
    439     def getCloudType(self): 
    440         """ """ 
    441         form=self.REQUEST.form 
    442         base=form.get('base','') 
    443         if base in ['tags','subject_area','target_group','language']: 
    444             return base 
    445  
    446439    def browsingSearch(self, REQUEST=None, **kw):         
    447440        """ This is a general purpose catalog search that can convert readable keywords from request into actual search terms. 
     
    756749    def fastFindEmptyValues(self, results, index_to_look): 
    757750        """ Takes Lazy results and return those results where the given index returns empty""" 
    758  
    759         t=time.time() 
    760751        new_results=[] 
    761  
    762752        def safeData(index, key): 
    763753            v=index.getEntryForObject(key, []) 
     
    778768        index=self._catalog.getIndex(index_to_look) 
    779769        wakeUpAndFilter(results) 
    780         print time.time()-t 
    781770        assert isinstance(results,LazyMap) 
    782771        return LazyMap(results._func, new_results, len(new_results)) 
     
    948937        return new 
    949938         
    950  
    951 # 
    952 #    def getTagCloud(self, search_results, index_type): 
    953 #        """ Build a cloud based on how many occurences of this item are in results """ 
    954 #        if not search_results: 
    955 #            return [] 
    956 #        lemill_tool = getToolByName(self, 'lemill_tool') 
    957 #        pc = getToolByName(self, 'portal_catalog') 
    958 #        from math import log 
    959 #        maxcount=0 
    960 # 
    961 #        hits={} 
    962 #        hits=pc.fastCount(search_results, index_type) 
    963 #        resultlist=zip(hits.values(),hits.keys()) 
    964 #        if not resultlist: 
    965 #            return [] 
    966 #        resultlist.sort() 
    967 #        resultlist.reverse() 
    968 #        maxcount=resultlist[0][0] # first! 
    969 #        # if the first cut score for tag is x, we want to cut off all of the tags with score x.  
    970 #        if len(resultlist)>100: 
    971 #            #cutpoint = [x[0] for x in resultlist].index(resultlist[100]) can't figure this now, fix later 
    972 #            cutpoint = 100 
    973 #            resultlist = resultlist[:cutpoint] 
    974 #        mincount=resultlist[-1][0] 
    975 #        resultlist=[(x[1], x[0], '',x[1],x[1]) for x in resultlist] 
    976 # 
    977 #        # adjust to 1-8. We don't have to worry about score 0, they're already removed. 
    978 #        if maxcount>1: 
    979 #            resultlist=map(adjust, resultlist) 
    980 #        # prettify language names 
    981 #        if index_type=='Language' or index_type=='getLanguage_skills': 
    982 #            resultlist=[(x[0],x[1],x[2],x[3],lemill_tool.getPrettyLanguage(x[4])) for x in resultlist]             
    983 #        if index_type=='getTarget_group': 
    984 #            def compfunc(t2,t1): 
    985 #                if t2[0] in TARGET_GROUP and t1[0] in TARGET_GROUP: 
    986 #                    return  TARGET_GROUP.index(t2[0]) - TARGET_GROUP.index(t1[0]) 
    987 #                else: 
    988 #                    return -1 
    989 #            resultlist.sort(cmp=compfunc) 
    990 #        else:     
    991 #            resultlist.sort() 
    992 #        return resultlist 
    993 #         
    994 # 
    995 #    def getTitleCloud(self, search_results, browse_type): 
    996 #        """ Build a cloud based on popularity score for that resource """ 
    997 #        pc=getToolByName(self,'portal_catalog') 
    998 #        # uniquetuplelist contains result metadata reordered: (sort_title, count, url, indexvalue, title) 
    999 #        if not search_results: 
    1000 #            return [] 
    1001 # 
    1002 #        def isDefaultTitle(x): 
    1003 #            """ some heuristic to recognize default titles """ 
    1004 #            return re.match(r'.*\.(...)$', x) or re.match(r'.*\.(....)$', x)  
    1005 #                     
    1006 #        popularity = pc.fastMetadata(search_results, ('getScore','rid','getNicename','sortable_title')) 
    1007 #        popularity.sort(reverse=True) 
    1008 #        popularity=popularity[:100] 
    1009 #        titlecloud=[(sortable_title, getScore, self.REQUEST.physicalPathToURL(pc.getpath(rid)), sortable_title, getNicename or sortable_title) for (getScore, rid, getNicename, sortable_title) in popularity if sortable_title] 
    1010 #         
    1011 #        if not titlecloud: 
    1012 #            return [] 
    1013 #        titlecloud.sort() 
    1014 #        maxscore=max([x[1] for x in titlecloud]) 
    1015 #        if maxscore>1: 
    1016 #            titlecloud=map(adjust, titlecloud) 
    1017 #        return titlecloud 
    1018  
    1019  
    1020  
    1021  
    1022  
    1023939CatalogTool.__doc__ = PloneCatalogTool.__doc__ 
    1024940 
  • trunk/skins/lemill/cloud.pt

    r3126 r3127  
    1010  <div class="clear" style="height:40px"></div> 
    1111  <div class="cloud"> 
    12     <p class="size1" tal:define="cloud_type python:context.portal_catalog.getCloudType()"> 
     12    <p class="size1" tal:define="cloud_type request/form/base | nothing"> 
    1313    <a style="text-decoration: underline;" tal:condition="python:cloud_type=='language'" href="browse?language=&empties=Language" i18n:translate="">No language specified</a> 
    1414    <a style="text-decoration: underline;" tal:condition="python:cloud_type=='subject_area'" href="browse?subject_area=&empties=getSubject_area" i18n:translate="">No subject area specified</a> 
Note: See TracChangeset for help on using the changeset viewer.