publish

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 35 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ListingFieldDraftCount = "Draft Count"
	ListingFieldLive       = "Live"

	VersionsPublishBar = "VersionsPublishBar"

	SlugVersion = "version"
)
View Source
const (
	EventPublish   = "publish_EventPublish"
	EventRepublish = "publish_EventRepublish"
	EventUnpublish = "publish_EventUnpublish"

	EventDuplicateVersion = "publish_EventDuplicateVersion"

	ActivityPublish   = "Publish"
	ActivityRepublish = "Republish"
	ActivityUnPublish = "UnPublish"

	ParamScriptAfterPublish = "publish_param_script_after_publish"
)
View Source
const (
	PermAll       = "publish:*"
	PermPublish   = "publish:publish"
	PermUnpublish = "publish:unpublish"
	PermSchedule  = "publish:schedule"  // Prerequisite: PermPublish/PermUnpublish
	PermDuplicate = "publish:duplicate" // Prerequisite: presets.PermUpdate
)
View Source
const (
	PortalSchedulePublishDialog = "publish_PortalSchedulePublishDialog"
	PortalPublishCustomDialog   = "publish_PortalPublishCustomDialog"
)
View Source
const FilterKeyLive = "live"
View Source
const I18nPublishKey i18n.ModuleKey = "I18nPublishKey"
View Source
const ListSubqueryConditionQueryPrefix = "__PUBLISH_LIST_SUBQUERY_CONDITION__: "
View Source
const VersionListDialogURISuffix = "-version-list-dialog"

Variables

View Source
var (
	NonVersionPublishModels map[string]interface{}
	VersionPublishModels    map[string]interface{}
	ListPublishModels       map[string]interface{}
)
View Source
var (
	StatusDraft   = "draft"
	StatusOnline  = "online"
	StatusOffline = "offline"
)

@snippet_begin(PublishStatus)

View Source
var Messages_en_US = &Messages{
	StatusDraft:                             "Draft",
	StatusOnline:                            "Online",
	StatusOffline:                           "Offline",
	StatusNext:                              "Next",
	Publish:                                 "Publish",
	Unpublish:                               "Unpublish",
	Republish:                               "Republish",
	Areyousure:                              "Are you sure?",
	ScheduledStartAt:                        "Start at",
	ScheduledEndAt:                          "End at",
	ScheduledStartAtShouldLaterThanNow:      "Start at should be later than now",
	ScheduledEndAtShouldLaterThanNowOrEmpty: "End at should be later than now or empty",
	ScheduledEndAtShouldLaterThanStartAt:    "End at should be later than start at",
	ScheduledStartAtShouldNotEmpty:          "Start at should not be empty",
	PublishedAt:                             "Start at",
	UnPublishedAt:                           "End at",
	ActualPublishTime:                       "Actual Publish Time",
	SchedulePublishTime:                     "Schedule Publish Time",
	NotSet:                                  "Not set",
	WhenDoYouWantToPublish:                  "When do you want to publish?",
	PublishScheduleTip:                      "After you set the {SchedulePublishTime}, the system will automatically publish/unpublish it.",
	DateTimePickerClearText:                 "Clear",
	DateTimePickerOkText:                    "OK",
	SaveAsNewVersion:                        "Save As New Version",
	SwitchedToNewVersion:                    "Switched To New Version",
	SuccessfullyCreated:                     "Successfully Created",
	SuccessfullyRename:                      "Successfully Rename",
	SuccessfullyPublish:                     "Successfully Publish",
	SuccessfullyUnPublish:                   "Successfully Unpublish",
	OnlineVersion:                           "Online Version",
	NextVersion:                             "Next Version",
	VersionsList:                            "Versions List",
	AllVersions:                             "All versions",
	NamedVersions:                           "Named versions",
	RenameVersion:                           "Rename Version",
	DeleteVersionConfirmationTextTemplate:   "Are you sure you want to delete version {VersionName} ?",
	ToStatusOnlineTemplate:                  "{VersionName} will be online at {ScheduleTime}",
	ToStatusOfflineTemplate:                 "{VersionName} will be offline at {ScheduleTime}",

	FilterTabAllVersions:   "All Versions",
	FilterTabOnlineVersion: "Online Versions",
	FilterTabNamedVersions: "Named Versions",
	Rename:                 "Rename",
	PageOverView:           "Page Overview",
	Duplicate:              "Duplicate",

	HeaderVersion: "Version",
	HeaderStatus:  "Status",
	HeaderStartAt: "Start At",
	HeaderEndAt:   "End At",
	HeaderOption:  "Option",

	HeaderDraftCount: "Draft Count",
	HeaderLive:       "Live",
}
View Source
var Messages_ja_JP = &Messages{
	StatusDraft:                             "下書き",
	StatusOnline:                            "オンライン",
	StatusOffline:                           "オフライン",
	StatusNext:                              "次",
	Publish:                                 "公開する",
	Unpublish:                               "非公開",
	Republish:                               "再公開",
	Areyousure:                              "よろしいですか?",
	ScheduledStartAt:                        "開始時刻",
	ScheduledEndAt:                          "終了時刻",
	ScheduledStartAtShouldLaterThanNow:      "開始時刻は現在より遅くなければならない",
	ScheduledEndAtShouldLaterThanNowOrEmpty: "終了時刻は現在よりも遅いか、または空でなければならない",
	ScheduledEndAtShouldLaterThanStartAt:    "終了時刻は開始時刻より遅くする",
	ScheduledStartAtShouldNotEmpty:          "開始時刻は空であってはならない",
	PublishedAt:                             "開始時間",
	UnPublishedAt:                           "公開終了日時",
	ActualPublishTime:                       "実際の公開時間",
	SchedulePublishTime:                     "公開時間設定",
	NotSet:                                  "未設定",
	WhenDoYouWantToPublish:                  "公開日時を設定してください",
	PublishScheduleTip:                      "{SchedulePublishTime}を設定すると、システムが自動的に公開/非公開を行います。",
	DateTimePickerClearText:                 "消去する",
	DateTimePickerOkText:                    "OK",
	SaveAsNewVersion:                        "新しいバージョンとして保存",
	SwitchedToNewVersion:                    "新バージョンに変更しました",
	SuccessfullyCreated:                     "作成に成功しました",
	SuccessfullyRename:                      "名前の変更に成功しました",
	SuccessfullyPublish:                     "公開に成功しました",
	SuccessfullyUnPublish:                   "非公開に成功しました",
	OnlineVersion:                           "オンラインバージョン",
	NextVersion:                             "次のバージョン",
	VersionsList:                            "バージョンリスト",
	AllVersions:                             "すべてのバージョン",
	NamedVersions:                           "指定バージョン",
	RenameVersion:                           "バージョン名の変更",
	DeleteVersionConfirmationTextTemplate:   "本当にバージョン{VersionName}を削除しますか?",
	ToStatusOnlineTemplate:                  "{VersionName} は {ScheduleTime} にオンラインになります",
	ToStatusOfflineTemplate:                 "{VersionName} は {ScheduleTime} にオフラインになります",

	FilterTabAllVersions:   "すべてのバージョン",
	FilterTabOnlineVersion: "オンラインバージョン",
	FilterTabNamedVersions: "名前付きバージョン",
	Rename:                 "名称変更",
	PageOverView:           "ページ概要",
	Duplicate:              "コピー",

	HeaderVersion: "バージョン",
	HeaderStatus:  "ステータス",
	HeaderStartAt: "開始日",
	HeaderEndAt:   "終了時",
	HeaderOption:  "オプション",

	HeaderDraftCount: "下書き数",
	HeaderLive:       "公開ステータス",
}
View Source
var Messages_zh_CN = &Messages{
	StatusDraft:                             "草稿",
	StatusOnline:                            "在线",
	StatusOffline:                           "离线",
	StatusNext:                              "下一个",
	Publish:                                 "发布",
	Unpublish:                               "取消发布",
	Republish:                               "重新发布",
	Areyousure:                              "你确定吗?",
	ScheduledStartAt:                        "发布时间",
	ScheduledEndAt:                          "下线时间",
	ScheduledStartAtShouldLaterThanNow:      "计划发布时间应当晚于现在时间",
	ScheduledEndAtShouldLaterThanNowOrEmpty: "计划下线时间应当晚于现在时间",
	ScheduledEndAtShouldLaterThanStartAt:    "计划下线时间应当晚于计划发布时间",
	ScheduledStartAtShouldNotEmpty:          "计划发布时间不得为空",
	PublishedAt:                             "发布时间",
	UnPublishedAt:                           "下线时间",
	ActualPublishTime:                       "实际发布时间",
	SchedulePublishTime:                     "计划发布时间",
	NotSet:                                  "未设定",
	WhenDoYouWantToPublish:                  "你希望什么时候发布?",
	PublishScheduleTip:                      "设定好 {SchedulePublishTime} 之后, 系统会按照时间自动将它发布/下线。",
	DateTimePickerClearText:                 "清空",
	DateTimePickerOkText:                    "确定",
	SaveAsNewVersion:                        "保存为一个新版本",
	SwitchedToNewVersion:                    "切换到新版本",
	SuccessfullyCreated:                     "成功创建",
	SuccessfullyRename:                      "成功命名",
	SuccessfullyPublish:                     "成功发布",
	SuccessfullyUnPublish:                   "已取消发布",
	OnlineVersion:                           "在线版本",
	NextVersion:                             "下个版本",
	VersionsList:                            "版本列表",
	AllVersions:                             "所有版本",
	NamedVersions:                           "已命名版本",
	RenameVersion:                           "命名版本",
	DeleteVersionConfirmationTextTemplate:   "你确定你要删除此版本 {VersionName} 吗?",
	ToStatusOnlineTemplate:                  "{VersionName} 将在 {ScheduleTime} 上线",
	ToStatusOfflineTemplate:                 "{VersionName} 将在 {ScheduleTime} 下线",

	FilterTabAllVersions:   "所有版本",
	FilterTabOnlineVersion: "在线版本",
	FilterTabNamedVersions: "已命名版本",
	Rename:                 "重命名",
	PageOverView:           "页面概览",
	Duplicate:              "复制",

	HeaderVersion: "版本",
	HeaderStatus:  "状态",
	HeaderStartAt: "开始时间",
	HeaderEndAt:   "结束时间",
	HeaderOption:  "操作",

	HeaderDraftCount: "草稿数",
	HeaderLive:       "发布状态",
}

Functions

func DefaultVersionBar added in v3.0.1

func DefaultVersionBar(db *gorm.DB) presets.ObjectComponentFunc

func DefaultVersionComponentFunc added in v3.0.1

func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionComponentConfig) presets.FieldComponentFunc

func DeniedDo added in v3.0.2

func DeniedDo(verifier *perm.Verifier, obj any, r *http.Request, actions ...string) bool

func GetStatusLabelColor added in v3.0.1

func GetStatusLabelColor(status string, msgr *Messages) (label, color string)

func IsVersion

func IsVersion(obj interface{}) (IsVersion bool)

func MustFilterQuery added in v3.0.2

func MustFilterQuery(compo *presets.ListingCompo) url.Values

func NewListenerModelsDeleted added in v3.0.2

func NewListenerModelsDeleted(mb *presets.ModelBuilder, slug string) h.HTMLComponent

func NewListenerVersionSelected added in v3.0.2

func NewListenerVersionSelected(evCtx *web.EventContext, mb *presets.ModelBuilder, slug string) h.HTMLComponent

func NewLiveFilterItem added in v3.0.4

func NewLiveFilterItem(ctx context.Context, columnPrefix string) (*vx.FilterItem, error)

func NotifVersionSelected added in v3.0.2

func NotifVersionSelected(mb *presets.ModelBuilder) string

func RunJob

func RunJob(jobName string, interval time.Duration, timeout time.Duration, f func())

func RunPublisher

func RunPublisher(ctx context.Context, db *gorm.DB, storage oss.StorageInterface, publisher *Builder)

func ScheduleTimeString added in v3.0.1

func ScheduleTimeString(t *time.Time) string

func StatusListFunc added in v3.0.1

func StatusListFunc() presets.FieldComponentFunc

func UploadOrDelete

func UploadOrDelete(objs []*PublishAction, storage oss.StorageInterface) (err error)

func WithScheduleRecordsFinder added in v3.2.0

func WithScheduleRecordsFinder(ctx context.Context, f ScheduleRecordsFinderFunc) context.Context

Types

type AfterPublishInterface

type AfterPublishInterface interface {
	AfterPublish(ctx context.Context, db *gorm.DB, storage oss.StorageInterface) error
}

type AfterUnPublishInterface

type AfterUnPublishInterface interface {
	AfterUnPublish(ctx context.Context, db *gorm.DB, storage oss.StorageInterface) error
}

type Builder

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

func New

func New(db *gorm.DB, storage oss.StorageInterface) *Builder

func (*Builder) Activity added in v3.0.1

func (b *Builder) Activity(v *activity.Builder) (r *Builder)

func (*Builder) AfterInstall added in v3.0.1

func (b *Builder) AfterInstall(f func()) *Builder

func (*Builder) AutoSchedule added in v3.0.2

func (b *Builder) AutoSchedule(v bool) (r *Builder)

func (*Builder) ContextValueFuncs added in v3.0.1

func (b *Builder) ContextValueFuncs(vs ...ContextValueFunc) *Builder

func (*Builder) FullUrl added in v3.0.2

func (b *Builder) FullUrl(uri string) (s string)

func (*Builder) Install added in v3.0.1

func (b *Builder) Install(pb *presets.Builder) error

func (*Builder) ModelInstall added in v3.0.1

func (b *Builder) ModelInstall(pb *presets.Builder, m *presets.ModelBuilder) error

func (*Builder) Publish

func (b *Builder) Publish(ctx context.Context, record any) (err error)

func (*Builder) UnPublish

func (b *Builder) UnPublish(ctx context.Context, record any) (err error)

func (*Builder) WithContextValues added in v3.0.1

func (b *Builder) WithContextValues(ctx context.Context) context.Context

func (*Builder) WrapPublish added in v3.0.6

func (b *Builder) WrapPublish(w func(in PublishFunc) PublishFunc) *Builder

func (*Builder) WrapUnPublish added in v3.0.6

func (b *Builder) WrapUnPublish(w func(in UnPublishFunc) UnPublishFunc) *Builder

type ContextValueFunc added in v3.0.1

type ContextValueFunc func(ctx context.Context) context.Context

type List

type List struct {
	PageNumber  int
	Position    int
	ListDeleted bool
	ListUpdated bool
}

@snippet_begin(PublishList)

func (*List) EmbedList added in v3.0.1

func (s *List) EmbedList() *List

type ListInterface

type ListInterface interface {
	EmbedList() *List
}

type ListPublishBuilder

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

func NewListPublishBuilder

func NewListPublishBuilder(db *gorm.DB, storage oss.StorageInterface) *ListPublishBuilder

func (*ListPublishBuilder) GetOldItemsFunc

func (b *ListPublishBuilder) GetOldItemsFunc(f func(record interface{}) (result []interface{}, err error)) *ListPublishBuilder

func (*ListPublishBuilder) NeedNextPageFunc

func (b *ListPublishBuilder) NeedNextPageFunc(f func(totalNumberPerPage, currentPageNumber, totalNumberOfItems int) bool) *ListPublishBuilder

func (*ListPublishBuilder) PublishActionsFunc

func (b *ListPublishBuilder) PublishActionsFunc(f func(db *gorm.DB, lp ListPublisher, result []*OnePageItems, indexPage *OnePageItems) (objs []*PublishAction)) *ListPublishBuilder

func (*ListPublishBuilder) Run

func (b *ListPublishBuilder) Run(_ context.Context, model interface{}) (err error)

model is a empty struct example: Product{}

func (*ListPublishBuilder) TotalNumberPerPage

func (b *ListPublishBuilder) TotalNumberPerPage(number int) *ListPublishBuilder

func (*ListPublishBuilder) WithValue

func (b *ListPublishBuilder) WithValue(key, val interface{}) *ListPublishBuilder

type ListPublisher

type ListPublisher interface {
	GetListUrl(pageNumber string) string
	GetListContent(db *gorm.DB, onePageItems *OnePageItems) string
	Sort(array []interface{})
}

type Messages added in v3.0.1

type Messages struct {
	StatusDraft                             string
	StatusOnline                            string
	StatusOffline                           string
	StatusNext                              string
	Publish                                 string
	Unpublish                               string
	Republish                               string
	Areyousure                              string
	ScheduledStartAt                        string
	ScheduledEndAt                          string
	ScheduledStartAtShouldLaterThanNow      string
	ScheduledEndAtShouldLaterThanNowOrEmpty string
	ScheduledEndAtShouldLaterThanStartAt    string
	ScheduledStartAtShouldNotEmpty          string
	PublishedAt                             string
	UnPublishedAt                           string
	ActualPublishTime                       string
	SchedulePublishTime                     string
	NotSet                                  string
	WhenDoYouWantToPublish                  string
	PublishScheduleTip                      string
	DateTimePickerClearText                 string
	DateTimePickerOkText                    string
	SaveAsNewVersion                        string
	SwitchedToNewVersion                    string
	SuccessfullyCreated                     string
	SuccessfullyRename                      string
	SuccessfullyPublish                     string
	SuccessfullyUnPublish                   string
	OnlineVersion                           string
	NextVersion                             string
	VersionsList                            string
	AllVersions                             string
	NamedVersions                           string
	RenameVersion                           string
	DeleteVersionConfirmationTextTemplate   string
	ToStatusOnlineTemplate                  string
	ToStatusOfflineTemplate                 string

	FilterTabAllVersions   string
	FilterTabOnlineVersion string
	FilterTabNamedVersions string
	Rename                 string
	PageOverView           string
	Duplicate              string

	HeaderVersion string
	HeaderStatus  string
	HeaderStartAt string
	HeaderEndAt   string
	HeaderOption  string

	HeaderDraftCount string
	HeaderLive       string
}

func (*Messages) DeleteVersionConfirmationText added in v3.0.1

func (msgr *Messages) DeleteVersionConfirmationText(versionName string) string

func (*Messages) ToStatusOffline added in v3.0.5

func (msgr *Messages) ToStatusOffline(versionName string, scheduleTime string) string

func (*Messages) ToStatusOnline added in v3.0.5

func (msgr *Messages) ToStatusOnline(versionName string, scheduleTime string) string

type OnePageItems

type OnePageItems struct {
	Items      []interface{}
	PageNumber int
}

type PayloadModelsDeletedAddon added in v3.0.2

type PayloadModelsDeletedAddon struct {
	NextVersionSlug string `json:"next_version_slug"`
}

type PayloadVersionSelected added in v3.0.2

type PayloadVersionSelected struct {
	Slug string `json:"slug"`
}

type PreviewBuilderInterface added in v3.0.2

type PreviewBuilderInterface interface {
	PreviewHTML(obj interface{}) string
	ExistedL10n() bool
}

type PublishAction

type PublishAction struct {
	Url      string
	Content  string
	IsDelete bool
}

type PublishActionsFunc added in v3.0.2

type PublishActionsFunc func(ctx context.Context, db *gorm.DB, storage oss.StorageInterface, obj any) (actions []*PublishAction, err error)

@snippet_end

type PublishFunc added in v3.0.6

type PublishFunc func(ctx context.Context, record any) error

type PublishInterface

type PublishInterface interface {
	GetPublishActions(ctx context.Context, db *gorm.DB, storage oss.StorageInterface) (actions []*PublishAction, err error)
}

@snippet_end

type PublishModelInterface added in v3.0.2

type PublishModelInterface interface {
	PublishUrl(db *gorm.DB, ctx context.Context, storage oss.StorageInterface) string
}

type Schedule

type Schedule struct {
	ScheduledStartAt *time.Time `gorm:"index"`
	ScheduledEndAt   *time.Time `gorm:"index"`

	ActualStartAt *time.Time
	ActualEndAt   *time.Time
}

@snippet_begin(PublishSchedule)

func EmbedSchedule added in v3.0.2

func EmbedSchedule(v any) *Schedule

func (*Schedule) EmbedSchedule added in v3.0.1

func (s *Schedule) EmbedSchedule() *Schedule

type ScheduleInterface

type ScheduleInterface interface {
	EmbedSchedule() *Schedule
}

type ScheduleOperation added in v3.2.0

type ScheduleOperation string
const (
	ScheduleOperationPublish   ScheduleOperation = "publish"
	ScheduleOperationUnPublish ScheduleOperation = "unpublish"
)

type SchedulePublishBuilder

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

func NewSchedulePublishBuilder

func NewSchedulePublishBuilder(publisher *Builder) *SchedulePublishBuilder

func (*SchedulePublishBuilder) Run

func (b *SchedulePublishBuilder) Run(ctx context.Context, model interface{}) (err error)

model is a empty struct example: Product{}

type SchedulePublisher

type SchedulePublisher interface {
	SchedulePublishDBScope(db *gorm.DB) *gorm.DB
	ScheduleUnPublishDBScope(db *gorm.DB) *gorm.DB
}

type ScheduleRecordsFinderFunc added in v3.2.0

type ScheduleRecordsFinderFunc func(ctx context.Context, operation ScheduleOperation, b *Builder, db *gorm.DB, records any) error

type Status

type Status struct {
	Status    string `gorm:"default:'draft'"`
	OnlineUrl string
}

func EmbedStatus added in v3.0.1

func EmbedStatus(v any) *Status

func (*Status) EmbedStatus added in v3.0.1

func (s *Status) EmbedStatus() *Status

type StatusInterface

type StatusInterface interface {
	EmbedStatus() *Status
}

type UnPublishFunc added in v3.0.6

type UnPublishFunc func(ctx context.Context, record any) error

type UnPublishInterface

type UnPublishInterface interface {
	GetUnPublishActions(ctx context.Context, db *gorm.DB, storage oss.StorageInterface) (actions []*PublishAction, err error)
}

type Version

type Version struct {
	Version       string `gorm:"primaryKey;size:128;not null;"`
	VersionName   string
	ParentVersion string
}

@snippet_begin(PublishVersion)

func EmbedVersion added in v3.0.1

func EmbedVersion(v any) *Version

func (*Version) CreateVersion

func (version *Version) CreateVersion(db *gorm.DB, paramID string, obj interface{}) (string, error)

func (*Version) EmbedVersion added in v3.0.1

func (s *Version) EmbedVersion() *Version

func (*Version) GetNextVersion added in v3.0.1

func (version *Version) GetNextVersion(t *time.Time) string

type VersionComponentConfig added in v3.0.1

type VersionComponentConfig struct {
	// If you want to use custom publish dialog, you can update the portal named PublishCustomDialogPortalName
	PublishEvent              func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string
	UnPublishEvent            func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string
	RePublishEvent            func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string
	Top                       bool
	DisableListeners          bool
	DisableDataChangeTracking bool
}

type VersionInterface

type VersionInterface interface {
	EmbedVersion() *Version
}

type WrapPublishInterface added in v3.0.2

type WrapPublishInterface interface {
	WrapPublishActions(in PublishActionsFunc) PublishActionsFunc
}

type WrapUnPublishInterface added in v3.0.2

type WrapUnPublishInterface interface {
	WrapUnPublishActions(in PublishActionsFunc) PublishActionsFunc
}

Jump to

Keyboard shortcuts

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