Documentation ¶
Index ¶
- type App
- type CategorizedImage
- type Handler
- func (h *Handler) AboutHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CacheImageRedirect(w http.ResponseWriter, r *http.Request)
- func (h *Handler) IndexHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) NotFoundHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RandomRead(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ReadHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) StoryHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) WriteHandler(w http.ResponseWriter, r *http.Request)
- type Inventory
- func (inv *Inventory) ByCategory(category string) (images []CategorizedImage)
- func (inv *Inventory) ByCategoryAndIdentifier(category, identifier string) (*CategorizedImage, error)
- func (inv *Inventory) Categories() (categories []string)
- func (inv *Inventory) NumAssets() int
- func (inv *Inventory) Ok() bool
- func (inv *Inventory) RandomImageIdentifier() (rid string, err error)
- func (inv *Inventory) RandomVideoIdentifier() (vid string, err error)
- type Story
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Inventory *Inventory // contains filtered or unexported fields }
App configuration and data access layer.
type CategorizedImage ¶
CategorizedImage belongs to a category, path records the absolute path. The identifier is just the basename of the image, e.g. 12 for 12.jpg file.
type Handler ¶
type Handler struct { App *App StaticDir string TemplatesDir string Version string // contains filtered or unexported fields }
Handler implements HTTP request for reading, writing and rendering stories. Has access to application and static directory for assets, e.g. cached images.
func (*Handler) AboutHandler ¶
func (h *Handler) AboutHandler(w http.ResponseWriter, r *http.Request)
AboutHandler render information about the app.
func (*Handler) CacheImageRedirect ¶
func (h *Handler) CacheImageRedirect(w http.ResponseWriter, r *http.Request)
CacheImageRedirect is a helper handler, which creates an image on the fly, of just redirects to the static location of the image.
func (*Handler) IndexHandler ¶
func (h *Handler) IndexHandler(w http.ResponseWriter, r *http.Request)
IndexHandler render the home page.
func (*Handler) NotFoundHandler ¶
func (h *Handler) NotFoundHandler(w http.ResponseWriter, r *http.Request)
NotFoundHandler renders a 404 page.
func (*Handler) RandomRead ¶
func (h *Handler) RandomRead(w http.ResponseWriter, r *http.Request)
RandomRead redirects to a random read page.
func (*Handler) ReadHandler ¶
func (h *Handler) ReadHandler(w http.ResponseWriter, r *http.Request)
ReadHandler reads a story, given a random (image) identifier, e.g. "121403" or similar.
func (*Handler) StoryHandler ¶
func (h *Handler) StoryHandler(w http.ResponseWriter, r *http.Request)
StoryHandler links to a single story. One image can have multiple.
func (*Handler) WriteHandler ¶
func (h *Handler) WriteHandler(w http.ResponseWriter, r *http.Request)
WriteHandler creates a new story.
type Inventory ¶
type Inventory struct { Images []CategorizedImage Videos []string }
Inventory make images and videos accessible in various ways. The slices contain the absolute path and a bit of derived information. This struct exposes a few functions, that help to locate images by category, by identifier and the like. TODO(miku): maybe categorize videos as well.
func (*Inventory) ByCategory ¶
func (inv *Inventory) ByCategory(category string) (images []CategorizedImage)
ByCategory returns image paths by category, empty list, if the category does not exist.
func (*Inventory) ByCategoryAndIdentifier ¶
func (inv *Inventory) ByCategoryAndIdentifier(category, identifier string) (*CategorizedImage, error)
ByCategoryAndIdentifier returns the image descriptor for a given category and identifier.
func (*Inventory) Categories ¶
Categories returns the unique image categories.
func (*Inventory) Ok ¶
Ok checks if the inventory is somewhat usable. Also, we want three categories at the moment.
func (*Inventory) RandomImageIdentifier ¶
RandomImageIdentifier returns a random composite image identifier from fixed categories (artifacts, people, landscape).
func (*Inventory) RandomVideoIdentifier ¶
RandomVideoIdentifier returns the id to a random video.