Changeset 555

Show
Ignore:
Timestamp:
09/29/06 10:53:51
Author:
mylan
Message:

Add Delicious,Digg,Yahoo,Google,Spurl bookmarklets. Refactoring SimpleBlog_macros. Hide unused categories from portlet.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/Blog.py

    r554 r555  
    101101                                                    condition="python:0", # this line have to be removed in order to be visible/editable 
    102102                                    description="Enter administrator's email for receaving notification about blog's activity"), 
    103                ) 
     103               ), 
     104    BooleanField('allowDelicious', 
     105                default = 1, 
     106                accessor = 'isDeliciousEnabled', 
     107                schemata = 'interface',  
     108                widget=BooleanWidget(label="Turn Delicious bookmarklet", 
     109                                    label_msgid="label_allow_delicious", 
     110                                    description_msgid="help_allow_delicious"), 
     111                ), 
     112    BooleanField('allowDigg', 
     113                default = 1, 
     114                accessor = 'isDiggEnabled', 
     115                schemata = 'interface', 
     116                widget=BooleanWidget(label="Turn Digg bookmarklet", 
     117                                    label_msgid="label_allow_digg", 
     118                                    description_msgid="help_allow_digg"), 
     119                ), 
     120    BooleanField('allowYahoo', 
     121                default = 1, 
     122                accessor = 'isYahooEnabled', 
     123                schemata = 'interface',  
     124                widget=BooleanWidget(label="Turn Yahoo bookmarklet", 
     125                                    label_msgid="label_allow_yahoo", 
     126                                    description_msgid="help_allow_yahoo"), 
     127                ), 
     128    BooleanField('allowGoogle', 
     129                default = 1, 
     130                accessor = 'isGoogleEnabled', 
     131                schemata = 'interface', 
     132                widget=BooleanWidget(label="Turn Google bookmarklet", 
     133                                    label_msgid="label_allow_google", 
     134                                    description_msgid="help_allow_google"), 
     135                ), 
     136    BooleanField('allowSpurl', 
     137                default = 1, 
     138                accessor = 'isSpurlEnabled', 
     139                schemata = 'interface',  
     140                widget=BooleanWidget(label="Turn Spurl bookmarklet", 
     141                                    label_msgid="label_allow_spurl", 
     142                                    description_msgid="help_allow_spurl"), 
     143                ), 
    104144    #BooleanField('allowComments', 
    105145    #              default = 1, 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/BlogEntry.py

    r554 r555  
    1616import sys 
    1717from util import * 
     18from config import DIGG_TOPICS 
    1819 
    1920schema  =  BaseFolderSchema +  Schema(( 
     
    136137                        label = 'Bottom Adsence', 
    137138                        description = None)), 
     139    StringField('diggTopic', 
     140                default='offbeat_news', 
     141                vocabulary=DIGG_TOPICS, 
     142                widget=SelectionWidget(label='Digg topic', 
     143                        label_msgid="label_digg_topic", 
     144                        description_msgid="help_digg_topic", 
     145                        i18n_domain="SimpleBlog", 
     146                        description='Choose the digg topic.')), 
    138147    )) 
    139148 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/__init__.py

    r554 r555  
    1919    from AccessControl import ModuleSecurityInfo, allow_module 
    2020    ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('addTrackBack') 
     21    ModuleSecurityInfo('Products.SimpleBlog.util').declarePublic('encodeURLData') 
    2122 
    2223    #allow_module('Products.SimpleBlog.Extensions.utils') 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/config.py

    r554 r555  
    1111    ('descriptionOnly', 'Description only', 'display_description_only'),  
    1212    ('titleOnly', 'Title only', 'display_title_only') )) 
     13 
     14DIGG_TOPICS = DisplayList(( \ 
     15     ('apple', 'Technology:Apple') \ 
     16    ,('design', 'Technology:Design') \ 
     17    ,('gadgets', 'Technology:Gadgets') \ 
     18    ,('hardware', 'Technology:Hardware') \ 
     19    ,('tech_news', 'Technology:Industry News') \ 
     20    ,('linux_unix', 'Technology:Linux/Unix') \ 
     21    ,('mods', 'Technology:Mods') \ 
     22    ,('programming', 'Technology:Programming') \ 
     23    ,('security', 'Technology:Security') \ 
     24    ,('software', 'Technology:Software') \ 
     25    ,('tech_deals', 'Technology:Tech Deals') \ 
     26    ,('space', 'Science:Space') \ 
     27    ,('environment', 'Science:Environment') \ 
     28    ,('health', 'Science:Health') \ 
     29    ,('general_sciences', 'Science:General Sciences') \ 
     30    ,('business_finance', 'World & Business:Business Finance') \ 
     31    ,('politics', 'World & Business:Political News') \ 
     32    ,('political_opinion', 'World & Business:Political Opinion') \ 
     33    ,('world_news', 'World & Business:World News') \ 
     34    ,('offbeat_news', 'World & Business:Offbeat News') \ 
     35    ,('baseball', 'Sports:Baseball') \ 
     36    ,('basketball', 'Sports:Basketball') \ 
     37    ,('extreme_sports', 'Sports:Extreme Sports') \ 
     38    ,('football', 'Sports:Football - US/Canada') \ 
     39    ,('golf', 'Sports:Golf') \ 
     40    ,('hockey', 'Sports:Hockey') \ 
     41    ,('motorsport', 'Sports:Motorsport') \ 
     42    ,('soccer', 'Sports:Soccer') \ 
     43    ,('tennis', 'Sports:Tennis') \ 
     44    ,('other_sports', 'Sports:Other Sports') \ 
     45    ,('videos_animation', 'Videos:Animation') \ 
     46    ,('videos_comedy', 'Videos:Comedy') \ 
     47    ,('videos_educational', 'Videos:Educational') \ 
     48    ,('videos_gaming', 'Videos:Gaming') \ 
     49    ,('videos_music', 'Videos:Music') \ 
     50    ,('videos_people', 'Videos:People') \ 
     51    ,('videos_sports', 'Videos:Sports') \ 
     52    ,('celebrity', 'Entertainment:Celebrity') \ 
     53    ,('movies', 'Entertainment:Movies') \ 
     54    ,('music', 'Entertainment:Music') \ 
     55    ,('television', 'Entertainment:Television') \ 
     56    ,('gaming_news', 'Gaming:Gaming News') \ 
     57    ,('playable_web_games', 'Gaming:Playable Web Games') \ 
     58)).sortedByValue() 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/skins/SimpleBlog/SimpleBlog_macros.pt

    r554 r555  
    44<body> 
    55 
     6<div metal:define-macro="blogGlobals" 
     7     tal:define="global fp python:here.simpleblog_tool.getFrontPage(here); 
     8                 global isDeliciousEnaled fp/isDeliciousEnabled; 
     9                 global isDiggEnabled fp/isDiggEnabled; 
     10                 global isYahooEnabled fp/isYahooEnabled; 
     11                 global isGoogleEnabled fp/isGoogleEnabled; 
     12                 global isSpurlEnabled fp/isSpurlEnabled; 
     13                 global isTagsEnabled fp/isTagsEnabled; 
     14                 global isAllowTrackback fp/getAllowTrackback" 
     15     tal:omit-tag=""> 
     16</div> 
     17 
    618<div metal:define-macro="full" tal:define="showReadMore python:0" class="simpleBlogEntry"> 
     19    <div metal:use-macro="obj/SimpleBlog_macros/macros/blogGlobals"/> 
    720    <div tal:define="size headerSize | python:1;title obj/title_or_id; 
    8                          showIcons obj/simpleblog_tool/getShowIcons"  
     21                    showIcons fp/simpleblog_tool/getShowIcons"  
    922             class="simpleBlogTitle"> 
    1023                <tal:x replace='structure string:<h${size} class="noMargin">'/> 
     
    2538 
    2639<div metal:define-macro="descriptionOnly"  tal:define="showReadMore python:1" class="simpleBlogEntry"> 
     40    <div metal:use-macro="obj/SimpleBlog_macros/macros/blogGlobals"/> 
    2741    <div tal:define="size headerSize | python:1;title obj/title_or_id; 
    28                          showIcons obj/simpleblog_tool/getShowIcons"  
     42                    showIcons fp/simpleblog_tool/getShowIcons"  
    2943             class="simpleBlogTitle"> 
    3044                <tal:x replace='structure string:<h${size} class="noMargin">'/> 
     
    4458 
    4559<div metal:define-macro="titleOnly" tal:define="showReadMore python:1" class="simpleBlogTitle"> 
     60    <div metal:use-macro="obj/SimpleBlog_macros/macros/blogGlobals"/> 
    4661    <tal:block tal:define="size headerSize | python:1;title obj/title_or_id; 
    47                                showIcons obj/simpleblog_tool/getShowIcons"> 
     62                        showIcons fp/simpleblog_tool/getShowIcons"> 
    4863                <tal:x replace='structure string:<h${size} class="noMargin">'/> 
    4964            <a href="" tal:attributes="href obj/absolute_url" style="cursor:pointer;"> 
     
    5873</div> 
    5974 
    60 <div metal:define-macro="ByLine" class="BlogByLine"> 
     75<div metal:define-macro="ByLine" class="BlogByLine" 
     76     tal:define="fp nocall:fp | python:here.simpleblog_tool.getFrontPage(here);"> 
    6177     <span i18n:translate="blog_by_line"> 
    6278    Submitted by  
     
    7187                <strong><a href="#"  
    7288                           tal:define="quotedCat python:pss.url_quote(cat)" 
    73                            tal:attributes="href string:${here/absolute_url}/SimpleBlogCatSearch?category=${quotedCat}"  
     89                           tal:attributes="href string:${fp/absolute_url}/SimpleBlogCatSearch?category=${quotedCat}" 
    7490                           title="category"><span  tal:omit-tag="" tal:content="cat"/></a></strong> 
    7591           </tal:categories> 
     
    7995 
    8096<div metal:define-macro="technoratiTags" 
    81       tal:define="cats python:obj.EntryTag();" 
    82      tal:condition="python:here.isTagsEnabled() and cats" 
     97     tal:define="cats python:obj.EntryTag(); 
     98                 isTagsEnabled isTagsEnabled | here/isTagsEnabled" 
     99     tal:condition="python:isTagsEnabled and cats" 
    83100     tal:omit-tag=""> 
    84101     _____<br/> 
     
    97114    <tal:x define="allowed python:obj.portal_discussion.isDiscussionAllowedFor(obj); 
    98115                   ccount python:allowed and obj.portal_discussion.getDiscussionFor(obj).replyCount(obj); 
    99                    tballowed python:here.getAllowTrackback(); 
    100                    tbcount python:len(obj.getTrackbacks())"> 
     116                   tballowed isAllowTrackback | here/getAllowTrackback; 
     117                   tbcount python:len(obj.getTrackbacks()); 
     118                   fp nocall:fp | python:here.simpleblog_tool.getFrontPage(here)"> 
    101119         <span i18n:translate="blog_by_line"> 
    102120         <span tal:define="edate python:obj.simpleblog_tool.getEntryDate(obj)" 
     
    111129                    <strong><a href="#"  
    112130                               tal:define="quotedCat python:pss.url_quote(cat)" 
    113                                tal:attributes="href string:${here/absolute_url}/SimpleBlogCatSearch?category=${quotedCat}"  
     131                               tal:attributes="href string:${fp/absolute_url}/SimpleBlogCatSearch?category=${quotedCat}" 
    114132                               title="category"><span  tal:omit-tag="" tal:content="cat"/></a></strong> 
    115133               </tal:categories> 
     
    128146         <div tal:condition="tballowed"> trackback URL: &nbsp; 
    129147               <tal:x replace="string:${obj/absolute_url}/sbtrackback"/> 
     148         </div> 
     149         <div tal:define="entryURL obj/absolute_url; 
     150                          entryTitle obj/Title; 
     151                          entryDescription obj/Description; 
     152                          entryDiggTopic obj/getDiggTopic; 
     153                          encodeURLData python:modules['Products.SimpleBlog.util'].encodeURLData;" 
     154              tal:omit-tag=""> 
     155                <span tal:condition="isDeliciousEnaled | obj/isDeliciousEnabled"> 
     156                   <a href="" 
     157                      title="" 
     158                      tal:define="url_data python:encodeURLData({'url':entryURL,'title':entryTitle});" 
     159                      tal:attributes="href string:http://del.icio.us/post?${url_data}; 
     160                                      title string:del.icio.us: ${entryTitle}"> 
     161                      <img src="" 
     162                           alt="del.icio.us" 
     163                           tal:attributes="src string:$portal_url/delicious.gif;" /></a> 
     164                </span>&nbsp;<span tal:condition="isDiggEnabled | obj/isDiggEnabled"> 
     165                    <a href="" 
     166                        title="" 
     167                        tal:define="url_data python:encodeURLData({'phase':'2','url':entryURL,'title':entryTitle,'bodytext':entryDescription,'topic':entryDiggTopic});" 
     168                        tal:attributes="href string:http://digg.com/submit?${url_data}; 
     169                                        title string:Digg: ${entryTitle}"> 
     170                    <img src="" 
     171                        alt="Digg" 
     172                        tal:attributes="src string:$portal_url/digg.gif;" /></a> 
     173                </span>&nbsp;<span tal:condition="isYahooEnabled | obj/isYahooEnabled"> 
     174                   <a href="" 
     175                      title="" 
     176                      tal:define="url_data python:encodeURLData({'u':entryURL,'t':entryTitle});" 
     177                      tal:attributes="href string:http://myweb2.search.yahoo.com/myresults/bookmarklet?${url_data}; 
     178                                      title string:Yahoo: ${entryTitle}"> 
     179                      <img src="" 
     180                           alt="Yahoo" 
     181                           tal:attributes="src string:$portal_url/yahoo.gif;" /></a> 
     182                </span>&nbsp;<span tal:condition="isGoogleEnabled | obj/isGoogleEnabled"> 
     183                   <a href="" 
     184                      title="" 
     185                      tal:define="url_data python:encodeURLData({'op':'edit','output':'popup','bkmk':entryURL,'title':entryTitle});" 
     186                      tal:attributes="href string:http://www.google.com/bookmarks/mark?${url_data}; 
     187                                      title string:Google: ${entryTitle}"> 
     188                      <img src="" 
     189                           alt="Google" 
     190                           tal:attributes="src string:$portal_url/google.gif;" /></a> 
     191                </span>&nbsp;<span tal:condition="isSpurlEnabled | obj/isSpurlEnabled"> 
     192                   <a href="" 
     193                      title="" 
     194                      tal:define="url_data python:encodeURLData({'url':entryURL,'title':entryTitle});" 
     195                      tal:attributes="href string:http://www.spurl.net/spurl.php?${url_data}; 
     196                                      title string:Spurl: ${entryTitle}"> 
     197                      <img src="" 
     198                           alt="Spurl" 
     199                           tal:attributes="src string:$portal_url/spurl.gif;" /></a> 
     200                </span> 
    130201         </div> 
    131202 
     
    205276    <tal:cats tal:repeat="cat python:here.simpleblog_tool.getSortedKeys(cats)"> 
    206277        <dd tal:define="pss modules/Products.PythonScripts.standard; 
     278                        fp nocall:fp | python:here.simpleblog_tool.getFrontPage(here); 
    207279                        quotedCat python:pss.url_quote(cat); 
    208280                        category python:'%s (%s)' %(cat,cats[cat])" 
     281            tal:condition="python:cats[cat]>0" 
    209282            tal:attributes="class python:test(toggle, 'portletItem even', 'portletItem odd')"> 
    210             <a tal:condition="python:cats[cat]>0"  href="#"  
    211                            tal:attributes="href string:${here/absolute_url}/SimpleBlogCatSearch?category=${quotedCat}; 
    212                                            title cat"><span tal:content="category"/></a> 
    213                         <span tal:condition="python:cats[cat]==0" tal:content="category"/>  
     283            <a href="#"  
     284               tal:attributes="href string:${fp/absolute_url}/SimpleBlogCatSearch?category=${quotedCat}; 
     285                               title cat"><span tal:content="category"/></a> 
    214286            <tal:toggle tal:define="global toggle python:test(toggle==1,0,1)"/> 
    215287        </dd> 
  • SimpleBlog/branches/plone-2.1-Blogging-APIs/util.py

    r554 r555  
    6161                  blog_name = blog_name, 
    6262                  excerpt = excerpt) 
     63 
     64def encodeURLData(data_dict): 
     65    """ encode URL data """ 
     66    return urllib.urlencode(data_dict)