epgo

package module
v0.0.10-alpha8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

README

epgo

This project contains the epgo go package for working with EPrints REST API. It also includes a set of command line utilities for harvesting content, building feeds and website pages that run indepenantly of EPrints itself (e.g. You could have a website/feeds generated from an EPrints repository running on a different system).

The command line utilities

  • epgo is a command line utility utilizing EPrints' REST API to produce alternative feeds and formats. Currently it supports generating a feed of repository items based on publication dates.
  • epgo-genpages is a command line utility that builds JSON documents based on the content harvested with epgo.
    • For HTML, HTML include, RSS 2 documents mkpage

The utilities can be configured from the environment. The environment can be overridden by command line options. For details run the individual command wiht the '-help' option. E.g. ./bin/epgo -help

Documentation

Overview

Package epgo is a collection of structures and functions for working with the E-Prints REST API

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Package epgo is a collection of structures and functions for working with the E-Prints REST API

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const (
	// Version is the revision number for this implementation of epgo
	Version = "v0.0.10-alpha7"

	// LicenseText holds the string for rendering License info on the command line
	LicenseText = `` /* 1529-byte string literal not displayed */

	// EPrintsExportBatchSize sets the summary output frequency when exporting content from E-Prints
	EPrintsExportBatchSize = 1000

	// DefaultFeedSize sets the default size of rss, JSON, HTML include and index lists
	DefaultFeedSize = 25
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	XMLName   xml.Name `json:"-"`
	ID        string   `xml:"id,attr" json:"id"`
	DocID     int      `xml:"docid" json:"docid"`
	RevNumber int      `xml:"rev_number" json:"rev_number"`
	Files     []*File  `xml:"files>file" json:"files"`
	EPrintID  int      `xml:"eprintid" json:"eprintid"`
	Pos       int      `xml:"pos" json:"pos"`
	Placement int      `xml:"placement" json:"placement"`
	MimeType  string   `xml:"mime_type" json:"mime_type"`
	Format    string   `xml:"format" json:"format"`
	Language  string   `xml:"language" json:"language"`
	Security  string   `xml:"security" json:"security"`
	License   string   `xml:"license" json:"license"`
	Main      string   `xml:"main" json:"main"`
	Content   string   `xml:"content" json:"content"`
}

Document structures in Record

type DocumentList

type DocumentList []*Document

DocumentList is an array of pointers to Document structs

type EPrintsAPI

type EPrintsAPI struct {
	XMLName xml.Name `json:"-"`
	// EPGO_EPRINT_URL
	URL *url.URL `xml:"epgo>eprint_url" json:"eprint_url"`
	// EPGO_DATASET
	Dataset string `xml:"epgo>dataset" json:"dataset"`
	// EPGO_HTDOCS
	Htdocs string `xml:"epgo>htdocs" json:"htdocs"`
}

EPrintsAPI holds the basic connectin information to read the REST API for EPrints

func New

func New(cfg *cli.Config) (*EPrintsAPI, error)

New creates a new API instance

func (*EPrintsAPI) BuildPages

func (api *EPrintsAPI) BuildPages(feedSize int, title, target string, filter func(*EPrintsAPI, int, int) ([]*Record, error)) error

BuildPages generates JSON and BibTeX versions of collected records by calling RenderDocuments with the appropriate data.

func (*EPrintsAPI) BuildSelectLists

func (api *EPrintsAPI) BuildSelectLists() error

BuildSelectLists iterates over the exported data and creates fresh selectLists

func (*EPrintsAPI) ExportEPrints

func (api *EPrintsAPI) ExportEPrints(count int) error

ExportEPrints from highest ID to lowest for cnt. Saves each record in a DB and indexes published ones

func (*EPrintsAPI) Get

func (api *EPrintsAPI) Get(uri string) (*Record, error)

Get retrieves an EPrint record from the dataset

func (*EPrintsAPI) GetAllRecords

func (api *EPrintsAPI) GetAllRecords() ([]*Record, error)

GetAllRecords reads and returns all records sorted by Publication Date returning an array of keys in ascending or decending order

func (*EPrintsAPI) GetArticles

func (api *EPrintsAPI) GetArticles(start, count int) ([]*Record, error)

GetArticles reads the index for published content and returns a populated array of records found in index in decending order

func (*EPrintsAPI) GetEPrint

func (api *EPrintsAPI) GetEPrint(uri string) (*Record, error)

GetEPrint retrieves an EPrint record via REST API and returns a Record structure and error

func (*EPrintsAPI) GetFunderArticles

func (api *EPrintsAPI) GetFunderArticles(funderName string, start, count int) ([]*Record, error)

GetFunderArticles returns a list of EPrint records with funderName

func (*EPrintsAPI) GetFunderPublications

func (api *EPrintsAPI) GetFunderPublications(funderName string, start, count int) ([]*Record, error)

GetFunderPublications returns a list of EPrint records with funderName

func (*EPrintsAPI) GetFunders

func (api *EPrintsAPI) GetFunders() ([]string, error)

GetFunders returns a JSON list of unique Group names in index

func (*EPrintsAPI) GetGrantNumberArticles

func (api *EPrintsAPI) GetGrantNumberArticles(funderName string, grantNumber string, start, count int) ([]*Record, error)

GetGrantNumberArticles returns a list of EPrint records with funderName

func (*EPrintsAPI) GetGrantNumberPublications

func (api *EPrintsAPI) GetGrantNumberPublications(funderName string, grantNumber string, start, count int) ([]*Record, error)

GetGrantNumberPublications returns a list of EPrint records with funderName

func (*EPrintsAPI) GetGrantNumbersByFunder

func (api *EPrintsAPI) GetGrantNumbersByFunder() ([]string, error)

GetGrantNumbersByFunder returns a JSON list of unique Funder/Grant names in index

func (*EPrintsAPI) GetIDsBySelectList

func (api *EPrintsAPI) GetIDsBySelectList(slName string, filterFn func(s string) bool) ([]string, error)

GetIDsBySelectList returns a list of ePrint IDs from a select list filterd by filterFn SelectLists are sorted by creation...

func (*EPrintsAPI) GetLocalGroupArticles

func (api *EPrintsAPI) GetLocalGroupArticles(groupName string, start, count int) ([]*Record, error)

GetLocalGroupArticles returns a list of EPrint records with groupName

func (*EPrintsAPI) GetLocalGroupPublications

func (api *EPrintsAPI) GetLocalGroupPublications(groupName string, start, count int) ([]*Record, error)

GetLocalGroupPublications returns a list of EPrint records with groupName

func (*EPrintsAPI) GetLocalGroups

func (api *EPrintsAPI) GetLocalGroups() ([]string, error)

GetLocalGroups returns a JSON list of unique Group names in index

func (*EPrintsAPI) GetORCIDArticles

func (api *EPrintsAPI) GetORCIDArticles(orcid string, start, count int) ([]*Record, error)

GetORCIDArticles returns a list of EPrint records with a given ORCID

func (*EPrintsAPI) GetORCIDPublications

func (api *EPrintsAPI) GetORCIDPublications(orcid string, start, count int) ([]*Record, error)

GetORCIDPublications returns a list of EPrint records with a given ORCID

func (*EPrintsAPI) GetORCIDs

func (api *EPrintsAPI) GetORCIDs() ([]string, error)

GetORCIDs returns a list unique of ORCID IDs in index

func (*EPrintsAPI) GetPublications

func (api *EPrintsAPI) GetPublications(start, count int) ([]*Record, error)

GetPublications reads the index for published content and returns a populated array of records found in index in ascending or decending order

func (*EPrintsAPI) ListEPrintsURI

func (api *EPrintsAPI) ListEPrintsURI() ([]string, error)

ListEPrintsURI returns a list of eprint record ids from the EPrints REST API

func (*EPrintsAPI) ListURI

func (api *EPrintsAPI) ListURI(start, count int) ([]string, error)

ListURI returns a list of eprint record ids from the dataset

func (*EPrintsAPI) RenderDocuments

func (api *EPrintsAPI) RenderDocuments(docTitle, docDescription, docpath string, records []*Record) error

RenderDocuments writes JSON, BibTeX documents to the directory indicated by docpath

func (*EPrintsAPI) RenderEPrint

func (api *EPrintsAPI) RenderEPrint(basepath string, record *Record) error

RenderEPrint writes a single EPrint record to disc.

type File

type File struct {
	XMLName   xml.Name `json:"-"`
	ID        string   `xml:"id,attr" json:"id"`
	FileID    int      `xml:"fileid" json:"fileid"`
	DatasetID string   `xml:"datasetid" json:"datasetid"`
	ObjectID  int      `xml:"objectid" json:"objectid"`
	Filename  string   `xml:"filename" json:"filename"`
	MimeType  string   `xml:"mime_type" json:"mime_type"`
	Hash      string   `xml:"hash" json:"hash"`
	HashType  string   `xml:"hash_type" json:"hash_type"`
	FileSize  int      `xml:"filesize" json:"filesize"`
	MTime     string   `xml:"mtime" json:"mtime"`
	URL       string   `xml:"url" json:"url"`
}

File structures in Document

type Funder

type Funder struct {
	XMLName     xml.Name `json:"-"`
	Agency      string   `xml:"agency" json:"agency"`
	GrantNumber string   `xml:"grant_number,omitempty" json:"grant_number"`
}

Funder is a structure describing a funding source for record

type FunderList

type FunderList []*Funder

FunderList is an array of pointers to Funder structs

func (FunderList) ToAgencies

func (funders FunderList) ToAgencies() []string

ToAgencies takes an array of pointers to Funders and returns a list of Agency names

func (FunderList) ToGrantNumbers

func (funders FunderList) ToGrantNumbers() []string

ToGrantNumbers takes an array of pointers to Funders and returns a list of Agency names

type NumberingSystem

type NumberingSystem struct {
	XMLName xml.Name `json:"-"`
	Name    string   `xml:"name" json:"name"`
	ID      string   `xml:"id" json:"id"`
}

NumberingSystem is a structure describing other numbering systems for record

type Person

type Person struct {
	XMLName xml.Name `json:"-"`
	Given   string   `xml:"name>given" json:"given"`
	Family  string   `xml:"name>family" json:"family"`
	ID      string   `xml:"id,omitempty" json:"id"`
	ORCID   string   `xml:"orcid,omitempty" json:"orcid"`
}

Person returns the contents of eprint>creators>item>name as a struct

type PersonList

type PersonList []*Person

PersonList is an array of pointers to Person structs

func (PersonList) ToNames

func (persons PersonList) ToNames() []string

ToNames takes an array of pointers to Person and returns a list of names (family, given)

func (PersonList) ToORCIDs

func (persons PersonList) ToORCIDs() []string

ToORCIDs takes an an array of pointers to Person and returns a list of ORCID ids

type Record

type Record struct {
	XMLName              xml.Name           `json:"-"`
	Title                string             `xml:"eprint>title" json:"title"`
	URI                  string             `json:"uri"`
	Abstract             string             `xml:"eprint>abstract" json:"abstract"`
	Documents            DocumentList       `xml:"eprint>documents>document" json:"documents"`
	Note                 string             `xml:"eprint>note" json:"note"`
	ID                   int                `xml:"eprint>eprintid" json:"id"`
	RevNumber            int                `xml:"eprint>rev_number" json:"rev_number"`
	UserID               int                `xml:"eprint>userid" json:"userid"`
	Dir                  string             `xml:"eprint>dir" json:"eprint_dir"`
	Datestamp            string             `xml:"eprint>datestamp" json:"datestamp"`
	LastModified         string             `xml:"eprint>lastmod" json:"lastmod"`
	StatusChange         string             `xml:"eprint>status_changed" json:"status_changed"`
	Type                 string             `xml:"eprint>type" json:"type"`
	MetadataVisibility   string             `xml:"eprint>metadata_visibility" json:"metadata_visibility"`
	Creators             PersonList         `xml:"eprint>creators>item" json:"creators"`
	IsPublished          string             `xml:"eprint>ispublished" json:"ispublished"`
	Subjects             []string           `xml:"eprint>subjects>item" json:"subjects"`
	FullTextStatus       string             `xml:"eprint>full_text_status" json:"full_text_status"`
	Keywords             string             `xml:"eprint>keywords" json:"keywords"`
	Date                 string             `xml:"eprint>date" json:"date"`
	DateType             string             `xml:"eprint>date_type" json:"date_type"`
	Publication          string             `xml:"eprint>publication" json:"publication"`
	Volume               string             `xml:"eprint>volume" json:"volume"`
	Number               string             `xml:"eprint>number" json:"number"`
	PageRange            string             `xml:"eprint>pagerange" json:"pagerange"`
	IDNumber             string             `xml:"eprint>id_number" json:"id_number"`
	Referred             bool               `xml:"eprint>refereed" json:"refereed"`
	ISSN                 string             `xml:"eprint>issn" json:"issn"`
	OfficialURL          string             `xml:"eprint>official_url" json:"official_url"`
	RelatedURL           []*RelatedURL      `xml:"eprint>related_url>item" json:"related_url"`
	ReferenceText        []string           `xml:"eprint>referencetext>item" json:"referencetext"`
	Rights               string             `xml:"eprint>rights" json:"rights"`
	OfficialCitation     string             `xml:"eprint>official_cit" json:"official_citation"`
	OtherNumberingSystem []*NumberingSystem `xml:"eprint>other_numbering_system>item,omitempty" json:"other_numbering_system"`
	Funders              FunderList         `xml:"eprint>funders>item" json:"funders"`
	Collection           string             `xml:"eprint>collection" json:"collection"`
	Reviewer             string             `xml:"eprint>reviewer" json:"reviewer"`
	LocalGroup           []string           `xml:"eprint>local_group>item" json:"local_group"`
}

Record returns a structure that can be converted to JSON easily

func (*Record) PubDate

func (record *Record) PubDate() string

func (*Record) ToBibTeXElement

func (rec *Record) ToBibTeXElement() *bibtex.Element

ToBibTeXElement takes an epgo.Record and turns it into a bibtex.Element record

type RelatedURL

type RelatedURL struct {
	XMLName     xml.Name `json:"-"`
	URL         string   `xml:"url" json:"url"`
	Type        string   `xml:"type" json:"type"`
	Description string   `xml:"description" json:"description"`
}

RelatedURL is a structure containing information about a relationship

Directories

Path Synopsis
cmds
epgo command
Package epgo is a collection of structures and functions for working with the E-Prints REST API @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.
Package epgo is a collection of structures and functions for working with the E-Prints REST API @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.
epgo-genpages command
Package epgo is a collection of structures and functions for working with the E-Prints REST API @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.
Package epgo is a collection of structures and functions for working with the E-Prints REST API @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL