This commit is contained in:
2025-08-30 20:52:27 -04:00
parent e7ebccd4a9
commit f53959b38f
31 changed files with 789 additions and 479 deletions

7
web/models/device.go Normal file
View File

@@ -0,0 +1,7 @@
package models
type Device struct {
DeviceName string
LastSynced string
CreatedAt string
}

View File

@@ -29,5 +29,4 @@ type DocumentMetadata struct {
Author string
Description string
Source metadata.Source
Error *string
}

12
web/models/info.go Normal file
View File

@@ -0,0 +1,12 @@
package models
type UserInfo struct {
Username string
IsAdmin bool
}
type ServerInfo struct {
RegistrationEnabled bool
SearchEnabled bool
Version string
}

View File

@@ -0,0 +1,13 @@
package models
type NotificationType int
const (
NotificationTypeSuccess NotificationType = iota
NotificationTypeError
)
type Notification struct {
Content string
Type NotificationType
}

52
web/models/page.go Normal file
View File

@@ -0,0 +1,52 @@
package models
type PageContext struct {
Route PageRoute
UserInfo *UserInfo
ServerInfo *ServerInfo
Notifications []*Notification
}
func (ctx PageContext) WithRoute(route PageRoute) PageContext {
ctx.Route = route
return ctx
}
type PageRoute string
const (
HomePage PageRoute = "home"
DocumentPage PageRoute = "document"
DocumentsPage PageRoute = "documents"
ProgressPage PageRoute = "progress"
ActivityPage PageRoute = "activity"
SearchPage PageRoute = "search"
SettingsPage PageRoute = "settings"
AdminGeneralPage PageRoute = "admin-general"
AdminImportPage PageRoute = "admin-import"
AdminUsersPage PageRoute = "admin-users"
AdminLogsPage PageRoute = "admin-logs"
)
var pageTitleMap = map[PageRoute]string{
HomePage: "Home",
DocumentPage: "Document",
DocumentsPage: "Documents",
ProgressPage: "Progress",
ActivityPage: "Activity",
SearchPage: "Search",
SettingsPage: "Settings",
AdminGeneralPage: "Admin - General",
AdminImportPage: "Admin - Import",
AdminUsersPage: "Admin - Users",
AdminLogsPage: "Admin - Logs",
}
func (p PageRoute) Title() string {
return pageTitleMap[p]
}
func (p PageRoute) Valid() bool {
_, ok := pageTitleMap[p]
return ok
}