Documentation ¶
Index ¶
- Constants
- func ImageToBaseString(img image.Image) (string, error)
- type App
- func (a *App) AdminInstitutions(userName string) Institutions
- func (a *App) GetArtwork(instID, collID, artwID string) (*Artwork, bool)
- func (a *App) GetCollection(instID, collID string) (*Collection, bool)
- func (a *App) GetInstitution(instID string) (*Institution, bool)
- func (a *App) GetPublishedTimeline(filter string) ([]*Artwork, error)
- func (a *App) GetTimeline(filter string) ([]*Artwork, error)
- type Artwork
- func (artw *Artwork) AddPart(p *Part)
- func (artw *Artwork) Artpart(p *Part) (image.Image, error)
- func (artw *Artwork) Image() (image.Image, error)
- func (artw *Artwork) ImgFile() (string, error)
- func (artw *Artwork) InstitutionTwitter() string
- func (artw *Artwork) IsAdminUser(userName string) bool
- func (artw *Artwork) Marshal() ([]byte, error)
- func (artw *Artwork) Path() string
- func (artw *Artwork) WriteData() error
- type Collection
- type Institution
- type Institutions
- type Part
- type Timeline
- type TimelineItem
- type User
Constants ¶
const ConfFileName = "conf.yml"
ConfFileName is the static value for all yaml conf files
const DataFileName = "data.json"
DataFileName defines the filename where data is stored.
const TimeStampLayout = "200601021504"
TimeStampLayout defines the time layout string for the timestamp const TimeStampLayout = "200601021504 -0700 MST"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
Institutions Institutions
}
App wraps the whole logic for a simple communication from the http handlers.
func (*App) AdminInstitutions ¶
func (a *App) AdminInstitutions(userName string) Institutions
AdminInstitutions returns all the intitutions, where the user is admin
func (*App) GetArtwork ¶
GetArtwork returns the pointer to the given ids.
func (*App) GetCollection ¶
func (a *App) GetCollection(instID, collID string) (*Collection, bool)
GetCollection returns the pointer to the given ids.
func (*App) GetInstitution ¶
func (a *App) GetInstitution(instID string) (*Institution, bool)
GetInstitution returns the pointer to the given id. Second return parameter gives false, when no entry is found.
func (*App) GetPublishedTimeline ¶
GetPublishedTimeline calls GetTimeline() and filters all artworks which has a timestamp in the future. So just the published artworks are returned
func (*App) GetTimeline ¶
GetTimeline returns artworks, which can displayed in a timeline filter allows to get just special artowrks The logic is /[institution]/[collection]/[artwork.Name] The filter uses the simple regexp.MatchString() function
type Artwork ¶
type Artwork struct { Timestamp string `json:"timestamp"` ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` TweetID int64 `json:"tweet"` HashTag string `json:"hashtag"` URIPath string `json:"-"` ShortLink string `json:"shortlink"` Parts []*Part // contains filtered or unexported fields }
Artwork is one element like for example a picture. The picture should be placed inside a folder. One artwork per folder! The foldername is then used as the id. The conf file here is stored as JSON, because the content is created and edited via a configuration dialog. Path contains the part of the url how the artwork can be found: /[institution]/[collection]/[artwork]
func NewArtwork ¶
func NewArtwork(fpath string, coll *Collection) (*Artwork, error)
NewArtwork loads an artwork configuration and return a pointer.
func (*Artwork) Artpart ¶
Artpart creates the part of the artwork. Every number is relative to the size of the picture. To get the x value in pixel you need to multiply it to the width
func (*Artwork) InstitutionTwitter ¶
InstitutionTwitter returns the twitter name of the institution
func (*Artwork) IsAdminUser ¶
IsAdminUser returns true, when the given user has admin rights
func (*Artwork) Marshal ¶
Marshal wraps the json marshal func. If the file format should be changed it can be done here.
type Collection ¶
type Collection struct { ID string `json:"id" yaml:"id"` Name string `json:"name" yaml:"name"` Description string `json:"description" yaml:"description"` License string `json:"license" yaml:"license"` Order int `json:"order" yaml:"order"` Artworks []*Artwork `json:"artworks" yaml:"-"` // contains filtered or unexported fields }
Collection represents a group of artworks, which are presented together. It could be grouped after artist or a specific style. The Order property allows to sort the collections of a institution.
func NewCollection ¶
func NewCollection(fpath string, inst *Institution) (*Collection, error)
NewCollection loads the configuration and creates a pointer to the new collection
func (*Collection) GetArtwork ¶
func (coll *Collection) GetArtwork(artwID string) (*Artwork, bool)
GetArtwork searches for an artwork id and returns a pointer to the artwork. If there is not artwork found with the given ID the second return value returns false.
type Institution ¶
type Institution struct { ID string `json:"id" yaml:"id"` Name string `json:"name" yaml:"name"` Description string `json:"description" yaml:"description"` License string `json:"license" yaml:"license"` TwitterName string `json:"twittername" yaml:"twitter_name"` Order int `json:"order" yaml:"order"` Collections map[string]*Collection `json:"collections" yaml:"-"` Admins []string `json:"admins" yaml:"admins"` }
Institution defines a museum or another partner of the site, which offers collections of digital art images.
Following structure of the folders is needed:
institution └───collections
└───collection1 ├───pic1 └───pic2
The ID has to be unique and is always used inside the url.
func NewInstitution ¶
func NewInstitution(fpath string) (*Institution, error)
NewInstitution takes a filepath and loads the configuration. Then it loads all the collections.
type Institutions ¶
type Institutions []*Institution
Institutions holds the complete logic of the artsparts site. The insitutions are organized over a slice.
type Part ¶
type Part struct { Text string `json:"tweettext"` X float64 `json:"x"` Y float64 `json:"y"` Width float64 `json:"width"` Height float64 `json:"height"` User string `json:"user"` TweetID int64 `json:"tweet_id,omitempty"` MediaID int64 `json:"media_id,omitempty"` }
Part represends a part, which is tweeted from artsparts all coordinates are relative to get the pixel the values have to be multiplied with the image size. For example X * ImageWidth = Pixel for X