media

package
v0.0.0-...-06d4dd4 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2013 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var API = Api{

	AllThumbnails: view.RenderViewWithURLBindURLArgs(
		func(ctx *view.Context, thumbnailSize int) error {
			ctx.Response.Header().Set("Content-Type", "application/json")
			ctx.Response.WriteString("[\n")
			first := true
			i := Config.Backend.ImageIterator()
			var image Image
			for i.Next(&image) {
				thumbnail, err := image.Thumbnail(thumbnailSize)
				if err != nil {
					return err
				}
				if first {
					first = false
				} else {
					ctx.Response.WriteString(",\n")
				}
				ctx.Response.Printf(
					`{"id": "%s", "title": "%s", "url": "%s"}`,
					image.ID, image.Title, thumbnail.FileURL().URL(ctx),
				)
			}
			if i.Err() != nil {
				return i.Err()
			}
			ctx.Response.WriteString("\n]")
			return nil
		},
	),
}
View Source
var Config = Configuration{
	DummyImageColor: "#a8a8a8",
	Admin: AdminConfiguration{
		ImageEditorClass:    "media-image-editor",
		ThumbnailSize:       200,
		ThumbnailFrameClass: "thumbnail-frame",
		ActionsClass:        "actions",
	},
	ImageRefController: ImageRefControllerConfiguration{
		Class:               "media-imageref-editor",
		ThumbnailSize:       100,
		ThumbnailFrameClass: "thumbnail-frame",
		ActionsClass:        "actions",
	},
	BlobRefController: BlobRefControllerConfiguration{
		Class:        "media-blobref-editor",
		ActionsClass: "actions",
	},
}
View Source
var FileView = view.NewViewURLWrapper(view.RenderView(
	func(ctx *view.Context) error {
		reader, _, contentType, err := Config.Backend.FileReader(ctx.URLArgs[0])
		if err != nil {
			if _, ok := err.(ErrNotFound); ok {
				err = view.NotFound(ctx.URLArgs[0] + "/" + ctx.URLArgs[1] + " not found")
				config.Logger.Println("FileView:", err)
				return err
			}
			return err
		}
		defer reader.Close()
		_, err = io.Copy(ctx.Response, reader)
		if err != nil {
			config.Logger.Println("FileView:", err)
			return err
		}
		ctx.Response.Header().Set("Content-Type", contentType)
		return nil
	},
))
View Source
var UploadBlob = view.NewViewURLWrapper(view.RenderViewBindURLArgs(
	func(ctx *view.Context, thumbnailSize int) error {
		formatError := func(err error) error {
			config.Logger.Println("UploadBlob:", err)
			return fmt.Errorf(`{success: false, error: "%s"}`, err.Error())
		}

		filename := ctx.Request.Header.Get("X-File-Name")
		var r io.ReadCloser
		if filename != "" {
			r = ctx.Request.Body
		} else {
			f, h, err := ctx.Request.FormFile("qqfile")
			if err != nil {
				return formatError(err)
			}
			filename = h.Filename
			r = f
		}
		defer r.Close()
		blob, err := NewBlobFromReader(filename, r)
		if err != nil {
			return formatError(err)
		}

		ctx.Response.Printf(`{success: true, blobID: "%s", blobSize: %d}`, blob.ID, blob.Size)
		return nil
	},
))
View Source
var UploadImage = view.NewViewURLWrapper(view.RenderViewBindURLArgs(
	func(ctx *view.Context, thumbnailSize int) error {
		formatError := func(err error) error {
			config.Logger.Println("UploadImage:", err)
			return fmt.Errorf(`{success: false, error: "%s"}`, err.Error())
		}

		filename := ctx.Request.Header.Get("X-File-Name")
		var r io.ReadCloser
		if filename != "" {
			r = ctx.Request.Body
		} else {
			f, h, err := ctx.Request.FormFile("qqfile")
			if err != nil {
				return formatError(err)
			}
			filename = h.Filename
			r = f
		}
		defer r.Close()

		i, err := NewImageFromReader(filename, r)
		if err != nil {
			return formatError(err)
		}
		v, err := i.Thumbnail(thumbnailSize)
		if err != nil {
			return formatError(err)
		}

		ctx.Response.Printf(`{success: true, imageID: "%s", thumbnailURL: "%s", thumbnailSize: %d}`, i.ID, v.FileURL().URL(ctx), thumbnailSize)
		return nil
	},
))

Functions

func BlobIterator

func BlobIterator() model.Iterator

func BlobsAdmin

func BlobsAdmin() view.View

func ColoredImageDataURL

func ColoredImageDataURL(c color.Color) string

ColoredImageDataURL creates a 1 pixel image with the given color and encodes it as data URL.

func ImageDataURL

func ImageDataURL(imageURL string) (dataURL string, err error)

ImageDataURL loads an image and encodes it as a data URL. Use a file-URL that begins with file:// to load local files.

func ImageIterator

func ImageIterator() model.Iterator

func ImagesAdmin

func ImagesAdmin() view.View

func MakePrettyUrlFilename

func MakePrettyUrlFilename(filename string) string

MakePrettyUrlFilename modifies a filename so it looks good as part on an URL.

func NewImageOfType

func NewImageOfType(src image.Image, width, height int) image.Image

func NewImageOfTypeRect

func NewImageOfTypeRect(src image.Image, bounds image.Rectangle) image.Image

func RequireUploadBlobButtonScript

func RequireUploadBlobButtonScript(parentSelector, dropZoneSelector, listSelector, onComplete string) view.View

Uses https://github.com/valums/file-uploader

func RequireUploadImageButtonScript

func RequireUploadImageButtonScript(parentSelector, dropZoneSelector, listSelector string, thumbnailSize int, onComplete string) view.View

Uses https://github.com/valums/file-uploader

func ResampleImage

func ResampleImage(m image.Image, r image.Rectangle, w, h int) image.Image

Resample returns a resampled copy of the image slice r of m. The returned image has width w and height h.

func SubImageWithoutOffset

func SubImageWithoutOffset(src image.Image, rect image.Rectangle) image.Image

func UploadBlobButton

func UploadBlobButton(dropZoneSelector, listSelector, onComplete string) view.View

func UploadImageButton

func UploadImageButton(dropZoneSelector, listSelector string, thumbnailSize int, onComplete string) view.View

func ViewPath

func ViewPath(name string) view.ViewPath

ViewPath returns the view.ViewPath for all media URLs.

Types

type AdminConfiguration

type AdminConfiguration struct {
	ImageEditorClass    string
	ThumbnailSize       int
	ThumbnailFrameClass string
	ActionsClass        string
	ButtonClass         string
}

type Api

type Api struct {
	AllThumbnails view.ViewWithURL
}

type Backend

type Backend interface {
	FileWriter(filename, contentType string) (writer io.WriteCloser, id string, err error)
	// Returns ErrNotFound if no file with id is found.
	FileReader(id string) (reader io.ReadCloser, filename, contentType string, err error)
	// Returns ErrNotFound if no file with id is found.
	DeleteFile(id string) error

	LoadBlob(id string) (*Blob, error)
	SaveBlob(blob *Blob) error
	// DeleteBlob does not delete the file associated with it, also use DeleteFile().
	DeleteBlob(blob *Blob) error

	// BlobIterator returns an iterator that iterates
	// all blobs as Blob structs.
	BlobIterator() model.Iterator

	// CountBlobRefs counts all BlobRef occurrences with blobID
	// in all known databases.
	CountBlobRefs(blobID string) (count int, err error)

	// RemoveAllBlobRefs removes all BlobRef occurrences with blobID
	// in all known databases.
	RemoveAllBlobRefs(blobID string) (count int, err error)

	// Returns ErrNotFound if no image with id is found.
	LoadImage(id string) (*Image, error)

	// SaveImage saves image and updates its ID if it is empty.
	SaveImage(image *Image) error

	DeleteImage(image *Image) error

	// ImageIterator returns an iterator that iterates
	// all images as Image structs.
	ImageIterator() model.Iterator

	// CountImageRefs counts all ImageRef occurrences with imageID
	// in all known databases.
	CountImageRefs(imageID string) (count int, err error)

	// RemoveAllImageRefs removes all ImageRef occurrences with imageID
	// in all known databases.
	RemoveAllImageRefs(imageID string) (count int, err error)
}

type Blob

type Blob struct {
	ID          model.String `bson:",omitempty"`
	Title       model.String
	Link        model.Url
	Filename    model.String
	ContentType model.String
	Size        model.Int
	FileID      model.String
}

func LoadBlob

func LoadBlob(id string) (*Blob, error)

LoadBlob loads an existing image from Config.Backend.

func NewBlob

func NewBlob(filename string, data []byte) (*Blob, error)

func NewBlobFromReader

func NewBlobFromReader(filename string, reader io.Reader) (*Blob, error)

func NewBlobFromURL

func NewBlobFromURL(url string) (*Blob, error)

NewBlobFromURL creates and saves a new Blob by downloading it from url.

func (*Blob) CountRefs

func (self *Blob) CountRefs() (int, error)

func (*Blob) Delete

func (self *Blob) Delete() error
func (self *Blob) FileLink(class string) *view.Link

func (*Blob) FileReader

func (self *Blob) FileReader() (reader io.ReadCloser, filename, contentType string, err error)

FileReader returns a reader for the blob-file if it exists.

func (*Blob) FileURL

func (self *Blob) FileURL() view.URL

func (*Blob) FileWriter

func (self *Blob) FileWriter() (writer io.WriteCloser, err error)

FileWriter deletes the current blob-file and returns a writer for a new file. The ID of the new file is set at Blob, but Blob is not saved. You have to call Save() after FileWriter().

func (*Blob) Init

func (self *Blob) Init() *Blob

func (*Blob) RemoveAllRefs

func (self *Blob) RemoveAllRefs() (count int, err error)

func (*Blob) Save

func (self *Blob) Save() error

type BlobRef

type BlobRef string

func NewBlobRef

func NewBlobRef(blob *Blob) *BlobRef
func (self *BlobRef) FileLink(class string) (*view.Link, error)

func (*BlobRef) FileURL

func (self *BlobRef) FileURL() (view.URL, error)

func (*BlobRef) Get

func (self *BlobRef) Get() (*Blob, error)

Blob loads the referenced blob, or returns nil if the reference is empty.

func (*BlobRef) IsEmpty

func (self *BlobRef) IsEmpty() bool

func (*BlobRef) Required

func (self *BlobRef) Required(metaData *model.MetaData) bool

func (*BlobRef) Set

func (self *BlobRef) Set(blob *Blob)

SetBlob sets the ID of blob, or an empty reference if blob is nil.

func (*BlobRef) SetString

func (self *BlobRef) SetString(str string) error

func (*BlobRef) String

func (self *BlobRef) String() string

func (*BlobRef) TryGet

func (self *BlobRef) TryGet() (*Blob, bool, error)

func (*BlobRef) Validate

func (self *BlobRef) Validate(metaData *model.MetaData) error

type BlobRefController

type BlobRefController struct {
	view.SetModelValueControllerBase
}

func (BlobRefController) NewInput

func (self BlobRefController) NewInput(withLabel bool, metaData *model.MetaData, form *view.Form) (input view.View, err error)

func (BlobRefController) Supports

func (self BlobRefController) Supports(metaData *model.MetaData, form *view.Form) bool

type BlobRefControllerConfiguration

type BlobRefControllerConfiguration struct {
	Class        string
	ActionsClass string
}

type Configuration

type Configuration struct {
	Backend                 Backend
	NoDynamicStyleAndScript bool
	DummyImageColor         string // web color

	Admin              AdminConfiguration
	ImageRefController ImageRefControllerConfiguration
	BlobRefController  BlobRefControllerConfiguration
	// contains filtered or unexported fields
}

func (*Configuration) Close

func (self *Configuration) Close() error

func (*Configuration) Init

func (self *Configuration) Init() error

func (*Configuration) Name

func (self *Configuration) Name() string

type ErrNotFound

type ErrNotFound string

func (ErrNotFound) Error

func (self ErrNotFound) Error() string

type HorAlignment

type HorAlignment int
const (
	HorCenter HorAlignment = iota
	Left
	Right
)

type Image

type Image struct {
	ID       model.String `bson:",omitempty"`
	Title    model.String
	Link     model.Url
	Size     model.Int
	Versions []ImageVersion
}

func LoadImage

func LoadImage(id string) (*Image, error)

LoadImage loads an existing image from Config.Backend.

func NewImage

func NewImage(filename string, data []byte) (*Image, error)

NewImage creates and saves a new Image. GIF, TIFF, BMP images will be read, but saved as PNG.

func NewImageFromReader

func NewImageFromReader(filename string, reader io.Reader) (*Image, error)

NewImageFromReader creates and saves a new Image from reader. GIF, TIFF, BMP images will be read, but saved as PNG.

func NewImageFromURL

func NewImageFromURL(url string) (*Image, error)

NewImageFromURL creates and saves a new Image by downloading it from url. GIF, TIFF, BMP images will be read, but saved as PNG.

func (*Image) AspectRatio

func (self *Image) AspectRatio() float64

AspectRatio returns Width / Height

func (*Image) ContentType

func (self *Image) ContentType() string

func (*Image) CountRefs

func (self *Image) CountRefs() (int, error)

func (*Image) Delete

func (self *Image) Delete() error

func (*Image) DeleteVersion

func (self *Image) DeleteVersion(index int) error

func (*Image) DeleteVersions

func (self *Image) DeleteVersions() error

func (*Image) FileURL

func (self *Image) FileURL() view.URL

func (*Image) Filename

func (self *Image) Filename() string

func (*Image) Grayscale

func (self *Image) Grayscale() bool

func (*Image) Height

func (self *Image) Height() int

func (*Image) Init

func (self *Image) Init() *Image

func (*Image) OriginalVersion

func (self *Image) OriginalVersion() *ImageVersion

func (*Image) Rectangle

func (self *Image) Rectangle() image.Rectangle

func (*Image) RemoveAllRefs

func (self *Image) RemoveAllRefs() (count int, err error)

func (*Image) Save

func (self *Image) Save() error

func (*Image) Thumbnail

func (self *Image) Thumbnail(size int) (im *ImageVersion, err error)

func (*Image) ThumbnailLinkedView

func (self *Image) ThumbnailLinkedView(size int, imageClass, linkClass string) (*view.Link, error)

func (*Image) ThumbnailView

func (self *Image) ThumbnailView(size int, class string) (*view.Image, error)

func (*Image) Version

func (self *Image) Version(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool) (im *ImageVersion, err error)

func (*Image) VersionCentered

func (self *Image) VersionCentered(width, height int, grayscale bool) (im *ImageVersion, err error)

func (*Image) VersionCenteredLinkedView

func (self *Image) VersionCenteredLinkedView(width, height int, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionCenteredView

func (self *Image) VersionCenteredView(width, height int, grayscale bool, class string) (*view.Image, error)

func (*Image) VersionHeight

func (self *Image) VersionHeight(height int, grayscale bool) (im *ImageVersion, err error)

func (*Image) VersionHeightLinkedView

func (self *Image) VersionHeightLinkedView(height int, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionHeightView

func (self *Image) VersionHeightView(height int, grayscale bool, class string) (*view.Image, error)

func (*Image) VersionLinkedView

func (self *Image) VersionLinkedView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionSourceRect

func (self *Image) VersionSourceRect(sourceRect image.Rectangle, width, height int, grayscale bool, outsideColor color.Color) (im *ImageVersion, err error)

VersionSourceRect searches and returns an existing matching version, or a new one will be created and saved.

func (*Image) VersionSourceRectLinkedView

func (self *Image) VersionSourceRectLinkedView(sourceRect image.Rectangle, width, height int, grayscale bool, outsideColor color.Color, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionSourceRectView

func (self *Image) VersionSourceRectView(sourceRect image.Rectangle, width, height int, grayscale bool, outsideColor color.Color, class string) (*view.Image, error)

func (*Image) VersionTouchOrigFromOutside

func (self *Image) VersionTouchOrigFromOutside(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, outsideColor color.Color) (im *ImageVersion, err error)

func (*Image) VersionTouchOrigFromOutsideCentered

func (self *Image) VersionTouchOrigFromOutsideCentered(width, height int, grayscale bool, outsideColor color.Color) (im *ImageVersion, err error)

func (*Image) VersionTouchOrigFromOutsideCenteredLinkedView

func (self *Image) VersionTouchOrigFromOutsideCenteredLinkedView(width, height int, grayscale bool, outsideColor color.Color, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionTouchOrigFromOutsideCenteredView

func (self *Image) VersionTouchOrigFromOutsideCenteredView(width, height int, grayscale bool, outsideColor color.Color, class string) (*view.Image, error)

func (*Image) VersionTouchOrigFromOutsideLinkedView

func (self *Image) VersionTouchOrigFromOutsideLinkedView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, outsideColor color.Color, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionTouchOrigFromOutsideView

func (self *Image) VersionTouchOrigFromOutsideView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, outsideColor color.Color, class string) (*view.Image, error)

func (*Image) VersionView

func (self *Image) VersionView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, class string) (*view.Image, error)

func (*Image) VersionWidth

func (self *Image) VersionWidth(width int, grayscale bool) (im *ImageVersion, err error)

func (*Image) VersionWidthLinkedView

func (self *Image) VersionWidthLinkedView(width int, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*Image) VersionWidthView

func (self *Image) VersionWidthView(width int, grayscale bool, class string) (*view.Image, error)

func (*Image) Width

func (self *Image) Width() int

type ImageRef

type ImageRef string

func NewImageRef

func NewImageRef(image *Image) *ImageRef

func (*ImageRef) Get

func (self *ImageRef) Get() (*Image, error)

Image loads the referenced image, or returns nil if the reference is empty.

func (*ImageRef) IsEmpty

func (self *ImageRef) IsEmpty() bool

func (*ImageRef) OriginalVersion

func (self *ImageRef) OriginalVersion() (*ImageVersion, error)

func (*ImageRef) OriginalVersionLinkedView

func (self *ImageRef) OriginalVersionLinkedView(imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) OriginalVersionView

func (self *ImageRef) OriginalVersionView(class string) (*view.Image, error)

func (*ImageRef) Required

func (self *ImageRef) Required(metaData *model.MetaData) bool

func (*ImageRef) Set

func (self *ImageRef) Set(image *Image)

SetImage sets the ID of image, or an empty reference if image is nil.

func (*ImageRef) SetString

func (self *ImageRef) SetString(str string) error

func (*ImageRef) String

func (self *ImageRef) String() string

func (*ImageRef) Thumbnail

func (self *ImageRef) Thumbnail(size int) (im *ImageVersion, err error)

func (*ImageRef) ThumbnailLinkedView

func (self *ImageRef) ThumbnailLinkedView(size int, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) ThumbnailView

func (self *ImageRef) ThumbnailView(size int, class string) (*view.Image, error)

func (*ImageRef) TryGet

func (self *ImageRef) TryGet() (*Image, bool, error)

func (*ImageRef) Validate

func (self *ImageRef) Validate(metaData *model.MetaData) error

func (*ImageRef) Version

func (self *ImageRef) Version(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool) (im *ImageVersion, err error)

func (*ImageRef) VersionCentered

func (self *ImageRef) VersionCentered(width, height int, grayscale bool) (im *ImageVersion, err error)

func (*ImageRef) VersionCenteredLinkedView

func (self *ImageRef) VersionCenteredLinkedView(width, height int, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionCenteredView

func (self *ImageRef) VersionCenteredView(width, height int, grayscale bool, class string) (*view.Image, error)

func (*ImageRef) VersionHeight

func (self *ImageRef) VersionHeight(height int, grayscale bool) (im *ImageVersion, err error)

func (*ImageRef) VersionHeightLinkedView

func (self *ImageRef) VersionHeightLinkedView(height int, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionHeightView

func (self *ImageRef) VersionHeightView(height int, grayscale bool, class string) (*view.Image, error)

func (*ImageRef) VersionLinkedView

func (self *ImageRef) VersionLinkedView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionSourceRect

func (self *ImageRef) VersionSourceRect(sourceRect image.Rectangle, width, height int, grayscale bool, outsideColor color.Color) (im *ImageVersion, err error)

func (*ImageRef) VersionSourceRectLinkedView

func (self *ImageRef) VersionSourceRectLinkedView(sourceRect image.Rectangle, width, height int, grayscale bool, outsideColor color.Color, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionSourceRectView

func (self *ImageRef) VersionSourceRectView(sourceRect image.Rectangle, width, height int, grayscale bool, outsideColor color.Color, class string) (*view.Image, error)

func (*ImageRef) VersionTouchOrigFromOutside

func (self *ImageRef) VersionTouchOrigFromOutside(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, outsideColor color.Color) (im *ImageVersion, err error)

func (*ImageRef) VersionTouchOrigFromOutsideCentered

func (self *ImageRef) VersionTouchOrigFromOutsideCentered(width, height int, grayscale bool, outsideColor color.Color) (im *ImageVersion, err error)

func (*ImageRef) VersionTouchOrigFromOutsideCenteredLinkedView

func (self *ImageRef) VersionTouchOrigFromOutsideCenteredLinkedView(width, height int, grayscale bool, outsideColor color.Color, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionTouchOrigFromOutsideCenteredView

func (self *ImageRef) VersionTouchOrigFromOutsideCenteredView(width, height int, grayscale bool, outsideColor color.Color, class string) (*view.Image, error)

func (*ImageRef) VersionTouchOrigFromOutsideLinkedView

func (self *ImageRef) VersionTouchOrigFromOutsideLinkedView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, outsideColor color.Color, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionTouchOrigFromOutsideView

func (self *ImageRef) VersionTouchOrigFromOutsideView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, outsideColor color.Color, class string) (*view.Image, error)

func (*ImageRef) VersionView

func (self *ImageRef) VersionView(width, height int, horAlign HorAlignment, verAlign VerAlignment, grayscale bool, class string) (*view.Image, error)

func (*ImageRef) VersionWidth

func (self *ImageRef) VersionWidth(width int, grayscale bool) (im *ImageVersion, err error)

func (*ImageRef) VersionWidthLinkedView

func (self *ImageRef) VersionWidthLinkedView(width int, grayscale bool, imageClass, linkClass string) (*view.Link, error)

func (*ImageRef) VersionWidthView

func (self *ImageRef) VersionWidthView(width int, grayscale bool, class string) (*view.Image, error)

type ImageRefController

type ImageRefController struct {
	view.SetModelValueControllerBase
}

func (ImageRefController) NewInput

func (self ImageRefController) NewInput(withLabel bool, metaData *model.MetaData, form *view.Form) (input view.View, err error)

func (ImageRefController) Supports

func (self ImageRefController) Supports(metaData *model.MetaData, form *view.Form) bool

type ImageRefControllerConfiguration

type ImageRefControllerConfiguration struct {
	Class               string
	ThumbnailFrameClass string
	ThumbnailSize       int
	ActionsClass        string
}

type ImageVersion

type ImageVersion struct {
	ID           model.String `bson:",omitempty"`
	Filename     model.String
	ContentType  model.String
	SourceRect   ModelRect
	OutsideColor model.Color
	Width        model.Int
	Height       model.Int
	Grayscale    model.Bool
	// contains filtered or unexported fields
}

func (*ImageVersion) AspectRatio

func (self *ImageVersion) AspectRatio() float64

AspectRatio returns Width / Height

func (*ImageVersion) FileURL

func (self *ImageVersion) FileURL() view.URL

func (*ImageVersion) LinkedView

func (self *ImageVersion) LinkedView(imageClass, linkClass string) *view.Link

func (*ImageVersion) LoadImage

func (self *ImageVersion) LoadImage() (image.Image, error)

func (*ImageVersion) SaveImage

func (self *ImageVersion) SaveImage(im image.Image) error

func (*ImageVersion) SaveImageData

func (self *ImageVersion) SaveImageData(data []byte) error

func (*ImageVersion) View

func (self *ImageVersion) View(class string) *view.Image

type ModelRect

type ModelRect struct {
	MinX model.Int
	MinY model.Int
	MaxX model.Int
	MaxY model.Int
}

func (*ModelRect) Rectangle

func (self *ModelRect) Rectangle() image.Rectangle

func (*ModelRect) SetRectangle

func (self *ModelRect) SetRectangle(r image.Rectangle)

type VerAlignment

type VerAlignment int
const (
	VerCenter VerAlignment = iota
	Top
	Bottom
)

Jump to

Keyboard shortcuts

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