Documentation
¶
Index ¶
- Constants
- Variables
- func CommentsChanged(repo *EntForumRepository) func(ctx context.Context, nodeID int) error
- func ForumUninstallStep(settings ForumSettingsRepository, vocabularies interface{ ... }, ...) func(ctx context.Context) error
- func RegisterAdminRoutes(r modulekit.Mux, fc *ForumController, admin func(http.Handler) http.Handler)
- func RegisterForumRoutes(r modulekit.Mux, store *sessions.CookieStore, fc *ForumController)
- func SitemapPaths(svc ForumService) func(ctx context.Context) ([]string, error)
- func Wire(d modulekit.Deps) modulekit.Parts
- type DefaultForumService
- func (s *DefaultForumService) CountTopics(ctx context.Context, sectionID int) (int, error)
- func (s *DefaultForumService) CreateTopic(ctx context.Context, sectionID int, title, body string, authorID int) (*ForumTopicDetail, error)
- func (s *DefaultForumService) GetCategory(ctx context.Context, id int) (*ForumCategory, error)
- func (s *DefaultForumService) GetForumIndex(ctx context.Context) (*ForumIndex, error)
- func (s *DefaultForumService) GetForumTermsForSelect(ctx context.Context) ([]ForumTermOption, error)
- func (s *DefaultForumService) GetSectionBySlug(ctx context.Context, slug string) (*ForumSectionPage, int, error)
- func (s *DefaultForumService) GetStatistics(ctx context.Context) (*ForumStatistics, error)
- func (s *DefaultForumService) GetTopic(ctx context.Context, slug string) (*ForumTopicDetail, error)
- func (s *DefaultForumService) GetTopicSectionID(ctx context.Context, nodeID int) (int, error)
- func (s *DefaultForumService) GetTopics(ctx context.Context, sectionID int, filter ForumTopicFilter) ([]ForumTopic, error)
- func (s *DefaultForumService) ListTopics(ctx context.Context, filter ForumTopicFilter) ([]ForumTopic, int, error)
- func (s *DefaultForumService) SectionPathPrefix(ctx context.Context) string
- func (s *DefaultForumService) SetTopicSticky(ctx context.Context, topic modulekit.Node, sticky bool) error
- func (s *DefaultForumService) UpdateTopic(ctx context.Context, nodeID int, title, body string, sectionID int) error
- type EntForumRepository
- func (r *EntForumRepository) CountTopicsBySection(ctx context.Context, sectionID int) (int, error)
- func (r *EntForumRepository) CountTopicsFiltered(ctx context.Context, filter ForumTopicFilter) (int, error)
- func (r *EntForumRepository) CreateTopic(ctx context.Context, sectionID int, title, body string, authorID int) (*ForumTopicDetail, error)
- func (r *EntForumRepository) GetForumCategories(ctx context.Context) ([]ForumCategory, error)
- func (r *EntForumRepository) GetForumStatistics(ctx context.Context) (*ForumStatistics, error)
- func (r *EntForumRepository) GetForumTermsForSelect(ctx context.Context) ([]ForumTermOption, error)
- func (r *EntForumRepository) GetSectionBySlug(ctx context.Context, slug string) (*ForumSection, error)
- func (r *EntForumRepository) GetTopicBySlug(ctx context.Context, slug string) (*ForumTopicDetail, error)
- func (r *EntForumRepository) GetTopicSectionID(ctx context.Context, nodeID int) (int, error)
- func (r *EntForumRepository) GetTopicsBySection(ctx context.Context, sectionID int, filter ForumTopicFilter) ([]ForumTopic, error)
- func (r *EntForumRepository) ListTopics(ctx context.Context, filter ForumTopicFilter) ([]ForumTopic, error)
- func (r *EntForumRepository) RecountTopicStats(ctx context.Context, nodeID int) error
- func (r *EntForumRepository) SectionPathPrefix(ctx context.Context) (string, error)
- func (r *EntForumRepository) SetSticky(ctx context.Context, nodeID int, sticky bool) error
- func (r *EntForumRepository) TopicExistsBySlug(ctx context.Context, slug string) (bool, error)
- func (r *EntForumRepository) UpdateTopic(ctx context.Context, nodeID int, title, body string, sectionID int) error
- type EntForumSettingsRepository
- type ForumCategory
- type ForumCategoryRowDTO
- type ForumCommentRowDTO
- type ForumController
- func (c *ForumController) ActiveTopics(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) CreateTopicForm(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) CreateTopicSubmit(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) DeleteTopic(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) DeleteTopicConfirm(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) EditTopicForm(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) EditTopicSubmit(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) ForumSettingsPage(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) Index(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) Section(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) SectionFallback(w http.ResponseWriter, r *http.Request) bool
- func (c *ForumController) StickTopic(w http.ResponseWriter, r *http.Request)
- func (c *ForumController) UnansweredTopics(w http.ResponseWriter, r *http.Request)
- type ForumDeps
- type ForumIndex
- type ForumLastComment
- type ForumLastTopic
- type ForumRepository
- type ForumSection
- type ForumSectionPage
- type ForumService
- type ForumSettings
- type ForumSettingsRepository
- type ForumStatistics
- type ForumStatisticsDTO
- type ForumTermOption
- type ForumTopic
- type ForumTopicDetail
- type ForumTopicDetailDTO
- type ForumTopicFilter
- type ForumTopicRowDTO
- type ForumTopicSection
- type Taxonomy
Constants ¶
const ( ActionGroup = "forum" ActionTopicMove = "forum.topic_move" ActionTopicPin = "forum.topic_pin" ActionTopicUnpin = "forum.topic_unpin" )
The forum's actions in the action log: their group and types. A topic created or deleted is the core's "Content" group (modulekit.RecordNodeCreated, the core's deletion).
Variables ¶
var Assets embed.FS
Assets - the module's templates/ and static/, built into the binary (modules.Assets, paths.SetModuleAssets): a site runs without the module's source directory.
Functions ¶
func CommentsChanged ¶
func CommentsChanged(repo *EntForumRepository) func(ctx context.Context, nodeID int) error
CommentsChanged - the forum's CommentsService.OnNodeCommentsChanged hook: a topic's reply count and last reply time follow its comments (the topic lists sort and filter by them). Nothing while the module is off (its tables may not exist).
func ForumUninstallStep ¶
func ForumUninstallStep(settings ForumSettingsRepository, vocabularies interface { DeleteVocabularyIfUnused(ctx context.Context, vid int) (bool, error) }, logger *slog.Logger) func(ctx context.Context) error
ForumUninstallStep - the forum module's own uninstall step: its vocabulary of sections (forum settings) is deleted with its terms unless something else uses it (a taxonomy field, a search badge, a field value). Runs after the forum's content is gone, before its settings table is dropped.
func RegisterAdminRoutes ¶
func RegisterAdminRoutes(r modulekit.Mux, fc *ForumController, admin func(http.Handler) http.Handler)
RegisterAdminRoutes registers the forum settings page behind admin (sign-in and the admin permission).
func RegisterForumRoutes ¶
func RegisterForumRoutes(r modulekit.Mux, store *sessions.CookieStore, fc *ForumController)
RegisterForumRoutes registers the forum's pages: the index, the active and unanswered topics, a section, and a topic's new, edit, delete and pin actions (a new topic - signed in only).
func SitemapPaths ¶
func SitemapPaths(svc ForumService) func(ctx context.Context) ([]string, error)
SitemapPaths - the forum sections for the sitemap (AddSitemapPaths), at their terms' addresses, as the forum links to them.
Types ¶
type DefaultForumService ¶
type DefaultForumService struct {
// contains filtered or unexported fields
}
DefaultForumService implements ForumService.
func (*DefaultForumService) CountTopics ¶
CountTopics counts topics in a section.
func (*DefaultForumService) CreateTopic ¶
func (s *DefaultForumService) CreateTopic(ctx context.Context, sectionID int, title, body string, authorID int) (*ForumTopicDetail, error)
CreateTopic creates a new forum topic; the action log gets "Content created".
func (*DefaultForumService) GetCategory ¶
func (s *DefaultForumService) GetCategory(ctx context.Context, id int) (*ForumCategory, error)
GetCategory - see ForumService.GetCategory.
func (*DefaultForumService) GetForumIndex ¶
func (s *DefaultForumService) GetForumIndex(ctx context.Context) (*ForumIndex, error)
GetForumIndex retrieves the main forum page data.
func (*DefaultForumService) GetForumTermsForSelect ¶
func (s *DefaultForumService) GetForumTermsForSelect(ctx context.Context) ([]ForumTermOption, error)
GetForumTermsForSelect returns forum terms for the section dropdown.
func (*DefaultForumService) GetSectionBySlug ¶
func (s *DefaultForumService) GetSectionBySlug(ctx context.Context, slug string) (*ForumSectionPage, int, error)
GetSectionBySlug - see ForumService.GetSectionBySlug.
func (*DefaultForumService) GetStatistics ¶
func (s *DefaultForumService) GetStatistics(ctx context.Context) (*ForumStatistics, error)
GetStatistics retrieves overall forum statistics.
func (*DefaultForumService) GetTopic ¶
func (s *DefaultForumService) GetTopic(ctx context.Context, slug string) (*ForumTopicDetail, error)
GetTopic retrieves a forum topic by slug.
func (*DefaultForumService) GetTopicSectionID ¶
GetTopicSectionID returns the section (tid) for a forum topic.
func (*DefaultForumService) GetTopics ¶
func (s *DefaultForumService) GetTopics(ctx context.Context, sectionID int, filter ForumTopicFilter) ([]ForumTopic, error)
GetTopics retrieves topics for a section with filters.
func (*DefaultForumService) ListTopics ¶
func (s *DefaultForumService) ListTopics(ctx context.Context, filter ForumTopicFilter) ([]ForumTopic, int, error)
ListTopics - a page of topics by the filter and their total.
func (*DefaultForumService) SectionPathPrefix ¶
func (s *DefaultForumService) SectionPathPrefix(ctx context.Context) string
SectionPathPrefix - see ForumService.SectionPathPrefix.
func (*DefaultForumService) SetTopicSticky ¶
func (s *DefaultForumService) SetTopicSticky(ctx context.Context, topic modulekit.Node, sticky bool) error
SetTopicSticky pins the topic at the top of its section (or unpins it); the action log gets "Topic pinned" or "Topic unpinned".
func (*DefaultForumService) UpdateTopic ¶
func (s *DefaultForumService) UpdateTopic(ctx context.Context, nodeID int, title, body string, sectionID int) error
UpdateTopic updates a forum topic; moved to another section, it is "Topic moved" in the action log, from which section to which.
type EntForumRepository ¶
type EntForumRepository struct {
// contains filtered or unexported fields
}
EntForumRepository handles forum data access.
func NewForumRepository ¶
func NewForumRepository(db *sql.DB, nodes modulekit.NodesRepository, users modulekit.UserRepository, taxonomy Taxonomy) *EntForumRepository
NewForumRepository creates a new forum repository: its own tables on db (the module's own ent schema, ent/), a topic's node, author and section through the core; its lists in SQL over both. A built-in module, tested with the engine, may read the core's tables in its SQL; a module of its own repository goes through the SDK's services instead (docs/modules/sdk.md): the core's columns aren't its API.
func (*EntForumRepository) CountTopicsBySection ¶
CountTopicsBySection counts the public topics of a section.
func (*EntForumRepository) CountTopicsFiltered ¶
func (r *EntForumRepository) CountTopicsFiltered(ctx context.Context, filter ForumTopicFilter) (int, error)
CountTopicsFiltered counts the topics ListTopics pages over.
func (*EntForumRepository) CreateTopic ¶
func (r *EntForumRepository) CreateTopic(ctx context.Context, sectionID int, title, body string, authorID int) (*ForumTopicDetail, error)
CreateTopic creates a new forum topic.
func (*EntForumRepository) GetForumCategories ¶
func (r *EntForumRepository) GetForumCategories(ctx context.Context) ([]ForumCategory, error)
GetForumCategories retrieves all forum categories with sections and statistics.
func (*EntForumRepository) GetForumStatistics ¶
func (r *EntForumRepository) GetForumStatistics(ctx context.Context) (*ForumStatistics, error)
GetForumStatistics retrieves overall forum statistics.
func (*EntForumRepository) GetForumTermsForSelect ¶
func (r *EntForumRepository) GetForumTermsForSelect(ctx context.Context) ([]ForumTermOption, error)
GetForumTermsForSelect returns all forum terms (categories and sections) for the section dropdown.
func (*EntForumRepository) GetSectionBySlug ¶
func (r *EntForumRepository) GetSectionBySlug(ctx context.Context, slug string) (*ForumSection, error)
GetSectionBySlug retrieves a forum section by slug with its parent category (for breadcrumbs).
func (*EntForumRepository) GetTopicBySlug ¶
func (r *EntForumRepository) GetTopicBySlug(ctx context.Context, slug string) (*ForumTopicDetail, error)
GetTopicBySlug retrieves a topic by slug, or by the path of its page (a slug without the type's prefix has it added there, NodeRelPath), whatever its status: who may see it is the page's to decide (AuthService.CanViewNode on ForumTopicDetail.node).
func (*EntForumRepository) GetTopicSectionID ¶
GetTopicSectionID returns the taxonomy term ID (section) of a forum topic.
func (*EntForumRepository) GetTopicsBySection ¶
func (r *EntForumRepository) GetTopicsBySection(ctx context.Context, sectionID int, filter ForumTopicFilter) ([]ForumTopic, error)
GetTopicsBySection retrieves topics of a forum section.
func (*EntForumRepository) ListTopics ¶
func (r *EntForumRepository) ListTopics(ctx context.Context, filter ForumTopicFilter) ([]ForumTopic, error)
ListTopics retrieves topics by the filter.
func (*EntForumRepository) RecountTopicStats ¶
func (r *EntForumRepository) RecountTopicStats(ctx context.Context, nodeID int) error
RecountTopicStats sets the topic's comment count and last comment time from its comments (nothing for a node that isn't a topic).
func (*EntForumRepository) SectionPathPrefix ¶
func (r *EntForumRepository) SectionPathPrefix(ctx context.Context) (string, error)
SectionPathPrefix - see ForumRepository.SectionPathPrefix.
func (*EntForumRepository) TopicExistsBySlug ¶
TopicExistsBySlug reports whether a forum topic with the given slug exists.
func (*EntForumRepository) UpdateTopic ¶
func (r *EntForumRepository) UpdateTopic(ctx context.Context, nodeID int, title, body string, sectionID int) error
UpdateTopic updates a forum topic's title, body and section (in one transaction).
type EntForumSettingsRepository ¶
type EntForumSettingsRepository struct {
// contains filtered or unexported fields
}
EntForumSettingsRepository - forum_settings, on the module's own ent schema (ent/).
func NewForumSettingsRepository ¶
func NewForumSettingsRepository(db *sql.DB) *EntForumSettingsRepository
NewForumSettingsRepository - the forum settings' repository on db.
func (*EntForumSettingsRepository) Get ¶
func (r *EntForumSettingsRepository) Get(ctx context.Context) (*ForumSettings, error)
Get - the forum's settings, from its single row.
func (*EntForumSettingsRepository) Update ¶
func (r *EntForumSettingsRepository) Update(ctx context.Context, s *ForumSettings) error
Update saves s to the single settings row (VocabularyID 0 - none).
type ForumCategory ¶
type ForumCategory struct {
ID int
Name string
Description string
Slug string
Weight int
Sections []ForumSection
}
ForumCategory represents a top-level forum category (container)
func ToForumCategoriesEntity ¶
func ToForumCategoriesEntity(rows []ForumCategoryRowDTO) []ForumCategory
ToForumCategoriesEntity converts DTO rows to entity categories.
type ForumCategoryRowDTO ¶
type ForumCategoryRowDTO struct {
ContainerID int
ContainerName string
ContainerDesc string
ContainerSlug string
ContainerWeight int
SectionID sql.NullInt64
SectionName sql.NullString
SectionDesc sql.NullString
SectionSlug sql.NullString
SectionWeight sql.NullInt64
TopicsCount int
PostsCount int
LastActivity sql.NullTime
LastTopicTitle sql.NullString
LastTopicSlug sql.NullString
LastAuthor sql.NullString
}
ForumCategoryRowDTO represents a row from GetForumCategories query.
type ForumCommentRowDTO ¶
type ForumCommentRowDTO struct {
ID int
ParentID sql.NullInt64
CreatedAt time.Time
Content string
AuthorID int
AuthorName string
AuthorCreated time.Time
}
ForumCommentRowDTO represents a comment row from GetTopicBySlug query.
type ForumController ¶
type ForumController struct {
*modulekit.BaseController
// contains filtered or unexported fields
}
ForumController handles forum HTTP requests.
func NewForumController ¶
func NewForumController(deps modulekit.BaseDeps, d ForumDeps) *ForumController
NewForumController creates a ForumController.
func (*ForumController) ActiveTopics ¶
func (c *ForumController) ActiveTopics(w http.ResponseWriter, r *http.Request)
ActiveTopics handles GET /forum/active: every section's topics by their last post.
func (*ForumController) CreateTopicForm ¶
func (c *ForumController) CreateTopicForm(w http.ResponseWriter, r *http.Request)
CreateTopicForm displays the form for creating a forum topic.
func (*ForumController) CreateTopicSubmit ¶
func (c *ForumController) CreateTopicSubmit(w http.ResponseWriter, r *http.Request)
CreateTopicSubmit handles the create forum topic form submission.
func (*ForumController) DeleteTopic ¶
func (c *ForumController) DeleteTopic(w http.ResponseWriter, r *http.Request)
DeleteTopic handles the delete forum topic form submission: the topic is deleted for good, with its replies.
func (*ForumController) DeleteTopicConfirm ¶
func (c *ForumController) DeleteTopicConfirm(w http.ResponseWriter, r *http.Request)
DeleteTopicConfirm displays the delete confirmation page for a forum topic.
func (*ForumController) EditTopicForm ¶
func (c *ForumController) EditTopicForm(w http.ResponseWriter, r *http.Request)
EditTopicForm displays the form for editing a forum topic.
func (*ForumController) EditTopicSubmit ¶
func (c *ForumController) EditTopicSubmit(w http.ResponseWriter, r *http.Request)
EditTopicSubmit handles the edit forum topic form submission.
func (*ForumController) ForumSettingsPage ¶
func (c *ForumController) ForumSettingsPage(w http.ResponseWriter, r *http.Request)
ForumSettingsPage handles GET/POST /admin/config/forum - the forum's vocabulary (ForumSettings). Same pattern as UploadSettingsPage.
func (*ForumController) Index ¶
func (c *ForumController) Index(w http.ResponseWriter, r *http.Request)
Index displays the main forum page with categories and sections.
func (*ForumController) Section ¶
func (c *ForumController) Section(w http.ResponseWriter, r *http.Request)
Section displays a forum section with its topics: the section, category or topic whose slug is the URL's path.
func (*ForumController) SectionFallback ¶
func (c *ForumController) SectionFallback(w http.ResponseWriter, r *http.Request) bool
SectionFallback serves a forum section at the forum vocabulary's own term path prefix (/<prefix>/category/section - the URLs of its terms), besides the module's /forum/… routes. Returns false for any other path.
func (*ForumController) StickTopic ¶
func (c *ForumController) StickTopic(w http.ResponseWriter, r *http.Request)
StickTopic handles POST /forum/topic/{id}/sticky: sticky=1 pins the topic at the top of its section, anything else unpins it; back to the topic.
func (*ForumController) UnansweredTopics ¶
func (c *ForumController) UnansweredTopics(w http.ResponseWriter, r *http.Request)
UnansweredTopics handles GET /forum/unanswered: topics without replies, newest first.
type ForumDeps ¶
type ForumDeps struct {
ForumService ForumService
TaxonomyService modulekit.TaxonomyService
NodeDeleter modulekit.NodeDeleter
Settings ForumSettingsRepository
}
ForumDeps - what NewForumController needs besides the BaseDeps.
type ForumIndex ¶
type ForumIndex struct {
Categories []ForumCategory
Statistics *ForumStatistics
}
ForumIndex represents the main forum page data
type ForumLastComment ¶
ForumLastComment represents the last comment info
type ForumLastTopic ¶
ForumLastTopic represents the last topic info in a section
type ForumRepository ¶
type ForumRepository interface {
GetForumCategories(ctx context.Context) ([]ForumCategory, error)
GetSectionBySlug(ctx context.Context, slug string) (*ForumSection, error)
GetTopicsBySection(ctx context.Context, sectionID int, filter ForumTopicFilter) ([]ForumTopic, error)
CountTopicsBySection(ctx context.Context, sectionID int) (int, error)
// ListTopics - topics by the filter (one section or all, optionally
// only unanswered), each with its section when listing all.
ListTopics(ctx context.Context, filter ForumTopicFilter) ([]ForumTopic, error)
// CountTopicsFiltered - how many topics ListTopics pages over.
CountTopicsFiltered(ctx context.Context, filter ForumTopicFilter) (int, error)
GetTopicBySlug(ctx context.Context, slug string) (*ForumTopicDetail, error)
GetForumStatistics(ctx context.Context) (*ForumStatistics, error)
GetForumTermsForSelect(ctx context.Context) ([]ForumTermOption, error)
GetTopicSectionID(ctx context.Context, nodeID int) (int, error)
CreateTopic(ctx context.Context, sectionID int, title, body string, authorID int) (*ForumTopicDetail, error)
UpdateTopic(ctx context.Context, nodeID int, title, body string, sectionID int) error
// SetSticky pins the topic at the top of its section's list (or not).
SetSticky(ctx context.Context, nodeID int, sticky bool) error
TopicExistsBySlug(ctx context.Context, slug string) (bool, error)
// SectionPathPrefix - the forum vocabulary's term path prefix (its
// sections' URLs start with it, e.g. "forums"), "" - none set.
SectionPathPrefix(ctx context.Context) (string, error)
}
ForumRepository defines methods for forum data access
type ForumSection ¶
type ForumSection struct {
ID int
ParentID int
Name string
Description string
Slug string
Weight int
TopicsCount int
PostsCount int
LastTopic *ForumLastTopic
// Parent category for breadcrumbs
ParentName string
ParentSlug string
}
ForumSection represents a forum section within a category
func ToForumSectionEntity ¶
func ToForumSectionEntity(row ForumCategoryRowDTO) ForumSection
ToForumSectionEntity converts a DTO row to a ForumSection entity.
type ForumSectionPage ¶
type ForumSectionPage struct {
Section *ForumSection
Topics []ForumTopic
TotalCount int
}
ForumSectionPage represents a forum section page data
type ForumService ¶
type ForumService interface {
GetForumIndex(ctx context.Context) (*ForumIndex, error)
// SectionPathPrefix - the forum vocabulary's term path prefix: the
// URL prefix of its sections ("" - none).
SectionPathPrefix(ctx context.Context) string
// GetSectionBySlug - the section or category whose slug is slug;
// ErrEntityNotFound when none.
GetSectionBySlug(ctx context.Context, slug string) (*ForumSectionPage, int, error)
// GetCategory - a category (root term) with its sections and stats.
GetCategory(ctx context.Context, id int) (*ForumCategory, error)
GetTopics(ctx context.Context, sectionID int, filter ForumTopicFilter) ([]ForumTopic, error)
CountTopics(ctx context.Context, sectionID int) (int, error)
// ListTopics - a page of topics by the filter and how many there are
// in all (the active and unanswered lists).
ListTopics(ctx context.Context, filter ForumTopicFilter) ([]ForumTopic, int, error)
GetTopic(ctx context.Context, slug string) (*ForumTopicDetail, error)
GetStatistics(ctx context.Context) (*ForumStatistics, error)
GetForumTermsForSelect(ctx context.Context) ([]ForumTermOption, error)
GetTopicSectionID(ctx context.Context, nodeID int) (int, error)
CreateTopic(ctx context.Context, sectionID int, title, body string, authorID int) (*ForumTopicDetail, error)
UpdateTopic(ctx context.Context, nodeID int, title, body string, sectionID int) error
// SetTopicSticky pins the topic at the top of its section (or not).
SetTopicSticky(ctx context.Context, topic modulekit.Node, sticky bool) error
}
ForumService defines the forum business logic.
func NewForumService ¶
func NewForumService(r ForumRepository, baseLogger *slog.Logger) ForumService
NewForumService creates a new forum service.
type ForumSettings ¶
type ForumSettings struct {
VocabularyID int
}
ForumSettings - the forum module's settings (single DB row). The vocabulary's root terms are the forum's categories, their children its sections; 0 - none chosen, the forum is empty.
type ForumSettingsRepository ¶
type ForumSettingsRepository interface {
Get(ctx context.Context) (*ForumSettings, error)
Update(ctx context.Context, s *ForumSettings) error
}
ForumSettingsRepository persists the single forum settings row, same shape as UploadSettingsRepository.
type ForumStatistics ¶
type ForumStatistics struct {
TotalTopics int
TotalPosts int
TotalUsers int
LatestUsers []string
ActiveUsersCount int
}
ForumStatistics represents overall forum statistics
func ToForumStatisticsEntity ¶
func ToForumStatisticsEntity(dto ForumStatisticsDTO, latestUsers []string) ForumStatistics
ToForumStatisticsEntity converts DTO to ForumStatistics entity.
type ForumStatisticsDTO ¶
ForumStatisticsDTO represents statistics from GetForumStatistics query.
type ForumTermOption ¶
type ForumTermOption struct {
ID int
Name string
ParentID int
DisplayName string // With "- " prefix for sections
}
ForumTermOption represents a forum term for the section select dropdown
type ForumTopic ¶
type ForumTopic struct {
ID int
Title string
Slug string
Author *modulekit.User
CreatedAt time.Time
Sticky bool
CommentCount int
ViewsCount int
LastComment *ForumLastComment
// Section - the topic's section, in lists across sections (nil in a
// section's own list).
Section *ForumTopicSection
IsHot bool
}
ForumTopic represents a forum topic in a list
func ToForumTopicEntity ¶
func ToForumTopicEntity(row ForumTopicRowDTO) ForumTopic
ToForumTopicEntity converts a DTO row to a ForumTopic entity.
func ToForumTopicsEntity ¶
func ToForumTopicsEntity(rows []ForumTopicRowDTO) []ForumTopic
ToForumTopicsEntity converts DTO rows to entity topics.
type ForumTopicDetail ¶
type ForumTopicDetail struct {
ID int
Title string
Slug string
Content string
Author *modulekit.User
CreatedAt time.Time
UpdatedAt time.Time
Sticky bool
ViewsCount int
CommentCount int
LastCommentAt time.Time
Comments []modulekit.Comment
// Section for breadcrumbs (includes parent category)
Section *ForumSection
// contains filtered or unexported fields
}
ForumTopicDetail represents detailed forum topic info
func ToForumTopicDetail ¶
func ToForumTopicDetail(n modulekit.Node, author *modulekit.User, stats *generated.ForumStats, body string) ForumTopicDetail
ToForumTopicDetail - a topic from its node (the core's), its author (nil - the account is gone), its stats row (nil - none yet) and body.
type ForumTopicDetailDTO ¶
type ForumTopicDetailDTO struct {
ID int
Title string
Slug string
CreatedAt time.Time
UpdatedAt time.Time
AuthorID int
AuthorName string
AuthorCreated time.Time
Sticky bool
CommentCount int
LastCommentAt time.Time
ViewsCount int
Content string
}
ForumTopicDetailDTO represents a topic from GetTopicBySlug query.
type ForumTopicFilter ¶
type ForumTopicFilter struct {
// SectionID - the section's topics (0 - every section's).
SectionID int
// Unanswered - only topics without replies.
Unanswered bool
Offset int
Limit int
OrderBy string
OrderDir string
Sticky *bool
}
ForumTopicFilter represents filter options for topics
type ForumTopicRowDTO ¶
type ForumTopicRowDTO struct {
ID int
Title string
Slug string
CreatedAt time.Time
AuthorID int
AuthorName string
Sticky bool
CommentCount int
LastCommentAt time.Time
ViewsCount int
LastCommentAuthor sql.NullString
SectionName string
SectionSlug string
}
ForumTopicRowDTO represents a row from GetTopicsBySection query.
type ForumTopicSection ¶
ForumTopicSection - a section as a topic list names it.
type Taxonomy ¶
type Taxonomy interface {
VocabularyByID(ctx context.Context, id int) (*modulekit.TaxonomyVocabulary, error)
TermByID(ctx context.Context, id int) (*modulekit.TaxonomyTerm, error)
TermBySlug(ctx context.Context, slug string) (*modulekit.TaxonomyTerm, error)
TermsByVocabularyID(ctx context.Context, vocabularyID int) (modulekit.TaxonomyTerms, error)
NodeTermsByID(ctx context.Context, nodeID int) (modulekit.TaxonomyTerms, error)
UpdateNodeTerms(ctx context.Context, nodeID int, termIDs []int) error
}
Taxonomy - the core's vocabularies and terms the forum's sections are (Deps.Taxonomy).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
migrations
command
Command migrations writes the module's next migration (kosatka.GenerateMigrations), run from the module's root with the two test databases running:
|
Command migrations writes the module's next migration (kosatka.GenerateMigrations), run from the module's root with the two test databases running: |
|
Package ent - the forum module's own ent schema (schema/), its generated client (generated/, go generate) and migration files (migrations/<dialect>/, cmd/migrations writes them), apart from the core's: the module's set of migrations (Schema).
|
Package ent - the forum module's own ent schema (schema/), its generated client (generated/, go generate) and migration files (migrations/<dialect>/, cmd/migrations writes them), apart from the core's: the module's set of migrations (Schema). |
|
schema
Package schema - the forum module's own ent schema: its tables, apart from the core's.
|
Package schema - the forum module's own ent schema: its tables, apart from the core's. |
|
Package manifest declares the forum module (its registry entry).
|
Package manifest declares the forum module (its registry entry). |
|
Package translations holds the forum module's interface catalogs (<lang>.json, see pkg/i18n): the strings only the module's code uses.
|
Package translations holds the forum module's interface catalogs (<lang>.json, see pkg/i18n): the strings only the module's code uses. |