unsplash

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pingback

func Pingback(s *xorm.Session, f *files.File)

Pingback pings the unsplash api if an unsplash photo has been accessed.

func ProxyUnsplashImage

func ProxyUnsplashImage(c echo.Context) error

ProxyUnsplashImage proxies a thumbnail from unsplash for privacy reasons. @Summary Get an unsplash image @Description Get an unsplash image. **Returns json on error.** @tags project @Produce octet-stream @Param image path int true "Unsplash Image ID" @Security JWTKeyAuth @Success 200 {file} blob "The image" @Failure 404 {object} models.Message "The image does not exist." @Failure 500 {object} models.Message "Internal error" @Router /backgrounds/unsplash/image/{image} [get]

func ProxyUnsplashThumb

func ProxyUnsplashThumb(c echo.Context) error

ProxyUnsplashThumb proxies a thumbnail from unsplash for privacy reasons. @Summary Get an unsplash thumbnail image @Description Get an unsplash thumbnail image. The thumbnail is cropped to a max width of 200px. **Returns json on error.** @tags project @Produce octet-stream @Param image path int true "Unsplash Image ID" @Security JWTKeyAuth @Success 200 {file} blob "The thumbnail" @Failure 404 {object} models.Message "The image does not exist." @Failure 500 {object} models.Message "Internal error" @Router /backgrounds/unsplash/image/{image}/thumb [get]

Types

type Photo

type Photo struct {
	ID          string `json:"id"`
	CreatedAt   string `json:"created_at"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	Color       string `json:"color"`
	Description string `json:"description"`
	BlurHash    string `json:"blur_hash"`
	User        struct {
		Username string `json:"username"`
		Name     string `json:"name"`
	} `json:"user"`
	Urls struct {
		Raw     string `json:"raw"`
		Full    string `json:"full"`
		Regular string `json:"regular"`
		Small   string `json:"small"`
		Thumb   string `json:"thumb"`
	} `json:"urls"`
	Links struct {
		Self             string `json:"self"`
		HTML             string `json:"html"`
		Download         string `json:"download"`
		DownloadLocation string `json:"download_location"`
	} `json:"links"`
}

Photo represents an unpslash photo as returned by their api

type Provider

type Provider struct {
}

Provider represents an unsplash image provider

func (*Provider) Search

func (p *Provider) Search(_ *xorm.Session, search string, page int64) (result []*background.Image, err error)

Search is the implementation to search on unsplash @Summary Search for a background from unsplash @Description Search for a project background from unsplash @tags project @Produce json @Security JWTKeyAuth @Param s query string false "Search backgrounds from unsplash with this search term." @Param p query int false "The page number. Used for pagination. If not provided, the first page of results is returned." @Success 200 {array} background.Image "An array with photos" @Failure 500 {object} models.Message "Internal error" @Router /backgrounds/unsplash/search [get]

func (*Provider) Set

func (p *Provider) Set(s *xorm.Session, image *background.Image, project *models.Project, auth web.Auth) (err error)

Set sets an unsplash photo as project background @Summary Set an unsplash photo as project background @Description Sets a photo from unsplash as project background. @tags project @Accept json @Produce json @Security JWTKeyAuth @Param id path int true "Project ID" @Param project body background.Image true "The image you want to set as background" @Success 200 {object} models.Project "The background has been successfully set." @Failure 400 {object} web.HTTPError "Invalid image object provided." @Failure 403 {object} web.HTTPError "The user does not have access to the project" @Failure 500 {object} models.Message "Internal error" @Router /projects/{id}/backgrounds/unsplash [post]

type SearchResult

type SearchResult struct {
	Total      int      `json:"total"`
	TotalPages int      `json:"total_pages"`
	Results    []*Photo `json:"results"`
}

SearchResult is a search result from unsplash's api

Jump to

Keyboard shortcuts

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