source: main/trunk/model-cols/niupepa/perllib/plugins/NiupepaPlugin.pm@ 26229

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

can't use doctype in gs3 to signal commentary/abstract etc as we need to keep doctype for simple/hierarchy etc. So use DocType instead. Haven't checked how this works with gs2

File size: 2.6 KB
Line 
1# NiupepaPlugin,
2
3package NiupepaPlugin;
4
5use PagedImagePlugin;
6
7use strict;
8no strict 'refs'; # allow filehandles to be variables and viceversa
9no strict 'subs';
10
11sub BEGIN {
12 @NiupepaPlugin::ISA = ('PagedImagePlugin');
13}
14
15my $arguments =
16 [
17 { 'name' => "block_exp",
18 'desc' => "{BasePlugin.block_exp}",
19 'type' => "regexp",
20 'deft' => &get_default_block_exp(),
21 'reqd' => "no" }
22];
23
24my $options = { 'name' => "NiupepaPlugin",
25 'desc' => "PagedImagePlugin variant for niupepa collection",
26 'abstract' => "no",
27 'inherits' => "yes",
28 'args' => $arguments };
29
30sub new {
31 my ($class) = shift (@_);
32 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
33 push(@$pluginlist, $class);
34
35 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
36 push(@{$hashArgOptLists->{"OptList"}},$options);
37
38 my $self = new PagedImagePlugin($pluginlist, $inputargs, $hashArgOptLists);
39
40 return bless $self, $class;
41}
42
43sub get_default_block_exp {
44 my $self = shift (@_);
45
46 return q^(images|text|meta\.txt$|\.issue$)^;
47}
48
49
50sub plugin_specific_process {
51 my $self = shift(@_);
52 my ($base_dir, $file,$doc_obj, $gli) = @_;
53 print STDERR "in plugin specific process\n";
54 my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
55 my $topsection = $doc_obj->get_top_section();
56 my ($full_dir) = $filename_full_path =~ /^(.*?)([^\/\\]*)$/;
57 print STDERR "$filename_full_path, $full_dir\n";
58 my ($issuekey) = $filename_no_path =~ /^([^\.\_]*)/;
59 my $commentary = &util::filename_cat($full_dir,"$issuekey.commentary");
60 if (-e $commentary) {
61 print STDERR "setting hascom 1 for $filename_no_path \n";
62 $doc_obj->set_utf8_metadata_element ($topsection, "hascom", "1");
63 $doc_obj->set_utf8_metadata_element ($topsection, "commentary", $issuekey . "commentary");
64 } else {
65 print STDERR "didn't find commentary $commentary\n";
66 }
67 my ($paper_id) = $filename_no_path;
68 $paper_id =~ s/\.item//;
69 my $abstract_OID = $paper_id . "abstract";
70 my $abstract_file .= "$paper_id.abstract";
71 my $afile = &util::filename_cat($full_dir, "abstracts", $abstract_file);
72 if (-e $afile) {
73 print STDERR "setting abstract $abstract_OID for $filename_no_path \n";
74 $doc_obj->set_utf8_metadata_element ($topsection, 'abstract', $abstract_OID);
75 }else {
76 print STDERR "didn't find abstract $afile\n";
77 }
78
79 $doc_obj->set_utf8_metadata_element ($topsection, 'Title', &niupepautil::get_title_string($paper_id));
80 $doc_obj->set_utf8_metadata_element ($topsection, "DocType", "Niupepa");
81}
821;
Note: See TracBrowser for help on using the repository browser.