?? highwire.pm
字號(hào):
use strict;use Bibliotech::CitationSource;use Bibliotech::CitationSource::NPG;package Bibliotech::CitationSource::Highwire;use base 'Bibliotech::CitationSource';use URI;use URI::QueryParam;use Data::Dumper;# Necessary for integrating 'Science' plug-in into the Highwire plug-inuse LWP;use HTTP::Request::Common;sub api_version { 1;}sub name { 'Highwire';}sub version { #'$Revision: 1.7 $'; '$Revision: 1.7 $';}sub understands { my ($self, $uri, $ris_host) = @_; return 0 unless $uri->scheme eq 'http'; #check the host return 0 unless Bibliotech::CitationSource::Highwire::HostTable::defined($uri->host); return 1 if ($uri->path =~ m!^/cgi/((content/(summary|short|extract|abstract|full))|reprint)/(${ris_host};)?.+!i); return 0;}sub citations { my ($self, $article_uri) = @_; my $ris; eval { my $ris_host = Bibliotech::CitationSource::Highwire::HostTable::getRISPrefix($article_uri->host); # # Some entries will require a login/password; structure in hash is a reference not scalar # my($ris_login); if(ref($ris_host)) { $ris_login = $self->highwire_account($ris_host->{ACCT_TYPE}); $ris_host = $ris_host->{RIS_PREFIX}; # re-assign this as a scalar } die "do not understand URI\n" unless $self->understands($article_uri, $ris_host); my $file; $file = $article_uri->path; #strip fragments or queries $file =~ s/(?:#|\?).*//; die "no file name seen in URI\n" unless $file; #find the ID my $id; if($file =~ m!^/cgi/(?:(?:content/(?:summary|short|extract|abstract|full))|reprint)/(?:${ris_host};)?(.+)$!i) { $id = $1; } die "Couldn't extract Highwire ID\n" unless $id; my $query_uri = new URI("http://" . $article_uri->host . "/cgi/citmgr_refman?gca=" . $ris_host . ";" . $id); # # use query w/ authorization if needed # my $ris_raw; my $ua; my $response; if($ris_login) { $ua = $self->ua; $response = $ua->request(POST $query_uri, [ 'username' => $ris_login->{USER}, 'code' => $ris_login->{PW}]); if($response->is_success) { $ris_raw = $response->content; } else { die $response->status_line; } } else { $ris_raw = $self->get($query_uri); } $ris = new Bibliotech::CitationSource::NPG::RIS ($ris_raw); if (!$ris->has_data) { # give it one more try sleep 2; if($ris_login) { $response = $ua->request(POST $query_uri, [ 'username' => $ris_login->{USER}, 'code' => $ris_login->{PW}]); if($response->is_success) { $ris_raw = $response->content; } else { die $response->status_line; } } else { $ris_raw = $self->get($query_uri); } $ris = new Bibliotech::CitationSource::NPG::RIS ($ris_raw); } die "RIS obj false\n" unless $ris; die "RIS file contained no data\n" unless $ris->has_data; }; die $@ if $@ =~ /at .* line \d+/; $self->errstr($@), return undef if $@; return bless [bless $ris, 'Bibliotech::CitationSource::Highwire::Result'], 'Bibliotech::CitationSource::ResultList';}## Necessary for integrating 'Science' plug-in into the Highwire plug-in# 'Science' requires login/password to get citation data# Add other login/pw as needed; follow science model in bibliotech.conf# Then add conditional for new "acct_type"#sub user { my($self, $var) = @_; shift->cfg($var);}sub password { my($self, $var) = @_; shift->cfg($var);}sub highwire_account { my($self, $acct_type) = @_; my($login); if($acct_type eq 'SCIENCE') { $login->{USER} = $self->user('SCI_USER'); $login->{PW} = $self->password('SCI_PASSWORD'); } ($login->{USER} && $login->{PW}) ? return $login : return undef;}package Bibliotech::CitationSource::Highwire::Result;use base ('Bibliotech::CitationSource::NPG::RIS', 'Bibliotech::CitationSource::Result');sub type { 'Highwire';}sub source { 'Highwire RIS file';}sub identifiers { {doi => shift->doi};}sub justone { my ($self, $field) = @_; my $super = 'SUPER::'.$field; my $stored = $self->$super or return undef; return ref $stored ? $stored->[0] : $stored;}sub authors { my ($self) = @_; my $authors = $self->SUPER::authors; my @authors = map(Bibliotech::CitationSource::Highwire::Result::Author->new($_), ref $authors ? @{$authors} : $authors); bless \@authors, 'Bibliotech::CitationSource::Result::AuthorList';}# override - from Nature the abbreviated name arrives in JOsub periodical_name { shift->collect(qw/JF/); }sub periodical_abbr { shift->collect(qw/JO JA J1 J2/); }sub journal { my ($self) = @_; return Bibliotech::CitationSource::Highwire::Result::Journal->new($self->justone('journal'), $self->justone('journal_abbr'), $self->justone('issn'));}sub pubmed { undef; }sub doi { shift->justone('misc3'); }sub title { shift->justone('title'); }sub volume { shift->justone('volume'); }sub issue { shift->justone('issue'); }sub page { shift->page_range; }sub url { shift->collect(qw/UR L3/); }sub date { my $date = shift->justone('date'); $date =~ s|^(\d+/\d+/\d+)/.*$|$1|; return $date;}sub last_modified_date { shift->date(@_);}package Bibliotech::CitationSource::Highwire::Result::Author;use base 'Class::Accessor::Fast';__PACKAGE__->mk_accessors(qw/firstname forename initials lastname/);sub new { my ($class, $author) = @_; my $self = {}; bless $self, ref $class || $class; my ($lastname, $firstname); if ($author =~ /^(.+?),\s*(.*)$/) { ($lastname, $firstname) = ($1, $2); } elsif ($author =~ /^(.*)\s+(.+)$/) { ($firstname, $lastname) = ($1, $2); } else { $lastname = $author; } $self->forename($firstname); my $initials = join(' ', map { s/^(.).*$/$1/; $_; } split(/\s+/, $firstname)) || undef; $firstname =~ s/(\s\w\.?)+$//; $self->firstname($firstname); $self->lastname($lastname); $self->initials($initials); return $self;}package Bibliotech::CitationSource::Highwire::Result::Journal;use base 'Class::Accessor::Fast';__PACKAGE__->mk_accessors(qw/name medline_ta issn/);sub new { my ($class, $name, $medline_ta, $issn) = @_; my $self = {}; bless $self, ref $class || $class; $self->name($name); $self->medline_ta($medline_ta); $self->issn($issn); return $self;}package Bibliotech::CitationSource::Highwire::HostTable;%Bibliotech::CitationSoure::Highwire::HostTable::Hosts = ( #Archives of General Psychiatry 'archpsyc.ama-assn.org' => 'archpsyc', #Mutagenesis 'mutage.oupjournals.org' => 'mutage', #Visual Communication 'vcj.sagepub.com' => 'spvcj', #Social Science Computer Review 'ssc.sagepub.com' => 'spssc', #Studies in Christian Ethics 'sce.sagepub.com' => 'spsce', #Stem Cells 'stemcells.alphamedpress.org' => 'stemcells', #QJM 'qjmed.oupjournals.org' => 'qjmed', #Journal of Virology 'jvi.asm.org' => 'jvi', #International Journal for Quality in Health Care 'intqhc.oupjournals.org' => 'intqhc', #Environment and Behavior 'eab.sagepub.com' => 'speab', #Gender & Society 'gas.sagepub.com' => 'spgas', #Educational Policy 'epx.sagepub.com' => 'spepx', #Critique of Anthropology 'coa.sagepub.com' => 'spcoa', #Journal of Epidemiology & Community Health 'jech.bmjjournals.com' => 'jech', #Journal of Conflict Resolution 'jcr.sagepub.com' => 'spjcr', #The World Bank Research Observer 'wbro.oupjournals.org' => 'wbro', #Family and Consumer Sciences Research Journal 'fcs.sagepub.com' => 'spfcs', #Endocrine Reviews 'edrv.endojournals.org' => 'edrv', #The EMBO Journal 'embojournal.npgjournals.com' => 'emboj', #Journal of Macromarketing 'jmk.sagepub.com' => 'spjmk', #Oxford Review of Economic Policy 'oxrep.oupjournals.org' => 'oxrep', #Journal of European Social Policy 'esp.sagepub.com' => 'spesp', #Cancer Epidemiology Biomarkers & Prevention 'cebp.aacrjournals.org' => 'cebp', #American Journal of Clinical Nutrition 'www.ajcn.org' => 'ajcn', #The Journal of Foraminiferal Research 'jfr.geoscienceworld.org' => 'gsjfr', #Industrial and Corporate Change 'icc.oupjournals.org' => 'indcor', #Genes & Development 'www.genesdev.org' => 'genesdev', #International Journal of Lexicography 'ijl.oupjournals.org' => 'lexico', #The International Journal of Robotics Research 'ijr.sagepub.com' => 'spijr', #American Journal of Respiratory Cell and Molecular Biology 'www.ajrcmb.org' => 'ajrcmb', #Journal of Holistic Nursing 'jhn.sagepub.com' => 'spjhn', #Graft 'gft.sagepub.com' => 'spgft', #Childhood 'chd.sagepub.com' => 'spchd', #Journal of Consumer Culture 'joc.sagepub.com' => 'spjoc', #The Plant Cell Online 'www.plantcell.org' => 'plantcell', #Research on Social Work Practice 'rsw.sagepub.com' => 'sprsw', #International Political Science Review/ Revue internationale de science politique 'ips.sagepub.com' => 'spips', #Youth & Society 'yas.sagepub.com' => 'spyas', #Journal of European Studies 'jes.sagepub.com' => 'spjes', #French Studies 'fs.oupjournals.org' => 'frestu', #Journal of Intelligent Material Systems and Structures 'jim.sagepub.com' => 'spjim', #Qualitative Inquiry 'qix.sagepub.com' => 'spqix', #European Journal of Endocrinology 'www.eje-online.org' => 'eje', #Journal of Bioactive and Compatible Polymers 'jbc.sagepub.com' => 'spjbc', #American Journal of Public Health 'www.ajph.org' => 'ajph', #Structural Health Monitoring 'shm.sagepub.com' => 'spshm', #International Studies 'isq.sagepub.com' => 'spisq', #Geology 'geology.geoscienceworld.org' => 'gsgeology', #EMBO Reports 'emboreports.npgjournals.com' => 'emborep', #Journal of Pharmacy Practice 'jpp.sagepub.com' => 'spjpp', #Journal of Nuclear Medicine 'jnm.snmjournals.org' => 'jnumed', #Journal of Psychotherapy Practice and Research 'jppr.psychiatryonline.org' => 'jppr', #Work and Occupations 'wox.sagepub.com' => 'spwox', #International Review for the Sociology of Sport 'irs.sagepub.com' => 'spirs', #IEICE Transactions on Communications 'ietcom.oupjournals.org' => 'ietcom', #Forum for Modern Language Studies 'fmls.oupjournals.org' => 'formod', #The Medieval History Journal 'mhj.sagepub.com' => 'spmhj', #British Journal of Criminology 'bjc.oupjournals.org' => 'crimin', #The European Journal of Orthodontics 'ejo.oupjournals.org' => 'eortho', #Journal of Anglican Studies 'ast.sagepub.com' => 'spast', #Homicide Studies 'hsx.sagepub.com' => 'sphsx', #Qualitative Health Research 'qhr.sagepub.com' => 'spqhr', #The Journal of Physiology 'jp.physoc.org' => 'jphysiol', #Infection and Immunity 'iai.asm.org' => 'iai', #Mineralogical Magazine 'minmag.geoscienceworld.org' => 'gsminmag', #Advances in Developing Human Resources 'adh.sagepub.com' => 'spadh', #Bulletin of Science, Technology & Society 'bst.sagepub.com' => 'spbst', #Journal of the American Podiatric Medical Association 'www.japmaonline.org' => 'jpodma', #Annals of Oncology 'annonc.oupjournals.org' => 'annonc', #Journal of Health Psychology 'hpq.sagepub.com' => 'sphpq', #Journal of Marketing Education 'jmd.sagepub.com' => 'spjmd', #SIMULATION 'sim.sagepub.com' => 'spsim', #Chest 'www.chestjournal.org' => 'chest', #Antimicrobial Agents and Chemotherapy 'aac.asm.org' => 'aac', #Molecular Cancer Research 'mcr.aacrjournals.org' => 'molcanres', #Molecular and Cellular Biology 'mcb.asm.org' => 'mcb', #International Journal of Cultural Studies 'ics.sagepub.com' => 'spics', #Nursing Science Quarterly 'nsq.sagepub.com' => 'spnsq', #The Journal of Applied Behavioral Science 'jab.sagepub.com' => 'spjab', #Recent Progress in Hormone Research 'rphr.endojournals.org' => 'rphr', #The Diabetes Educator 'tde.sagepub.com' => 'sptde', #Palynology 'palynology.geoscienceworld.org' => 'gspalynol', #Archives of Internal Medicine 'archinte.ama-assn.org' => 'archinte', #Teaching Mathematics and its Applications 'teamat.oupjournals.org' => 'teamat', #Journal of Planning History 'jph.sagepub.com' => 'spjph',
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -