Bug 23148: Fix bridge image paths in de-DE installer files
[koha.git] / misc / cronjobs / sitemap.pl
blobfb738e08232f3df5d2a1137fd6ea2e1d49934693
1 #!/usr/bin/perl
3 # Copyright 2015 Tamil s.a.r.l.
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 package Main;
22 use Modern::Perl;
23 use utf8;
24 use Pod::Usage;
25 use Getopt::Long;
27 use Koha::Script -cron;
28 use C4::Biblio;
29 use Koha::Sitemapper;
32 my ($verbose, $help, $url, $dir, $short) = (0, 0, '', '.', 1);
33 GetOptions(
34 'verbose' => \$verbose,
35 'help' => \$help,
36 'url=s' => \$url,
37 'dir=s' => \$dir,
38 'short!' => \$short,
41 sub usage {
42 pod2usage( -verbose => 2 );
43 exit;
46 usage() if $help;
48 unless ($url) {
49 $url = C4::Context->preference("OPACBaseURL");
50 unless ($url) {
51 say "OPACBaseURL syspref isn't defined. You can use --url parameter.";
52 exit;
55 $url =~ s/\/*$//g;
57 my $sitemapper = Koha::Sitemapper->new(
58 verbose => $verbose,
59 url => $url,
60 dir => $dir,
61 short => $short,
63 $sitemapper->run();
66 =head1 USAGE
68 =over
70 =item sitemap.pl [--verbose|--help|--short|--noshort|--url|--dir]
72 =back
74 =head1 SYNOPSIS
76 sitemap.pl --verbose
77 sitemap.pl --noshort --dir /home/koha/mylibrary/www
78 sitemap.pl --url opac.myDNSname.org
80 =head1 DESCRIPTION
82 Process all biblio records from a Koha instance and generate Sitemap files
83 complying with this protocol as described on L<http://sitemaps.org>. The goal of
84 this script is to be able to provide to search engines direct access to biblio
85 records. It avoid leaving search engine browsing Koha OPAC and so generating
86 a lot of traffic, and workload, for a bad result.
88 A file name F<sitemapindex.xml> is generated. It contains references to Sitemap
89 multiples files. Each file contains at most 50,000 urls, and is named
90 F<sitemapXXXX.xml>.
92 The files must be stored on Koha OPAC root directory, ie
93 F<<koha-root>/koha-tmpl/>. Place also in this directory a F<robots.txt> file
94 like this one:
96 Sitemap: sitemapindex.xml
97 User-agent: *
98 Disallow: /cgi-bin/
100 =head1 PARAMETERS
102 =over
104 =item B<--url=Koha OPAC base URL>
106 If omitted, OPACBaseURL syspref is used.
108 =item B<--short|noshort>
110 By default, --short. With --short, URL to bib record ends with
111 /bib/biblionumber. With --noshort, URL ends with
112 /cgi-bin/koha/opac-detail.pl?biblionumber=bibnum
114 =item B<--dir>
116 Directory where to write sitemap files. By default, the current directory.
118 =item B<--verbose|-v>
120 Enable script verbose mode: a message is displayed for each 10,000 biblio
121 records processed.
123 =item B<--help|-h>
125 Print this help page.
127 =back
129 =cut