Documentation
¶
Overview ¶
Package web provides the HTTP server and web interface for go-pugleaf
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf ¶
Package web provides the HTTP server and web interface for go-pugleaf
Index ¶
- Constants
- Variables
- func EmbeddedFileHandler(filePath string) gin.HandlerFunc
- func EmbeddedStaticHandler(prefix string) gin.HandlerFunc
- func GetAndClearFlash(sessionID string) (success, errorMsg string)
- func ListEmbeddedFiles() ([]string, error)
- func SetFlashError(sessionID, msg string)
- func SetFlashSuccess(sessionID, msg string)
- func UseEmbeddedStatic() bool
- type AIChatPageData
- type AdminPageData
- type ArticlePageData
- type AuthUser
- type ChatMessage
- type FlashMessage
- type GroupPageData
- type GroupThreadsPageData
- type GroupsPageData
- type HierarchiesPageData
- type HierarchyBreadcrumb
- type HierarchyGroupsPageData
- type HierarchyNode
- type HierarchyTreePageData
- type LoginPageData
- type NewsPageData
- type ProfilePageData
- type ProxyModel
- type ProxyModelResponse
- type RegisterPageData
- type SearchPageData
- type SectionArticlePageData
- type SectionGroupPageData
- type SectionPageData
- type SessionData
- type SpamArticleInfo
- type StatsPageData
- type TemplateData
- type WebServer
- func (s *WebServer) APIAuthRequired() gin.HandlerFunc
- func (s *WebServer) ApacheLogFormat() gin.HandlerFunc
- func (s *WebServer) AssignNewsgroupHandler(c *gin.Context)
- func (s *WebServer) BotDetectionMiddleware() gin.HandlerFunc
- func (s *WebServer) CreateSectionHandler(c *gin.Context)
- func (s *WebServer) DeleteSectionHandler(c *gin.Context)
- func (s *WebServer) GetGroupCount() int
- func (s *WebServer) GetPort() int
- func (s *WebServer) NNTPGetTCPPort() int
- func (s *WebServer) NNTPGetTLSPort() int
- func (s *WebServer) ReverseProxyMiddleware() gin.HandlerFunc
- func (s *WebServer) SectionsHandler(c *gin.Context)
- func (s *WebServer) Start() error
- func (s *WebServer) StartSessionCleanup()
- func (s *WebServer) UnassignNewsgroupHandler(c *gin.Context)
- func (s *WebServer) UpdateSectionHandler(c *gin.Context)
- func (s *WebServer) WebAdminRequired() gin.HandlerFunc
- func (s *WebServer) WebAuthRequired() gin.HandlerFunc
Constants ¶
const APIAuthHeader = "X-API"
const OllamaHostname = "ollama-proxy.local:21434"
const ProxyURL = "http://" + OllamaHostname + "/models"
const ThreadMessages_perPage int = 50 // Static page size for optimal caching
This file should contain the thread-related page functions from server.go:
Functions to be moved from server.go:
- func (s *WebServer) singleThreadPage(c *gin.Context) (line ~1394) Handles "/groups/:group/thread/:threadRoot" route to display a single thread flat view
This file will handle thread-specific page functionality for single thread flat views. Note: Tree-related functions are in threadTreePage.go
const Threads_perPage int64 = 50 // Static page size for optimal caching
Variables ¶
var EmbeddedStaticFS embed.FS
var LIMIT_GROUPS_IN_HIERARCHY_TREE = 128
var LIMIT_groupPage = 128
var LIMIT_hierarchiesPage = 512
var LIMIT_hierarchyGroupsPage = 256
var LIMIT_hierarchyTreePage = 384
var LIMIT_listGroups = 128
This file should contain the API endpoint functions from server.go:
var LIMIT_sectionGroupPage = 128
var LIMIT_sectionPage = 128
This file should contain the sections page related functions from server.go:
Functions ¶
func EmbeddedFileHandler ¶
func EmbeddedFileHandler(filePath string) gin.HandlerFunc
EmbeddedFileHandler returns a Gin handler for serving a single embedded file
func EmbeddedStaticHandler ¶
func EmbeddedStaticHandler(prefix string) gin.HandlerFunc
EmbeddedStaticHandler returns a Gin handler for serving embedded static files
func GetAndClearFlash ¶
GetAndClearFlash retrieves and clears flash messages for a session
func ListEmbeddedFiles ¶
ListEmbeddedFiles returns a list of all embedded static files for debugging
func SetFlashError ¶
func SetFlashError(sessionID, msg string)
SetFlashError sets a temporary error message for a session
func SetFlashSuccess ¶
func SetFlashSuccess(sessionID, msg string)
SetFlashSuccess sets a temporary success message for a session
func UseEmbeddedStatic ¶
func UseEmbeddedStatic() bool
UseEmbeddedStatic returns true if embedded static files are available
Types ¶
type AIChatPageData ¶
type AIChatPageData struct {
TemplateData
ChatHistory []ChatMessage
Error string
SessionToken string // Strong session token for chat history
AvailableModels []*models.AIModel // Available AI models for selection
DefaultModel *models.AIModel // Default selected model
ChatCounts map[string]int // Chat message counts per model
MaxInputLength int // Maximum input length for chat messages
}
AIChatPageData for the chat page template
type AdminPageData ¶
type AdminPageData struct {
TemplateData
Users []*models.User
Newsgroups []*models.Newsgroup
NewsgroupPagination *models.PaginationInfo
NewsgroupSearch string
Providers []*models.Provider
APITokens []*database.APIToken
AIModels []*models.AIModel
NNTPUsers []*models.NNTPUser
SiteNews []*models.SiteNews // Added for site news management
Sections []*models.Section // Added for section management
SectionGroups []*models.SectionGroup // Added for section-newsgroup assignments
SpamArticles []*SpamArticleInfo // Added for spam management
SpamPagination *models.PaginationInfo // Added for spam pagination
CurrentUser *models.User
AdminCount int
EnabledTokensCount int
ActiveSessions int
ActiveNNTPUsers int
PostingNNTPUsers int
Uptime string
CacheStats map[string]interface{} // Added for cache monitoring
NewsgroupCacheStats map[string]interface{} // Added for newsgroup cache monitoring
ArticleCacheStats map[string]interface{} // Added for article cache monitoring
NNTPAuthCacheStats map[string]interface{} // Added for NNTP auth cache monitoring
MessageIdCacheStats map[string]interface{} // Added for message ID cache monitoring
RegistrationEnabled bool // Added for registration control
Success string
Error string
ActiveTab string // Added for tab state
}
AdminPageData represents data for admin page
type ArticlePageData ¶
type ArticlePageData struct {
TemplateData
GroupName string
GroupPtr *string
ArticleNum int64
Article *models.Article
Thread []*models.Overview
PrevArticle int64
NextArticle int64
}
ArticlePageData represents data for article page
type AuthUser ¶
type AuthUser struct {
ID int64 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
DisplayName string `json:"display_name"`
CreatedAt string `json:"created_at"`
}
AuthUser represents a user for authentication
type ChatMessage ¶
ChatMessage represents a single chat message (extend as needed for frontend)
type FlashMessage ¶
FlashMessage represents a temporary success/error message
type GroupPageData ¶
type GroupPageData struct {
TemplateData
GroupName string
GroupPtr *string
Articles []*models.Overview
Pagination *models.PaginationInfo
}
GroupPageData represents data for group page
type GroupThreadsPageData ¶
type GroupThreadsPageData struct {
TemplateData
GroupName string
ForumThreads []*models.ForumThread
TotalThreads int64
TotalMessages int
CurrentPage int64
TotalPages int64
PerPage int64
HasPrevPage bool
HasNextPage bool
PrevPage int64
NextPage int64
}
GroupThreadsPageData represents data for group threads page
type GroupsPageData ¶
type GroupsPageData struct {
TemplateData
Groups []*models.Newsgroup
Pagination *models.PaginationInfo
GroupCount int
}
GroupsPageData represents data for groups page
type HierarchiesPageData ¶
type HierarchiesPageData struct {
TemplateData
Hierarchies []*models.Hierarchy
Pagination *models.PaginationInfo
SortBy string
}
HierarchiesPageData represents data for hierarchies page
type HierarchyBreadcrumb ¶
HierarchyBreadcrumb represents a breadcrumb item in hierarchy navigation
type HierarchyGroupsPageData ¶
type HierarchyGroupsPageData struct {
TemplateData
HierarchyName string
Groups []*models.Newsgroup
Pagination *models.PaginationInfo
SortBy string
}
HierarchyGroupsPageData represents data for groups within a hierarchy
type HierarchyNode ¶
HierarchyNode represents a node in the hierarchy tree
type HierarchyTreePageData ¶
type HierarchyTreePageData struct {
TemplateData
HierarchyName string
CurrentPath string
RelativePath string // Path relative to hierarchy (e.g., "arts" for "alt.arts")
ParentPath string
Breadcrumbs []HierarchyBreadcrumb
SubHierarchies []HierarchyNode
Groups []*models.Newsgroup
TotalSubItems int
TotalGroups int
ShowingGroups bool
SortBy string
Pagination *models.PaginationInfo
AtMaxDepth bool // True if we're at the maximum supported hierarchy depth (level 3)
}
HierarchyTreePageData represents data for hierarchical tree navigation
type LoginPageData ¶
type LoginPageData struct {
TemplateData
Error string
RedirectURL string
}
LoginPageData represents data for login page
type NewsPageData ¶
type NewsPageData struct {
TemplateData
}
NewsPageData represents data for news page
type ProfilePageData ¶
type ProfilePageData struct {
TemplateData
User *models.User
Error string
Success string
}
ProfilePageData represents data for profile page
type ProxyModel ¶
type ProxyModelResponse ¶
type ProxyModelResponse struct {
Models []ProxyModel `json:"models"`
}
ProxyModelResponse represents the response from ollama-proxy /models endpoint
type RegisterPageData ¶
type RegisterPageData struct {
TemplateData
Error string
Username string
Email string
}
RegisterPageData represents data for register page
type SearchPageData ¶
type SearchPageData struct {
TemplateData
Query string
SearchType string
Results interface{}
ResultCount int
HasResults bool
Pagination *models.PaginationInfo
}
SearchPageData represents data for search page
type SectionArticlePageData ¶
type SectionArticlePageData struct {
TemplateData
Section *models.Section
GroupName string
ArticleNum int64
Article *models.Article
Thread []*models.Overview
PrevArticle int64
NextArticle int64
}
SectionArticlePageData represents data for article page within a section
type SectionGroupPageData ¶
type SectionGroupPageData struct {
TemplateData
Section *models.Section
GroupName string
Articles []*models.Overview
Pagination *models.PaginationInfo
GroupExists bool
}
SectionGroupPageData represents data for group page within a section
type SectionPageData ¶
type SectionPageData struct {
TemplateData
Section *models.Section
Groups []*models.SectionGroup
Pagination *models.PaginationInfo
TotalGroups int
AvailableSections []*models.Section
}
SectionPageData represents data for section page (shows groups in section)
type SessionData ¶
type SessionData struct {
SessionID string
UserID int64
User *AuthUser
ExpiresAt time.Time
TmpError string // Temporary error message for rendering
TmpSuccess string // Temporary success message for rendering
}
SessionData represents session information with user data
func (*SessionData) GetError ¶
func (s *SessionData) GetError() string
GetError retrieves and clears the temporary error message
func (*SessionData) GetSuccess ¶
func (s *SessionData) GetSuccess() string
GetSuccess retrieves and clears the temporary success message
func (*SessionData) SetError ¶
func (s *SessionData) SetError(msg string)
SetError sets a temporary error message in session data
func (*SessionData) SetSuccess ¶
func (s *SessionData) SetSuccess(msg string)
SetSuccess sets a temporary success message in session data
type SpamArticleInfo ¶
SpamArticleInfo wraps Overview with group name for admin spam management
type StatsPageData ¶
type StatsPageData struct {
TemplateData
Groups []*models.Newsgroup
TotalArticles int64
}
StatsPageData represents data for stats page
type TemplateData ¶
type TemplateData struct {
Title template.HTML
CurrentTime string
Port int
NNTPtcpPort int
NNTPtlsPort int
GroupCount int
User *AuthUser
IsAdmin bool
AppVersion string
RegistrationEnabled bool
SiteNews []*models.SiteNews // For home page news display
AvailableSections []*models.Section // For global sections navigation
AvailableAIModels []*models.AIModel // For conditional AI chat navigation
}
TemplateData represents common template data
type WebServer ¶
type WebServer struct {
DB *database.Database
Router *gin.Engine
Config *config.WebConfig
NNTP *nntp.NNTPServer
StartTime time.Time // Track server start time for uptime calculations
SectionsCache map[string]bool // In-memory cache of valid section names for route filtering
// contains filtered or unexported fields
}
Server represents the web server
func NewServer ¶
func NewServer(db *database.Database, webconfig *config.WebConfig, nntpconfig *nntp.NNTPServer) *WebServer
NewServer creates a new web server instance
func (*WebServer) APIAuthRequired ¶
func (s *WebServer) APIAuthRequired() gin.HandlerFunc
AuthRequired middleware for API token authentication
func (*WebServer) ApacheLogFormat ¶
func (s *WebServer) ApacheLogFormat() gin.HandlerFunc
func (*WebServer) AssignNewsgroupHandler ¶
AssignNewsgroupHandler handles assigning newsgroups to a section using pattern matching
func (*WebServer) BotDetectionMiddleware ¶
func (s *WebServer) BotDetectionMiddleware() gin.HandlerFunc
Custom bot detection middleware
func (*WebServer) CreateSectionHandler ¶
CreateSectionHandler handles creating a new section
func (*WebServer) DeleteSectionHandler ¶
DeleteSectionHandler handles deleting a section
func (*WebServer) GetGroupCount ¶
GetGroupCount returns the total number of active newsgroups
func (*WebServer) NNTPGetTCPPort ¶
NNTPGetTCPPort returns the listening TCP port from the config
func (*WebServer) NNTPGetTLSPort ¶
NNTPGetTLSPort returns the listening TLS port from the config
func (*WebServer) ReverseProxyMiddleware ¶
func (s *WebServer) ReverseProxyMiddleware() gin.HandlerFunc
ReverseProxyMiddleware handles X-Forwarded headers when running behind a reverse proxy
func (*WebServer) SectionsHandler ¶
SectionsHandler handles the main sections admin page
func (*WebServer) StartSessionCleanup ¶
func (s *WebServer) StartSessionCleanup()
StartSessionCleanup starts a background goroutine to clean up expired sessions
func (*WebServer) UnassignNewsgroupHandler ¶
UnassignNewsgroupHandler handles removing a newsgroup from a section
func (*WebServer) UpdateSectionHandler ¶
UpdateSectionHandler handles updating an existing section
func (*WebServer) WebAdminRequired ¶
func (s *WebServer) WebAdminRequired() gin.HandlerFunc
WebAdminRequired middleware for admin-only routes
func (*WebServer) WebAuthRequired ¶
func (s *WebServer) WebAuthRequired() gin.HandlerFunc
WebAuthRequired middleware for web authentication (different from API auth)
Source Files
¶
- embedded_static.go
- web_admin.go
- web_adminPage.go
- web_admin_apitokens.go
- web_admin_cache.go
- web_admin_newsgroups.go
- web_admin_nntp.go
- web_admin_ollama.go
- web_admin_provider.go
- web_admin_registration.go
- web_admin_sections.go
- web_admin_sitenews.go
- web_admin_userfuncs.go
- web_aichatPage.go
- web_apiHandlers.go
- web_apitokens.go
- web_articlePage.go
- web_auth.go
- web_groupThreadsPage.go
- web_groupsPage.go
- web_helpPage.go
- web_helpers.go
- web_hierarchiesPage.go
- web_homePage.go
- web_login.go
- web_newsPage.go
- web_profile.go
- web_registerPage.go
- web_searchPage.go
- web_sectionsPage.go
- web_session_cleanup.go
- web_statsPage.go
- web_threadPage.go
- web_threadTreePage.go
- web_utils.go
- webgroupPage.go
- webgroupPage_admin.go
- webserver.go
- webserver_core_routes.go