assets

package
v0.0.0-...-b75375f Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2014 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CdnInfos = []*CdnInfo{
	{Pattern: regexp.MustCompile("angular-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/angularjs/$1/angular.min.js"},
	{Pattern: regexp.MustCompile("CFInstall-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/chrome-frame/$1/CFInstall.min.js"},
	{Pattern: regexp.MustCompile("dojo-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/dojo/$1/dojo/dojo.js"},
	{Pattern: regexp.MustCompile("ext-core-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/ext-core/$1/ext-core.js"},
	{Pattern: regexp.MustCompile("jquery-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/jquery/$1/jquery.min.js", Fallback: "window.jQuery"},
	{Pattern: regexp.MustCompile("jquery-ui-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/jqueryui/$1/jquery-ui.min.js"},
	{Pattern: regexp.MustCompile("mootools-(:?core-)?([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/mootools/$1/mootools-yui-compressed.js"},
	{Pattern: regexp.MustCompile("prototype-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/prototype/$1/prototype.js"},
	{Pattern: regexp.MustCompile("scriptaculous-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/scriptaculous/$1/scriptaculous.js"},
	{Pattern: regexp.MustCompile("swfobject-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/swfobject/$1/swfobject.js"},
	{Pattern: regexp.MustCompile("webfont-([\\d\\.]+\\d)"), Repl: "//ajax.googleapis.com/ajax/libs/webfont/$1/webfont.js"},
}
View Source
var Service = "http://assets.gondolaweb.com/"

Service indicates the base URL for the assets service to use. POST calls will be made to:

Reducer + "css"
Reducer + "js"
Reducer + "less"
Reducer + "coffee"
...

The code to reduce or compile will be sent in the form parameter named "code".

Functions

func Cdn

func Cdn(name string) (string, string, error)

func Compile

func Compile(m *Manager, name string, typ Type, opts Options) (string, error)

func Conditional

func Conditional(c *Condition, html string) template.HTML

func Register

func Register(name string, parser AssetParser)

func RegisterBundler

func RegisterBundler(b Bundler)

func RegisterCompiler

func RegisterCompiler(c Compiler)

func Render

func Render(m *Manager, a *Asset) (template.HTML, error)

func RenderTo

func RenderTo(w io.Writer, m *Manager, a *Asset) error

Types

type Asset

type Asset struct {
	Name       string
	Type       Type
	Position   Position
	Condition  *Condition
	Attributes Attributes
	HTML       string
}

func Bundle

func Bundle(groups []*Group, opts Options) (*Asset, error)

func CSS

func CSS(name string) *Asset

func CdnAssets

func CdnAssets(m *Manager, asset *Asset) ([]*Asset, error)

func Script

func Script(name string) *Asset

func (*Asset) Code

func (a *Asset) Code(m *Manager) (string, error)

func (*Asset) IsHTML

func (a *Asset) IsHTML() bool

func (*Asset) IsRemote

func (a *Asset) IsRemote() bool

func (*Asset) IsTemplate

func (a *Asset) IsTemplate() bool

func (*Asset) Rename

func (a *Asset) Rename(name string)

func (*Asset) String

func (a *Asset) String() string

func (*Asset) TemplateName

func (a *Asset) TemplateName() string

type AssetParser

type AssetParser func(m *Manager, names []string, options Options) ([]*Asset, error)

func SingleParser

func SingleParser(parser SingleAssetParser) AssetParser

type Attributes

type Attributes map[string]string

func (Attributes) String

func (a Attributes) String() string

type Bundler

type Bundler interface {
	Bundle(w io.Writer, r io.Reader, opts Options) error
	Type() Type
}

type CdnInfo

type CdnInfo struct {
	Pattern  *regexp.Regexp
	Repl     string
	Fallback string
}

type Comparison

type Comparison int
const (
	ComparisonNone Comparison = iota
	ComparisonEqual
	ComparisonLessThan
	ComparisonLessThanOrEqual
	ComparisonGreaterThan
	ComparisonGreaterThanOrEqual
)

type Compiler

type Compiler interface {
	Compile(w io.Writer, r io.Reader, opts Options) error
	Type() Type
	Ext() string
}

type Condition

type Condition struct {
	Comparison Comparison
	Version    int
	NonIE      bool
}

func ParseCondition

func ParseCondition(val string) (*Condition, error)

type Group

type Group struct {
	Manager *Manager
	Assets  []*Asset
	Options Options
}

func Parse

func Parse(m *Manager, name string, names []string, opts Options) (*Group, error)

func (*Group) Names

func (g *Group) Names() []string

type Loader

type Loader func(dir string, name string) (ReadSeekerCloser, time.Time, error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func New

func New(fs vfs.VFS, prefix string) *Manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Create

func (m *Manager) Create(name string, overwrite bool) (io.WriteCloser, error)

func (*Manager) Handler

func (m *Manager) Handler() http.HandlerFunc

Handler returns an http.handlerFunc which serves the assets from this Manager. To avoid circular imports, this function returns an http.HandlerFunc rather than a gnd.la/app.Handler. To obtain a gnd.la/app.Handler use gnd.la/app.HandlerFromHTTPFunc.

func (*Manager) Has

func (m *Manager) Has(name string) bool

func (*Manager) Load

func (m *Manager) Load(name string) (io.ReadCloser, error)

func (*Manager) LoadURL

func (m *Manager) LoadURL(u *url.URL) (io.ReadCloser, error)

func (*Manager) Path

func (m *Manager) Path(u *url.URL) string

func (*Manager) Prefix

func (m *Manager) Prefix() string

func (*Manager) SetPrefix

func (m *Manager) SetPrefix(prefix string)

func (*Manager) URL

func (m *Manager) URL(name string) string

func (*Manager) VFS

func (m *Manager) VFS() vfs.VFS

type Options

type Options map[string]string

func ParseOptions

func ParseOptions(options string) (Options, error)

func (Options) Async

func (o Options) Async() bool

func (Options) BoolOpt

func (o Options) BoolOpt(key string) bool

func (Options) Bottom

func (o Options) Bottom() bool

func (Options) Bundable

func (o Options) Bundable() bool

func (Options) Bundle

func (o Options) Bundle() bool

func (Options) Cdn

func (o Options) Cdn() bool

func (Options) Debug

func (o Options) Debug() bool

func (Options) IntOpt

func (o Options) IntOpt(key string) (int, error)

func (Options) NoDebug

func (o Options) NoDebug() bool

func (Options) Priority

func (o Options) Priority() (int, error)

func (Options) String

func (o Options) String() string

func (Options) StringOpt

func (o Options) StringOpt(key string) string

func (Options) Top

func (o Options) Top() bool

type Position

type Position int
const (
	None Position = iota
	Top
	Bottom
)

func (Position) String

func (p Position) String() string

type ReadSeekCloser

type ReadSeekCloser interface {
	io.ReadSeeker
	io.Closer
}

func Seeker

func Seeker(r io.Reader) (ReadSeekCloser, error)

type ReadSeekerCloser

type ReadSeekerCloser interface {
	io.ReadCloser
	io.Seeker
}

func DefaultLoader

func DefaultLoader(dir string, name string) (ReadSeekerCloser, time.Time, error)

type SingleAssetParser

type SingleAssetParser func(m *Manager, name string, options Options) ([]*Asset, error)

type Type

type Type int
const (
	TypeOther Type = iota
	TypeCSS
	TypeJavascript
)

func (Type) Ext

func (t Type) Ext() string

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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