Skip to content

Instantly share code, notes, and snippets.

@vpeil
Created July 29, 2013 11:27
Show Gist options
  • Save vpeil/6103710 to your computer and use it in GitHub Desktop.
Save vpeil/6103710 to your computer and use it in GitHub Desktop.
Create a sitemap: making life easier for the google bot Comparison of Catmandu und non-Catmandu script. Which one do you like more?
use strict;
use lib qw(/srv/www/sbcat/lib/extension /srv/www/sbcat/lib/default);
use Orms;
use luurCfg;
use CQL::Parser;
use cql2sql;
my $basic_url = 'http://pub.uni-bielefeld.de/publication/' ;
my $outfile = '/srv/www/sbcat/htdocs/pub_index.txt' ;
sub _currentDateTime {
my ($sec, $min, $hour,$day,$mon,$year)= (localtime)[0..5];
$mon++; $year+=1900;
return sprintf("%d-%02d-%02d %02d:%02d:%02d", $year, $mon, $day, $hour, $min, $sec);
}
##### MAIN #######
my $cfg = new luurCfg;
my $luur = Orms->new($cfg->{ormsCfg});
my $o;
my $cquery = qq|submissionStatus exact public|;
my $parser = CQL::Parser->new();
my $cql = $parser->parse( $cquery );
my $sql = cql2sql($luur, $cql, undef, 1);
my $documents = $luur->{db}->{dbh}->selectcol_arrayref($sql);
my $retcd = open (OUT, ">$outfile" || die "Could not open out file") ;
foreach my $oId (@$documents) {
print OUT "$basic_url$oId\n";
}
close (OUT) ;
#!/usr/bin/env perl
use Catmandu::Sane;
use Catmandu;
Catmandu->load;
my $conf = Catmandu->config;
my $bag = Catmandu->store('search')->bag('publicationItem');
$bag->each( sub {
my $id = $_[0]->{_id};
say "$conf->{host}/publication/$id";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment