Changeset 98

Show
Ignore:
Timestamp:
09/23/06 00:20:10 (2 years ago)
Author:
bchoate
Message:

1.01 updates.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/App/FeedsWidget.pm

    r66 r98  
     1# Copyright 2002-2006 Appnel Internet Solutions, LLC 
     2# This code is distributed with permission by Six Apart 
    13package MT::App::FeedsWidget; 
    24use strict; 
     
    1315                      save     => \&save 
    1416    ); 
     17    my %param = @_; 
    1518    $app->{default_mode}   = 'start'; 
    16     $app->{template_dir}   = 'cms'; 
    17     $app->{plugins_dir}    = 'feeds-app-lite'; 
     19    $app->{plugins_dir}    = $param{FeedsAppDirectory} || 'feeds-app-lite'; 
     20    $app->{feedsapp}       = $param{FeedsAppName} || 'Feeds.App Lite'; 
    1821    $app->{requires_login} = 1; 
    1922    $app->{user_class}     = 'MT::Author'; 
    20     $app->{help_url} = File::Spec->catdir($app->static_path, 'plugins',  
    21                         'feeds-app-lite', 'docs', 'index.html'); 
     23    $app->{help_url}       = 
     24      join("/", 
     25           $app->static_path,   'plugins', 
     26           $app->{plugins_dir}, 'docs', 
     27           'index.html' 
     28      ); 
    2229    $app; 
    2330} 
     
    3239    $p->{need_uri} = $app->param('need_uri'); 
    3340    $p->{help_url} = $app->{help_url}; 
    34     $app->add_breadcrumb("Main Menu", $app->mt_uri); 
    35     $app->add_breadcrumb($blog->name, $app->mt_uri(mode => 'menu', args => { blog_id => $blog_id })); 
    36     $app->add_breadcrumb('Templates', $app->mt_uri(mode => 'list', args => { _type => 'template', blog_id => $blog_id })); 
    37     $app->add_breadcrumb('Feeds.App Lite', 'index.cgi'); 
     41    $app->add_breadcrumb($app->translate("Main Menu"), $app->mt_uri); 
     42    $app->add_breadcrumb( 
     43                         $blog->name, 
     44                         $app->mt_uri( 
     45                                      mode => 'menu', 
     46                                      args => {blog_id => $blog_id} 
     47                         ) 
     48    ); 
     49    $app->add_breadcrumb( 
     50                         $app->translate('Templates'), 
     51                         $app->mt_uri( 
     52                              mode => 'list', 
     53                              args => {_type => 'template', blog_id => $blog_id} 
     54                         ) 
     55    ); 
     56    $app->add_breadcrumb($app->translate($app->{feedsapp}), 'index.cgi'); 
    3857 
    3958    $app->{breadcrumbs}[-1]{is_last} = 1; 
     
    5877        $p->{not_found}  = 1; 
    5978        $p->{wizard_uri} = $app->uri . '?blog_id=' . $blog_id; 
    60         $p->{uri}        = $uri;        
     79        $p->{uri}        = $uri; 
    6180        if ($app->wm_url) { 
    62            $p->{wm_url} = $app->wm_url . '?blog_id=' . $blog_id; 
    63            $p->{wm_is} = 1; 
     81            $p->{wm_url} = $app->wm_url . '?blog_id=' . $blog_id; 
     82            $p->{wm_is} = 1; 
    6483        } 
    65         $app->add_breadcrumb("Main Menu", $app->mt_uri); 
    66         $app->add_breadcrumb($blog->name, $app->mt_uri(mode => 'menu', args => { blog_id => $blog_id })); 
    67         $app->add_breadcrumb('Templates', $app->mt_uri(mode => 'list', args => { _type => 'template', blog_id => $blog_id })); 
    68         $app->add_breadcrumb('Feeds.App Lite', 'index.cgi'); 
     84        $app->add_breadcrumb($app->translate("Main Menu"), $app->mt_uri); 
     85        $app->add_breadcrumb( 
     86                             $blog->name, 
     87                             $app->mt_uri( 
     88                                          mode => 'menu', 
     89                                          args => {blog_id => $blog_id} 
     90                             ) 
     91        ); 
     92        $app->add_breadcrumb( 
     93                             $app->translate('Templates'), 
     94                             $app->mt_uri( 
     95                                    mode => 'list', 
     96                                    args => 
     97                                      {_type => 'template', blog_id => $blog_id} 
     98                             ) 
     99        ); 
     100        $app->add_breadcrumb($app->translate($app->{feedsapp}), 'index.cgi'); 
    69101        return $app->build_page("msg.tmpl", $p); 
    70102    } elsif (@feeds == 1) {    # skip to the next step if only one choice 
     
    75107    } 
    76108    MT::Util::mark_odd_rows(\@feeds); 
    77     $p->{feeds} = \@feeds; 
     109    $p->{feeds}    = \@feeds; 
    78110    $p->{help_url} = $app->{help_url}; 
    79     $app->add_breadcrumb("Main Menu", $app->mt_uri); 
    80     $app->add_breadcrumb($blog->name, $app->mt_uri(mode => 'menu', args => { blog_id => $blog_id })); 
    81     $app->add_breadcrumb('Templates', $app->mt_uri(mode => 'list', args => { _type => 'template', blog_id => $blog_id })); 
    82     $app->add_breadcrumb('Feeds.App Lite', 'index.cgi'); 
     111    $app->add_breadcrumb($app->translate("Main Menu"), $app->mt_uri); 
     112    $app->add_breadcrumb( 
     113                         $blog->name, 
     114                         $app->mt_uri( 
     115                                      mode => 'menu', 
     116                                      args => {blog_id => $blog_id} 
     117                         ) 
     118    ); 
     119    $app->add_breadcrumb( 
     120                         $app->translate('Templates'), 
     121                         $app->mt_uri( 
     122                              mode => 'list', 
     123                              args => {_type => 'template', blog_id => $blog_id} 
     124                         ) 
     125    ); 
     126    $app->add_breadcrumb($app->translate($app->{feedsapp}), 'index.cgi'); 
    83127    $app->build_page("select.tmpl", $p); 
    84128} 
     
    100144        $p->{wizard_uri} = $app->uri . '?blog_id=' . $blog_id; 
    101145        $p->{uri}        = $uri; 
    102         $app->add_breadcrumb("Main Menu", $app->mt_uri); 
    103         $app->add_breadcrumb($blog->name, $app->mt_uri(mode => 'menu', args => { blog_id => $blog_id })); 
    104         $app->add_breadcrumb('Templates', $app->mt_uri(mode => 'list', args => { _type => 'template', blog_id => $blog_id })); 
    105         $app->add_breadcrumb('Feeds.App Lite', 'index.cgi'); 
     146        $app->add_breadcrumb($app->translate("Main Menu"), $app->mt_uri); 
     147        $app->add_breadcrumb( 
     148                             $blog->name, 
     149                             $app->mt_uri( 
     150                                          mode => 'menu', 
     151                                          args => {blog_id => $blog_id} 
     152                             ) 
     153        ); 
     154        $app->add_breadcrumb( 
     155                             $app->translate('Templates'), 
     156                             $app->mt_uri( 
     157                                    mode => 'list', 
     158                                    args => 
     159                                      {_type => 'template', blog_id => $blog_id} 
     160                             ) 
     161        ); 
     162        $app->add_breadcrumb($app->translate($app->{feedsapp}), 'index.cgi'); 
    106163        if ($app->wm_url) { 
    107            $p->{wm_url} = $app->wm_url . '?blog_id=' . $blog_id; 
    108            $p->{wm_is} = 1; 
     164            $p->{wm_url} = $app->wm_url . '?blog_id=' . $blog_id; 
     165            $p->{wm_is} = 1; 
    109166        } 
    110167        return $app->build_page("msg.tmpl", $p); 
    111168    } 
    112169    $p->{feed_title} = $feed->find_title($feed->feed) || $uri; 
    113     $p->{feed_uri} = $uri; 
    114     $p->{help_url} = $app->{help_url};     
    115     $app->add_breadcrumb("Main Menu", $app->mt_uri); 
    116     $app->add_breadcrumb($blog->name, $app->mt_uri(mode => 'menu', args => { blog_id => $blog_id })); 
    117     $app->add_breadcrumb('Templates', $app->mt_uri(mode => 'list', args => { _type => 'template', blog_id => $blog_id })); 
    118     $app->add_breadcrumb('Feeds.App Lite', 'index.cgi'); 
     170    $p->{feed_uri}   = $uri; 
     171    $p->{help_url}   = $app->{help_url}; 
     172    $app->add_breadcrumb($app->translate("Main Menu"), $app->mt_uri); 
     173    $app->add_breadcrumb( 
     174                         $blog->name, 
     175                         $app->mt_uri( 
     176                                      mode => 'menu', 
     177                                      args => {blog_id => $blog_id} 
     178                         ) 
     179    ); 
     180    $app->add_breadcrumb( 
     181                         $app->translate('Templates'), 
     182                         $app->mt_uri( 
     183                              mode => 'list', 
     184                              args => {_type => 'template', blog_id => $blog_id} 
     185                         ) 
     186    ); 
     187    $app->add_breadcrumb($app->translate($app->{feedsapp}), 'index.cgi'); 
    119188    $app->build_page("config.tmpl", $p); 
    120189} 
     
    131200    my $lastn = $app->param('lastn'); 
    132201    my $title = $app->param('feed_title'); 
    133     # XXX Hack-truncate feed widget title to the magic literal of 42 characters. 
    134     $title = substr $title, 0, 42; 
    135     my $p     = {blog_id => $blog_id, site_url => $blog->site_url}; 
    136     my $name  = "Widget: $title"; 
     202 
     203    my $p = {blog_id => $blog_id, site_url => $blog->site_url}; 
     204    # $title here is unknown length, so trim resulting template name to 
     205    # 50 bytes, which is the size of the template name field. 
     206    my $name = substr("Widget: $title", 0, 50); 
    137207    require MT::Template; 
    138     my $i
     208    my $i = 0
    139209    map { $_->remove } MT::Template->load({blog_id => '', type => 'custom'}); 
    140210    while ( 
     
    144214      ) { 
    145215        $i++; 
    146         $name = "Widget: $title $i"; 
     216        my $suffix = " $i"; 
     217        $name = substr("Widget: $title", 0, 50 - length($suffix)); 
     218        $name .= $suffix; 
    147219    } 
    148220    my $tmpl = MT::Template->new; 
     
    158230<h2 class="module-header">$title</h2> 
    159231<ul><MTFeedEntries$lastn> 
    160 <li><a href="<MTFeedEntryLink>"><MTFeedEntryTitle encode_html="1"></a></li> 
     232<li><a href="<\$MTFeedEntryLink encode_html="1"\$>"><\$MTFeedEntryTitle\$></a></li> 
    161233</MTFeedEntries></ul> 
    162234</MTFeed> 
     
    171243    $p->{wizard_uri} = $app->uri . '?blog_id=' . $blog_id; 
    172244    $p->{uri}        = $uri; 
    173     $app->add_breadcrumb("Main Menu", $app->mt_uri); 
    174     $app->add_breadcrumb($blog->name, $app->mt_uri(mode => 'menu', args => { blog_id => $blog_id })); 
    175     $app->add_breadcrumb('Templates', $app->mt_uri(mode => 'list', args => { _type => 'template', blog_id => $blog_id })); 
    176     $app->add_breadcrumb('Feeds.App Lite', 'index.cgi'); 
     245    $app->add_breadcrumb($app->translate("Main Menu"), $app->mt_uri); 
     246    $app->add_breadcrumb( 
     247                         $blog->name, 
     248                         $app->mt_uri( 
     249                                      mode => 'menu', 
     250                                      args => {blog_id => $blog_id} 
     251                         ) 
     252    ); 
     253    $app->add_breadcrumb( 
     254                         $app->translate('Templates'), 
     255                         $app->mt_uri( 
     256                              mode => 'list', 
     257                              args => {_type => 'template', blog_id => $blog_id} 
     258                         ) 
     259    ); 
     260    $app->add_breadcrumb($app->translate($app->{feedsapp}), 'index.cgi'); 
    177261    if ($app->wm_url) { 
    178262        $p->{wm_url} = $app->wm_url . '?blog_id=' . $blog_id; 
    179         $p->{wm_is} = 1; 
     263        $p->{wm_is} = 1; 
    180264    } 
    181265    $p->{help_url} = $app->{help_url}; 
     
    186270    my $app = shift; 
    187271    eval { require WidgetManager::App; }; 
    188     # if { MT::Plugin::WidgetManager::VERSION } is better 
    189  
    190272    unless ($@) { 
    191         my $wm = WidgetManager::App->new( Directory => $app->config_dir ); 
     273        my $wm = WidgetManager::App->new(Directory => $app->config_dir); 
    192274        return $wm->{script_url}; 
    193275    } 
  • trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/Feeds/Find.pm

    r66 r98  
    1 # Large parts sampled from Feed::Find. 
    2 package MT::Feeds::Find; 
     1# Copyright 2002-2006 Appnel Internet Solutions, LLC 
     2# This code is distributed with permission by Six Apart 
     3package MT::Feeds::Find; # Large parts sampled from Feed::Find. 
    34use strict; 
    45 
  • trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/Feeds/Lite.pm

    r66 r98  
     1# Copyright 2002-2006 Appnel Internet Solutions, LLC 
     2# This code is distributed with permission by Six Apart 
    13package MT::Feeds::Lite; 
    24use strict; 
     
    8385    my ($class, $xml) = @_; 
    8486    my $self = bless {}, $class; 
    85     MT::Util::init_sax(); # Make sure XML::SAX knows about available parsers 
     87    MT::Util::init_sax();    # Make sure XML::SAX knows about available parsers 
    8688    require XML::Elemental; 
    8789    require XML::Elemental::Util; 
  • trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/Feeds/Lite/CacheMgr.pm

    r41 r98  
     1# Copyright 2002-2006 Appnel Internet Solutions, LLC 
     2# This code is distributed with permission by Six Apart 
    13package MT::Feeds::Lite::CacheMgr; 
    24use strict; 
  • trunk/feeds-app-lite/plugins/feeds-app-lite/mt-feeds.pl

    r69 r98  
     1# Copyright 2002-2006 Appnel Internet Solutions, LLC 
     2# This code is distributed with permission by Six Apart 
    13package MT::FeedsLite; 
    24use strict; 
    35 
    46use vars qw($VERSION); 
    5 $VERSION = '1.0-dev'; 
     7$VERSION = '1.01-dev'; 
    68 
    79my $plugin = MT::Plugin::FeedsLite->new; 
    810MT->add_plugin($plugin); 
    911 
    10 MT->add_plugin_action('blog','index.cgi?', "Create a feed widget"); 
    11 MT->add_plugin_action('list_template','index.cgi?', "Create a feed widget"); 
     12MT->add_plugin_action('blog',          'index.cgi?', "Create a feed widget"); 
     13MT->add_plugin_action('list_template', 'index.cgi?', "Create a feed widget"); 
    1214 
    1315use MT::Template::Context; 
     
    2426use constant ENTRY => 'MT::Plugin::FeedsLite::entry'; 
    2527 
     28# Returns link if okay, "#" if not. 
     29sub sanitize_link { 
     30    my $link = shift; 
     31    $link = '' unless defined $link; 
     32    $link =~ s/^\s+//; 
     33    # check for malicious protocols 
     34    require MT::Util; 
     35    my $dec_val = MT::Util::decode_html($link); 
     36    $dec_val =~ s/&#0*58(?:=;|[^0-9])/:/; 
     37    $dec_val =~ s/&#x0*3[Aa](?:=;|[^a-fA-F0-9])/:/; 
     38    if ((my $prot) = $dec_val =~ m/^(.+?):/) { 
     39        return "#" if $prot =~ m/[\r\n\t]/; 
     40        $prot =~ s/\s+//gs; 
     41        return "#" if $prot =~ m/[^a-zA-Z0-9\+]/; 
     42        return "#" if $prot =~ m/script$/i; 
     43    } 
     44    return "#" unless $link =~ m/^https?:/i; 
     45    $link; 
     46} 
     47 
    2648sub feed { 
    2749    my ($ctx, $args, $cond) = @_; 
     
    2951      or return 
    3052      $ctx->error( 
    31          MT->translate( 
    32                        "'[_1]' is a required argument of [_2]", 'uri', 'MTFeed
     53         $plugin->translate( 
     54                       "'[_1]' is a required argument of [_2]", 'uri', 'MTFeeds
    3355         ) 
    3456      ); 
     
    4870 
    4971sub feed_title { 
    50     my $ctx  = shift; 
    51     my $lite = $ctx->stash(LITE) 
    52       or return _error($ctx); 
    53     $lite->find_title($lite->feed); 
     72    my ($ctx, $args) = @_; 
     73    my $lite = $ctx->stash(LITE) 
     74      or return _error($ctx); 
     75    require MT::Util; 
     76    my $title = $lite->find_title($lite->feed); 
     77    $title = '' unless defined $title; 
     78    $title = MT::Util::remove_html($title) 
     79        unless (exists $args->{remove_html}) && !$args->{remove_html}; 
     80    $title = MT::Util::encode_html($title) 
     81        unless (exists $args->{encode_html}) && !$args->{encode_html}; 
     82    delete $args->{encode_html} if exists $args->{encode_html}; 
     83    delete $args->{remove_html} if exists $args->{remove_html}; 
     84    $title; 
    5485} 
    5586 
     
    5889    my $lite = $ctx->stash(LITE) 
    5990      or return _error($ctx); 
    60     $lite->find_link($lite->feed); 
     91    my $link = $lite->find_link($lite->feed); 
     92    sanitize_link($link); 
    6193} 
    6294 
     
    83115 
    84116sub entry_title { 
    85     my $ctx  = shift
     117    my ($ctx, $args, $cond) = @_
    86118    my $lite = $ctx->stash(LITE) 
    87119      or return _error($ctx); 
    88120    my $entry = $ctx->stash(ENTRY) 
    89121      or return _error($ctx); 
    90     $lite->find_title($entry); 
     122    my $title = $lite->find_title($entry); 
     123    $title = '' unless defined $title; 
     124    $title = MT::Util::remove_html($title) 
     125        unless (exists $args->{remove_html}) && !$args->{remove_html}; 
     126    $title = MT::Util::encode_html($title) 
     127        unless (exists $args->{encode_html}) && !$args->{encode_html}; 
     128    delete $args->{encode_html} if exists $args->{encode_html}; 
     129    delete $args->{remove_html} if exists $args->{remove_html}; 
     130    $title; 
    91131} 
    92132 
     
    97137    my $entry = $ctx->stash(ENTRY) 
    98138      or return _error($ctx); 
    99     $lite->find_link($entry); 
     139    my $link = $lite->find_link($entry); 
     140    sanitize_link($link); 
    100141} 
    101142 
     
    105146      or return 
    106147      $ctx->error( 
    107                   MT->translate( 
     148                  $plugin->translate( 
    108149                                "'[_1]' is a required argument of [_2]", 'uri', 
    109150                                'MTFeedInclude' 
     
    113154    my $body  = <<BODY; 
    114155<MTFeed uri="$uri"> 
    115 <h2><MTFeedTitle encode_html="1"></h2> 
     156<h2><\$MTFeedTitle\$></h2> 
    116157<ul><MTFeedEntries$lastn> 
    117 <li><a href="<MTFeedEntryLink>"><MTFeedEntryTitle encode_html="1"></a></li> 
     158<li><a href="<\$MTFeedEntryLink encode_html="1"\$>"><\$MTFeedEntryTitle\$></a></li> 
    118159</MTFeedEntries></ul> 
    119160</MTFeed> 
     
    130171 
    131172sub _error { 
    132     $_[0]->error(MT->translate('MT[_1] was not used in the proper context.', 
     173    $_[0]->error($plugin->translate('MT[_1] was not used in the proper context.', 
    133174                 $_[0]->stash('tag'))); 
    134175} 
     
    160201    my $blog_id = $scope; 
    161202    $blog_id =~ s{\D}{}g; 
    162     $param->{blog_id} = $blog_id; 
     203    $param->{blog_id}    = $blog_id; 
    163204    $param->{wizard_uri} = $plugin->envelope . '/index.cgi'; 
    164205} 
  • trunk/feeds-app-lite/plugins/feeds-app-lite/tmpl/select.tmpl

    r66 r98  
    33<h2><MT_TRANS phrase="Feeds.App Lite Widget Creator"></h2> 
    44 
    5 <p><MT_TRANS phrase="Multiple feeds were discovered. Select the feed you wish to use. Feeds.App lite supports text-only RSS 1.0, 2.0 and Atom feeds."></p> 
     5<p><MT_TRANS phrase="Multiple feeds were discovered. Select the feed you wish to use. Feeds.App Lite supports text-only RSS 1.0, 2.0 and Atom feeds."></p> 
    66 
    77<form method="post" action="<TMPL_VAR NAME=SCRIPT_URL>">