Skip to content

Commit b26c65d

Browse files
committed
Enforce default list of ignored files
This is providing a better first time search The list can be customized or restored anytime by checking the box.
1 parent ae257d1 commit b26c65d

File tree

9 files changed

+152
-34
lines changed

9 files changed

+152
-34
lines changed

src/public/404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<title>Error 404 - grep.metacpan.org - this is the void there !</title>
77
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/recent" />
8-
<link href="/_assets/20250501123741-510a05c940bec575d4a5edfd45e2668f.css" rel="stylesheet" type="text/css">
8+
<link href="/_assets/20250502123204-510a05c940bec575d4a5edfd45e2668f.css" rel="stylesheet" type="text/css">
99
<link rel="search" href="/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
1010
<link rel="shortcut icon" href="/static/icons/favicon.ico">
1111
<link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-touch-icon.png">

src/public/500.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<title>Error 500 - grep.metacpan.org Oh Yeah It Can Happen !</title>
77
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/recent" />
8-
<link href="/_assets/20250501123741-510a05c940bec575d4a5edfd45e2668f.css" rel="stylesheet" type="text/css">
8+
<link href="/_assets/20250502123204-510a05c940bec575d4a5edfd45e2668f.css" rel="stylesheet" type="text/css">
99
<link rel="search" href="/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
1010
<link rel="shortcut icon" href="/static/icons/favicon.ico">
1111
<link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-touch-icon.png">

src/public/_assets/20250501123741-510a05c940bec575d4a5edfd45e2668f.css renamed to src/public/_assets/20250502123204-510a05c940bec575d4a5edfd45e2668f.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6974,7 +6974,7 @@ input#search-filetype-input-results{
69746974
width: 60px;
69756975
}
69766976

6977-
input#search-ignore-files{
6977+
.search-form input#ignore-files-input {
69786978
font-size: 16px;
69796979
padding: 4px 12px;
69806980
height: 30px;

src/public/_assets/20250501123741-8ee3b0e7a6641aed845899d0645808f6.js renamed to src/public/_assets/20250502123204-8ee3b0e7a6641aed845899d0645808f6.js

Lines changed: 54 additions & 11 deletions
Large diffs are not rendered by default.

src/public/javascripts/mousetrap.min.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/_display.tt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@
1212
<a href="/" class="small-logo"></a>
1313
</div>
1414
<div class="col-md-9">
15-
<form action="/search" class="search-form form-horizontal" onSubmit="doGrepping()">
15+
<form action="/search" id="search-form" class="search-form form-horizontal" onSubmit="doGrepping()">
1616
<div class="form-group">
1717
<div class="input-group" style="overflow: hidden; display: table;">
1818
<input type="text" name="q" size="41" autofocus="autofocus" id="search-input" class="form-control search-input-results" style="width:280px;" value="<% search | html_entity %>" autocomplete="off" placeholder="search with Perl Compatible RegEx" title="search">
1919
<input type="text" name="qd" size="35" id="search-distro-input-results" class="form-control optional-input" value="<% qd | html_entity %>" autocomplete="off" placeholder="in distro like ^App-.*" title="search in distro">
2020
<input type="text" name="qft" size="6" id="search-filetype-input-results" class="form-control optional-input" value="<% qft | html_entity %>" autocomplete="off" placeholder="*.pm" title="extension">
21-
<input type="text" name="qifl" size="35" id="search-ignore-files" class="form-control optional-input" value="<% qifl | html_entity %>" autocomplete="off" placeholder="ignore files like: *.t, ppport.h" title="ignore filter">
21+
<input type="text" name="qifl" size="35" id="ignore-files-input" class="form-control optional-input" value="<% qifl | html_entity %>" autocomplete="off" placeholder="ignore files like: *.t, ppport.h" title="ignore filter">
2222
<span class="input-group-btn">
2323
<button class="btn search-btn" type="submit">Search</button>
2424
</span>
25-
<div style="float: block; "><label for="ci-input" style="font-weight: normal;"><input type="checkbox" name="qci" <% qci ? 'checked' : '' %> id="ci-input" class="">&nbsp;case&nbsp;insensitive&nbsp;search</label>
26-
<label for="ls-input" style="font-weight: normal;"><input type="checkbox" name="qls" <% qls ? 'checked' : '' %> id="ls-input" class="">&nbsp;list&nbsp;distro/files</label>
27-
25+
<div style="float: block; ">
26+
<label for="ci-default-excludes" style="font-weight: normal;">
27+
<input type="checkbox" name="default-excludes" id="ci-default-excludes" onClick="MetaCPANGrep.setupIgnoreList(); false;">&nbsp;common&nbsp;exclude&nbsp;rules
28+
</label>
29+
<label for="ci-input" style="font-weight: normal;"><input type="checkbox" name="qci" <% qci ? 'checked' : '' %> id="ci-input" class="">&nbsp;case&nbsp;insensitive&nbsp;search</label>
30+
<label for="ls-input" style="font-weight: normal;"><input type="checkbox" name="qls" <% qls ? 'checked' : '' %> id="ls-input" class="">&nbsp;list&nbsp;distro/files</label>
2831
</div>
2932
</div>
3033
</div>

src/views/index.tt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
<br>
1616
<!-- .class + .class { width: 100px } -->
1717
<div style="text-align:left; font-size: 14px;">
18-
<label for="ci-default-excludes" style="font-weight: normal;"><input type="checkbox" name="default-excludes" id="ci-default-excludes" onClick="setupDefaultIgnoreList(); false;">&nbsp;common&nbsp;exclude&nbsp;rules</label>
18+
<label for="ci-default-excludes" style="font-weight: normal;">
19+
<input type="checkbox" name="default-excludes" id="ci-default-excludes" onClick="MetaCPANGrep.setupIgnoreList(); false;">&nbsp;common&nbsp;exclude&nbsp;rules
20+
</label>
1921
<br>
2022
<label for="ci-input" style="font-weight: normal;"><input type="checkbox" name="qci" id="ci-input">&nbsp;case&nbsp;insensitive&nbsp;search</label>
2123
<label for="ls-input" style="font-weight: normal;"><input type="checkbox" name="qls" <% qls ? 'checked' : '' %> id="ls-input" class="">&nbsp;list&nbsp;distro/files</label>
@@ -35,3 +37,9 @@
3537
</div>
3638

3739
</div>
40+
41+
<script type="text/javascript">
42+
$(document).ready(function() {
43+
MetaCPANGrep.homepageSetup();
44+
});
45+
</script>

src/views/layouts/main.tt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
<title>Let's grep the CPAN together: search a pattern among all perl distributions</title>
1111
<% END %>
1212
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/recent" />
13-
<link rel="stylesheet" type="text/css" href="/_assets/20250501123741-510a05c940bec575d4a5edfd45e2668f.css">
13+
<link rel="stylesheet" type="text/css" href="/_assets/20250502123204-510a05c940bec575d4a5edfd45e2668f.css">
1414
<link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css">
1515
<link rel="search" href="/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
1616
<link rel="shortcut icon" href="/static/icons/favicon.ico">
1717
<link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-touch-icon.png">
18-
<script src="/_assets/20250501123741-8ee3b0e7a6641aed845899d0645808f6.js" type="text/javascript"></script>
18+
<script src="/javascripts/jquery.js"></script>
19+
<script src="/javascripts/mousetrap.min.js"></script>
20+
<script src="/_assets/20250502123204-8ee3b0e7a6641aed845899d0645808f6.js" type="text/javascript"></script>
1921
<!-- google analytics -->
2022
<!-- Global site tag (gtag.js) - Google Analytics -->
2123
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-27829474-2"></script>

tools/update-assets.pl

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,71 @@
11
#!/usr/bin/env perl
22

3-
use strict;
4-
use warnings;
3+
use v5.036;
54

65
use FindBin;
76
use Git::Repository ();
7+
use Pod::Usage;
88
use Test::More;
99

10-
run() unless caller();
10+
=head1 NAME
1111
12-
sub run {
12+
update-assets.pl - Asset versioning tool for the MetaCPAN Grep Frontend
13+
14+
=head1 SYNOPSIS
15+
16+
# Run the script to update and timestamp all assets
17+
./tools/update-assets.pl
18+
19+
=head1 DESCRIPTION
20+
21+
This script implements a cache-busting strategy for web assets by:
22+
23+
1. Finding all CSS/JS assets referenced in HTML and view files
24+
2. Creating new copies with timestamp-based filenames (YYYYMMDDHHMMSS-filename.js)
25+
3. Updating all references in source files to point to the new timestamped versions
26+
4. Removing the old asset files
27+
5. Committing all changes to Git
28+
29+
The script helps ensure that users always receive the latest version of assets
30+
when changes are deployed, preventing browsers from using cached outdated versions.
31+
32+
=head1 PROCESS
33+
34+
The script:
35+
36+
1. Uses Git to find all references to assets in /_assets/ directory
37+
2. For each asset found:
38+
- Creates a new copy with a timestamp prefix
39+
- Uses sed to replace all references in source files
40+
- Adds new files to Git and removes old ones
41+
3. Commits all changes with a message "Bump assets to TIMESTAMP"
42+
43+
=head1 REQUIREMENTS
44+
45+
- Git::Repository Perl module
46+
- Command-line access to Git repository
47+
- Unix-like environment (uses sed)
48+
49+
=head1 AUTHOR
50+
51+
MetaCPAN Team
52+
53+
=cut
54+
55+
exit( run(@ARGV) // 0 ) unless caller();
56+
57+
sub run(@args) {
58+
59+
if ( grep { $_ eq '--help' || $_ eq '-h' } @args ) {
60+
return pod2usage( -verbose => 2, -exitval => 0 );
61+
}
1362

1463
my $root = $FindBin::Bin . q{/..};
1564

1665
my $git = Git::Repository->new( work_tree => $root );
1766

18-
my @out = $git->run( 'grep', q{/_assets/}, 'views', 'public/*.html' );
19-
#note explain \@out;
67+
my @out = $git->run( 'grep', q{/_assets/}, map {"src/$_"} 'views',
68+
'public/*.html' );
2069

2170
my %assets;
2271

@@ -25,7 +74,8 @@ sub run {
2574
if ( $line =~ qr{/_assets/([a-zA-Z0-9-]+\.(css|js))} ) {
2675
my $asset = $1;
2776
if ( !exists $assets{$asset} ) {
28-
$assets{$asset} = -e qq{$root/public/_assets/$asset} ? {} : 0;
77+
$assets{$asset}
78+
= -e qq{$root/src/public/_assets/$asset} ? {} : 0;
2979
}
3080
next if !$assets{$asset};
3181
$assets{$asset}->{$file} = 1; # only tag the file once
@@ -45,13 +95,13 @@ sub run {
4595
my ( $prefix, $base ) = split( '-', $asset, 2 );
4696
$base = $prefix if !defined $base;
4797
my $new = qq{/_assets/$ts-$base};
48-
my $new_asset_file = qq{$root/public/$new};
49-
my $old_asset = "$root/public/_assets/$asset";
98+
my $new_asset_file = qq{$root/src/public/$new};
99+
my $old_asset = "$root/src/public/_assets/$asset";
50100
system( 'cp', $old_asset, $new_asset_file ) == 0
51-
or die;
101+
or die;
52102

53103
my $cmd = qq{sed -i -e "s|/_assets/$asset|$new|g" }
54-
. join( ' ', sort keys %{ $assets{$asset} } );
104+
. join( ' ', sort keys %{ $assets{$asset} } );
55105
qx{$cmd};
56106
warn "Error: $cmd - $!" if $? != 0;
57107

@@ -67,13 +117,14 @@ sub run {
67117

68118
if ($ok) {
69119
$git->run( 'commit', '-m', "Bump assets to $ts" )
70-
or die "Error while committing";
120+
or die "Error while committing";
71121
note qq{Assets updated to: $ts};
72122
note scalar $git->run( 'show', '--stat', '-n1' );
73123
}
74124
else {
75125
note q{Nothing to do};
76126
}
77127

128+
return;
78129
}
79130

0 commit comments

Comments
 (0)