Bug 7607: (follow-up) Address OPAC and limits
[koha.git] / misc / devel / add_missing_filters.pl
blobcc1b877e1e99484f23532514517c5ef30c73002b
1 #!/usr/bin/perl
3 use Modern::Perl;
5 use File::Slurp;
6 use Pod::Usage;
7 use Getopt::Long;
9 use t::lib::QA::TemplateFilters;
11 my ( $help, $verbose, @files );
12 GetOptions(
13 'h|help' => \$help,
14 'v|verbose' => \$verbose,
15 ) || pod2usage(1);
17 @files = @ARGV;
19 pod2usage(1) if $help or not @files;
21 my $i;
22 my $total = scalar @files;
23 my $num_width = length $total;
24 for my $file ( @ARGV ) {
25 if ( $verbose ) {
26 print sprintf "|%-25s| %${num_width}s / %s (%.2f%%)\r",
27 '=' x (24*$i++/$total). '>',
28 $i, $total, 100*$i/+$total;
29 flush STDOUT;
32 my $content = read_file( $file );
33 my $new_content = t::lib::QA::TemplateFilters::fix_filters($content);
34 $new_content .= "\n";
35 if ( $content ne $new_content ) {
36 say "$file -- Modified";
37 write_file($file, $new_content);
42 =head1 NAME
44 add_missing_filters.pl - Will add the missing filters to the template files given in parameters.
46 =head1 SYNOPSIS
48 perl misc/devel/add_missing_filters.pl **/*.tt
50 /!\ It is highly recommended to execute this script on a clean git install, with all your files and changes committed.
52 Options:
53 -?|--help brief help message
54 -v|--verbose verbose mode
56 =head1 OPTIONS
58 =over 8
60 =item B<--help|-?>
62 Print a brief help message and exits
64 =item B<-v|--verbose>
66 Verbose mode.
68 =back
70 =head1 AUTHOR
72 Jonathan Druart <jonathan.druart@bugs.koha-community.org>
74 =head1 COPYRIGHT
76 Copyright 2018 Koha Development Team
78 =head1 LICENSE
80 This file is part of Koha.
82 Koha is free software; you can redistribute it and/or modify it
83 under the terms of the GNU General Public License as published by
84 the Free Software Foundation; either version 3 of the License, or
85 (at your option) any later version.
87 Koha is distributed in the hope that it will be useful, but
88 WITHOUT ANY WARRANTY; without even the implied warranty of
89 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90 GNU General Public License for more details.
92 You should have received a copy of the GNU General Public License
93 along with Koha; if not, see <http://www.gnu.org/licenses>.