advert

package
v0.0.0-...-a09a905 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Contype = echo.NewKVData()
	AdMode  = echo.NewKVData()
)
View Source
var ErrAdSlotDoesNotExist = errors.New(`ad slot does not exist`)

Functions

func DeleteCachedAdvert

func DeleteCachedAdvert(ctx echo.Context, idents ...string)

func GenAdvertCondition

func GenAdvertCondition() db.Compounds
func GenLink(v Adverter, content string) string

func GenStyle

func GenStyle(p Adverter) string

func GetAdvertForHTML

func GetAdvertForHTML(ctx echo.Context, idents ...string) interface{}

GetAdvertForHTML(ctx,`home1`).Place(`home1`).HTML()

func Render

func Render(v Adverter) string

Types

type AdItem

type AdItem struct {
	*dbschema.OfficialAdItem
}

func NewAdItem

func NewAdItem(ctx echo.Context) *AdItem

func (*AdItem) Add

func (f *AdItem) Add() (pk interface{}, err error)

func (*AdItem) Edit

func (f *AdItem) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*AdItem) Exists

func (f *AdItem) Exists(name string) (bool, error)

func (*AdItem) ExistsOther

func (f *AdItem) ExistsOther(name string, id uint64) (bool, error)

type AdPosition

type AdPosition struct {
	*dbschema.OfficialAdPosition
}

func NewAdPosition

func NewAdPosition(ctx echo.Context) *AdPosition

func (*AdPosition) Add

func (f *AdPosition) Add() (pk interface{}, err error)

func (*AdPosition) Edit

func (f *AdPosition) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*AdPosition) Exists

func (f *AdPosition) Exists(name string, ident string, excludeId uint64) error

func (*AdPosition) GetAdvertsByIdent

func (f *AdPosition) GetAdvertsByIdent(multilingual bool, idents ...string) (PositionAdverts, error)

func (*AdPosition) GetIDByIdent

func (f *AdPosition) GetIDByIdent(ident string) (uint64, error)

func (*AdPosition) GetOneAdvertByIdent

func (f *AdPosition) GetOneAdvertByIdent(ident string) (*dbschema.OfficialAdItem, error)

type AdPublisher

type AdPublisher struct {
	*dbschema.OfficialAdPublisher
}

func NewAdPublisher

func NewAdPublisher(ctx echo.Context) *AdPublisher

func (*AdPublisher) Add

func (f *AdPublisher) Add() (pk interface{}, err error)

func (*AdPublisher) Edit

func (f *AdPublisher) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*AdPublisher) Exists

func (f *AdPublisher) Exists(ownerType string, ownerID uint64) (bool, error)

func (*AdPublisher) ExistsOther

func (f *AdPublisher) ExistsOther(ownerType string, ownerID uint64, id uint64) (bool, error)

type AdSettings

type AdSettings struct {
	*dbschema.OfficialAdSettings
}

func NewAdSettings

func NewAdSettings(ctx echo.Context) *AdSettings

func (*AdSettings) Add

func (f *AdSettings) Add() (pk interface{}, err error)

func (*AdSettings) Edit

func (f *AdSettings) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*AdSettings) Exists

func (f *AdSettings) Exists(name string) (bool, error)

func (*AdSettings) ExistsOther

func (f *AdSettings) ExistsOther(name string, id uint64) (bool, error)

func (*AdSettings) List

func (f *AdSettings) List(filter Filter, offset, size int) error

TODO: unimplemented

type Adverter

type Adverter interface {
	GetWidth() uint
	GetHeight() uint
	GetURL() string
	GetContent() string
	GetContype() string
	GetTitle() string
	GetDescription() string
}

type CachedAdvert

type CachedAdvert struct {
	List        PositionAdverts
	RefreshedAt time.Time
}

func GetCachedAdvert

func GetCachedAdvert(ctx echo.Context, idents ...string) (*CachedAdvert, error)

func (*CachedAdvert) GenHTML

func (c *CachedAdvert) GenHTML() *CachedAdvert

type ContentRenderer

type ContentRenderer func(Adverter) string

type Filter

type Filter struct {
	Client string
	AreaID uint
	Age    uint
	NowTS  int64
	Gendar string
}

func (*Filter) GenCond

func (f *Filter) GenCond() *db.Compounds

type ItemAndPosition

type ItemAndPosition struct {
	*dbschema.OfficialAdItem
	Rendered   string
	AdPosition *dbschema.OfficialAdPosition `db:"-,relation=id:position_id|gtZero"`
}

func (*ItemAndPosition) GetContent

func (i *ItemAndPosition) GetContent() string

func (*ItemAndPosition) GetContype

func (i *ItemAndPosition) GetContype() string

func (*ItemAndPosition) GetDescription

func (i *ItemAndPosition) GetDescription() string

func (*ItemAndPosition) GetHeight

func (i *ItemAndPosition) GetHeight() uint

func (*ItemAndPosition) GetTitle

func (i *ItemAndPosition) GetTitle() string

func (*ItemAndPosition) GetURL

func (i *ItemAndPosition) GetURL() string

func (*ItemAndPosition) GetWidth

func (i *ItemAndPosition) GetWidth() uint

type ItemAndRendered

type ItemAndRendered struct {
	*dbschema.OfficialAdItem
	Rendered string
}

type ItemResponse

type ItemResponse struct {
	Content     string `json:"content" xml:"content"`
	Contype     string `json:"contype" xml:"contype"`
	URL         string `json:"url" xml:"url"`
	Start       uint   `json:"start,omitempty" xml:"start,omitempty"`
	End         uint   `json:"end,omitempty" xml:"end,omitempty"`
	Width       uint   `json:"width,omitempty" xml:"width,omitempty"`
	Height      uint   `json:"height,omitempty" xml:"height,omitempty"`
	Rendered    string `json:"rendered,omitempty" xml:"rendered,omitempty"`
	Title       string `json:"title" xml:"title"`
	Description string `json:"description" xml:"description"`
}

func NewItemResponse

func NewItemResponse(item *dbschema.OfficialAdItem, position *dbschema.OfficialAdPosition) *ItemResponse

func (*ItemResponse) GenHTML

func (i *ItemResponse) GenHTML() *ItemResponse

func (*ItemResponse) GetContent

func (i *ItemResponse) GetContent() string

func (*ItemResponse) GetContype

func (i *ItemResponse) GetContype() string

func (*ItemResponse) GetDescription

func (i *ItemResponse) GetDescription() string

func (*ItemResponse) GetHeight

func (i *ItemResponse) GetHeight() uint

func (*ItemResponse) GetTitle

func (i *ItemResponse) GetTitle() string

func (*ItemResponse) GetURL

func (i *ItemResponse) GetURL() string

func (*ItemResponse) GetWidth

func (i *ItemResponse) GetWidth() uint

func (*ItemResponse) HTML

func (i *ItemResponse) HTML() template.HTML

type ItemsResponse

type ItemsResponse []*ItemResponse

func (ItemsResponse) First

func (i ItemsResponse) First() *ItemResponse

func (*ItemsResponse) GenHTML

func (i *ItemsResponse) GenHTML() *ItemsResponse

func (ItemsResponse) Last

func (i ItemsResponse) Last() *ItemResponse

func (*ItemsResponse) Place

func (c *ItemsResponse) Place(_ string) *ItemsResponse

func (ItemsResponse) Rand

func (i ItemsResponse) Rand() *ItemResponse

func (ItemsResponse) Shuffle

func (i ItemsResponse) Shuffle() ItemsResponse

func (ItemsResponse) Size

func (i ItemsResponse) Size() int

func (ItemsResponse) Valid

func (i ItemsResponse) Valid() bool

type PositionAdverts

type PositionAdverts map[string]ItemsResponse

func (*PositionAdverts) GenHTML

func (c *PositionAdverts) GenHTML() *PositionAdverts

func (PositionAdverts) Place

func (c PositionAdverts) Place(ident string) ItemsResponse

func (PositionAdverts) Valid

func (c PositionAdverts) Valid() bool

type PositionWithRendered

type PositionWithRendered struct {
	*dbschema.OfficialAdPosition
	Rendered string
}

func (*PositionWithRendered) GetContent

func (i *PositionWithRendered) GetContent() string

func (*PositionWithRendered) GetContype

func (i *PositionWithRendered) GetContype() string

func (*PositionWithRendered) GetDescription

func (i *PositionWithRendered) GetDescription() string

func (*PositionWithRendered) GetHeight

func (i *PositionWithRendered) GetHeight() uint

func (*PositionWithRendered) GetTitle

func (i *PositionWithRendered) GetTitle() string

func (*PositionWithRendered) GetURL

func (i *PositionWithRendered) GetURL() string

func (*PositionWithRendered) GetWidth

func (i *PositionWithRendered) GetWidth() uint

Jump to

Keyboard shortcuts

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