Changeset 3094 for trunk


Ignore:
Timestamp:
11/05/10 16:24:50 (9 years ago)
Author:
jukka
Message:

Restored and refactored RSS support.

Location:
trunk
Files:
2 added
4 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/BlogPost.py

    r3026 r3094  
    240240 
    241241 
    242     ################# RSS ###################################### 
    243  
    244     def getRSSResults(self): 
    245         """ Returns list of tuples (discussion_obj, display_macro_path, url) with blogpost itself leading the bunch """ 
    246         url_base=self.absolute_url() 
    247         title='re:%s' % self.Title() 
    248         return [(self, 'here/rss_macros/macros/real_object', url_base)]+[(x, 'here/rss_macros/macros/discussion_comment', '%s#%s' % (url_base, x.id), title) for x in self.getSortedDiscussion()] 
    249  
    250  
    251242registerType(BlogPost, PROJECTNAME) 
  • trunk/Collection.py

    r3040 r3094  
    657657 
    658658 
    659     ################# RSS ###################################### 
    660  
    661     def getRSSResults(self): 
    662         """ Returns list of tuples (resource_md_obj, display_macro_path, url) """ 
    663         return [(x, 'here/rss_macros/macros/brain_object', self.getPathInsideCollection(x)) for x in self.getAllRelatedResources()] 
    664  
    665          
    666  
    667659    ########## Collectiong PDF file generation section ########## 
    668660 
  • trunk/Discussable.py

    r2944 r3094  
    131131 
    132132    ################# RSS ###################################### 
    133  
    134     def getRSSResults(self): 
    135         """ Returns list of tuples (discussion_obj, display_macro_path, url) """ 
    136         url_base=self.getDiscussionURL() 
    137         title='re:%s' % self.Title() 
    138         return [(x, 'here/rss_macros/macros/discussion_comment', '%s#%s' % (url_base, x.id), title) for x in self.getSortedDiscussion()] 
     133    # currently not used 
     134    def getRSSResults(self,max=30): 
     135        """ Return discussion comments, metadata returned: 
     136        'getURL', 'getLatestEdit', 'Title', 'listCreators','Rights' """ 
     137        results=[] 
     138        url_base=self.getDiscussionURL()  
     139        title='re:%s' % self.Title()                 
     140        for reply in self.getSortedDiscussion()[:max]: 
     141            r_dict={'getURL':'#'.join((url_base, reply.id)), 'getLatestEdit':reply.created, 'Title':title, 'listCreators':[reply.Creator()],'Rights':'CC-SA 2.5'} 
     142            results.append(r_dict) 
     143        return results 
     144 
    139145 
    140146    ################ Notifications ############################## 
  • trunk/GroupBlog.py

    r3077 r3094  
    499499    ################# RSS ###################################### 
    500500 
    501     def getRSSResults(self): 
    502         """ Returns latest forum topics and comments """ 
     501    def getRSSResults(self, max=30): 
     502        """ Returns latest forum topics and comments  
     503        metadata returned: 
     504        'getURL', 'getLatestEdit', 'Title', 'listCreators','Rights' 
     505        """ 
    503506        results=self.getPosts(batch=False, objects=True, limit=10) 
    504         full_results=[] 
     507        sortable_results=[] 
    505508        for result in results: 
    506             full_results.append((result.created, result, 'here/rss_macros/macros/real_object', result.absolute_url(), result.Title())) 
    507             url_base=self.absolute_url()  
     509            r_dict={'getURL':result.absolute_url(), 'getLatestEdit':result.created(), 'Title':result.Title(), 'listCreators':[result.Creator()], 'Rights':'CC-SA 2.5'}  
     510            sortable_results.append((result.created(), r_dict)) 
     511            url_base=result.absolute_url()  
    508512            title='re:%s' % result.Title()                 
    509             for x in result.getDiscussion().values(): 
    510                 full_results.append((x.created, x, 'here/rss_macros/macros/discussion_comment','%s#%s' % (url_base, x.id),title)) 
    511         full_results.sort(reverse=True)         
    512         return [(x[1],x[2],x[3],x[4]) for x in full_results[:30]] 
     513            for reply in result.getDiscussion().values(): 
     514                r_dict={'getURL':'#'.join((url_base, reply.id)), 'getLatestEdit':reply.created, 'Title':title, 'listCreators':[reply.Creator()],'Rights':'CC-SA 2.5'} 
     515                sortable_results.append((reply.created, r_dict)) 
     516        sortable_results.sort(reverse=True) 
     517        rez= [x[1] for x in sortable_results[:max]] 
     518        return rez     
    513519 
    514520         
  • trunk/LargeSectionFolder.py

    r3077 r3094  
    695695            return '' 
    696696 
    697  
    698     ################# RSS ###################################### 
    699  
    700     def getRSSResults(self): 
    701         """ Placeholder """ 
    702         return [] 
    703  
    704  
    705697##################### Subclasses        ################################ 
    706698 
  • trunk/LeMillCatalogTool.py

    r3093 r3094  
    526526        if not 'Language' in keywords: 
    527527            found=False 
    528             if 'base' in keywords and keywords['base']=='language': 
     528            if 'RSS' in keywords: 
     529                found=True 
     530            elif 'base' in keywords and keywords['base']=='language': 
    529531                found=True                 
    530532            elif 'portal_type' in keywords and ('MemberFolder' in keywords['portal_type'] or 'GroupBlog' in keywords['portal_type']): 
     
    545547                    del keywords['Language'] 
    546548 
    547         if 'base' in keywords: 
    548             del keywords['base'] 
     549        for k in ['base','portfolio','RSS']: 
     550            if k in keywords: 
     551                del keywords[k] 
    549552        try: 
    550553            results = self.searchResults(keywords)                 
  • trunk/skins/lemill/RSS.pt

    r2929 r3094  
    1111<tal:defines define="syn context/portal_syndication;  
    1212                max max_items|python:syn.getMaxItems(here); 
    13                 limit_display limit_display|request/limit_display|nothing; 
    14                 results here/getRSSResults|python:[]; 
    15                 over_limit python: limit_display and len(results) > limit_display; 
    16                 results python: (over_limit and results[:limit_display]) or results; 
    17                 results python:results[:max]; 
     13                results python:here.RSSResults(max); 
     14                template here/RSSSender; 
    1815                here_url here/absolute_url; 
    19                 portal nocall:here/portal_url"> 
     16                portal nocall:here/portal_url;"> 
    2017<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Content-Type', 'text/xml;;charset=utf-8')" /> 
    21 <channel rdf:about="" tal:attributes="rdf:about string:${here_url}/view" > 
     18<channel rdf:about="" tal:attributes="rdf:about string:${here_url}" > 
    2219  <title tal:content="python: '%s: %s' % (portal.Title(), context.pretty_title_or_id())">The title</title> 
    23   <link tal:content="string:${here_url}/view">http://url.to.back</link> 
     20  <link tal:content="string:${here_url}${template}?${request/QUERY_STRING}">http://url.to.back</link> 
    2421  <description content="context/Description">Default RSS description</description> 
    2522  <syn:updatePeriod tal:content="python:syn.getUpdatePeriod(context) or default">hourly</syn:updatePeriod> 
     
    2825  <image rdf:resource="" tal:attributes="rdf:resource string:${here_url}/${context/base_properties/logoName}" /> 
    2926  <items> 
    30     <rdf:Seq><tal:block repeat="obj_tuple results"> 
    31             <rdf:li rdf:resource="" 
    32                 tal:attributes="rdf:resource python:obj_tuple[2]" /> 
     27    <rdf:Seq><tal:block repeat="md results"> 
     28            <rdf:li rdf:resource="" tal:attributes="rdf:resource md/getURL" /> 
    3329    </tal:block></rdf:Seq> 
    3430  </items> 
    3531</channel>    
    36 <tal:loop_objects repeat="obj_tuple results"> 
    37   <tal:obj_def define="obj python:obj_tuple[0]"><metal:block use-macro="python:path(obj_tuple[1])" /></tal:obj_def> 
     32<tal:loop_objects repeat="md results"> 
     33        <item rdf:about="" tal:attributes="rdf:about md/getURL" tal:define="modDate md/getLatestEdit | nothing;creators md/listCreators;"> 
     34            <link tal:content="md/getURL">Identifier</link> 
     35            <title tal:content="md/Title | nothing ">Title</title> 
     36            <dc:creator tal:content="python:', '.join(creators)">Creator</dc:creator>         
     37            <dc:rights tal:content="md/Rights | python:'CC-SA 2.5'">Rights</dc:rights>                 
     38            <dc:date tal:content="modDate/HTML4 | nothing">Modification date</dc:date>   
     39        </item> 
    3840</tal:loop_objects> 
    3941</tal:defines> 
  • trunk/skins/lemill/browse.cpt

    r3054 r3094  
    1111 
    1212<div metal:fill-slot="main" tal:define="browse_type here/portal_catalog/decideBrowsingSubType; results results | python:[]"> 
    13     <h1 i18n:translate="heading_browse_content" tal:condition="python:browse_type=='content'">Browse content</h1> 
    14     <h1 i18n:translate="heading_browse_methods" tal:condition="python:browse_type=='methods'">Browse methods</h1> 
    15     <h1 i18n:translate="heading_browse_tools" tal:condition="python:browse_type=='tools'">Browse tools</h1> 
    16     <h1 i18n:translate="heading_browse_community" tal:condition="python:browse_type=='community'">Browse community</h1> 
    17     <h1 i18n:translate="heading_browse_drafts" tal:condition="python:browse_type=='drafts'">My drafts</h1> 
    18     <h1 i18n:translate="heading_browse_published" tal:condition="python:browse_type=='published'">My published</h1> 
    19  
     13    <h1><tal:b i18n:translate="heading_browse_content" condition="python:browse_type=='content'">Browse content</tal:b> 
     14    <tal:b i18n:translate="heading_browse_methods" condition="python:browse_type=='methods'">Browse methods</tal:b> 
     15    <tal:b i18n:translate="heading_browse_tools" condition="python:browse_type=='tools'">Browse tools</tal:b> 
     16    <tal:b i18n:translate="heading_browse_community" condition="python:browse_type=='community'">Browse community</tal:b> 
     17    <tal:b i18n:translate="heading_browse_drafts" condition="python:browse_type=='drafts'">My drafts</tal:b> 
     18    <tal:b i18n:translate="heading_browse_published" condition="python:browse_type=='published'">My published</tal:b>  
     19    <a href="" tal:attributes="href string:$here_url/RSS?${request/QUERY_STRING}"><img i18n:domain="plone" i18n:attributes="title title_rss_feed; alt label_rss_feed;" tal:attributes="src string:$portal_url/rss.gif" src="rss.gif" alt="RSS Feed" title="RSS feed of these search results" /></a> 
     20</h1> 
    2021    <!-- listing --> 
    2122 
  • trunk/skins/lemill/collection_view.cpt

    r3014 r3094  
    7474your experiences by <span i18n:name="newstory"><a href="edit" tal:attributes="href string:${here/absolute_url}/edit"  i18n:translate="link_writing_teaching_and_learning_story">writing a teaching and learning story</a></span>.</p> 
    7575 
    76         <div class="visualClear" style="height:20px"><!-- --></div> 
    77  
    78  
    79         <div> 
    80             <a href="RSS" tal:attributes="href string:${here_url}/RSS"><img i18n:domain="plone" i18n:attributes="title title_rss_feed_for_collection; alt label_rss_feed;" 
    81              tal:attributes="src string:$portal_url/rss.gif" 
    82              src="rss.gif" 
    83              alt="RSS Feed" 
    84              title="RSS feed for this collection" /></a> 
    85             <a href="RSS"  tal:attributes="href string:${here_url}/RSS" i18n:translate="rss_collections_text">Subscribe to RSS feed for this collection</a> 
    86         </div> 
    87  
    88  
    8976      </metal:main_macro> 
    9077    </metal:fill>     
  • trunk/skins/lemill/discussion.pt

    r3070 r3094  
    11<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" metal:use-macro="here/main_template/macros/master" i18n:domain="lemill"> 
    2  
    3   <metal:headslot fill-slot="head_slot"> 
    4     <link rel="alternate" title="RSS 1.0" type="application/rss+xml" 
    5           tal:attributes="href string:${here_url}/RSS"/> 
    6   </metal:headslot> 
    7  
    82 
    93 <body> 
     
    7771            </div> 
    7872 
    79             <div> 
    80                 <a href="CommentRSS" tal:attributes="href string:${here/absolute_url}/RSS"> 
    81                     <img i18n:domain="plone" i18n:attributes="title title_rss_feed_comments; alt label_rss_feed;" 
    82                         tal:attributes="src string:$portal_url/rss.gif" src="rss.gif" alt="RSS Feed" title="RSS feed of comments" /> 
    83                 </a> 
    84                 <a href="CommentRSS"  tal:attributes="href string:${here/absolute_url}/RSS" i18n:translate="rss_comments_text" i18n:domain="lemill">Subscribe to RSS feed for comments</a> 
    85             </div> 
    86  
    8773        </div> 
    8874        </metal:comments_macro> 
  • trunk/skins/lemill/portfolio.cpt

    r3076 r3094  
    55 
    66<metal:block metal:fill-slot="head_slot"> 
    7     <link rel="alternate" title="RSS 1.0" type="application/rss+xml" 
    8           tal:condition="request/SearchableText|nothing" 
    9           tal:attributes="href string:$here_url/search_rss?${request/QUERY_STRING}"/> 
     7    <link rel="alternate" title="RSS 1.0" type="application/rss+xml" tal:define="pf_string python:test(request['QUERY_STRING'],'&amp;portfolio=1', 'portfolio=1')"  
     8          tal:attributes="href string:$here_url/RSS?${request/QUERY_STRING}${pf_string}"/> 
    109</metal:block> 
    11  
    12 <metal:block fill-slot="top_slot" 
    13              tal:define="dummy python:request.set('disable_border',1)" /> 
    1410 
    1511<metal:portlet fill-slot="portlet_slot"> 
     
    5753<div metal:fill-slot="main" tal:define="pf_owner context/getMemberId | nothing; mf context/getMemberFolder | nothing ;this_group context/getBlog | nothing;"> 
    5854    <tal:proper_portfolio condition="python: mf or this_group"> 
    59     <h1 i18n:translate="title_for_portfolio"><a href="" tal:attributes="href context/absolute_url" tal:content="context/getNicename" i18n:name="name">name</a>'s Portfolio</h1> 
     55    <h1><tal:b i18n:translate="title_for_portfolio"><a href="" tal:attributes="href context/absolute_url" tal:content="context/getNicename" i18n:name="name">name</a>'s Portfolio</tal:b> <a href="" tal:define="pf_string python:test(request['QUERY_STRING'],'&amp;portfolio=1', 'portfolio=1')" tal:attributes="href string:$here_url/RSS?${request/QUERY_STRING}${pf_string}"><img i18n:domain="plone" i18n:attributes="title title_rss_feed; alt label_rss_feed;" tal:attributes="src string:$portal_url/rss.gif" src="rss.gif" alt="RSS Feed" title="RSS feed of these search results" /></a></h1> 
    6056     
    6157    <div tal:condition="results" tal:define="batch python:context.portal_catalog.batch(results, request);"> 
  • trunk/skins/lemill/search.cpt

    r3054 r3094  
    66<metal:block metal:fill-slot="head_slot"> 
    77    <link rel="alternate" title="RSS 1.0" type="application/rss+xml" 
    8           tal:condition="request/SearchableText|nothing" 
    9           tal:attributes="href string:$here_url/search_rss?${request/QUERY_STRING}"/> 
     8          tal:attributes="href string:$here_url/RSS?${request/QUERY_STRING}"/> 
    109</metal:block> 
    11  
    12 <metal:block fill-slot="top_slot" 
    13              tal:define="dummy python:request.set('disable_border',1)" /> 
    1410 
    1511<metal:portlet fill-slot="portlet_slot"> 
     
    5652 
    5753<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> 
     54    <h1><tal:b 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>"</tal:b> 
     55        <tal:b condition="python:search_type=='recent_edits'" i18n:translate="heading_recent_edits">Recent edits</tal:b> 
     56        <tal:b condition="python:search_type=='new_resources'" i18n:translate="heading_new_resources">New resources</tal:b> 
     57        <tal:b condition="python:search_type=='new_members'" i18n:translate="heading_new_members">New members</tal:b> 
     58        <a href="" tal:attributes="href string:$here_url/RSS?${request/QUERY_STRING}"><img i18n:domain="plone" i18n:attributes="title title_rss_feed; alt label_rss_feed;" tal:attributes="src string:$portal_url/rss.gif" src="rss.gif" alt="RSS Feed" title="RSS feed of these search results" /></a> 
     59    </h1> 
    6260    <div tal:condition="results" tal:define="batch python:context.portal_catalog.batch(results, request);"> 
    6361           
     
    6866 
    6967    </div> 
     68    <tal:rss_and_resultcount metal:use-macro="here/browse_macros/macros/rss_count"/> 
     69 
    7070</div> 
    7171 
Note: See TracChangeset for help on using the changeset viewer.