news

package
v0.0.217 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NewsTopicName is the default name for the hidden news forum.
	NewsTopicName = "A NEWS TOPIC"

	// NewsTopicDescription describes the hidden news forum.
	NewsTopicDescription = "THIS IS A HIDDEN FORUM FOR A NEWS TOPIC"

	// SectionWeight controls the order of news in navigation menus.
	SectionWeight = 10
)
View Source
const (
	EmailTemplateAdminNotificationNewsAdd notif.EmailTemplateName        = "adminNotificationNewsAddEmail"
	EmailTemplateNewsAdd                  notif.EmailTemplateName        = "newsAddEmail"
	NotificationTemplateNewsAdd           notif.NotificationTemplateName = "news_add"

	EmailTemplateAdminNotificationNewsReply notif.EmailTemplateName        = "adminNotificationNewsReplyEmail"
	EmailTemplateNewsReply                  notif.EmailTemplateName        = "replyEmail"
	NotificationTemplateNewsReply           notif.NotificationTemplateName = "reply"

	EmailTemplateAdminNotificationNewsEdit notif.EmailTemplateName        = "adminNotificationNewsEditEmail"
	EmailTemplateNewsEdit                  notif.EmailTemplateName        = "newsEditEmail"
	NotificationTemplateNewsEdit           notif.NotificationTemplateName = "news_edit"

	EmailTemplateAdminNotificationNewsUserAllow     notif.EmailTemplateName = "adminNotificationNewsUserAllowEmail"
	EmailTemplateAdminNotificationNewsUserDisallow  notif.EmailTemplateName = "adminNotificationNewsUserDisallowEmail"
	EmailTemplateAdminNotificationNewsDelete        notif.EmailTemplateName = "adminNotificationNewsDeleteEmail"
	EmailTemplateAdminNotificationNewsCommentEdit   notif.EmailTemplateName = "adminNotificationNewsCommentEditEmail"
	EmailTemplateAdminNotificationNewsCommentCancel notif.EmailTemplateName = "adminNotificationNewsCommentCancelEmail"
)
View Source
const (
	// TaskAdd represents adding an announcement.
	TaskAdd tasks.TaskString = "Add"
	// TaskDelete removes an item such as an announcement.
	TaskDelete = "Delete"
	// TaskEdit modifies an existing news post.
	TaskEdit = "Edit"
	// TaskNewPost creates a new news post.
	TaskNewPost tasks.TaskString = "New Post"
	// TaskReply posts a reply to a news thread.
	TaskReply tasks.TaskString = "Reply"
	// TaskEditReply edits a comment or reply.
	TaskEditReply tasks.TaskString = "Edit Reply"
	// TaskCancel cancels the current operation and returns to the previous page.
	TaskCancel tasks.TaskString = "Cancel"
	// TaskUserAllow grants a role to a user.
	TaskUserAllow = "User Allow"
	// TaskUserDisallow removes a role from a user.
	TaskUserDisallow = "User Disallow"

	// TaskMarkRead marks a news item as read for the current user.
	TaskMarkRead tasks.TaskString = forumhandlers.TaskMarkThreadRead
)

Task constants used within the news handlers.

View Source
const AdminNewsDeleteConfirmPageTmpl tasks.Template = "domains/news/adminNewsDeleteConfirmPage.gohtml"
View Source
const AdminNewsEditPageTmpl tasks.Template = "domains/news/adminNewsEditPage.gohtml"
View Source
const AdminNewsListPageTmpl tasks.Template = "domains/news/adminNewsListPage.gohtml"
View Source
const AdminNewsPostPageTmpl tasks.Template = "domains/news/adminNewsPostPage.gohtml"
View Source
const (
	NewsCreatePageTmpl tasks.Template = "domains/news/createPage.gohtml"
)
View Source
const NewsEditPageTmpl tasks.Template = "domains/news/newsEditPage.gohtml"
View Source
const (
	NewsPageTmpl tasks.Template = "domains/news/page.gohtml"
)
View Source
const (
	NewsPostPageTmpl tasks.Template = "domains/news/postPage.gohtml"
)
View Source
const NewsPreviewPageTmpl tasks.Template = "domains/news/preview.gohtml"
View Source
const SearchResultNewsActionPageTmpl tasks.Template = "domains/search/resultNewsActionPage.gohtml"

Variables

This section is empty.

Functions

func AdminNewsDeleteConfirmPage

func AdminNewsDeleteConfirmPage(w http.ResponseWriter, r *http.Request)

func AdminNewsPage

func AdminNewsPage(w http.ResponseWriter, r *http.Request)

func AdminNewsPostPage

func AdminNewsPostPage(w http.ResponseWriter, r *http.Request)

func CanEditNewsPost added in v0.0.214

func CanEditNewsPost(cd *common.CoreData, postID int32) bool

CanEditNewsPost reports whether cd can modify the specified news post.

func CanPostNews

func CanPostNews(cd *common.CoreData) bool

CanPostNews reports whether the current user can create news posts.

func CustomNewsIndex

func CustomNewsIndex(data *common.CoreData, r *http.Request)

func EnforceNewsPostAccess

func EnforceNewsPostAccess(next http.Handler) http.Handler

EnforceNewsPostAccess ensures the user has permission to edit the news post specified in the URL path. It sets the current news post ID context on success.

func MatchCanPostNews

func MatchCanPostNews(r *http.Request, rm *mux.RouteMatch) bool

MatchCanPostNews matches requests where the user has permission to post news.

func NewNewsPostTask

func NewNewsPostTask() tasks.Task

func NewNewsTask

func NewNewsTask() tasks.Task

func NewsCreatePageHandler

func NewsCreatePageHandler(w http.ResponseWriter, r *http.Request)

func NewsGeneralIndexItems

func NewsGeneralIndexItems(cd *common.CoreData, r *http.Request) []common.IndexItem

func NewsPageHandler

func NewsPageHandler(w http.ResponseWriter, r *http.Request)

func NewsPostPageHandler

func NewsPostPageHandler(w http.ResponseWriter, r *http.Request)

func NewsRssPage

func NewsRssPage(w http.ResponseWriter, r *http.Request)

func PreviewPage

func PreviewPage(w http.ResponseWriter, r *http.Request)

func Register

func Register(reg *router.Registry)

Register registers the news router module.

func RegisterAdminRoutes

func RegisterAdminRoutes(ar *mux.Router)

RegisterAdminRoutes attaches news admin endpoints to ar.

func RegisterRoutes

func RegisterRoutes(r *mux.Router, _ *config.RuntimeConfig) []navpkg.RouterOptions

RegisterRoutes attaches the public news endpoints to r.

func RegisterTasks

func RegisterTasks() []tasks.NamedTask

RegisterTasks registers news related tasks with the global registry.

func SearchResultNewsActionPage

func SearchResultNewsActionPage(w http.ResponseWriter, r *http.Request)

func SharedPreviewPage

func SharedPreviewPage(w http.ResponseWriter, r *http.Request)

SharedPreviewPage renders an OpenGraph preview for a news post.

Types

type AnnouncementAddTask

type AnnouncementAddTask struct{ tasks.TaskString }

AnnouncementAddTask enables an announcement for a news post.

func (AnnouncementAddTask) Action

func (AnnouncementAddTask) AdminEmailTemplate

func (AnnouncementAddTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (AnnouncementAddTask) AdminInternalNotificationTemplate

func (AnnouncementAddTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (AnnouncementAddTask) RequiredTemplates

func (AnnouncementAddTask) RequiredTemplates() []tasks.Template

type AnnouncementDeleteTask

type AnnouncementDeleteTask struct{ tasks.TaskString }

AnnouncementDeleteTask disables the announcement for a news post.

func (AnnouncementDeleteTask) Action

func (AnnouncementDeleteTask) AdminEmailTemplate

func (AnnouncementDeleteTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (AnnouncementDeleteTask) AdminInternalNotificationTemplate

func (AnnouncementDeleteTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (AnnouncementDeleteTask) RequiredTemplates

func (AnnouncementDeleteTask) RequiredTemplates() []tasks.Template

type CancelTask

type CancelTask struct{ tasks.TaskString }

CancelTask cancels comment editing.

func (CancelTask) Action

func (CancelTask) Action(w http.ResponseWriter, r *http.Request) any

func (CancelTask) AdminEmailTemplate

func (CancelTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (CancelTask) AdminInternalNotificationTemplate

func (CancelTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (CancelTask) RequiredTemplates

func (CancelTask) RequiredTemplates() []tasks.Template

type DeleteNewsPostTask

type DeleteNewsPostTask struct{ tasks.TaskString }

DeleteNewsPostTask removes a news post.

func (DeleteNewsPostTask) Action

type EditReplyTask

type EditReplyTask struct{ tasks.TaskString }

EditReplyTask updates an existing comment.

func (EditReplyTask) Action

func (EditReplyTask) AdminEmailTemplate

func (EditReplyTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (EditReplyTask) AdminInternalNotificationTemplate

func (EditReplyTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (EditReplyTask) RequiredTemplates

func (EditReplyTask) RequiredTemplates() []tasks.Template

type EditTask

type EditTask struct{ tasks.TaskString }

func (EditTask) Action

func (EditTask) Action(w http.ResponseWriter, r *http.Request) any

func (EditTask) AdminEmailTemplate

func (EditTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (EditTask) AdminInternalNotificationTemplate

func (EditTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (EditTask) Page

func (EditTask) Page(w http.ResponseWriter, r *http.Request)

func (EditTask) RequiredTemplates

func (EditTask) RequiredTemplates() []tasks.Template

RequiredTemplates declares the templates used by this task's pages.

type MarkReadTask

type MarkReadTask struct{ tasks.TaskString }

MarkReadTask clears the new and unread labels on a news post.

func (MarkReadTask) Action

Action handles clearing new and unread labels on a news post.

func (*MarkReadTask) Matcher

func (t *MarkReadTask) Matcher() mux.MatcherFunc

type NewPostTask

type NewPostTask struct{ tasks.TaskString }

func (NewPostTask) Action

func (NewPostTask) AdminEmailTemplate

func (NewPostTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (NewPostTask) AdminInternalNotificationTemplate

func (NewPostTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (NewPostTask) AutoSubscribeGrants

func (NewPostTask) AutoSubscribeGrants(evt eventbus.TaskEvent) ([]notif.GrantRequirement, error)

func (NewPostTask) AutoSubscribePath

func (NewPostTask) AutoSubscribePath(evt eventbus.TaskEvent) (string, string, error)

AutoSubscribePath links the newly created post so that any future replies notify the author by default. Subscribing the poster ensures they are notified when readers engage with their new thread. AutoSubscribePath keeps authors in the loop on new post discussions. AutoSubscribePath implements notif.AutoSubscribeProvider. Subscriptions use the thread path derived from postcountworker data when possible.

func (NewPostTask) RequiredTemplates

func (NewPostTask) RequiredTemplates() []tasks.Template

func (NewPostTask) SubscribedEmailTemplate

func (NewPostTask) SubscribedEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (NewPostTask) SubscribedInternalNotificationTemplate

func (NewPostTask) SubscribedInternalNotificationTemplate(evt eventbus.TaskEvent) *string

type ReplyTask

type ReplyTask struct{ tasks.TaskString }

func (ReplyTask) Action

func (ReplyTask) Action(w http.ResponseWriter, r *http.Request) any

func (ReplyTask) AdminEmailTemplate

func (ReplyTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (ReplyTask) AdminInternalNotificationTemplate

func (ReplyTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (ReplyTask) AutoSubscribeGrants

func (ReplyTask) AutoSubscribeGrants(evt eventbus.TaskEvent) ([]notif.GrantRequirement, error)

func (ReplyTask) AutoSubscribePath

func (ReplyTask) AutoSubscribePath(evt eventbus.TaskEvent) (string, string, error)

AutoSubscribePath registers this reply so the author automatically follows subsequent comments on the news post. When users reply to a news post we automatically subscribe them so they receive updates to the thread they just engaged with. AutoSubscribePath allows commenters to automatically watch for further replies. AutoSubscribePath implements notif.AutoSubscribeProvider. A subscription to the underlying discussion thread is created using event data when available.

func (ReplyTask) IndexData

func (ReplyTask) IndexData(data map[string]any) []searchworker.IndexEventData

func (ReplyTask) IndexType

func (ReplyTask) IndexType() string

func (ReplyTask) RequiredTemplates

func (ReplyTask) RequiredTemplates() []tasks.Template

func (ReplyTask) SubscribedEmailTemplate

func (ReplyTask) SubscribedEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (ReplyTask) SubscribedInternalNotificationTemplate

func (ReplyTask) SubscribedInternalNotificationTemplate(evt eventbus.TaskEvent) *string

type SetLabelsTask

type SetLabelsTask struct{ tasks.TaskString }

SetLabelsTask replaces private labels on a news item.

func (SetLabelsTask) Action

type UserAllowTask

type UserAllowTask struct{ tasks.TaskString }

UserAllowTask grants a user a role.

func (UserAllowTask) Action

func (UserAllowTask) AdminEmailTemplate

func (UserAllowTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (UserAllowTask) AdminInternalNotificationTemplate

func (UserAllowTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (UserAllowTask) RequiredTemplates

func (UserAllowTask) RequiredTemplates() []tasks.Template

type UserDisallowTask

type UserDisallowTask struct{ tasks.TaskString }

UserDisallowTask removes a user's role.

func (UserDisallowTask) Action

func (UserDisallowTask) AdminEmailTemplate

func (UserDisallowTask) AdminEmailTemplate(evt eventbus.TaskEvent) (templates *notif.EmailTemplates, send bool)

func (UserDisallowTask) AdminInternalNotificationTemplate

func (UserDisallowTask) AdminInternalNotificationTemplate(evt eventbus.TaskEvent) *string

func (UserDisallowTask) RequiredTemplates

func (UserDisallowTask) RequiredTemplates() []tasks.Template

Jump to

Keyboard shortcuts

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