Changeset 98
- Timestamp:
- 09/23/06 00:20:10 (2 years ago)
- Files:
-
- trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/App/FeedsWidget.pm (modified) (11 diffs)
- trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/Feeds/Find.pm (modified) (1 diff)
- trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/Feeds/Lite.pm (modified) (2 diffs)
- trunk/feeds-app-lite/plugins/feeds-app-lite/lib/MT/Feeds/Lite/CacheMgr.pm (modified) (1 diff)
- trunk/feeds-app-lite/plugins/feeds-app-lite/mt-feeds.pl (modified) (11 diffs)
- trunk/feeds-app-lite/plugins/feeds-app-lite/tmpl/select.tmpl (modified) (1 diff)
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 1 3 package MT::App::FeedsWidget; 2 4 use strict; … … 13 15 save => \&save 14 16 ); 17 my %param = @_; 15 18 $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'; 18 21 $app->{requires_login} = 1; 19 22 $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 ); 22 29 $app; 23 30 } … … 32 39 $p->{need_uri} = $app->param('need_uri'); 33 40 $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'); 38 57 39 58 $app->{breadcrumbs}[-1]{is_last} = 1; … … 58 77 $p->{not_found} = 1; 59 78 $p->{wizard_uri} = $app->uri . '?blog_id=' . $blog_id; 60 $p->{uri} = $uri; 79 $p->{uri} = $uri; 61 80 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; 64 83 } 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'); 69 101 return $app->build_page("msg.tmpl", $p); 70 102 } elsif (@feeds == 1) { # skip to the next step if only one choice … … 75 107 } 76 108 MT::Util::mark_odd_rows(\@feeds); 77 $p->{feeds} = \@feeds;109 $p->{feeds} = \@feeds; 78 110 $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'); 83 127 $app->build_page("select.tmpl", $p); 84 128 } … … 100 144 $p->{wizard_uri} = $app->uri . '?blog_id=' . $blog_id; 101 145 $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'); 106 163 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; 109 166 } 110 167 return $app->build_page("msg.tmpl", $p); 111 168 } 112 169 $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'); 119 188 $app->build_page("config.tmpl", $p); 120 189 } … … 131 200 my $lastn = $app->param('lastn'); 132 201 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); 137 207 require MT::Template; 138 my $i ;208 my $i = 0; 139 209 map { $_->remove } MT::Template->load({blog_id => '', type => 'custom'}); 140 210 while ( … … 144 214 ) { 145 215 $i++; 146 $name = "Widget: $title $i"; 216 my $suffix = " $i"; 217 $name = substr("Widget: $title", 0, 50 - length($suffix)); 218 $name .= $suffix; 147 219 } 148 220 my $tmpl = MT::Template->new; … … 158 230 <h2 class="module-header">$title</h2> 159 231 <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> 161 233 </MTFeedEntries></ul> 162 234 </MTFeed> … … 171 243 $p->{wizard_uri} = $app->uri . '?blog_id=' . $blog_id; 172 244 $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'); 177 261 if ($app->wm_url) { 178 262 $p->{wm_url} = $app->wm_url . '?blog_id=' . $blog_id; 179 $p->{wm_is} = 1;263 $p->{wm_is} = 1; 180 264 } 181 265 $p->{help_url} = $app->{help_url}; … … 186 270 my $app = shift; 187 271 eval { require WidgetManager::App; }; 188 # if { MT::Plugin::WidgetManager::VERSION } is better189 190 272 unless ($@) { 191 my $wm = WidgetManager::App->new( Directory => $app->config_dir);273 my $wm = WidgetManager::App->new(Directory => $app->config_dir); 192 274 return $wm->{script_url}; 193 275 } 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 3 package MT::Feeds::Find; # Large parts sampled from Feed::Find. 3 4 use strict; 4 5 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 1 3 package MT::Feeds::Lite; 2 4 use strict; … … 83 85 my ($class, $xml) = @_; 84 86 my $self = bless {}, $class; 85 MT::Util::init_sax(); # Make sure XML::SAX knows about available parsers87 MT::Util::init_sax(); # Make sure XML::SAX knows about available parsers 86 88 require XML::Elemental; 87 89 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 1 3 package MT::Feeds::Lite::CacheMgr; 2 4 use 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 1 3 package MT::FeedsLite; 2 4 use strict; 3 5 4 6 use vars qw($VERSION); 5 $VERSION = '1.0 -dev';7 $VERSION = '1.01-dev'; 6 8 7 9 my $plugin = MT::Plugin::FeedsLite->new; 8 10 MT->add_plugin($plugin); 9 11 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");12 MT->add_plugin_action('blog', 'index.cgi?', "Create a feed widget"); 13 MT->add_plugin_action('list_template', 'index.cgi?', "Create a feed widget"); 12 14 13 15 use MT::Template::Context; … … 24 26 use constant ENTRY => 'MT::Plugin::FeedsLite::entry'; 25 27 28 # Returns link if okay, "#" if not. 29 sub 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/�*58(?:=;|[^0-9])/:/; 37 $dec_val =~ s/�*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 26 48 sub feed { 27 49 my ($ctx, $args, $cond) = @_; … … 29 51 or return 30 52 $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' 33 55 ) 34 56 ); … … 48 70 49 71 sub 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; 54 85 } 55 86 … … 58 89 my $lite = $ctx->stash(LITE) 59 90 or return _error($ctx); 60 $lite->find_link($lite->feed); 91 my $link = $lite->find_link($lite->feed); 92 sanitize_link($link); 61 93 } 62 94 … … 83 115 84 116 sub entry_title { 85 my $ctx = shift;117 my ($ctx, $args, $cond) = @_; 86 118 my $lite = $ctx->stash(LITE) 87 119 or return _error($ctx); 88 120 my $entry = $ctx->stash(ENTRY) 89 121 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; 91 131 } 92 132 … … 97 137 my $entry = $ctx->stash(ENTRY) 98 138 or return _error($ctx); 99 $lite->find_link($entry); 139 my $link = $lite->find_link($entry); 140 sanitize_link($link); 100 141 } 101 142 … … 105 146 or return 106 147 $ctx->error( 107 MT->translate(148 $plugin->translate( 108 149 "'[_1]' is a required argument of [_2]", 'uri', 109 150 'MTFeedInclude' … … 113 154 my $body = <<BODY; 114 155 <MTFeed uri="$uri"> 115 <h2>< MTFeedTitle encode_html="1"></h2>156 <h2><\$MTFeedTitle\$></h2> 116 157 <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> 118 159 </MTFeedEntries></ul> 119 160 </MTFeed> … … 130 171 131 172 sub _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.', 133 174 $_[0]->stash('tag'))); 134 175 } … … 160 201 my $blog_id = $scope; 161 202 $blog_id =~ s{\D}{}g; 162 $param->{blog_id} = $blog_id;203 $param->{blog_id} = $blog_id; 163 204 $param->{wizard_uri} = $plugin->envelope . '/index.cgi'; 164 205 } trunk/feeds-app-lite/plugins/feeds-app-lite/tmpl/select.tmpl
r66 r98 3 3 <h2><MT_TRANS phrase="Feeds.App Lite Widget Creator"></h2> 4 4 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> 6 6 7 7 <form method="post" action="<TMPL_VAR NAME=SCRIPT_URL>">
