[dw-free] move /syn to /feeds
[commit: http://hg.dwscoalition.org/dw-free/rev/0b30744ab665]
http://bugs.dwscoalition.org/show_bug.cgi?id=2396
Rename links to reflect site terminology.
Patch by
denise.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2396
Rename links to reflect site terminology.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- cgi-bin/redirect.dat
- htdocs/feeds/index.bml
- htdocs/feeds/index.bml.text
- htdocs/feeds/list.bml
- htdocs/feeds/list.bml.text
- htdocs/feeds/raw.bml
- htdocs/syn/index.bml
- htdocs/syn/index.bml.text
- htdocs/syn/list.bml
- htdocs/syn/list.bml.text
- htdocs/syn/raw.bml
-------------------------------------------------------------------------------- diff -r e83f4a208a85 -r 0b30744ab665 cgi-bin/redirect.dat --- a/cgi-bin/redirect.dat Thu Feb 25 16:52:24 2010 +0000 +++ b/cgi-bin/redirect.dat Tue Mar 02 10:29:53 2010 -0600 @@ -55,3 +55,10 @@ /translate/searchform.bml /admin/translate/searchform /translate/teams.bml /admin/translate/teams /translate/welcome.bml /admin/translate/welcome +/syn /feeds +/syn/ /feeds +/syn/index.bml /feeds +/syn/list /feeds/list +/syn/list.bml /feeds/list +/syn/raw /feeds/raw +/syn/raw.bml /feeds/raw diff -r e83f4a208a85 -r 0b30744ab665 htdocs/feeds/index.bml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/feeds/index.bml Tue Mar 02 10:29:53 2010 -0600 @@ -0,0 +1,264 @@ +<?page +title=><?_ml .title _ml?> +body<= + +<?_code +{ + use strict; + use vars qw(%POST); + + my $dbh = LJ::get_db_writer(); + my $u = LJ::get_remote(); + + unless ($u) { + return "<?needlogin?>"; + } + return "<?h1 $ML{'error.suspended.title'} h1?><?p $ML{'error.suspended.text'} p?>" if $u->is_suspended; + + if (LJ::did_post() && $POST{'userid'} != $u->{'userid'}) { + return "<?h1 $ML{'.invalid.submission'} h1?><?p $ML{'.user.nomatch'} p?>"; + } + + my $error = sub { + return "<?h1 $ML{'Error'} h1?><?p $_[0] p?><?p " . + BML::ml('Backlink', {'link' => '/syn/', 'text' => $ML{'.back'}}) . " p?>"; + }; + + # add custom feed + if ($POST{'action:addcustom'} || $GET{'url'}) { + my $acct = LJ::trim($POST{'acct'}); + my $url = LJ::trim($POST{'synurl'} || $GET{'url'}); + $url =~ s!^feed://!http://!; # eg, feed://www.example.com/ + $url =~ s/^feed://; # eg, feed:http://www.example.com/ + + if ($acct ne "") { + return $error->($ML{'.invalid.accountname'}) + if $acct && $acct !~ /^\w{3,20}$/; # This needs to be 5 less then the username limt. + return $error->( $ML{'.invalid.reserved'} ) + if LJ::User->is_protected_username( $acct ); + # Postpend _feed here, username should be valid by this point. + $acct .= "_feed"; + } + if ($url ne "") { + return $error->($ML{'.invalid.url'}) + unless $url =~ m!^http://([^:/]+)(?::(\d+))?!; + my $hostname = $1; + my $port = $2; + return $error->($ML{'.invalid.cantadd'}) + if $hostname =~ /\Q$LJ::DOMAIN\E/i; + + return $error->($ML{'.invalid.port'}) + if defined $port && $port != 80 && $port < 1024; + $url =~ s/:80// if $port == 80; + } + + my $su; # account to add + if ($url) { + $su = $dbh->selectrow_hashref("SELECT u.user, s.* FROM syndicated s, useridmap u ". + "WHERE s.synurl=? AND s.userid=u.userid", + undef, $url); + + unless ($su) { + # check cap to create new feeds + return $error->($ML{'.error.nocreate'}) + unless $u->can_create_feeds; + + # if no account name, give them a proper entry form to pick one, but don't reprompt + # for the url, just pass that through (we'll recheck it anyway, though) + unless ($acct) { + my $ret .= "<?h1 $ML{'.create'} h1?><?p " . BML::ml( '.create.name2', { 'feedurl' => LJ::eurl( $url ) } ) . " p?>"; + $ret .= "<form method='post' action='./'>"; + $ret .= LJ::html_hidden("userid", $u->{'userid'}, 'synurl', $url); + $ret .= "<blockquote>"; + $ret .= "<p>$ML{'.account'} <input size='15' maxlength='20' name='acct' />"; + $ret .= "<p><input name='action:addcustom' type='submit' value='" . LJ::ehtml($ML{'.create'}) . "' />"; + $ret .= "</blockquote></form>"; + return $ret; + } + + return "<?h1 $ML{'.invalid.needname.title'} h1?><?p $ML{'.invalid.needname.text'} p?>" + unless $acct; + + # create a safeagent to fetch the feed for validation purposes + my $ua = LJ::get_useragent( + role => 'syn_new', + max_size => (1024 * 300), + ); + $ua->agent("$LJ::SITENAME ($LJ::ADMIN_EMAIL; Initial check)"); + + my $res = $ua->get($url); + my $content = $res && $res->is_success ? $res->content : undef; + + unless ($content) { + my $msg = $u->show_raw_errors ? $res->status_line : $ML{'.invalid.http.text'}; + return "<?h1 $ML{'.invalid.http.title'} h1?><?p $msg p?>"; + } + + # Start out with the syn_url being equal to the url + # they entered of the resource. If we end up parsing + # the resource and finding it has a link to the real + # feed, we then want to save the real feed address + # to suck from. + my $syn_url = $url; + # analyze link/meta tags + while ($content =~ m!<(link|meta)\b([^>]+)>!g) { + my ($type, $val) = ($1, $2); + # RSS/Atom + # <link rel="alternate" type="application/(?:rss|atom)+xml" title="RSS" href="http://...." /> + # FIXME: deal with relative paths (eg, href="blah.rss") ... right now we need the full URI + if ($type eq "link" && + $val =~ m!rel=.alternate.!i && + $val =~ m!type=.application/(?:rss|atom)\+xml.!i && + $val =~ m!href=[\"\'](http://[^\"\']+)[\"\']!i) { + $syn_url = $1; + } + } + + + # Did we find a link to the real feed? If so, + # grab it + if ($syn_url ne $url) { + my $adu = $dbh->selectrow_hashref("SELECT u.user FROM syndicated s, useridmap u ". + "WHERE s.synurl=? AND s.userid=u.userid", + undef, $syn_url); + if ($adu) { + return BML::redirect("$LJ::SITEROOT/manage/circle/add?user=$adu->{user}&action=subscribe"); + } else { + $res = $ua->get($syn_url); + $content = $res && $res->is_success ? $res->content : ""; + } + } + + # check whatever we did get for validity (or pseudo-validity) + return "<?h1 $ML{'.invalid.notrss.title'} h1?><?p $ML{'.invalid.notrss.text'} p?>" + unless $content =~ m/<(\w+:)?(?:rss|feed|RDF)/; # Must have a <[?:]rss <[?:]feed (for Atom support) <[?:]RDF + + # create the feed account + my $synfeed = LJ::User->create_syndicated( + 'user' => $acct, + 'feedurl' => $syn_url, + ); + + return "<?h1 $ML{'.invalid.inuse.title'} h1?><?p $ML{'.invalid.inuse.text'} p?>" + unless $synfeed; + + $u->add_edge( $synfeed, watch => 1 ); + + $su = $dbh->selectrow_hashref("SELECT u.user, s.* FROM syndicated s, useridmap u ". + "WHERE s.userid=? AND s.userid=u.userid", + undef, $synfeed->id); + } + + } elsif ($acct) { + # account but no URL, we can add this in any case + $su = $dbh->selectrow_hashref("SELECT u.user, s.* FROM syndicated s, useridmap u ". + "WHERE u.userid=s.userid AND u.user=?", + undef, $acct); + unless ($su) { + return $error->($ML{'.invalid.notexist'}); + } + } else { + # need at least a URL + return $error->($ML{'.invalid.needurl'}); + } + + return $error->($ML{'.error.unknown'}) unless $su; + + # at this point, we have a new account, or an old account, but we have an account, so + # let's redirect them to the add page + return BML::redirect("$LJ::SITEROOT/manage/circle/add?user=$su->{user}&action=subscribe"); + } + + # get most popular feeds from memcache + my $popsyn = LJ::Syn::get_popular_feeds(); + + # load user's watch list so we can strip feeds they already watch + my %watched = map { $_ => 1 } $u->watched_userids; + + # populate @pop and add users they've chosen to add + my @pop; + my %urls; + my %names; + for (0 .. 99) { + next if not defined $popsyn->[$_]; + my ($user, $name, $suserid, $url, $count) = @{ $popsyn->[$_] }; + $names{$user} = $name; + + my $suser = LJ::load_userid($suserid); + LJ::load_user_props($suser, 'url'); + $urls{$user} = $suser->{url}; + + # skip suspended/deleted accounts, already watched feeds + next if $watched{$suserid} || !$suser->is_visible; + + if ($POST{'action:add'} && $POST{"add_$user"}) { + $u->add_edge( $suser, watch => {} ); + } else { + push @pop, [ $user, $url, $count ]; + last if @pop >= 20; + } + } + + # intro paragraph + my $title = BML::ml('.using.title', {'sitename' => $LJ::SITENAME}); + my $ret = "<?h1 $title h1?><?p $ML{'.using.text'} p?>"; + $ret .= "<?p " . BML::ml('.top1000.text', {'aopts' => "href='$LJ::SITEROOT/syn/list'"}) . " p?>"; + + $ret .= "<form method='post' action='./'>"; + $ret .= LJ::html_hidden("userid", $u->{'userid'}); + + $ret .= "<?h1 $ML{'.add.byurl.title'} h1?><?p $ML{'.add.byurl.text'} p?>"; + unless ( $u->can_create_feeds ) { + my $inline; + if ($inline .= LJ::Hooks::run_hook("cprod_inline", $u, 'Syn')) { + $ret .= $inline; + } else { + $ret .= "<p>".BML::ml('cprod.syn.text.v1')."</p>"; + } + } + $ret .= "<blockquote>"; + $ret .= "<p>$ML{'.feed.url'} <input size='40' maxlength='255' name='synurl' />"; + $ret .= "<p><input name='action:addcustom' type='submit' value='" . LJ::ehtml($ML{'.add'}) . "' />"; + $ret .= "</blockquote>"; + + $ret .= "</form>"; + + $ret .= "<form method='post' action='./'>"; + $ret .= LJ::html_hidden("userid", $u->{'userid'}); + + if (@pop) { + $ret .= "<?h1 $ML{'.add.pop.title'} h1?><?p $ML{'.add.pop.text'} p?>"; + $ret .= "<p><table cellpadding='3' style='margin-bottom: 10px; width: 80%;'>"; + $ret .= "<tr><td><b>$ML{'.table.account'}</b></td><td><b>$ML{'.table.feed'}</b></td><td></td>"; + $ret .= "<td align='right'><b>$ML{'.table.watchers'}</b></td></tr>"; + foreach (@pop) { + my ($user, $url, $count) = @$_; + $ret .= "<tr>"; + $ret .= "<td nowrap='nowrap' valign='top'><input type='checkbox' value='1' name='add_$user' /> "; + $ret .= LJ::ljuser($user, { 'type' => 'Y' }) . "</td>"; + $ret .= "<td valign='top'>"; + if ($urls{$user}) { + my $displayurl = $urls{$user}; + $displayurl = substr($urls{$user}, 0, 50) . "..." if length $displayurl > 60; + $ret .= "$names{$user}<br /><a href='$urls{$user}'>$displayurl</a></td>"; + } else { + $ret .= "$names{$user}</td>"; + } + $ret .= "<td valign='top'><a href='$url'>" . LJ::img('xml', '', { border => 0 }) . "</a></td>"; + $ret .= "<td align='right' valign='top'>$count</td>"; + $ret .= "</tr>"; + } + $ret .= "<tr><td align='left' colspan='4'>"; + $ret .= "<input type='submit' name='action:add' value='" . LJ::ehtml($ML{'.add.selected'}) . "'>"; + $ret .= "</td></tr>"; + $ret .= "</table>"; + } + + $ret .= "</form>"; + + return $ret; +} +_code?> + +<=body +page?> diff -r e83f4a208a85 -r 0b30744ab665 htdocs/feeds/index.bml.text --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/feeds/index.bml.text Tue Mar 02 10:29:53 2010 -0600 @@ -0,0 +1,77 @@ +;; -*- coding: utf-8 -*- +.account=Account: + +.add=Add Feed + +.add.byurl.text=Add a feed to your friends list by entering the feed URL below. + +.add.byurl.title=Add Feed by URL + +.add.pop.text=The following are some popular feeds you're not currently watching: + +.add.pop.title=Add Popular Feed + +.add.selected=Add Selected + +.back=Back + +.create=Create Feed + +.create.name2=A feed account for that URL ([[feedurl]]) isn't set up yet on this site. Please enter an account name to use with the feed. "_feed" will automatically be added to the end of the account name, so don't include that. After you create the feed account, it may take up to a day to start updating. + +.error.nocreate=The URL you have entered is not currently being syndicated on this site. Your account type does not have the ability to create new syndicated feeds. + +.error.unknown=Unknown Error + +.feed.url=Feed URL: + +.invalid.accountname=Invalid account name. + +.invalid.cantadd=You can't add RSS feeds from this site. + +.invalid.http.text=There was an error retrieving this URL. The server may be down or the content unavailable at this time. Please verify the URL you have provided and try again. + +.invalid.http.title=Error retrieving content + +.invalid.inuse.text=That account name is already in use. + +.invalid.inuse.title=Username in use + +.invalid.needname.text=To add a syndicated account that doesn't exist, go back and give it an account name. + +.invalid.needname.title=Need an account name + +.invalid.needurl=You must enter either a syndicated account's username or URL to add a new feed. + +.invalid.notexist=No syndicated account exists with that username. + +.invalid.notrss.text=The URL provided does not appear to contain XML formatted data. + +.invalid.notrss.title=Data not XML formatted + +.invalid.port=Non-standard port number not allowed + +.invalid.reserved=This account name is reserved. Please choose a different account name. + +.invalid.submission=Invalid form submission + +.invalid.url=The URL you have typed is invalid. Please make sure you have typed the URL correctly and try again. + +.remove=Remove Selected + +.table.account=Account + +.table.feed=Feed + +.table.watchers=Watchers + +.title=Syndication + +.top1000.text=Browse a list of our <a [[aopts]]>top 1000 syndicated feeds</a>. + +.user.nomatch=User posting doesn't match user that filled out the form. + +.using.text=Here you can add syndicated feeds (RSS) from other sites to your friends list, removing the need to check a dozen sites every day. + +.using.title=Using [[sitename]] for syndication + diff -r e83f4a208a85 -r 0b30744ab665 htdocs/feeds/list.bml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/feeds/list.bml Tue Mar 02 10:29:53 2010 -0600 @@ -0,0 +1,60 @@ +<?page +title=><?_ml .title _ml?> +body<= +<?_code + use strict; + use vars qw(%GET); + + my $ret; + + my $popsyn = LJ::Syn::get_popular_feeds(); + + my @data; + foreach (@$popsyn) { + my ($user, $name, $userid, $url, $count) = @$_; + push @data, { 'user' => $user, 'name' => $name, 'numreaders' => $count, 'synurl' => $url }; + } + + # Query already defaults to "numreaders" sort + if ($GET{'sort'} eq "username") { + @data = sort { $a->{'user'} cmp $b->{'user'} } @data; + } + if ($GET{'sort'} eq "feeddesc") { + @data = sort { $a->{'name'} cmp $b->{'name'} } @data; + } + + return "<?p $ML{'.error.nofeeds'} p?>" unless @data; + + my %items = BML::paging(\@data, $GET{'page'}, 100); + my $navbar = LJ::paging_bar($items{'page'}, $items{'pages'}); + @data = @{$items{'items'}}; + + $ret .= $navbar . "<table id='synlist'><tr valign='bottom'>"; + $ret .= $GET{'sort'} eq "username" ? "<th>" . $ML{'.username'} . "</th>": + "<th><a href='" . BML::self_link({ 'sort' => "username"}) . "'>" . $ML{'.username'} . "</a>"; + $ret .= $GET{'sort'} eq "feeddesc" ? "<th>" . $ML{'.feeddesc'} . "</th>": + "<th><a href='" . BML::self_link({ 'sort' => "feeddesc"}) . "'>" . $ML{'.feeddesc'} . "</a>"; + $ret .= $GET{'sort'} eq "numreaders" ? "<th>" . $ML{'.numreaders'} . "</th>": + "<th><a href='" . BML::self_link({ 'sort' => "numreaders"}) . "'>" . $ML{'.numreaders'} . "</a>"; + $ret .= "</th><th> </th></tr>"; + foreach (@data) { + $ret .= "<tr>"; + $ret .= "<td>" . LJ::ljuser($_->{'user'}, { 'type' => 'Y' }) . "</td>"; + $ret .= "<td>" . LJ::ehtml($_->{'name'}) . "</td>"; + $ret .= "<td>" . $_->{'numreaders'} . "</td>"; + $ret .= "<td><a href='" . LJ::ehtml($_->{'synurl'}) . "'>". + "<img src='$LJ::IMGPREFIX/xml.gif' width='36' height='14' align='middle' border='0' alt='$ML{'.xml_icon.alt'}' /></a></td>"; + $ret .= "</tr>"; + } + $ret .= "</table>" . $navbar; + return $ret; + +_code?> +<=body +head<= +<style type="text/css"> +#synlist { width: 100%; } +#synlist th { text-align: left; } +</style> +<=head +page?> diff -r e83f4a208a85 -r 0b30744ab665 htdocs/feeds/list.bml.text --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/feeds/list.bml.text Tue Mar 02 10:29:53 2010 -0600 @@ -0,0 +1,15 @@ +;; -*- coding: utf-8 -*- +.error.nofeeds=<b>Error:</b> No syndicated feeds have been updated in the past 24 hours. + +.feeddesc=Feed Description + +.feedurl=Feed URL + +.numreaders=Number of readers + +.title=Syndicated Feeds + +.username=Username + +.xml_icon.alt=[View Raw Feed] + diff -r e83f4a208a85 -r 0b30744ab665 htdocs/feeds/raw.bml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/feeds/raw.bml Tue Mar 02 10:29:53 2010 -0600 @@ -0,0 +1,17 @@ +<?_code +{ + my $ret; + my $db = LJ::get_db_reader(); + + my $popsyn = LJ::Syn::get_popular_feeds(); + + foreach (@$popsyn) { + my ($user, $name, $userid, $url, $count) = @$_; + $name =~ s/[\t\n]//g; $url =~ s/[\t\n]//g; + $ret .= join("\t", $user, $name, $url, $count) . "\n"; + } + + BML::set_content_type("text/plain; charset=utf-8"); + return $ret; +} +_code?> diff -r e83f4a208a85 -r 0b30744ab665 htdocs/syn/index.bml --- a/htdocs/syn/index.bml Thu Feb 25 16:52:24 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,264 +0,0 @@ -<?page -title=><?_ml .title _ml?> -body<= - -<?_code -{ - use strict; - use vars qw(%POST); - - my $dbh = LJ::get_db_writer(); - my $u = LJ::get_remote(); - - unless ($u) { - return "<?needlogin?>"; - } - return "<?h1 $ML{'error.suspended.title'} h1?><?p $ML{'error.suspended.text'} p?>" if $u->is_suspended; - - if (LJ::did_post() && $POST{'userid'} != $u->{'userid'}) { - return "<?h1 $ML{'.invalid.submission'} h1?><?p $ML{'.user.nomatch'} p?>"; - } - - my $error = sub { - return "<?h1 $ML{'Error'} h1?><?p $_[0] p?><?p " . - BML::ml('Backlink', {'link' => '/syn/', 'text' => $ML{'.back'}}) . " p?>"; - }; - - # add custom feed - if ($POST{'action:addcustom'} || $GET{'url'}) { - my $acct = LJ::trim($POST{'acct'}); - my $url = LJ::trim($POST{'synurl'} || $GET{'url'}); - $url =~ s!^feed://!http://!; # eg, feed://www.example.com/ - $url =~ s/^feed://; # eg, feed:http://www.example.com/ - - if ($acct ne "") { - return $error->($ML{'.invalid.accountname'}) - if $acct && $acct !~ /^\w{3,20}$/; # This needs to be 5 less then the username limt. - return $error->( $ML{'.invalid.reserved'} ) - if LJ::User->is_protected_username( $acct ); - # Postpend _feed here, username should be valid by this point. - $acct .= "_feed"; - } - if ($url ne "") { - return $error->($ML{'.invalid.url'}) - unless $url =~ m!^http://([^:/]+)(?::(\d+))?!; - my $hostname = $1; - my $port = $2; - return $error->($ML{'.invalid.cantadd'}) - if $hostname =~ /\Q$LJ::DOMAIN\E/i; - - return $error->($ML{'.invalid.port'}) - if defined $port && $port != 80 && $port < 1024; - $url =~ s/:80// if $port == 80; - } - - my $su; # account to add - if ($url) { - $su = $dbh->selectrow_hashref("SELECT u.user, s.* FROM syndicated s, useridmap u ". - "WHERE s.synurl=? AND s.userid=u.userid", - undef, $url); - - unless ($su) { - # check cap to create new feeds - return $error->($ML{'.error.nocreate'}) - unless $u->can_create_feeds; - - # if no account name, give them a proper entry form to pick one, but don't reprompt - # for the url, just pass that through (we'll recheck it anyway, though) - unless ($acct) { - my $ret .= "<?h1 $ML{'.create'} h1?><?p " . BML::ml( '.create.name2', { 'feedurl' => LJ::eurl( $url ) } ) . " p?>"; - $ret .= "<form method='post' action='./'>"; - $ret .= LJ::html_hidden("userid", $u->{'userid'}, 'synurl', $url); - $ret .= "<blockquote>"; - $ret .= "<p>$ML{'.account'} <input size='15' maxlength='20' name='acct' />"; - $ret .= "<p><input name='action:addcustom' type='submit' value='" . LJ::ehtml($ML{'.create'}) . "' />"; - $ret .= "</blockquote></form>"; - return $ret; - } - - return "<?h1 $ML{'.invalid.needname.title'} h1?><?p $ML{'.invalid.needname.text'} p?>" - unless $acct; - - # create a safeagent to fetch the feed for validation purposes - my $ua = LJ::get_useragent( - role => 'syn_new', - max_size => (1024 * 300), - ); - $ua->agent("$LJ::SITENAME ($LJ::ADMIN_EMAIL; Initial check)"); - - my $res = $ua->get($url); - my $content = $res && $res->is_success ? $res->content : undef; - - unless ($content) { - my $msg = $u->show_raw_errors ? $res->status_line : $ML{'.invalid.http.text'}; - return "<?h1 $ML{'.invalid.http.title'} h1?><?p $msg p?>"; - } - - # Start out with the syn_url being equal to the url - # they entered of the resource. If we end up parsing - # the resource and finding it has a link to the real - # feed, we then want to save the real feed address - # to suck from. - my $syn_url = $url; - # analyze link/meta tags - while ($content =~ m!<(link|meta)\b([^>]+)>!g) { - my ($type, $val) = ($1, $2); - # RSS/Atom - # <link rel="alternate" type="application/(?:rss|atom)+xml" title="RSS" href="http://...." /> - # FIXME: deal with relative paths (eg, href="blah.rss") ... right now we need the full URI - if ($type eq "link" && - $val =~ m!rel=.alternate.!i && - $val =~ m!type=.application/(?:rss|atom)\+xml.!i && - $val =~ m!href=[\"\'](http://[^\"\']+)[\"\']!i) { - $syn_url = $1; - } - } - - - # Did we find a link to the real feed? If so, - # grab it - if ($syn_url ne $url) { - my $adu = $dbh->selectrow_hashref("SELECT u.user FROM syndicated s, useridmap u ". - "WHERE s.synurl=? AND s.userid=u.userid", - undef, $syn_url); - if ($adu) { - return BML::redirect("$LJ::SITEROOT/manage/circle/add?user=$adu->{user}&action=subscribe"); - } else { - $res = $ua->get($syn_url); - $content = $res && $res->is_success ? $res->content : ""; - } - } - - # check whatever we did get for validity (or pseudo-validity) - return "<?h1 $ML{'.invalid.notrss.title'} h1?><?p $ML{'.invalid.notrss.text'} p?>" - unless $content =~ m/<(\w+:)?(?:rss|feed|RDF)/; # Must have a <[?:]rss <[?:]feed (for Atom support) <[?:]RDF - - # create the feed account - my $synfeed = LJ::User->create_syndicated( - 'user' => $acct, - 'feedurl' => $syn_url, - ); - - return "<?h1 $ML{'.invalid.inuse.title'} h1?><?p $ML{'.invalid.inuse.text'} p?>" - unless $synfeed; - - $u->add_edge( $synfeed, watch => 1 ); - - $su = $dbh->selectrow_hashref("SELECT u.user, s.* FROM syndicated s, useridmap u ". - "WHERE s.userid=? AND s.userid=u.userid", - undef, $synfeed->id); - } - - } elsif ($acct) { - # account but no URL, we can add this in any case - $su = $dbh->selectrow_hashref("SELECT u.user, s.* FROM syndicated s, useridmap u ". - "WHERE u.userid=s.userid AND u.user=?", - undef, $acct); - unless ($su) { - return $error->($ML{'.invalid.notexist'}); - } - } else { - # need at least a URL - return $error->($ML{'.invalid.needurl'}); - } - - return $error->($ML{'.error.unknown'}) unless $su; - - # at this point, we have a new account, or an old account, but we have an account, so - # let's redirect them to the add page - return BML::redirect("$LJ::SITEROOT/manage/circle/add?user=$su->{user}&action=subscribe"); - } - - # get most popular feeds from memcache - my $popsyn = LJ::Syn::get_popular_feeds(); - - # load user's watch list so we can strip feeds they already watch - my %watched = map { $_ => 1 } $u->watched_userids; - - # populate @pop and add users they've chosen to add - my @pop; - my %urls; - my %names; - for (0 .. 99) { - next if not defined $popsyn->[$_]; - my ($user, $name, $suserid, $url, $count) = @{ $popsyn->[$_] }; - $names{$user} = $name; - - my $suser = LJ::load_userid($suserid); - LJ::load_user_props($suser, 'url'); - $urls{$user} = $suser->{url}; - - # skip suspended/deleted accounts, already watched feeds - next if $watched{$suserid} || !$suser->is_visible; - - if ($POST{'action:add'} && $POST{"add_$user"}) { - $u->add_edge( $suser, watch => {} ); - } else { - push @pop, [ $user, $url, $count ]; - last if @pop >= 20; - } - } - - # intro paragraph - my $title = BML::ml('.using.title', {'sitename' => $LJ::SITENAME}); - my $ret = "<?h1 $title h1?><?p $ML{'.using.text'} p?>"; - $ret .= "<?p " . BML::ml('.top1000.text', {'aopts' => "href='$LJ::SITEROOT/syn/list'"}) . " p?>"; - - $ret .= "<form method='post' action='./'>"; - $ret .= LJ::html_hidden("userid", $u->{'userid'}); - - $ret .= "<?h1 $ML{'.add.byurl.title'} h1?><?p $ML{'.add.byurl.text'} p?>"; - unless ( $u->can_create_feeds ) { - my $inline; - if ($inline .= LJ::Hooks::run_hook("cprod_inline", $u, 'Syn')) { - $ret .= $inline; - } else { - $ret .= "<p>".BML::ml('cprod.syn.text.v1')."</p>"; - } - } - $ret .= "<blockquote>"; - $ret .= "<p>$ML{'.feed.url'} <input size='40' maxlength='255' name='synurl' />"; - $ret .= "<p><input name='action:addcustom' type='submit' value='" . LJ::ehtml($ML{'.add'}) . "' />"; - $ret .= "</blockquote>"; - - $ret .= "</form>"; - - $ret .= "<form method='post' action='./'>"; - $ret .= LJ::html_hidden("userid", $u->{'userid'}); - - if (@pop) { - $ret .= "<?h1 $ML{'.add.pop.title'} h1?><?p $ML{'.add.pop.text'} p?>"; - $ret .= "<p><table cellpadding='3' style='margin-bottom: 10px; width: 80%;'>"; - $ret .= "<tr><td><b>$ML{'.table.account'}</b></td><td><b>$ML{'.table.feed'}</b></td><td></td>"; - $ret .= "<td align='right'><b>$ML{'.table.watchers'}</b></td></tr>"; - foreach (@pop) { - my ($user, $url, $count) = @$_; - $ret .= "<tr>"; - $ret .= "<td nowrap='nowrap' valign='top'><input type='checkbox' value='1' name='add_$user' /> "; - $ret .= LJ::ljuser($user, { 'type' => 'Y' }) . "</td>"; - $ret .= "<td valign='top'>"; - if ($urls{$user}) { - my $displayurl = $urls{$user}; - $displayurl = substr($urls{$user}, 0, 50) . "..." if length $displayurl > 60; - $ret .= "$names{$user}<br /><a href='$urls{$user}'>$displayurl</a></td>"; - } else { - $ret .= "$names{$user}</td>"; - } - $ret .= "<td valign='top'><a href='$url'>" . LJ::img('xml', '', { border => 0 }) . "</a></td>"; - $ret .= "<td align='right' valign='top'>$count</td>"; - $ret .= "</tr>"; - } - $ret .= "<tr><td align='left' colspan='4'>"; - $ret .= "<input type='submit' name='action:add' value='" . LJ::ehtml($ML{'.add.selected'}) . "'>"; - $ret .= "</td></tr>"; - $ret .= "</table>"; - } - - $ret .= "</form>"; - - return $ret; -} -_code?> - -<=body -page?> diff -r e83f4a208a85 -r 0b30744ab665 htdocs/syn/index.bml.text --- a/htdocs/syn/index.bml.text Thu Feb 25 16:52:24 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -;; -*- coding: utf-8 -*- -.account=Account: - -.add=Add Feed - -.add.byurl.text=Add a feed to your friends list by entering the feed URL below. - -.add.byurl.title=Add Feed by URL - -.add.pop.text=The following are some popular feeds you're not currently watching: - -.add.pop.title=Add Popular Feed - -.add.selected=Add Selected - -.back=Back - -.create=Create Feed - -.create.name2=A feed account for that URL ([[feedurl]]) isn't set up yet on this site. Please enter an account name to use with the feed. "_feed" will automatically be added to the end of the account name, so don't include that. After you create the feed account, it may take up to a day to start updating. - -.error.nocreate=The URL you have entered is not currently being syndicated on this site. Your account type does not have the ability to create new syndicated feeds. - -.error.unknown=Unknown Error - -.feed.url=Feed URL: - -.invalid.accountname=Invalid account name. - -.invalid.cantadd=You can't add RSS feeds from this site. - -.invalid.http.text=There was an error retrieving this URL. The server may be down or the content unavailable at this time. Please verify the URL you have provided and try again. - -.invalid.http.title=Error retrieving content - -.invalid.inuse.text=That account name is already in use. - -.invalid.inuse.title=Username in use - -.invalid.needname.text=To add a syndicated account that doesn't exist, go back and give it an account name. - -.invalid.needname.title=Need an account name - -.invalid.needurl=You must enter either a syndicated account's username or URL to add a new feed. - -.invalid.notexist=No syndicated account exists with that username. - -.invalid.notrss.text=The URL provided does not appear to contain XML formatted data. - -.invalid.notrss.title=Data not XML formatted - -.invalid.port=Non-standard port number not allowed - -.invalid.reserved=This account name is reserved. Please choose a different account name. - -.invalid.submission=Invalid form submission - -.invalid.url=The URL you have typed is invalid. Please make sure you have typed the URL correctly and try again. - -.remove=Remove Selected - -.table.account=Account - -.table.feed=Feed - -.table.watchers=Watchers - -.title=Syndication - -.top1000.text=Browse a list of our <a [[aopts]]>top 1000 syndicated feeds</a>. - -.user.nomatch=User posting doesn't match user that filled out the form. - -.using.text=Here you can add syndicated feeds (RSS) from other sites to your friends list, removing the need to check a dozen sites every day. - -.using.title=Using [[sitename]] for syndication - diff -r e83f4a208a85 -r 0b30744ab665 htdocs/syn/list.bml --- a/htdocs/syn/list.bml Thu Feb 25 16:52:24 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -<?page -title=><?_ml .title _ml?> -body<= -<?_code - use strict; - use vars qw(%GET); - - my $ret; - - my $popsyn = LJ::Syn::get_popular_feeds(); - - my @data; - foreach (@$popsyn) { - my ($user, $name, $userid, $url, $count) = @$_; - push @data, { 'user' => $user, 'name' => $name, 'numreaders' => $count, 'synurl' => $url }; - } - - # Query already defaults to "numreaders" sort - if ($GET{'sort'} eq "username") { - @data = sort { $a->{'user'} cmp $b->{'user'} } @data; - } - if ($GET{'sort'} eq "feeddesc") { - @data = sort { $a->{'name'} cmp $b->{'name'} } @data; - } - - return "<?p $ML{'.error.nofeeds'} p?>" unless @data; - - my %items = BML::paging(\@data, $GET{'page'}, 100); - my $navbar = LJ::paging_bar($items{'page'}, $items{'pages'}); - @data = @{$items{'items'}}; - - $ret .= $navbar . "<table id='synlist'><tr valign='bottom'>"; - $ret .= $GET{'sort'} eq "username" ? "<th>" . $ML{'.username'} . "</th>": - "<th><a href='" . BML::self_link({ 'sort' => "username"}) . "'>" . $ML{'.username'} . "</a>"; - $ret .= $GET{'sort'} eq "feeddesc" ? "<th>" . $ML{'.feeddesc'} . "</th>": - "<th><a href='" . BML::self_link({ 'sort' => "feeddesc"}) . "'>" . $ML{'.feeddesc'} . "</a>"; - $ret .= $GET{'sort'} eq "numreaders" ? "<th>" . $ML{'.numreaders'} . "</th>": - "<th><a href='" . BML::self_link({ 'sort' => "numreaders"}) . "'>" . $ML{'.numreaders'} . "</a>"; - $ret .= "</th><th> </th></tr>"; - foreach (@data) { - $ret .= "<tr>"; - $ret .= "<td>" . LJ::ljuser($_->{'user'}, { 'type' => 'Y' }) . "</td>"; - $ret .= "<td>" . LJ::ehtml($_->{'name'}) . "</td>"; - $ret .= "<td>" . $_->{'numreaders'} . "</td>"; - $ret .= "<td><a href='" . LJ::ehtml($_->{'synurl'}) . "'>". - "<img src='$LJ::IMGPREFIX/xml.gif' width='36' height='14' align='middle' border='0' alt='$ML{'.xml_icon.alt'}' /></a></td>"; - $ret .= "</tr>"; - } - $ret .= "</table>" . $navbar; - return $ret; - -_code?> -<=body -head<= -<style type="text/css"> -#synlist { width: 100%; } -#synlist th { text-align: left; } -</style> -<=head -page?> diff -r e83f4a208a85 -r 0b30744ab665 htdocs/syn/list.bml.text --- a/htdocs/syn/list.bml.text Thu Feb 25 16:52:24 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -;; -*- coding: utf-8 -*- -.error.nofeeds=<b>Error:</b> No syndicated feeds have been updated in the past 24 hours. - -.feeddesc=Feed Description - -.feedurl=Feed URL - -.numreaders=Number of readers - -.title=Syndicated Feeds - -.username=Username - -.xml_icon.alt=[View Raw Feed] - diff -r e83f4a208a85 -r 0b30744ab665 htdocs/syn/raw.bml --- a/htdocs/syn/raw.bml Thu Feb 25 16:52:24 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -<?_code -{ - my $ret; - my $db = LJ::get_db_reader(); - - my $popsyn = LJ::Syn::get_popular_feeds(); - - foreach (@$popsyn) { - my ($user, $name, $userid, $url, $count) = @$_; - $name =~ s/[\t\n]//g; $url =~ s/[\t\n]//g; - $ret .= join("\t", $user, $name, $url, $count) . "\n"; - } - - BML::set_content_type("text/plain; charset=utf-8"); - return $ret; -} -_code?> --------------------------------------------------------------------------------
no subject
ie, will the redirects remember the ?url additions?
I ask because, while I can fix it easily, a lot of others will assume something is broken and not know what to do.
no subject