publish

package module
v0.0.0-...-c0687df Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 16 Imported by: 2

README

Publish

The Publish Plugin decouples the timing of data updates in the QOR Admin interface from the display of data on the frontend of the website which QOR Admin is backing. A GORM-backend model can be withheld from frontend display until it is "published".

GoDoc

Documentation

https://doc.getqor.com/plugins/publish.html

License

Released under the MIT License.

Documentation

Index

Constants

View Source
const (
	// PUBLISHED publish status published
	PUBLISHED = false
	// DIRTY publish status dirty
	DIRTY = true
)
View Source
const DISCARD_KEY = "qor:publish.discard"
View Source
const PUBLISH_KEY = "qor:publish.publish"
View Source
const (
	// PublishPermission publish permission
	PublishPermission roles.PermissionMode = "publish"
)

Variables

This section is empty.

Functions

func DraftTableName

func DraftTableName(table string) string

DraftTableName get draft table name of passed in string

func IsDraftMode

func IsDraftMode(db *aorm.DB) bool

IsDraftMode check if current db in draft mode

func IsPublishEvent

func IsPublishEvent(model interface{}) (ok bool)

IsPublishEvent check if current model is a publish event model

func IsPublishableModel

func IsPublishableModel(model interface{}) (ok bool)

IsPublishableModel check if current model is a publishable

func OriginalTableName

func OriginalTableName(table string) string

OriginalTableName get original table name of passed in string

func RegisterEvent

func RegisterEvent(name string, event EventInterface)

RegisterEvent register publish event

Types

type EventInterface

type EventInterface interface {
	Publish(db *aorm.DB, event PublishEventInterface) error
	Discard(db *aorm.DB, event PublishEventInterface) error
}

EventInterface defined methods needs for a publish event

type LoggerInterface

type LoggerInterface interface {
	Print(...interface{})
}

LoggerInterface logger interface used to print publish logs

var Logger LoggerInterface

Logger default logger used to print publish logs

type Plugin

type Plugin struct{}

type Publish

type Publish struct {
	DB              *aorm.DB
	SearchHandler   func(db *aorm.DB, context *core.Context) *aorm.DB
	WorkerScheduler *worker.Worker
	// contains filtered or unexported fields
}

Publish defined a publish struct

func New

func New(db *aorm.DB) *Publish

New initialize a publish instance

func (*Publish) AutoMigrate

func (pb *Publish) AutoMigrate(values ...interface{})

AutoMigrate run auto migrate in draft tables

func (*Publish) ConfigureResource

func (publish *Publish) ConfigureResource(res resource.Resourcer)

ConfigureQorResource configure qor resource for qor admin

func (*Publish) ConfigureResourceBeforeInitialize

func (publish *Publish) ConfigureResourceBeforeInitialize(res resource.Resourcer)

ConfigureQorResourceBeforeInitialize configure qor resource when initialize qor admin

func (Publish) Discard

func (pb Publish) Discard(records ...interface{})

Discard discard records

func (Publish) DraftDB

func (pb Publish) DraftDB() *aorm.DB

DraftDB get db in draft mode

func (Publish) Logger

func (pb Publish) Logger(l LoggerInterface) *Publish

Logger set logger that used to print publish logs

func (Publish) ProductionDB

func (pb Publish) ProductionDB() *aorm.DB

ProductionDB get db in production mode

func (Publish) Publish

func (pb Publish) Publish(records ...interface{})

Publish publish records

func (*Publish) SetWorker

func (publish *Publish) SetWorker(w *worker.Worker)

SetWorker set publish's worker

type PublishEvent

type PublishEvent struct {
	aorm.Model
	Name          string
	Description   string
	Argument      string `sql:"size:65532"`
	PublishStatus bool
	PublishedBy   string
}

PublishEvent default publish event model

func (*PublishEvent) Discard

func (publishEvent *PublishEvent) Discard(db *aorm.DB) error

Discard discard data

func (*PublishEvent) Publish

func (publishEvent *PublishEvent) Publish(db *aorm.DB) error

Publish publish data

func (PublishEvent) VisiblePublishResource

func (PublishEvent) VisiblePublishResource(*core.Context) bool

VisiblePublishResource force to display publish event in publish drafts even it is hidden in the menus

type PublishEventInterface

type PublishEventInterface interface {
	Publish(*aorm.DB) error
	Discard(*aorm.DB) error
}

PublishEventInterface defined publish event itself's interface

type QorWorkerArgument

type QorWorkerArgument struct {
	IDs []string
	worker.Schedule
}

QorWorkerArgument used for qor publish job's argument

type Status

type Status struct {
	PublishStatus bool
}

Status publish status, need to be embedded in your models to get the publish feature

func (*Status) ConfigureResource

func (s *Status) ConfigureResource(res resource.Resourcer)

ConfigureQorResource configure qor resource for qor admin

func (*Status) GetPublishStatus

func (s *Status) GetPublishStatus() bool

GetPublishStatus get publish status

func (*Status) SetPublishStatus

func (s *Status) SetPublishStatus(status bool)

SetPublishStatus set publish status

Jump to

Keyboard shortcuts

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