Skip to content

Commit 8b3eeb9

Browse files
authored
Merge pull request metacpan#2468 from metacpan/haarg/schema-updates
2 parents 8d350a1 + ab701b6 commit 8b3eeb9

File tree

10 files changed

+46
-89
lines changed

10 files changed

+46
-89
lines changed

root/contributing_not_found.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<div itemscope itemtype="http://schema.org/SoftwareApplication">
2-
<% INCLUDE inc/breadcrumbs.html schema_org = 1 %>
2+
<% INCLUDE inc/breadcrumbs.html %>
33

44
<ul class="nav-list slidepanel">
55
<li class="visible-xs">
66
<% INCLUDE mobile/toolbar-search-form.html %>
77
</li>
88
<li class="nav-header">
99
<%- module_date = datetime(module.date) -%>
10-
<time class="relatize" itemprop="dateModified" datetime="<% module_date.to_ymd %>"><% module_date.to_http %></time>
10+
<time class="relatize" datetime="<% module_date.to_ymd %>"><% module_date.to_http %></time>
1111
</li>
1212
<li>
1313
Distribution: <% module.distribution | html %></span>
1414
</li>
1515
<% IF documented_module.version %>
1616
<li>
17-
Module version: <span itemprop="softwareVersion"><% documented_module.version | html %></span>
17+
Module version: <span><% documented_module.version | html %></span>
1818
</li>
1919
<% END %>
2020
<li>
@@ -31,10 +31,10 @@
3131
<a data-keyboard-shortcut="g b" href="/source/<% module.author %>/<% module.release %>/<% module.path.split("/").splice(0,-1).join("/") %>"><i class="fa fa-fw fa-folder-open black"></i>Browse</a>
3232
(<a href="<% source_host %>/source/<% module.author %>/<% module.release %>/">raw</a>)
3333
</li>
34-
<% PROCESS inc/release-info.html schema_org = 1 %>
34+
<% PROCESS inc/release-info.html %>
3535
<li class="nav-header">Activity</li>
3636
<li><% INCLUDE inc/activity.html query = 'distribution=' _ release.distribution %></li>
37-
<% INCLUDE inc/release-tools.html schema_org = 1 %>
37+
<% INCLUDE inc/release-tools.html %>
3838
</ul>
3939

4040
<button id="right-panel-toggle" class="btn-link" onclick="togglePanel('right'); return false;"><span class="panel-hidden">Show</span><span class="panel-visible">Hide</span> Right Panel</button>

root/home.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
<%- rss = "recent"; rss_title = 'Recent CPAN Uploads - MetaCPAN' %>
22
<%- canonical = "/" %>
3+
<script type="application/ld+json">
4+
[
5+
{
6+
"@context": "https://schema.org",
7+
"@type": "WebSite",
8+
"name": "MetaCPAN",
9+
"url": "/",
10+
"image": "/static/icons/metacpan-icon-large.png"
11+
"potentialAction": {
12+
"@type": "SearchAction",
13+
"target": "/search?q={query}",
14+
"query-input": "required name=query",
15+
"query": "required"
16+
}
17+
}
18+
]
19+
</script>
320

421
<div align="center" class="home">
522
<a href="/" class="big-logo" alt="meta::cpan"></a>

root/inc/breadcrumbs.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030

3131
<div class="breadcrumbs">
32-
<span <% IF schema_org %>itemprop="author" itemscope itemtype="http://schema.org/Person"<% END %> >
33-
<a <% IF schema_org %>itemprop="url" <% END %> data-keyboard-shortcut="g a" rel="author" href="/author/<% IF module; module.author; ELSE; release.author; END %>" title="<% author.asciiname %>" class="author-name"><span <% IF schema_org %>itemprop="name"<% END %> ><% author.name %></span></a>
32+
<span>
33+
<a data-keyboard-shortcut="g a" rel="author" href="/author/<% IF module; module.author; ELSE; release.author; END %>" title="<% author.asciiname %>" class="author-name"><span><% author.name %></span></a>
3434
</span>
3535
<span>&nbsp;/&nbsp;</span>
3636
<div class="release status-<% release.status %> maturity-<% release.maturity %><% IF mark_unauthorized_releases && NOT release.authorized %> unauthorized<% END %>">
@@ -51,6 +51,6 @@
5151
<% INCLUDE inc/river-gauge.html, river = distribution.river, distribution = release.distribution %>
5252
<%- INCLUDE inc/favorite.html %>
5353
<%- IF module %>
54-
&nbsp;/&nbsp;<span <% IF schema_org %>itemprop="name"<% END %> ><% module.documentation or module.module.0.name %></span>
54+
&nbsp;/&nbsp;<span><% module.documentation or module.module.0.name %></span>
5555
<%- END %>
5656
</div>

root/inc/rating.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<% stars = (rating.avg * 2).fmt('%.0f') / 2 %>
2-
<span <% IF schema_org %>itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"<% END %> >
3-
<a href="https://cpanratings.perl.org/rate/?distribution=<% distribution %>"><% prefix | none %><span class="rating-<% stars * 10 %>"></span></a><span class="hidden" <% IF schema_org %>itemprop="ratingValue"<% END %> ><% stars %></span> (<a href="https://cpanratings.perl.org/dist/<% distribution %>"><span <% IF schema_org %>itemprop="reviewCount"<% END %> ><% rating.count %></span> review<% IF rating.count > 1; 's'; END %></a>)
2+
<span>
3+
<a href="https://cpanratings.perl.org/rate/?distribution=<% distribution %>"><% prefix | none %><span class="rating-<% stars * 10 %>"></span></a></span> (<a href="https://cpanratings.perl.org/dist/<% distribution %>"><span><% rating.count %></span> review<% IF rating.count > 1; 's'; END %></a>)
44
</span>

root/inc/release-tools.html

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<li class="nav-header">Tools</li>
22
<li>
3-
<a <% IF schema_org %>itemprop="downloadUrl"<% END %> href="<% release.download_url.replace('cpan\.cpantesters\.org', 'cpan.metacpan.org').replace('^http://', 'https://') %>">
4-
<i class="fa fa-download fa-fw black"></i>Download (<span <% IF schema_org %>itemprop="fileSize"<% END %> ><% release.stat.size | format_bytes %>b</span>)</a>
5-
<% IF schema_org %>
6-
<span class="invisible" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
7-
<span itemprop="price">0</span>
8-
</span>
9-
<% END %>
3+
<a href="<% release.download_url.replace('cpan\.cpantesters\.org', 'cpan.metacpan.org').replace('^http://', 'https://') %>">
4+
<i class="fa fa-download fa-fw black"></i>Download (<span><% release.stat.size | format_bytes %>b</span>)</a>
105
</li>
116
<li>
127
<a href="https://explorer.metacpan.org/?url=<% ("/" _ ( module ? ['module', module.author, module.release, module.path] : ['release', release.author, release.name] ).map(->(p){ p | uri }).join("/") ) %>">
@@ -84,6 +79,6 @@
8479
</li>
8580
<%- IF canonical %>
8681
<% IF has_latest %><li>
87-
<a <% IF schema_org %>itemprop="url"<% END %> href="<% canonical %>">Latest version</a>
82+
<a href="<% canonical %>">Latest version</a>
8883
</li><%- END %>
8984
<%- END %>

root/pod.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
%>
1111

1212
<div itemscope itemtype="http://schema.org/SoftwareApplication">
13-
<% INCLUDE inc/breadcrumbs.html schema_org = 1 %>
13+
<% INCLUDE inc/breadcrumbs.html %>
1414
<ul class="nav-list slidepanel">
1515
<li class="visible-xs">
1616
<% INCLUDE mobile/toolbar-search-form.html %>
1717
</li>
1818
<li class="nav-header">
1919
<%- module_date = datetime(module.date) -%>
20-
<time class="relatize" itemprop="dateModified" datetime="<% module_date.to_ymd %>"><% module_date.to_http %></time>
20+
<time class="relatize" datetime="<% module_date.to_ymd %>"><% module_date.to_http %></time>
2121
</li>
2222
<% INCLUDE inc/release-status.html maturity = release.maturity, banner_class = 'release-banner' %>
2323
<li>
2424
Distribution: <% module.distribution | html %></span>
2525
</li>
2626
<% IF documented_module.version %>
2727
<li>
28-
Module version: <span itemprop="softwareVersion"><% documented_module.version | html %></span>
28+
Module version: <% documented_module.version | html %>
2929
</li>
3030
<% END %>
3131
<% IF permalinks || release.status != 'latest';
@@ -48,10 +48,10 @@
4848
<a data-keyboard-shortcut="g b" href="<% source_base %>/<% module.path.split("/").splice(0,-1).join("/") %>"><i class="fa fa-fw fa-folder-open black"></i>Browse</a>
4949
(<a href="<% source_base %>/<% module.path.split("/").splice(0,-1).join("/") %>?raw=1">raw</a>)
5050
</li>
51-
<% PROCESS inc/release-info.html schema_org = 1 %>
51+
<% PROCESS inc/release-info.html %>
5252
<li class="nav-header">Activity</li>
5353
<li><% INCLUDE inc/activity.html query = 'distribution=' _ release.distribution %></li>
54-
<% INCLUDE inc/release-tools.html schema_org = 1 %>
54+
<% INCLUDE inc/release-tools.html %>
5555
</ul>
5656

5757
<button id="right-panel-toggle" class="btn-link" onclick="togglePanel('right'); return false;"><span class="panel-hidden">Show</span><span class="panel-visible">Hide</span> Right Panel</button>
10.6 KB
Loading

t/html.t

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use Path::Tiny qw( path );
88

99
# files that have inline <script> tags
1010
my %skip = map { $_ => 1 } (
11-
'root/account/profile.html', 'root/account/turing.html',
12-
'root/author.html', 'root/wrapper.html',
13-
'root/about/contributors.html', 'root/inc/favorite.html',
11+
'root/about/contributors.html', 'root/account/profile.html',
12+
'root/account/turing.html', 'root/wrapper.html',
1413
);
1514

1615
my $rule = Path::Iterator::Rule->new;
@@ -19,7 +18,13 @@ for my $file ( $rule->all('root') ) {
1918
my $html = path($file)->slurp_utf8;
2019
ok $html !~ /<style>/, "no inline style in $file";
2120
if ( not $skip{$file} ) {
22-
ok $html !~ /<script[>\s]/, "no inline script in $file";
21+
my @script_tags = $html =~ /<script\b([^>]*)>/;
22+
my @js = grep {
23+
/\btype="([^"]*)"/
24+
? ( $1 =~ /(?:j|java|emca)script/ ? 1 : () )
25+
: 1
26+
} @script_tags;
27+
ok !@js, "no inline script in $file";
2328
}
2429
}
2530

t/schema_org.t

Lines changed: 0 additions & 62 deletions
This file was deleted.

t/static-files.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ my %files = (
7373
'2a9659e15773869426894fe38acff4b797e17b65',
7474
'root/static/icons/metacpan-icon.png' =>
7575
'1b893940fe0107f9e9da5c50a40320c26f25774a',
76+
'root/static/icons/metacpan-icon-large.png' =>
77+
'b0697c267731b7ee53e8e7a3bbd9f6476c0ba29a',
7678
'root/static/icons/package.png' =>
7779
'cbb30244c85540bedd8761b1394cb5162c98c6b6',
7880
'root/static/icons/page_white.png' =>

0 commit comments

Comments
 (0)