source: main/trunk/model-cols/niupepa/perllib/niupepautil.pm@ 26201

Last change on this file since 26201 was 26201, checked in by kjdon, 12 years ago

a small subset of niupepa plus all the config files for building and development of the collection

File size: 1.4 KB
Line 
1package niupepautil;
2
3use util;
4use doc;
5use strict;
6
7# reads in the meta.txt file and sets metadata
8sub set_main_metadata {
9 my ($doc_obj, $dir, $verbosity) = @_;
10
11 my $metafile = &util::filename_cat ($dir, "meta.txt");
12 return unless (-e $metafile);
13
14 if (!open (METAFILE, $metafile)) {
15 print STDERR "NPPlug: Couldn't read $metafile\n" if $verbosity;
16 return;
17 }
18
19 my $cursection = $doc_obj->get_top_section();
20 my $line = "";
21 while (defined ($line = <METAFILE>)) {
22 next unless $line =~ /\w/;
23 chomp $line;
24 if ($line =~ /<([^>]*)>(.*)$/) {
25 # note we're using set_metadata_element (not add_metadata_element)
26 # this will override any previously set metadata of the same name
27 $doc_obj->set_utf8_metadata_element ($cursection, $1, $2);
28 } elsif ($verbosity) {
29 print STDERR "niupepautil: Badly formatted line in $metafile\n";
30 print STDERR "meta.txt lines should be formatted '<metaname>metavalue'\n";
31 }
32 }
33}
34
35sub get_title_string {
36 my ($paper_id) = @_;
37 print STDERR "paper_id = $paper_id\n";
38 my ($series, $vol, $num) = split /\_/, $paper_id;
39 my $title = "";
40 $title .= "_vol_ $vol" if defined $vol && $vol =~ /\w/;
41 if (defined $num && $num =~ /\w/) {
42 $title .= ", " if defined $vol && $vol =~ /\w/;
43 $title .= "_num_ $num";
44 }
45 return $title;
46}
47
48
491;
Note: See TracBrowser for help on using the repository browser.