use Carp qw(confess);
use utf8;
use JSON;
+use POSIX qw(strftime);
+use Storable;
use lib '/srv/koha_ffzg';
use C4::Context;
}
debug 'auth_department' => $auth_department;
+store $auth_department, '/dev/shm/auth_department.storable';
debug 'auth_group' => $auth_group;
debug 'department_in_sum' => $department_in_sum;
=cut
my $biblio_year;
+my $biblio_full_name;
my $type_stats;
my $parser = XML::LibXML->new();
my $extract = {
'008' => undef,
'100' => '(9|a)',
+ '245' => 'a',
'680' => 'i',
'700' => '(9|4|a)',
'942' => '(t|r|v)'
foreach my $authid ( @first_author ) {
push @{ $authors->{$authid}->{aut}->{ $category } }, $row->{biblionumber};
}
+ $biblio_full_name->{ $row->{biblionumber} } = $data->{100}->[0]->{a};
} else {
$have_100 = 0;
}
+ $biblio_full_name->{ $row->{biblionumber} } ||= $data->{245}->[0]->{a};
+
my $have_edt;
if ( exists $data->{700} ) {
}
debug 'authors' => $authors;
+store $authors, '/dev/shm/authors.storable';
debug 'type_stats' => $type_stats;
debug 'skip' => $skip;
debug 'biblio_year' => $biblio_year;
+debug 'biblio_full_name' => $biblio_full_name;
debug 'biblio_data' => $biblio_data;
debug 'biblio_author_external' => $biblio_author_external;
}
sub html_end {
- return qq|</body>\n</html>\n|;
+ return
+ qq|<small style="color:gray">Zadnji puta osvježeno: |,
+ strftime("%Y-%m-%d %H:%M:%S\n", localtime()),
+ qq|</body>\n</html>\n|;
}
mkdir 'html' unless -d 'html';
qq|</li>\n|;
}
+sub unique_biblionumber {
+ my @v = @_;
+ my $u;
+ $u->{$_}++ foreach @v;
+ return sort {
+ $biblio_year->{$b} <=> $biblio_year->{$a} ||
+ $biblio_full_name->{$a} cmp $biblio_full_name->{$b} ||
+ $a <=> $b
+ } keys %$u;
+}
+
sub author_html {
my ( $fh, $authid, $type, $label ) = @_;
foreach my $category ( sort keys %{ $authors->{$authid}->{$type} } ) {
my $label = $category_label->{$category} || 'Bez kategorije';
- print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ul>\n|;
- foreach my $biblionumber ( sort {
- $biblio_year->{$b} <=> $biblio_year->{$a} || $a <=> $b
- } @{ $authors->{$authid}->{$type}->{$category} } ) {
+ print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
+ foreach my $biblionumber ( unique_biblionumber @{ $authors->{$authid}->{$type}->{$category} } ) {
print $fh li_biblio( $biblionumber );
}
- print $fh qq|</ul>\n|;
+ print $fh qq|</ol>\n|;
}
}
+
sub count_author_years {
+ my $years = shift;
my ($authid) = @_;
- my $years;
foreach my $type ( keys %{ $authors->{$authid} } ) {
foreach my $category ( keys %{ $authors->{$authid}->{$type} } ) {
foreach my $biblionumber ( @{ $authors->{$authid}->{$type}->{$category} } ) {
return $years;
}
-foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
+sub html_year_selection {
+ my $fh = shift;
+ my @authids = @_;
- my $first = substr( $row->{full_name}, 0, 1 );
- if ( $first ne $first_letter ) {
- print $index qq{</ul>\n} if $first_letter;
- $first_letter = $first;
- print $index qq{<h1>$first</h1>\n<ul>\n};
- }
- print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
+ print $fh qq|<span id="years">Godine:\n|;
+ my $type_cat_count = {};
+ my $years;
- my $path = "html/$row->{authid}";
- open(my $fh, '>:encoding(utf-8)', "$path.new");
- print $fh html_title($row->{full_name}, "bibliografija");
- print $fh qq|<h1>$row->{full_name} - bibliografija</h1>|;
+ foreach my $authid ( @authids ) {
+ $years = count_author_years( $years, $authid );
+ }
- my $years = count_author_years( $row->{authid} );
- print $fh qq|<span id="years">Godine:|;
- my $type_cat_count = {};
foreach my $year ( sort { $b <=> $a } keys %$years ) {
- print $fh qq|<label><input name="year_selection" value="$year" type=checkbox onClick="toggle_year($year, this)" checked>$year</label> \n|;
+ print $fh qq|<label><input name="year_selection" value="$year" type=checkbox onClick="toggle_year($year, this)" checked="checked">$year</label> \n|;
foreach my $type_cat ( keys %{ $years->{$year} } ) {
$type_cat_count->{ $type_cat } += $years->{$year}->{$type_cat};
}
}
+
+ print $fh qq|
+<input type=button value="all" onClick="all_years(1)">
+<input type=button value="none" onClick="all_years(0)">
+ |;
+
print $fh qq|</span>|;
print $fh q|
}
}
+function all_years( turn_on ) {
+ $('input[name=year_selection]').each( function(i,el) {
+ if ( turn_on ) {
+ if ( ! el.checked ) {
+ el.checked = true;
+ year_show( el.value );
+ }
+ } else {
+ if ( el.checked ) {
+ el.checked = false;
+ year_hide( el.value );
+ }
+ }
+ } );
+}
+
$(document).ready( function() {
console.info('ready');
});
</script>
|;
+}
+
+foreach my $row ( sort { $a->{full_name} cmp $b->{full_name} } @authors ) {
+
+ my $first = substr( $row->{full_name}, 0, 1 );
+ if ( $first ne $first_letter ) {
+ print $index qq{</ul>\n} if $first_letter;
+ $first_letter = $first;
+ print $index qq{<h1>$first</h1>\n<ul>\n};
+ }
+ print $index qq{<li><a href="}, $row->{authid}, qq{.html">}, $row->{full_name}, "</a></li>\n";
+
+ my $path = "html/$row->{authid}";
+ open(my $fh, '>:encoding(utf-8)', "$path.new");
+ print $fh html_title($row->{full_name}, "bibliografija");
+ print $fh qq|<h1>$row->{full_name} - bibliografija</h1>\n|;
+
+ html_year_selection $fh => $row->{authid};
author_html( $fh, $row->{authid}, 'aut' => 'Primarno autorstvo' );
- author_html( $fh, $row->{authid}, 'sec' => 'Uredništva, prijevodi, krička izdanja' );
+ author_html( $fh, $row->{authid}, 'sec' => 'Uredništva, prijevodi, kritička izdanja' );
print $fh html_end;
close($fh);
debug 'department_category_author' => $department_category_author;
-mkdir 'html/departments' unless -d 'html/departments';
-
-sub unique_biblionumber {
- my @v = @_;
- my $u;
- $u->{$_}++ foreach @v;
- return sort { $biblio_year->{$b} <=> $biblio_year->{$a} || $a <=> $b } keys %$u;
-}
-
-open(my $dep_fh, '>:encoding(utf-8)', 'html/departments/index.new');
-print $dep_fh html_title('Odsijeci Filozofskog fakulteta u Zagrebu'), qq|<ul>\n|;
-foreach my $department ( sort keys %$department_category_author ) {
- my $dep = $department || 'Nema odsjeka';
- my $dep_file = unac_string('utf-8',$dep);
- print $dep_fh qq|<li><a href="$dep_file.html">$dep</a></li>\n|;
- open(my $fh, '>:encoding(utf-8)', "html/departments/$dep_file.new");
- print $fh html_title($department . ' bibliografija');
- print $fh qq|<h1>$department bibliografija</h1>\n|;
+sub department_html {
+ my ( $fh, $department, $type, $label ) = @_;
- print $fh qq|<h2>Primarno autorstvo</h2>\n|;
+ print $fh qq|<h2>$label</h2>\n|;
foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
my @authids = @{ $department_category_author->{$department}->{$category} };
next unless @authids;
- my @biblionumber = unique_biblionumber map { @{ $authors->{$_}->{aut}->{$category} } } grep { exists $authors->{$_}->{aut}->{$category} } @authids;
- my $unique;
- $unique->{$_}++ foreach @biblionumber;
+ my @biblionumber = unique_biblionumber map { @{ $authors->{$_}->{$type}->{$category} } } grep { exists $authors->{$_}->{$type}->{$category} } @authids;
next unless @biblionumber;
my $label = $category_label->{$category} || 'Bez kategorije';
- print $fh qq|<h3>$label</h3>\n<ul>\n|;
+ print $fh qq|<a name="$type-$category"><h3>$label</h3></a>\n<ol>\n|;
print $fh li_biblio( $_ ) foreach @biblionumber;
- print $fh qq|</ul>|;
+ print $fh qq|</ol>|;
}
+}
- print $fh qq|<h2>Sekundarno autorstvo</h2>\n|;
-
- foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
-
- my @authids = @{ $department_category_author->{$department}->{$category} };
- next unless @authids;
-
- my @biblionumber = unique_biblionumber map { @{ $authors->{$_}->{sec}->{$category} } } grep { exists $authors->{$_}->{sec}->{$category} } @authids;
- next unless @biblionumber;
+mkdir 'html/departments' unless -d 'html/departments';
- my $label = $category_label->{$category} || 'Bez kategorije';
- print $fh qq|<h3>$label</h3>\n<ul>\n|;
+open(my $dep_fh, '>:encoding(utf-8)', 'html/departments/index.new');
+print $dep_fh html_title('Odsjeci Filozofskog fakulteta u Zagrebu'), qq|<ul>\n|;
+foreach my $department ( sort keys %$department_category_author ) {
+ my $dep = $department || 'Nema odsjeka';
+ my $dep_file = unac_string('utf-8',$dep);
+ print $dep_fh qq|<li><a href="$dep_file.html">$dep</a></li>\n|;
+ open(my $fh, '>:encoding(utf-8)', "html/departments/$dep_file.new");
- print $fh li_biblio( $_ ) foreach @biblionumber;
+ print $fh html_title($department . ' bibliografija');
+ print $fh qq|<h1>$department bibliografija</h1>\n|;
- print $fh qq|</ul>|;
+ my @authids;
+ foreach my $category ( sort keys %{ $department_category_author->{$department} } ) {
+ push @authids, @{ $department_category_author->{$department}->{$category} };
}
+ html_year_selection $fh => @authids;
+
+ department_html( $fh, $department, 'aut', 'Primarno autorstvo' );
+ department_html( $fh, $department, 'sec', 'Sekundarno autorstvo' );
print $fh html_end;
close($fh);