citation

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: GPL-2.0, GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportBibtex

func ExportBibtex(citations []Citation)

exports all citations to bibtex

func ExportJson

func ExportJson(citations []Citation)

exports citations to short json

Types

type Citation

type Citation struct {
	Address      string // address
	Author       []CitationAuthor
	Booktitle    string // booktitle
	Chapter      string // chapter
	Citekey      string // citekey (generated)
	Doi          string // doi
	Editor       []CitationAuthor
	File         string // appended file
	Howpublished string // how published
	Institution  string // institution
	Id           int    // database id (generated)
	Isbn         string // isbn
	Issn         string // issn
	Journal      string // journal name
	Number       string // issue number
	Organization string // organization
	Pages        string // pages
	Publisher    string // publisher
	ResourceType string // needs to be converted to bibtex entry type
	Series       string // series
	School       string // school
	Title        string // title
	Url          string // doi url
	UrlDate      string // access date (generated)
	Volume       string // volume
	Year         string // year
}

the organized form of a citation

func ParseFromBibtex

func ParseFromBibtex(bibtex string) []Citation

tries to parse a bibtex string to []Citation assumes a reasonably well formatted bibtex file https://www.bibtex.com/g/bibtex-format/

func (*Citation) CopyFile

func (self *Citation) CopyFile(file string) string

copies source file to the bibliography folder and returns new name

func (*Citation) GetAuthorCitekey

func (self *Citation) GetAuthorCitekey() string

returns author abbreviation for citekey

func (*Citation) GetAuthorTui

func (self *Citation) GetAuthorTui() string

returns short author string for TUI either:

family name (if one author),
family and family (2 authors),
family et al. (more authors)

func (*Citation) GetAuthorsSql

func (self *Citation) GetAuthorsSql(citAuthors []CitationAuthor) string

returns authors as delimited string for the sql database

func (*Citation) GetCiteKey

func (self *Citation) GetCiteKey() string

returns citekey

func (*Citation) GetTitle

func (self *Citation) GetTitle() string

returns abbreviated title

func (*Citation) GetYear

func (self *Citation) GetYear() string

returns publication year

func (Citation) Print

func (self Citation) Print()

prints citation summary

type CitationAuthor

type CitationAuthor struct {
	Family string `json:"family"`
	Given  string `json:"given"`
}

an author's family and given name

func ParseAuthorsSql

func ParseAuthorsSql(authors string) []CitationAuthor

parses authors delimited string to []CitationAuthor

type CitationShort

type CitationShort struct {
	Authors string
	Title   string
	Year    string
	Citekey string
}

'short' citations for json export

type Client

type Client struct {
	// contains filtered or unexported fields
}

crossref / datacite api

func NewClient

func NewClient(source ClientType) Client

returns new client

func (*Client) GetCitation

func (self *Client) GetCitation(doi, file string) (Citation, error)

returns api call result

type ClientType

type ClientType int

which api to choose

const (
	CrossRefClient ClientType = 0
	DataCiteClient ClientType = 1
)

type Crossref added in v0.0.2

type Crossref struct {
	Status         string         `json:"status"`
	MessageType    string         `json:"message-type"`
	MessageVersion string         `json:"message-version"`
	Message        CrossrefFields `json:"message"`
}

type CrossrefFields added in v0.0.2

type CrossrefFields struct {
	Author         []CitationAuthor `json:"author"`
	ContainerTitle []string         `json:"container-title"`
	DOI            string           `json:"DOI"`
	Editor         []CitationAuthor `json:"editor"`
	ISBN           []string         `json:"ISBN"`
	ISSN           []string         `json:"ISSN"`
	Issue          string           `json:"issue"`
	Link           []ResourceLink   `json:"link"`
	Page           string           `json:"page"`
	Publisher      string           `json:"publisher"`
	Title          []string         `json:"title"`
	Type           string           `json:"type"`
	URL            string           `json:"URL"`
	Volume         string           `json:"volume"`
	Published      DatePart         `json:"published"`
}

type Datacite added in v0.0.2

type Datacite struct {
	Data struct {
		Attributes DataciteFields `json:"attributes"`
	} `json:"data"`
}

type DataciteFields added in v0.0.2

type DataciteFields struct {
	Author     []CitationAuthor `json:"author"`
	Container  string           `json:"container-title"`
	Doi        string           `json:"doi"`
	Identifier string           `json:"identifier"`
	Publisher  string           `json:"publisher"`
	Title      string           `json:"title"`
	Type       string           `json:"resource-type-id"`
	Url        string           `json:"url"`
	Year       string           `json:"published"`
}

type DatePart added in v0.0.2

type DatePart struct {
	Parts [][]int `json:"date-parts"`
}
type ResourceLink struct {
	URL string `json:"URL"`
}

Jump to

Keyboard shortcuts

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