From 6940399a2c83c6a5c8e3ba39ec3a489622dabff7 Mon Sep 17 00:00:00 2001 From: oiami Date: Thu, 7 Aug 2014 01:08:19 +0700 Subject: [PATCH 01/11] Make feed title more descriptive and add info about author ++ modules --- lib/MetaCPAN/Web/Controller/Feed.pm | 43 ++++++++++++--- root/static/less/account.less | 1 - root/static/less/button.less | 10 ++-- root/static/less/responsive.less | 1 + root/static/less/style.less | 86 +++++++++++++++-------------- t/controller/feed.t | 53 ++++++++++++++++++ 6 files changed, 139 insertions(+), 55 deletions(-) diff --git a/lib/MetaCPAN/Web/Controller/Feed.pm b/lib/MetaCPAN/Web/Controller/Feed.pm index 454b6921651..975d9f77bc5 100644 --- a/lib/MetaCPAN/Web/Controller/Feed.pm +++ b/lib/MetaCPAN/Web/Controller/Feed.pm @@ -72,15 +72,18 @@ sub author : Chained('index') PathPart Args(1) { my $author_cv = $c->model('API::Author')->get($author); my $releases_cv = $c->model('API::Release')->latest_by_author($author); - my $data = { - author => $author_cv->recv, - releases => - [ map { $_->{fields} } @{ $releases_cv->recv->{hits}{hits} } ], - }; - + my $author_info = $author_cv->recv; + my $faves_cv + = $c->model('API::Favorite')->by_user( $author_info->{user} ); + my $faves_data = $faves_cv->recv; + my $data = [ + sort { $b->{date} cmp $a->{date} } + map { $_->{fields} } @{ $faves_data->{hits}{hits} }, + @{ $releases_cv->recv->{hits}{hits} } + ]; $c->stash->{feed} = $self->build_feed( - title => "Recent CPAN uploads by $data->{author}->{name} - MetaCPAN", - entries => $data->{releases} + title => "Recent CPAN activity of $author - MetaCPAN", + entries => $self->build_author_entry( $author, $data ), ); } @@ -98,7 +101,7 @@ sub build_entry { my $e = XML::Feed::Entry->new('RSS'); $e->title( $entry->{name} ); $e->link( - $entry->{link} // join( '/', + $entry->{link} ||= join( '/', 'http://metacpan.org', 'release', $entry->{author}, $entry->{name} ) ); @@ -120,6 +123,28 @@ sub build_feed { return $feed->as_xml; } +sub build_author_entry { + my ( $self, $author, $activity ) = @_; + foreach my $item ( @{$activity} ) { + my $dist = $item->{distribution}; + $dist =~ s/-/::/g; + $item->{abstract} + ||= "$author ++ed $item->{distribution} from $item->{author}"; + $item->{link} + = $item->{name} + ? join( '/', + 'https://metacpan.org', 'release', + $item->{author}, $item->{name} ) + : join( '/', 'https://metacpan.org', 'pod', $dist ); + $item->{name} + = $item->{name} + ? "$author has released $item->{name}" + : "$author ++ed $item->{distribution}"; + unless ( $item->{author} eq $author ) { $item->{author} = $author } + } + return $activity; +} + sub end : Private { my ( $self, $c ) = @_; $c->res->content_type('application/rss+xml; charset=UTF-8'); diff --git a/root/static/less/account.less b/root/static/less/account.less index 7f8a9f4e06e..930f6b231e5 100644 --- a/root/static/less/account.less +++ b/root/static/less/account.less @@ -9,7 +9,6 @@ padding-left: 0px !important; } - #account-profile { .form-group:after { clear: both !important; diff --git a/root/static/less/button.less b/root/static/less/button.less index ca3372e8516..325a9c7daf2 100644 --- a/root/static/less/button.less +++ b/root/static/less/button.less @@ -18,16 +18,16 @@ font-size: 14px; line-height: 20px; margin-bottom: 0; + padding: 4px 12px; text-align: center; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); vertical-align: middle; - - + &:hover, &:focus { - background-color: #e6e6e6; - text-decoration: none; - background-image: none; + background-color: #e6e6e6; + text-decoration: none; + background-image: none; } } diff --git a/root/static/less/responsive.less b/root/static/less/responsive.less index 42e13bdcea8..74dce4b5697 100644 --- a/root/static/less/responsive.less +++ b/root/static/less/responsive.less @@ -136,6 +136,7 @@ .home input.home-search-input { position: relative; + right: 5px; width: 93%; font-size: 1.4em; } diff --git a/root/static/less/style.less b/root/static/less/style.less index 113555fcaa9..38b212ed3a0 100644 --- a/root/static/less/style.less +++ b/root/static/less/style.less @@ -31,21 +31,22 @@ @input-border-radius: none; @modal-md: 722px; @custom-grid-float-breakpoint: 0; +<<<<<<< HEAD @screen-xs-max: @screen-xs; @screen-sm-min: (@screen-xs + 1); h1, .h1, h2, .h2, h3, .h3 { - line-height: 35px; + line-height: 35px; } .black { - color: @black; + color: @black; } .border-radius(@radius) { - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; + -webkit-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; } .collapse .navbar-collapse { @@ -61,10 +62,15 @@ h1, .h1, h2, .h2, h3, .h3 { input#search-input { font-size: 16px; + height: 30px; +} + +.home { + padding: 40px 0 50px; } .home .btn { - font-size: 1.2em; + font-size: 1.2em; } .home input { @@ -125,7 +131,7 @@ body { } #map { - margin-right: 200px !important; + margin-right: 200px !important; } #map img { @@ -133,72 +139,72 @@ body { } .smaller { - font-size: 1.0em; - line-height: 2.5em; + font-size: 1.0em; + line-height: 2.5em; } .btn.btn-slidepanel { - border-radius: 2px; - padding: 1px 4px 5px 4px; - margin-top: 3px; + border-radius: 2px; + padding: 1px 4px 5px 4px; + margin-top: 3px; } .table.tablesorter th { - padding-right: 20px; + padding-right: 20px; } .container-top { - padding: 0 10px 10px 10px; + padding: 0 10px 10px 10px; } .head-small-logo { - width: 200px; + width: 200px; } .main-content { - margin-bottom: 60px; - margin-top: 25px; - line-height: 20px; + margin-bottom: 60px; + margin-top: 25px; + line-height: 20px; } #lab { - margin-top: -25px; - margin-bottom: 50px; + margin-top: -25px; + margin-bottom: 50px; } .tool-bar-form { - margin-top: 2px; - margin-bottom: 10px; - height: 30px; - width: 165px !important; + margin-top: 2px; + margin-bottom: 10px; + height: 30px; + width: 165px !important; } li button.dependencies-graph { - padding: 0; - font-size: inherit; - background: none !important; - background-image: none; - border: none; - color: @linkColor !important; + padding: 0; + font-size: inherit; + background: none !important; + background-image: none; + border: none; + color: @linkColor !important; } .top-content { - padding-bottom: 10px; + padding-bottom: 10px; } .row-fluid { - padding-bottom: 10px; + padding-bottom: 10px; } .footer { - .sponsor-logo { - border: none; - float: right; - width: 90%; - padding: 0px; - } + .sponsor-logo { + border: none; + float: right; + width: 90%; + padding: 0px; + } } .ui-tooltip-titlebar { - height: 25px !important; -} + height: 25px !important; +} \ No newline at end of file diff --git a/t/controller/feed.t b/t/controller/feed.t index c19f77afbbc..87f4a96d123 100644 --- a/t/controller/feed.t +++ b/t/controller/feed.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use MetaCPAN::Web::Test; use Try::Tiny; +use MetaCPAN::Web::Controller::Feed; my @tests = qw(/feed/recent /feed/author/PERLER /feed/distribution/Moose /feed/news); @@ -52,4 +53,56 @@ sub valid_xml { return $tx; } +subtest 'get correct author entry data format' => sub { + my $feed = MetaCPAN::Web::Controller::Feed->new(); + my $data = [ + { + abstract => "A brand new module from PERLHACKER", + author => "PERLHACKER", + date => "2012-12-12T05:17:44.000Z", + distribution => "Some-New-Module", + name => "Some-New-Module-0.001", + status => "latest", + }, + { + author => "ABIGAIL", + date => "2014-01-16T21:51:00.000Z", + distribution => "perl", + } + ]; + my $entry = $feed->build_author_entry( 'PERLHACKER', $data ); + is( + $entry->[0]->{abstract}, + 'A brand new module from PERLHACKER', + 'get correct release abstract' + ); + is( + $entry->[0]->{link}, + 'https://metacpan.org/release/PERLHACKER/Some-New-Module-0.001', + 'get correct release link' + ); + is( + $entry->[0]->{name}, + 'PERLHACKER has released Some-New-Module-0.001', + 'get correct release title' + ); + is( $entry->[0]->{author}, 'PERLHACKER', 'get correct author name' ); + is( + $entry->[1]->{abstract}, + 'PERLHACKER ++ed perl from ABIGAIL', + 'get correct favorite abstract' + ); + is( + $entry->[1]->{link}, + 'https://metacpan.org/pod/perl', + 'get correct link to ++ed module' + ); + is( + $entry->[1]->{name}, + 'PERLHACKER ++ed perl', + 'get correct ++ed title' + ); + is( $entry->[1]->{author}, + 'PERLHACKER', 'author on feed should be who ++' ); +}; done_testing; From bb218a331e26196c3c635cbb23b9ffdbf9adb574 Mon Sep 17 00:00:00 2001 From: oiami Date: Mon, 16 Jun 2014 22:50:36 +0700 Subject: [PATCH 02/11] Add new RSS feed icon --- root/static/icons/rss_feed.png | Bin 0 -> 3973 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 root/static/icons/rss_feed.png diff --git a/root/static/icons/rss_feed.png b/root/static/icons/rss_feed.png new file mode 100644 index 0000000000000000000000000000000000000000..cde1b070e7eedb88f0bde7e5033f9e1444cc4660 GIT binary patch literal 3973 zcmV;04|?#4P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<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S+p4nC`#pbpP^7UzVgm;d4)tHaqxs2f<>*C=$o$ z)-9wsLUQ~R$E?dX~xzspF%s0KGDM`Ff&tZ{NXg(+vsb#=LigxaBFKIfcnLQp9qNd+lRpbo?Z&bh7BMz4iF8|y`XAR< fSAP_oU;gg^OBe-1zQGGS00000NkvXXu0mjf$)kLG literal 0 HcmV?d00001 From 8882fef3aed4276a47951ebdbbfbf3b5654784bb Mon Sep 17 00:00:00 2001 From: oiami Date: Mon, 16 Jun 2014 22:52:14 +0700 Subject: [PATCH 03/11] Create author page title and add RSS feed subscription button --- root/author.html | 5 +++++ root/static/less/author.less | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/root/author.html b/root/author.html index 383ce5754e9..886cf78124a 100644 --- a/root/author.html +++ b/root/author.html @@ -144,7 +144,12 @@ +
+
<% INCLUDE inc/author-pic.html author = author %>
<% INCLUDE inc/release-table.html releases = aggregated, header = 1, tablesorter = 1, table_id = "author_releases" %> <% INCLUDE inc/favorite-table.html favorites = faves, author = 1 tablesorter = 1 %> diff --git a/root/static/less/author.less b/root/static/less/author.less index e1068c980be..64226200bb2 100644 --- a/root/static/less/author.less +++ b/root/static/less/author.less @@ -64,3 +64,25 @@ } } } + +#feed_subscription { + &.page-header { + margin: 0 0 5px; + font-weight: bold; + margin-left: 5px; + } + + p { + font-size: 16px; + display: inline; + } + + a { + display: inline; + width: 20px; + height: 20px; + background: url('/static/icons/rss_feed.png') no-repeat right top; + padding-right: 20px; + float: right; + } +} From f080a93bd69a796a0769821c5167642d999348d6 Mon Sep 17 00:00:00 2001 From: oiami Date: Tue, 17 Jun 2014 01:03:38 +0700 Subject: [PATCH 04/11] Add subscribe button to recent page --- root/recent.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/root/recent.html b/root/recent.html index 527134ebf5d..80b51cd2447 100644 --- a/root/recent.html +++ b/root/recent.html @@ -5,6 +5,10 @@ %>
+ <%- MoY = [undef, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; DoW = [undef, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; From 01c270afc274681478a44bc97ac07582e89cd34c Mon Sep 17 00:00:00 2001 From: oiami Date: Tue, 17 Jun 2014 01:07:24 +0700 Subject: [PATCH 05/11] Add another new rss icon --- root/static/css/style.css | 4 ++++ root/static/icons/icon-rss.png | Bin 0 -> 1411 bytes 2 files changed, 4 insertions(+) create mode 100644 root/static/icons/icon-rss.png diff --git a/root/static/css/style.css b/root/static/css/style.css index 55d204aa49c..139cc7b3227 100644 --- a/root/static/css/style.css +++ b/root/static/css/style.css @@ -338,4 +338,8 @@ div.qtip-github table th { .news_feed { float: right; +} + +#icon-rss { + background: url('/static/icons/icon-rss.png'); } \ No newline at end of file diff --git a/root/static/icons/icon-rss.png b/root/static/icons/icon-rss.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0529e293fa0323a17f6ea27e3cf4b45fb41a83 GIT binary patch literal 1411 zcmZ8h2~d+q6n=jW5#$gM2+%4N5L6H(K}A6t!W9q=0ZJ(Zq8U^!g8~K+BH=ICXq^${ zPJwELA|OW@Z7n5DEwt2HP|+${r3mzZf-ux09RA%u(V32K=DmIUzV977JG*k;u0R7l zD?I=(;0F2e(P~KQavA`3HQ>&5w9!oqicSYuVM;0n)t@i`sEkAohsQf0&Jd>`5U1I2 zIUJj`!{U93DG2~s_eDZs?eBj*9=m3*Qt@~Z{IS(z3`=9ndX=HsnVkF-t7IUOvX}G$MPbsqCmb(_MMZ%rL8D?WCfMV z$;sxjb*WU5K9!0G@sDVHjP#ELoo1pq;+XE{Cix={6;GG46TU24okz>(y+bUBt1mFZMY0cT*aaZ{dv!IFS;Eya@l(Pqdq74@)gEA zmT#g3ZFE_W>o`zxz$rL}Q#rtShvWS{rRXz#F{9T~zzDI7a(g5)5$Wx%R%OVdD?LlH zZRf1bL&^=yV_I@rF19?s=RDNVktZ_RKm5zto}0b1h0NkPN`>8B^Mj$&bT7VFcy?iy z&yAdm?^!Fimd6)2o-RG(wYJRF#U;bTZml4|=AJrQ-T{y31Pv$?fuZa+B@Md>M z%?Ik6Gk&$|Wjv_vQ@AUXtS+H)aIbuv*1T;pR zD=PK4uw~HG-PxVl`NzKa>j?v$18q+CB3`t<-(}yN5jmvLTe?=#B=Gq7Qe0;Ey|R5xBRC<0^984mLz%op^6yEliS1L%43iBJQ8&{F4QF`S7v9=WWJ11 zODuM<^4ymeCngJ?jQG%{HS>e>1GB_2FaRUgeEF;ZJscZR5I+frYv;Q0F2NenZYc6$Jq#6pgB^gtPx6 zq(Zv(!~mb8YBLZIzKHbjHRUyU59MRv07^u%hXyT7(F`^O>)=Ne=4(d8A?7tWicahZ t{pfZ8ca{YJtwfYJR{sY%&*K_~? literal 0 HcmV?d00001 From ffd33d9cda72ac37e50ab8023e512e3be54c782f Mon Sep 17 00:00:00 2001 From: oiami Date: Tue, 17 Jun 2014 01:21:55 +0700 Subject: [PATCH 06/11] Add distibution subscription to dependencies section --- root/inc/dependencies.html | 1 + 1 file changed, 1 insertion(+) diff --git a/root/inc/dependencies.html b/root/inc/dependencies.html index 339bd9bcfa7..e90b85b1068 100644 --- a/root/inc/dependencies.html +++ b/root/inc/dependencies.html @@ -32,6 +32,7 @@ Dependency graph <%- END %> +
  • Subscribe to <% release.distribution.replace('-', '::') %>
  • <%- INCLUDE inc/dependencies-graph.html %> From 9fa2341ea52e899b91d4c88209786ac62c531374 Mon Sep 17 00:00:00 2001 From: oiami Date: Tue, 8 Jul 2014 21:47:42 +0700 Subject: [PATCH 07/11] Serate methods from their data types --- lib/MetaCPAN/Web/Controller/Feed.pm | 59 ++++++++++++++----------- t/controller/feed.t | 67 ++++++++++++++++------------- 2 files changed, 72 insertions(+), 54 deletions(-) diff --git a/lib/MetaCPAN/Web/Controller/Feed.pm b/lib/MetaCPAN/Web/Controller/Feed.pm index 975d9f77bc5..0491c9ae734 100644 --- a/lib/MetaCPAN/Web/Controller/Feed.pm +++ b/lib/MetaCPAN/Web/Controller/Feed.pm @@ -72,18 +72,21 @@ sub author : Chained('index') PathPart Args(1) { my $author_cv = $c->model('API::Author')->get($author); my $releases_cv = $c->model('API::Release')->latest_by_author($author); + my $release_data + = [ map { $_->{fields} } @{ $releases_cv->recv->{hits}{hits} } ]; my $author_info = $author_cv->recv; my $faves_cv = $c->model('API::Favorite')->by_user( $author_info->{user} ); - my $faves_data = $faves_cv->recv; - my $data = [ - sort { $b->{date} cmp $a->{date} } - map { $_->{fields} } @{ $faves_data->{hits}{hits} }, - @{ $releases_cv->recv->{hits}{hits} } - ]; + my $faves_data + = [ map { $_->{fields} } @{ $faves_cv->recv->{hits}{hits} } ]; + $c->stash->{feed} = $self->build_feed( title => "Recent CPAN activity of $author - MetaCPAN", - entries => $self->build_author_entry( $author, $data ), + entries => [ + sort { $b->{date} cmp $a->{date} } + @{ $self->_format_release_entries($release_data) }, + @{ $self->_format_favorite_entries( $author, $faves_data ) } + ], ); } @@ -123,26 +126,32 @@ sub build_feed { return $feed->as_xml; } -sub build_author_entry { - my ( $self, $author, $activity ) = @_; - foreach my $item ( @{$activity} ) { - my $dist = $item->{distribution}; - $dist =~ s/-/::/g; - $item->{abstract} - ||= "$author ++ed $item->{distribution} from $item->{author}"; - $item->{link} - = $item->{name} - ? join( '/', +sub _format_release_entries { + my ( $self, $releases ) = @_; + my @release_data; + foreach my $item ( @{$releases} ) { + $item->{link} = join( '/', 'https://metacpan.org', 'release', - $item->{author}, $item->{name} ) - : join( '/', 'https://metacpan.org', 'pod', $dist ); - $item->{name} - = $item->{name} - ? "$author has released $item->{name}" - : "$author ++ed $item->{distribution}"; - unless ( $item->{author} eq $author ) { $item->{author} = $author } + $item->{author}, $item->{name} ); + $item->{name} = "$item->{author} has released $item->{name}"; + push( @release_data, $item ); + } + return \@release_data; +} + +sub _format_favorite_entries { + my ( $self, $author, $data ) = @_; + my @fav_data; + foreach my $fav ( @{$data} ) { + $fav->{abstract} + = "$author ++ed $fav->{distribution} from $fav->{author}"; + $fav->{author} = $author; + $fav->{link} = join( '/', + 'https://metacpan.org', 'release', $fav->{distribution} ); + $fav->{name} = "$author ++ed $fav->{distribution}"; + push( @fav_data, $fav ); } - return $activity; + return \@fav_data; } sub end : Private { diff --git a/t/controller/feed.t b/t/controller/feed.t index 87f4a96d123..aae9f058b5f 100644 --- a/t/controller/feed.t +++ b/t/controller/feed.t @@ -53,56 +53,65 @@ sub valid_xml { return $tx; } -subtest 'get correct author entry data format' => sub { - my $feed = MetaCPAN::Web::Controller::Feed->new(); - my $data = [ - { - abstract => "A brand new module from PERLHACKER", - author => "PERLHACKER", - date => "2012-12-12T05:17:44.000Z", - distribution => "Some-New-Module", - name => "Some-New-Module-0.001", - status => "latest", - }, +my $feed = MetaCPAN::Web::Controller::Feed->new(); + +subtest 'get correct author favorite data format' => sub { + my $favorite_data = [ { - author => "ABIGAIL", - date => "2014-01-16T21:51:00.000Z", - distribution => "perl", + author => 'DOLMEN', + date => '2013-07-05T14:41:26.000Z', + distribution => 'Git-Sub', } ]; - my $entry = $feed->build_author_entry( 'PERLHACKER', $data ); + + my $entry = $feed->_format_favorite_entries( 'PERLHACKER', $favorite_data ); is( $entry->[0]->{abstract}, - 'A brand new module from PERLHACKER', + 'PERLHACKER ++ed Git-Sub from DOLMEN', 'get correct release abstract' ); is( $entry->[0]->{link}, - 'https://metacpan.org/release/PERLHACKER/Some-New-Module-0.001', + 'https://metacpan.org/release/Git-Sub', 'get correct release link' ); is( $entry->[0]->{name}, - 'PERLHACKER has released Some-New-Module-0.001', + 'PERLHACKER ++ed Git-Sub', 'get correct release title' ); is( $entry->[0]->{author}, 'PERLHACKER', 'get correct author name' ); +}; + +subtest 'get correct author release data format' => sub { + my $data = [ + { + abstract => 'Easy OO access to the FreshBooks.com API', + author => 'OALDERS', + date => '2014-05-03T03:06:44.000Z', + distribution => 'Net-FreshBooks-API', + name => 'Net-FreshBooks-API-0.24', + status => 'latest', + } + ]; + + my $entry = $feed->_format_release_entries($data); is( - $entry->[1]->{abstract}, - 'PERLHACKER ++ed perl from ABIGAIL', - 'get correct favorite abstract' + $entry->[0]->{abstract}, + 'Easy OO access to the FreshBooks.com API', + 'get correct release abstract' ); is( - $entry->[1]->{link}, - 'https://metacpan.org/pod/perl', - 'get correct link to ++ed module' + $entry->[0]->{link}, + 'https://metacpan.org/release/OALDERS/Net-FreshBooks-API-0.24', + 'get correct release link' ); is( - $entry->[1]->{name}, - 'PERLHACKER ++ed perl', - 'get correct ++ed title' + $entry->[0]->{name}, + 'OALDERS has released Net-FreshBooks-API-0.24', + 'get correct release title' ); - is( $entry->[1]->{author}, - 'PERLHACKER', 'author on feed should be who ++' ); + is( $entry->[0]->{author}, 'OALDERS', 'get correct author name' ); }; + done_testing; From cde400459631703e307ff7776a93e3dd95f143df Mon Sep 17 00:00:00 2001 From: oiami Date: Mon, 21 Jul 2014 12:38:06 +0700 Subject: [PATCH 08/11] Change author and recent page title and feed icon --- root/author.html | 6 ++++-- root/recent.html | 6 ++++-- root/static/less/author.less | 6 +++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/root/author.html b/root/author.html index 886cf78124a..1791e336a6b 100644 --- a/root/author.html +++ b/root/author.html @@ -147,8 +147,10 @@
    <% INCLUDE inc/author-pic.html author = author %>
    <% INCLUDE inc/release-table.html releases = aggregated, header = 1, tablesorter = 1, table_id = "author_releases" %> diff --git a/root/recent.html b/root/recent.html index 80b51cd2447..1c32d783e9c 100644 --- a/root/recent.html +++ b/root/recent.html @@ -6,8 +6,10 @@
    <%- MoY = [undef, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; diff --git a/root/static/less/author.less b/root/static/less/author.less index 64226200bb2..c875f7d0b34 100644 --- a/root/static/less/author.less +++ b/root/static/less/author.less @@ -81,8 +81,12 @@ display: inline; width: 20px; height: 20px; - background: url('/static/icons/rss_feed.png') no-repeat right top; padding-right: 20px; float: right; + } + + .fa { + float: right; + margin-right: -15px; } } From 6808469ddce90cb5ad6efedac7bf0ad3b0c13d02 Mon Sep 17 00:00:00 2001 From: oiami Date: Sat, 26 Jul 2014 11:56:53 +0700 Subject: [PATCH 09/11] Change position of rss subscription url --- root/inc/dependencies.html | 1 - root/inc/release-tools.html | 5 +++++ root/static/less/style.less | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/root/inc/dependencies.html b/root/inc/dependencies.html index e90b85b1068..339bd9bcfa7 100644 --- a/root/inc/dependencies.html +++ b/root/inc/dependencies.html @@ -32,7 +32,6 @@ Dependency graph <%- END %> -
  • Subscribe to <% release.distribution.replace('-', '::') %>
  • <%- INCLUDE inc/dependencies-graph.html %> diff --git a/root/inc/release-tools.html b/root/inc/release-tools.html index 7d747353c48..a94eeb380c8 100644 --- a/root/inc/release-tools.html +++ b/root/inc/release-tools.html @@ -19,6 +19,11 @@ Rate this distribution +
  • + + Subscribe this distribution + +
  • diff --git a/root/static/less/style.less b/root/static/less/style.less index 38b212ed3a0..6b6b9407bee 100644 --- a/root/static/less/style.less +++ b/root/static/less/style.less @@ -31,7 +31,6 @@ @input-border-radius: none; @modal-md: 722px; @custom-grid-float-breakpoint: 0; -<<<<<<< HEAD @screen-xs-max: @screen-xs; @screen-sm-min: (@screen-xs + 1); @@ -207,4 +206,9 @@ li button.dependencies-graph { .ui-tooltip-titlebar { height: 25px !important; +} + +#rss-subscription { + width: 1.2em; + font-size: 1.1em; } \ No newline at end of file From 41244ca7256ed91a0269cb817beac31c197f30cf Mon Sep 17 00:00:00 2001 From: oiami Date: Thu, 7 Aug 2014 14:19:48 +0700 Subject: [PATCH 10/11] Tidy up --- t/controller/feed.t | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/controller/feed.t b/t/controller/feed.t index aae9f058b5f..8080630c074 100644 --- a/t/controller/feed.t +++ b/t/controller/feed.t @@ -64,7 +64,8 @@ subtest 'get correct author favorite data format' => sub { } ]; - my $entry = $feed->_format_favorite_entries( 'PERLHACKER', $favorite_data ); + my $entry + = $feed->_format_favorite_entries( 'PERLHACKER', $favorite_data ); is( $entry->[0]->{abstract}, 'PERLHACKER ++ed Git-Sub from DOLMEN', From b40d2bd8ea1ad10773daed8876bed1289007b49b Mon Sep 17 00:00:00 2001 From: oiami Date: Thu, 7 Aug 2014 14:48:09 +0700 Subject: [PATCH 11/11] Use general css class and inherit width from parent on of list --- root/pod.html | 2 +- root/static/less/nav-list.less | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/root/pod.html b/root/pod.html index be3afd4eb4f..71c8ce9b79e 100644 --- a/root/pod.html +++ b/root/pod.html @@ -5,7 +5,7 @@ <% INCLUDE inc/breadcrumbs.html plussers_div = plusser_authors%> -