hmn/src/templates/types.go

320 lines
5.3 KiB
Go
Raw Normal View History

2021-03-14 20:49:58 +00:00
package templates
import (
"html/template"
"time"
)
2021-04-22 23:02:50 +00:00
2021-03-14 20:49:58 +00:00
type BaseData struct {
2021-08-28 12:21:03 +00:00
Title string
CanonicalLink string
OpenGraphItems []OpenGraphItem
BackgroundImage BackgroundImage
Theme string
BodyClasses []string
Breadcrumbs []Breadcrumb
Notices []Notice
ReportIssueMailto string
2021-03-26 03:33:00 +00:00
CurrentUrl string
2021-05-11 22:53:23 +00:00
LoginPageUrl string
ProjectCSSUrl string
2021-03-26 03:33:00 +00:00
Project Project
User *User
Session *Session
2021-05-11 22:53:23 +00:00
IsProjectPage bool
Header Header
Footer Footer
2021-05-11 22:53:23 +00:00
}
2021-08-17 05:18:04 +00:00
func (bd *BaseData) AddImmediateNotice(class, content string) {
bd.Notices = append(bd.Notices, Notice{
Class: class,
Content: template.HTML(content),
})
}
2021-05-11 22:53:23 +00:00
type Header struct {
2021-10-21 02:21:24 +00:00
AdminUrl string
UserProfileUrl string
UserSettingsUrl string
LoginActionUrl string
LogoutActionUrl string
ForgotPasswordUrl string
RegisterUrl string
HMNHomepageUrl string
ProjectIndexUrl string
PodcastUrl string
ForumsUrl string
LibraryUrl string
2021-05-11 22:53:23 +00:00
}
type Footer struct {
HomepageUrl string
AboutUrl string
ManifestoUrl string
CodeOfConductUrl string
CommunicationGuidelinesUrl string
ProjectIndexUrl string
ForumsUrl string
ContactUrl string
2021-03-14 20:49:58 +00:00
}
2021-04-22 23:02:50 +00:00
type Thread struct {
Title string
2021-04-29 04:52:27 +00:00
Locked bool
Sticky bool
2021-04-22 23:02:50 +00:00
}
type Post struct {
ID int
Url string
DeleteUrl string
EditUrl string
ReplyUrl string
Preview string
ReadOnly bool
Author User
Content template.HTML
PostDate time.Time
2021-08-28 17:07:45 +00:00
AuthorNumPosts int
AuthorNumProjects int
Editor *User
EditDate time.Time
EditReason string
2021-04-23 04:07:44 +00:00
IP string
2021-07-20 03:07:15 +00:00
ReplyPost *Post
}
2021-03-18 01:25:06 +00:00
type Project struct {
2021-06-06 23:48:43 +00:00
Name string
Subdomain string
Color1 string
Color2 string
Url string
Blurb string
ParsedDescription template.HTML
Owners []User
Logo string
2021-06-06 23:48:43 +00:00
LifecycleBadgeClass string
LifecycleString string
2021-03-18 01:25:06 +00:00
IsHMN bool
HasBlog bool
HasForum bool
HasLibrary bool
UUID string
DateApproved time.Time
2021-03-18 01:25:06 +00:00
}
2021-03-26 03:33:00 +00:00
type User struct {
2021-07-22 02:16:10 +00:00
ID int
Username string
Email string
IsStaff bool
2021-04-17 00:01:13 +00:00
2021-04-22 23:02:50 +00:00
Name string
Blurb string
Bio string
2021-04-22 23:02:50 +00:00
Signature string
2021-06-22 09:50:40 +00:00
DateJoined time.Time
2021-04-22 23:02:50 +00:00
AvatarUrl string
ProfileUrl string
2021-04-17 00:01:13 +00:00
2021-08-08 20:05:52 +00:00
DarkTheme bool
ShowEmail bool
2021-08-08 20:05:52 +00:00
Timezone string
2021-04-17 00:01:13 +00:00
CanEditLibrary bool
DiscordSaveShowcase bool
DiscordDeleteSnippetOnMessageDelete bool
2021-03-26 03:33:00 +00:00
}
2021-06-22 09:50:40 +00:00
type Link struct {
Name string
Url string
LinkText string
Icon string
2021-07-08 07:40:30 +00:00
}
2021-07-23 03:09:46 +00:00
type Podcast struct {
Title string
Description string
Language string
ImageUrl string
Url string
RSSUrl string
AppleUrl string
GoogleUrl string
SpotifyUrl string
}
type PodcastEpisode struct {
GUID string
Title string
Description string
DescriptionHtml template.HTML
EpisodeNumber int
Url string
ImageUrl string
FileUrl string
FileSize int64
PublicationDate time.Time
Duration int
}
2021-08-08 20:05:52 +00:00
// NOTE(asaf): See /src/rawdata/scss/_notices.scss for a list of classes.
2021-07-08 07:40:30 +00:00
type Notice struct {
Content template.HTML
Class string
2021-06-22 09:50:40 +00:00
}
type Session struct {
CSRFToken string
}
2021-03-14 20:49:58 +00:00
type OpenGraphItem struct {
Property string
Name string
Value string
}
type BackgroundImage struct {
Url string
Size string // A valid CSS background-size value
}
2021-04-22 23:02:50 +00:00
type PostType int
const (
PostTypeUnknown PostType = iota
PostTypeBlogPost
PostTypeBlogComment
PostTypeForumThread
PostTypeForumReply
)
2021-04-22 23:02:50 +00:00
// Data from post_list_item.html
type PostListItem struct {
Title string
Url string
UUID string
2021-04-22 23:02:50 +00:00
Breadcrumbs []Breadcrumb
PostType PostType
PostTypePrefix string
User User
Date time.Time
Unread bool
Classes string
Preview string
LastEditDate time.Time
}
// Data from thread_list_item.html
type ThreadListItem struct {
2021-06-22 10:27:27 +00:00
Title string
Url string
FirstUser User
FirstDate time.Time
LastUser User
LastDate time.Time
Unread bool
Classes string
Content string
2021-04-22 23:02:50 +00:00
}
2021-06-22 09:50:40 +00:00
type TimelineType int
const (
TimelineTypeUnknown TimelineType = iota
TimelineTypeForumThread
TimelineTypeForumReply
TimelineTypeBlogPost
TimelineTypeBlogComment
TimelineTypeSnippetImage
TimelineTypeSnippetVideo
TimelineTypeSnippetAudio
TimelineTypeSnippetYoutube
)
type TimelineItem struct {
Type TimelineType
TypeTitle string
Class string
Date time.Time
Url string
2021-06-22 12:02:47 +00:00
UUID string
2021-06-22 09:50:40 +00:00
OwnerAvatarUrl string
OwnerName string
OwnerUrl string
Description template.HTML
DiscordMessageUrl string
Width int
Height int
AssetUrl string
2021-06-23 20:13:22 +00:00
MimeType string
2021-06-22 09:50:40 +00:00
YoutubeID string
Title string
Breadcrumbs []Breadcrumb
}
2021-06-06 23:48:43 +00:00
type ProjectCardData struct {
Project *Project
Classes string
}
2021-04-22 23:02:50 +00:00
type Breadcrumb struct {
Name, Url string
Current bool
2021-04-22 23:02:50 +00:00
}
2021-04-25 19:33:22 +00:00
type Pagination struct {
Current int
Total int
FirstUrl string
LastUrl string
PreviousUrl string
NextUrl string
}
2021-08-08 20:05:52 +00:00
type EmailBaseData struct {
To template.HTML
From template.HTML
Subject template.HTML
Separator template.HTML
}
2021-08-16 04:40:56 +00:00
type DiscordUser struct {
Username string
Discriminator string
Avatar string
}