sirkulator

package module
v0.0.0-...-0d6871a Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: AGPL-3.0 Imports: 13 Imported by: 0

README

Sirkulator

Sirkulator er et biblioteksystem i emning. Kanskje det blir bra, eller kanskje det ikke blir noe av.

Status

  • 2022 januar: Første spadestikk. Ingenting virker ennå! Kom tilbake om et års tid.

Lisens

AGPLv3

Documentation

Index

Constants

View Source
const (
	CodeInternal     = "internal"     // 500 catch-all "our" errors
	CodeConflict     = "conflict"     // 409
	CodeInvalid      = "invalid"      // 400 user errors
	CodeNotFound     = "not_found"    // 404
	CodeUnauthorized = "unauthorized" // 401

)

Application error codes, which map nicely to http status codes

Variables

View Source
var (
	ErrInternal     = Error{Code: CodeInternal}
	ErrConflict     = Error{Code: CodeConflict}
	ErrInvalid      = Error{Code: CodeInvalid}
	ErrNotFound     = Error{Code: CodeNotFound}
	ErrUnauthorized = Error{Code: CodeUnauthorized}
)
View Source
var GetNewID func() string = shortid.MustGenerate

GetNewID returns a new string ID which can be used to persist a new Resource to DB. NOTE: Currently this is a variable so that it can be overwritten with a

deterministic function for test purposes. TODO revise.

Functions

This section is empty.

Types

type AgentContribution

type AgentContribution struct {
	SimpleResource
	Year  int // TODO publication year or first published year?
	Roles []marc.Relator
}

AgentContribution is a contribution from the viewpoint of an Agent (Person|Corporation).

type Character

type Character struct {
	Name           string   `json:"name"`
	NameVariations []string `json:"name_variations"`
}

Character is a fictional or mythical person/character. Examples: Ulysses, Apollon, Zevs, Donald Duck, Harry Hole

type Corporation

type Corporation struct {
	YearRange      YearRange `json:"year_range"`
	Name           string    `json:"name"`
	Description    string    `json:"description"`
	ParentName     string    `json:"parent_name,omitempty"`
	NameVariations []string  `json:"name_variations"`
	Notes          []string  `json:"notes"`
}

Corporation TODO rename Organization?

func (Corporation) Label

func (c Corporation) Label() string

type Dewey

type Dewey struct {
	Number string   `json:"number"` // same as resource.ID
	Name   string   `json:"name"`   // Only norwegian label for now
	Terms  []string `json:"terms"`  // Henvisningstermer

}

func (Dewey) Label

func (d Dewey) Label() string

type Error

type Error struct {
	Code    string
	Message string
}

func Errorf

func Errorf(code string, format string, args ...any) *Error

Errorf returns an Error with the given code and formatted message.

func (Error) Error

func (e Error) Error() string

type Image

type Image struct {
	ID     string
	Type   string // MIME type, but stored without "image/" prefix
	Height int
	Width  int
}

type Persistable

type Persistable interface {
	Validate(url.Values) (Persistable, bool)
	Label() string
}

type Person

type Person struct {
	YearRange      YearRange    `json:"year_range"` // TODO pointer *YearRange?
	Name           string       `json:"name"`
	Description    string       `json:"description"`
	NameVariations []string     `json:"name_variations"`
	Gender         vocab.Gender `json:"gender"`
	Countries      []string     `json:"countries"`
	Nationalities  []string     `json:"nationalities"`
	Notes          []string     `json:"notes"`
}

func (Person) Label

func (p Person) Label() string

type Publication

type Publication struct {
	// Title and publishing info
	Title    string   `json:"title"`
	Subtitle string   `json:"subtitle,omitempty"`
	Series   []string `json:"series"`
	// Note, Year|YearFirst=0 means we cannot have a publication published in year 0,
	// assumed this to be not a practical problem, not a lot of known classics published that year (TODO any?)
	// https://en.wikipedia.org/wiki/Ancient_literature
	Year json.Number `json:"year,omitempty"`

	// "Work" / orignal title info
	// WorkRepresentative bool  / WorkExample - prefer first edition in original language
	// WorkClassic bool // homer, bible, pre 1500 books etc
	YearFirst        json.Number `json:"year_first,omitempty"`
	TitleOriginal    string      `json:"title_original,omitempty"`
	LanguageOriginal string      `json:"language_original,omitempty"`

	// Content info
	Language       string   `json:"language,omitempty"`
	LanguagesOther []string `json:"languages_other"`
	GenreForms     []string `json:"genre_forms"`
	Audiences      []string `json:"audiences"`
	Fiction        bool     `json:"fiction"`
	Nonfiction     bool     `json:"nonfiction"`
	Subjects       []string

	// Physical info
	Binding  vocab.Binding `json:"binding"` // hardcover, paperback, innbundet, heftet etc...
	NumPages json.Number   `json:"numpages,omitempty"`
}

func (Publication) Label

func (p Publication) Label() string

TODO how to get author into the picture?

type PublicationContribution

type PublicationContribution struct {
	Agent SimpleResource
	Roles []marc.Relator
}

PublicationContribution is a contribution from the view point of a Publication.

type Publisher

type Publisher struct {
	YearRange      YearRange `json:"year_range"` // TODO pointer *YearRange?
	Name           string    `json:"name"`
	Description    string    `json:"description"`
	NameVariations []string  `json:"name_variations"`
	Notes          []string  `json:"notes"`
}

func (Publisher) Label

func (p Publisher) Label() string

type PublisherPublication

type PublisherPublication struct {
	SimpleResource
	Year int
}

type Relation

type Relation struct {
	ID     int64
	FromID string
	ToID   string
	Type   string
	Data   map[string]any // TODO consider map[string]string or [][2]string
}

type RelationExp

type RelationExp struct {
	Relation
	Label string
	From  SimpleResource
	To    SimpleResource
}

type Resource

type Resource struct {
	Type  ResourceType
	ID    string
	Label string // Synthesized from Data properties
	Links [][2]string
	Data  any // TODO Persistable?

	CreatedAt  time.Time
	UpdatedAt  time.Time
	ArchivedAt time.Time
}

func (Resource) Document

func (r Resource) Document() search.Document

type ResourceText

type ResourceText struct {
	ID        int64
	Text      string
	Format    string
	Source    string
	SourceURL string
	UpdatedAt time.Time
}

type ResourceType

type ResourceType int
const (
	// TODO consider string consts instead
	TypeUnknown ResourceType = iota
	TypePublication
	TypePublisher
	TypePerson
	TypeCorporation
	TypeLiteraryAward
	TypeSeries
	TypeDewey
)

func AllResourceTypes

func AllResourceTypes() []ResourceType

func ParseResourceType

func ParseResourceType(s string) ResourceType

func (ResourceType) Label

func (r ResourceType) Label(tag language.Tag) string

Label returns a localized string representation of ResourceType.

func (ResourceType) String

func (r ResourceType) String() string

type SimpleResource

type SimpleResource struct {
	Type  ResourceType
	ID    string
	Label string
}

SimpleResource is a minimal representation of a Resource that can be displayed and referenced to (i.e generate a URL/link from type+ID). If ID is empty it is not persisted or intended for persistence.

type YearRange

type YearRange struct {
	From   json.Number `json:"from,omitempty"`
	To     json.Number `json:"to,omitempty"`
	Approx bool        `json:"approx"`
}

YearRange represents a span of years, with a from and to year, and a specification if it is accurate (Approx=false) or approximate (Approx=true). Using json.Number instead of int allow us to distinguish between year 0 and no value. It also simplifies form validation.

func (YearRange) Label

func (yr YearRange) Label(tag language.Tag) string

Label returns a localized string representation of YearRange.

func (YearRange) String

func (yr YearRange) String() string

String returns a (ideally language-agnostic) string representation of YearRange. TODO find language independent representation of BC/AD

func (YearRange) Valid

func (yr YearRange) Valid() bool

Directories

Path Synopsis
cmd
package etl
package etl
client
package client TODO rename httpclient?
package client TODO rename httpclient?
internal
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.
Package marc implements decoding of MARCXML (MarcXchange (ISO25577) bibliographic MARC records, and convenience methods for extracting values from record fields.
Package marc implements decoding of MARCXML (MarcXchange (ISO25577) bibliographic MARC records, and convenience methods for extracting values from record fields.
iso3166
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.
iso6393
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.
rda
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.

Jump to

Keyboard shortcuts

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