feat: add admin publishing workflow and yar theme
Add Go/Postgres admin APIs, Angular admin UI, manual build flow, asset uploads, markdown import/export, configurable slug generation, and the Yar reading theme. Exclude local docs and generated development artifacts from version control.
This commit is contained in:
parent
b78f4b39c9
commit
f0b50d13ea
121 changed files with 27139 additions and 550 deletions
72
backend/internal/admin/status.go
Normal file
72
backend/internal/admin/status.go
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
package admin
|
||||
|
||||
import "fmt"
|
||||
|
||||
func ValidPostStatus(status PostStatus) bool {
|
||||
switch status {
|
||||
case PostStatusDraft, PostStatusPublished, PostStatusArchived, PostStatusDeleted:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsPublicPostStatus(status PostStatus) bool {
|
||||
return status == PostStatusPublished || status == PostStatusArchived
|
||||
}
|
||||
|
||||
func ValidVersionReason(reason VersionReason) bool {
|
||||
switch reason {
|
||||
case VersionReasonSave, VersionReasonPublish, VersionReasonUnpublish, VersionReasonArchive, VersionReasonRestore, VersionReasonImport, VersionReasonRollback:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func ValidBuildJobStatus(status BuildJobStatus) bool {
|
||||
switch status {
|
||||
case BuildJobStatusQueued, BuildJobStatusRunning, BuildJobStatusSuccess, BuildJobStatusFailed, BuildJobStatusCancelled:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func ValidBuildJobTrigger(trigger BuildJobTrigger) bool {
|
||||
switch trigger {
|
||||
case BuildJobTriggerPublish, BuildJobTriggerManual, BuildJobTriggerImport, BuildJobTriggerSync:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func CanTransitionPostStatus(from PostStatus, to PostStatus) bool {
|
||||
if !ValidPostStatus(from) || !ValidPostStatus(to) {
|
||||
return false
|
||||
}
|
||||
if from == to {
|
||||
return true
|
||||
}
|
||||
|
||||
switch from {
|
||||
case PostStatusDraft:
|
||||
return to == PostStatusPublished || to == PostStatusArchived || to == PostStatusDeleted
|
||||
case PostStatusPublished:
|
||||
return to == PostStatusDraft || to == PostStatusArchived || to == PostStatusDeleted
|
||||
case PostStatusArchived:
|
||||
return to == PostStatusDraft || to == PostStatusPublished || to == PostStatusDeleted
|
||||
case PostStatusDeleted:
|
||||
return to == PostStatusDraft
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func ValidatePostStatusTransition(from PostStatus, to PostStatus) error {
|
||||
if CanTransitionPostStatus(from, to) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid post status transition: %s -> %s", from, to)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue