artsparts

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2017 License: GPL-3.0 Imports: 17 Imported by: 1

README

Stories in Ready Go Report Card Build Status

ArtsParts

ArtsParts is a funny way to share your favorite part of an artwork.

Twitter

The app uses twitter for login or sharing picture. All the picture parts are not stored localy. Everything will be uploaded to twitter and stored there. All the results are then just availiable over the tweets of the user.

Not only the user needs a own account also the running app needs to be registered at twitter.

Also every artwork is going to be tweeted by the app over the connected twitter account. At this point it is important to check that the license of the uploaded pictures allow it to share them over the twitter account.

Test picture

The test picture is provided by Stabi Hamburg under a open source license.

Documentation

Index

Constants

View Source
const ConfFileName = "conf.yml"

ConfFileName is the static value for all yaml conf files

View Source
const DataFileName = "data.json"

DataFileName defines the filename where data is stored.

View Source
const TimeStampLayout = "200601021504"

TimeStampLayout defines the time layout string for the timestamp const TimeStampLayout = "200601021504 -0700 MST"

Variables

This section is empty.

Functions

func ImageToBaseString

func ImageToBaseString(img image.Image) (string, error)

Types

type App

type App struct {
	Institutions Institutions
}

App wraps the whole logic for a simple communication from the http handlers.

func NewApp

func NewApp(fpath string) (*App, error)

NewApp creates a new app by a given filepath

func (*App) AdminInstitutions

func (a *App) AdminInstitutions(userName string) Institutions

AdminInstitutions returns all the intitutions, where the user is admin

func (*App) GetArtwork

func (a *App) GetArtwork(instID, collID, artwID string) (*Artwork, bool)

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

func (a *App) GetPublishedTimeline(filter string) ([]*Artwork, error)

GetPublishedTimeline calls GetTimeline() and filters all artworks which has a timestamp in the future. So just the published artworks are returned

func (*App) GetTimeline

func (a *App) GetTimeline(filter string) ([]*Artwork, error)

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) AddPart

func (artw *Artwork) AddPart(p *Part)

AddPart adds a Part to the artwork

func (*Artwork) Artpart

func (artw *Artwork) Artpart(p *Part) (image.Image, error)

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) Image

func (artw *Artwork) Image() (image.Image, error)

Image returns the Image of the artwork

func (*Artwork) ImgFile

func (artw *Artwork) ImgFile() (string, error)

ImgFile return the filename of the image.

func (*Artwork) InstitutionTwitter

func (artw *Artwork) InstitutionTwitter() string

InstitutionTwitter returns the twitter name of the institution

func (*Artwork) IsAdminUser

func (artw *Artwork) IsAdminUser(userName string) bool

IsAdminUser returns true, when the given user has admin rights

func (*Artwork) Marshal

func (artw *Artwork) Marshal() ([]byte, error)

Marshal wraps the json marshal func. If the file format should be changed it can be done here.

func (*Artwork) Path

func (artw *Artwork) Path() string

Path returns the stored path to the artwork as string

func (*Artwork) WriteData

func (artw *Artwork) WriteData() error

WriteData writes the artw into a file. If the file does not exist the file is created.

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

type Timeline

type Timeline []*Artwork

func (Timeline) Len

func (tl Timeline) Len() int

func (Timeline) Less

func (tl Timeline) Less(i, j int) bool

func (Timeline) Swap

func (tl Timeline) Swap(i, j int)

type TimelineItem

type TimelineItem struct {
	InsitutionName   string
	CollectionName   string
	ArtworkName      string
	ArtworkTimestamp int
}

type User

type User struct {
	TwitterID   int64
	TwitterName string
	Email       string
}

User of the artsparts page. Everything about the user goes over twitter. A twitter account and the authentication to the account is compulsary to use artsparts. The TwitterID is a unique number, which is normaly not known by the user. The TwitterName is the screen_name

Directories

Path Synopsis
Package shortlink is a very simple link shortener.
Package shortlink is a very simple link shortener.

Jump to

Keyboard shortcuts

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