Changeset 3054 for trunk


Ignore:
Timestamp:
10/06/10 23:18:52 (9 years ago)
Author:
jukka
Message:

Front page links to last weeks resources and members work now.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LeMillCatalogTool.py

    r3052 r3054  
    237237            count_indexes=('Language','getTarget_group','portal_type','getSubject_area') 
    238238         
    239         d={'do_languages':do_languages, 'do_subject_areas':do_subject_areas,'do_target_groups':do_target_groups,'do_types':do_types,'do_edited':do_edited, 'do_tags':do_tags, 'q':'', 'state':'', 'author':''} 
     239        d={'do_languages':do_languages, 'do_subject_areas':do_subject_areas,'do_target_groups':do_target_groups,'do_types':do_types,'do_edited':do_edited, 'do_tags':do_tags, 'q':'', 'state':'', 'author':'', 'created':''} 
    240240 
    241241 
     
    373373        return ''             
    374374 
     375    def decideSearchSubType(self): 
     376        """ Search page header needs to know what kind of search is going on """ 
     377        form=self.REQUEST.form         
     378        if 'created' in form: 
     379            if 'type' in form and form['type']=='MemberFolder': 
     380                return 'new_members' 
     381            else: 
     382                return 'new_resources' 
     383        if 'edited' in form and 'q' not in form: 
     384            return 'recent_edits' 
     385        return 'search' 
     386 
     387 
    375388    def browsingSearch(self, REQUEST=None, **kw):         
    376389        """ this search tries to use arguments from browsing form """ 
    377390        print 'browsing search called' 
    378391        t=time.time() 
     392        src=REQUEST.form 
     393        if '-C' in src: 
     394            del src['-C'] 
     395        if not (src or kw): 
     396            path=REQUEST['ACTUAL_URL'].split('/') 
     397            if 'browse' in path or 'search' in path or 'cloud' in path: 
     398                print 'empty search, return []' 
     399                return [] 
    379400        keywords={'sort_on':'getScore','sort_order':'reverse','getState':('draft', 'public')} 
    380         keywords.update(REQUEST.form.items()) 
     401        keywords.update(src) 
    381402        keywords.update(kw) 
    382403        if 'language' in keywords: 
     
    404425            del keywords['state'] 
    405426        if 'type' in keywords: 
    406             keywords['portal_type']=keywords['type'] 
     427            if keywords['type']=='lr': 
     428                keywords['portal_type']=list(CONTENT_TYPES)+['Activity','Tool'] 
     429            else: 
     430                keywords['portal_type']=keywords['type'] 
    407431            del keywords['type']  
    408432        else: # portal_type is determined by location  
     
    421445            keywords['SearchableText']=keywords['q'] 
    422446            del keywords['q'] 
     447        if 'created' in keywords: 
     448            keywords['created']={'query': self.ZopeTime()-int(keywords['created']), 'range':'min'} 
    423449        if 'edited' in keywords: 
    424450            keywords['getLatestEdit']={'query': self.ZopeTime()-int(keywords['edited']), 'range':'min'} 
    425         print 'keywords:', keywords 
     451            del keywords['edited'] 
    426452        if not 'Language' in keywords: 
    427453            found=False 
     
    429455                if keywords['base']=='language': 
    430456                    found=True 
    431             for compensating in ['SearchableText','listCreators','getTarget_group','getTags','getSubject_area']: 
     457            for compensating in ['SearchableText','listCreators','getTarget_group','getTags','getSubject_area','created','getLatestEdit']: 
    432458                if compensating in keywords: 
    433459                    found=True 
     
    438464            if not keywords['Language']: 
    439465                del keywords['Language'] 
     466        print 'keywords:', keywords 
    440467        try: 
    441468            results = self.searchResults(keywords)                 
  • trunk/skins/lemill/browse.cpt

    r3052 r3054  
    1010</metal:block> 
    1111 
    12 <div metal:fill-slot="main" tal:define="browse_type here/portal_catalog/decideBrowsingSubType"> 
     12<div metal:fill-slot="main" tal:define="browse_type here/portal_catalog/decideBrowsingSubType; results results | python:[]"> 
    1313    <h1 i18n:translate="heading_browse_content" tal:condition="python:browse_type=='content'">Browse content</h1> 
    1414    <h1 i18n:translate="heading_browse_methods" tal:condition="python:browse_type=='methods'">Browse methods</h1> 
  • trunk/skins/lemill/cloud.pt

    r3052 r3054  
    55 
    66<div metal:fill-slot="main"> 
    7   <div class="cloud" tal:define="wordtuples python:context.portal_catalog.buildCloudData(results, request);"> 
     7  <div class="cloud" tal:define="results results | python:context.portal_catalog.browsingSearch(request); wordtuples python:context.portal_catalog.buildCloudData(results, request);"> 
    88    <tal:taggy repeat="wordinfo wordtuples"><tal:taggyvalues define="nicename python:wordinfo[0]; tagsize python:wordinfo[1]; link_url python:wordinfo[2]; "><a tal:attributes="href link_url;class string:size$tagsize" tal:content="nicename" i18n:translate="" /> </tal:taggyvalues></tal:taggy>  
    99  </div> 
  • trunk/skins/lemill/front-page.cpt

    r3052 r3054  
    4747<div class="clear"></div> 
    4848<div class="lemill_numbers grid"> 
    49 <p i18n:translate="lemill_numbers"><span i18n:name="teachers" tal:content="oc/teachers" /> teachers from <a href="community/country"><span i18n:name="countries" tal:content="oc/countries" /> countries</a>. <span i18n:name="learning_resources" tal:content="oc/learning_resources" /> learning resources in <a href="content/language"><span i18n:name="languages" tal:content="oc/languages" /> languages</a>.</p> 
    50 <p i18n:translate="lemill_weekly_numbers"><a href="search?span=7&change_type=created&type=MemberFolder"><span i18n:name="weekly_members" tal:content="oc/weekly_members" /> new members</a>, <a href="search?span=7&change_type=created&type=lr"><span i18n:name="weekly_new" tal:content="oc/weekly_new" /> new learning resources</a>. <a href="search?span=7&change_type=modified&type=lr"><span i18n:name="weekly_edited" tal:content="oc/weekly_edited" /> edited resources</a> during the last week.</p> 
     49<p i18n:translate="lemill_numbers"><span i18n:name="teachers" tal:content="oc/teachers" /> teachers from <a href="community/cloud?base=country"><span i18n:name="countries" tal:content="oc/countries" /> countries</a>. <span i18n:name="learning_resources" tal:content="oc/learning_resources" /> learning resources in <a href="content/cloud?base=language"><span i18n:name="languages" tal:content="oc/languages" /> languages</a>.</p> 
     50<p i18n:translate="lemill_weekly_numbers"><a href="search?created=7&type=MemberFolder"><span i18n:name="weekly_members" tal:content="oc/weekly_members" /> new members</a>, <a href="search?created=7&type=lr"><span i18n:name="weekly_new" tal:content="oc/weekly_new" /> new learning resources</a>. <a href="search?edited=7&type=lr"><span i18n:name="weekly_edited" tal:content="oc/weekly_edited" /> edited resources</a> during the last week.</p> 
    5151</div> 
    5252<div class="clear"></div> 
  • trunk/skins/lemill/lemill_activities_view.pt

    r3052 r3054  
    3333            <a href="" tal:attributes="href python:'language?language=%s' % here.url_quote(result)" tal:content="python:here.script_getPrettyLanguage(result)">PLACEHOLDER</a>, </span><a href="rebuildTop3s" tal:condition="context/amIManager">( rebuild top results )</a><a href="cloud?base=language">...</a> 
    3434        </dd> 
    35         <dt><a i18n:translate="label_popularity" href="" tal:attributes="href string:cloud?${lang_filter}base=title">Popularity</a></dt> 
    36         <dd></dd> 
    37  
    3835        <dt><a i18n:translate="label_tags" href=""  tal:attributes="href string:cloud?${lang_filter}base=tags">Tags</a></dt> 
    3936        <dd><span tal:repeat="result python:context.portal_catalog.getTopFive(results,'getTags', 'browse?%stags=' % lang_filter)"> 
     
    4138            </span><a href="" tal:attributes="href string:cloud?${lang_filter}base=tags">...</a> 
    4239        </dd> 
     40        <dt><a i18n:translate="label_titles" href="" tal:attributes="href string:cloud?${lang_filter}base=title">Titles</a></dt> 
     41        <dd></dd> 
     42 
    4343    </dl> 
    4444    </div> 
  • trunk/skins/lemill/lemill_tools_view.pt

    r3052 r3054  
    3434            <a href="" tal:attributes="href python:'language?language=%s' % here.url_quote(result)" tal:content="python:here.script_getPrettyLanguage(result)">PLACEHOLDER</a>, </span><a href="rebuildTop3s" tal:condition="context/amIManager">( rebuild top results )</a><a href="cloud?base=language">...</a> 
    3535        </dd> 
    36         <dt><a i18n:translate="label_popularity" href="" tal:attributes="href string:cloud?${lang_filter}base=title">Popularity</a></dt> 
    37         <dd></dd> 
    38  
    3936        <dt><a i18n:translate="label_tags" href=""  tal:attributes="href string:cloud?${lang_filter}base=tags">Tags</a></dt> 
    4037        <dd><span tal:repeat="result python:context.portal_catalog.getTopFive(results,'getTags','browse?%stags=' % lang_filter)"> 
     
    4239            </span><a href="" tal:attributes="href string:cloud?${lang_filter}base=tags">...</a> 
    4340        </dd> 
     41        <dt><a i18n:translate="label_titles" href="" tal:attributes="href string:cloud?${lang_filter}base=title">Titles</a></dt> 
     42        <dd></dd> 
    4443    </dl> 
    4544    </div> 
  • trunk/skins/lemill/script_parseSearchForm.cpy

    r3052 r3054  
    4444    if form['edited']: 
    4545        new_args['edited']=form['edited'] 
    46  
     46if 'created' in form: 
     47    if form['created'] and not 'edited' in new_args: 
     48        new_args['created']=form['created'] 
    4749if new_args: 
    4850    next_action='redirect_to:string:search?%s' % urlencode(new_args) 
  • trunk/skins/lemill/search.cpt

    r3052 r3054  
    4848        </select> 
    4949        </p> 
     50     <input type="hidden" name="created" id="created" tal:attributes="value d/created" value=""/>      
    5051     <input type="hidden" name="q" id="q" tal:attributes="value d/q" value=""/> 
    5152     <input type="hidden" name="form.submitted" value="1" /> 
     
    5455</metal:portlet> 
    5556 
    56 <div metal:fill-slot="main"> 
    57     <h1 i18n:domain="lemill" i18n:translate="heading_search_for">Searching for "<span i18n:name="search_term" tal:content="request/form/q | nothing">word</span>"</h1> 
     57<div metal:fill-slot="main" tal:define="search_type here/portal_catalog/decideSearchSubType"> 
     58    <h1 tal:condition="python:search_type=='search'" i18n:translate="heading_search_for">Searching for "<span i18n:name="search_term" tal:content="request/form/q | nothing">word</span>"</h1> 
     59    <h1 tal:condition="python:search_type=='recent_edits'" i18n:translate="heading_recent_edits">Recent edits</h1> 
     60    <h1 tal:condition="python:search_type=='new_resources'" i18n:translate="heading_new_resources">New resources</h1> 
     61    <h1 tal:condition="python:search_type=='new_members'" i18n:translate="heading_new_members">New members</h1> 
    5862    <div tal:condition="results" tal:define="batch python:context.portal_catalog.batch(results, request);"> 
    5963           
Note: See TracChangeset for help on using the changeset viewer.