Documentation
¶
Overview ¶
Package web is the client-side router that manages the website If the `server` package interacts with the DB, the `web` package interacts with the user
Index ¶
- Constants
- Variables
- func ReadOrTruncate(r io.Reader) ([]byte, bool)
- type AttachmentEditorParams
- type AuditLogParams
- type BlogPostIndexParams
- type BlogPostParams
- type ContestInviteParams
- type ContestParams
- type ContestsIndexParams
- type DonateParams
- type IndexParams
- type MarkdownParams
- type PasswordResetParams
- type PasteParams
- type PblistParams
- type PostTopbar
- type ProblemArchiveParams
- type ProblemEditParams
- type ProblemListParams
- type ProblemListProgressParams
- type ProblemListingParams
- type ProblemParams
- type ProblemSearchParams
- type ProblemTopbar
- type ProblemTopbarParams
- type ProfileParams
- type SessionsParams
- type StatementEditorParams
- type StatusParams
- type SubParams
- type SubTaskEditParams
- type TagPageParams
- type TestEditParams
- type VerifiedEmailParams
- type Web
- func (rt *Web) Handler() http.Handler
- func (rt *Web) ProblemEditRouter(r chi.Router)
- func (rt *Web) SubTaskValidator() func(next http.Handler) http.Handler
- func (rt *Web) TestIDValidator() func(next http.Handler) http.Handler
- func (rt *Web) ValidateAttachmentID(next http.Handler) http.Handler
- func (rt *Web) ValidateBlogPostSlug(next http.Handler) http.Handler
- func (rt *Web) ValidateBlogPostVisible(next http.Handler) http.Handler
- func (rt *Web) ValidateContestID(next http.Handler) http.Handler
- func (rt *Web) ValidateContestVisible(next http.Handler) http.Handler
- func (rt *Web) ValidateListID(next http.Handler) http.Handler
- func (rt *Web) ValidatePasteID(next http.Handler) http.Handler
- func (rt *Web) ValidateProblemFullyVisible(next http.Handler) http.Handler
- func (rt *Web) ValidateProblemID(next http.Handler) http.Handler
- func (rt *Web) ValidateProblemVisible(next http.Handler) http.Handler
- func (rt *Web) ValidateSubmissionID(next http.Handler) http.Handler
- func (rt *Web) ValidateTagID(next http.Handler) http.Handler
- type WebCtx
- type WebLanguage
Constants ¶
const (
PblistCntCacheKey = WebCtx("pblist_cache")
)
Variables ¶
var ( DonationsEnabled = config.GenFlag[bool]("frontend.donations.enabled", true, "Donations page enabled") DonationsNag = config.GenFlag[bool]("frontend.donation.frontpage_nag", true, "Donations front page notification") MainPageLogin = config.GenFlag[bool]("feature.frontend.main_page_login", false, "Login modal on front page") PinnedProblemList = config.GenFlag[int]("frontend.front_page.pinned_problem_list", 0, "Pinned problem list (front page sidebar)") RootProblemList = config.GenFlag[int]("frontend.front_page.root_problem_list", 0, "Root problem list (front page main content)") )
var ( CCDisclaimer = config.GenFlag("frontend.footer.cc_disclaimer", true, "CC disclaimer in footer") DiscordInviteID = config.GenFlag("frontend.footer.discord_id", "Qa6Ytgh", "Invite ID for Discord server") AllSubsPage = config.GenFlag("feature.frontend.all_subs_page", true, "Anyone can view all submissions") FrontPageProblems = config.GenFlag("feature.frontend.front_page_pbs", true, "Show problems on front page") FrontPagePbDetails = config.GenFlag("feature.frontend.front_page_pbs_links", true, "On the front page problems, show links to other resources") FrontPageAnnouncement = config.GenFlag("frontend.front_page_announcement", "default", `Custom front page announcement ("default" = default text)`) SidebarContests = config.GenFlag("feature.frontend.front_page_csidebar", true, "Show contests in sidebar on the front page") ShowTrending = config.GenFlag("frontend.front_page.show_trending", true, "Show trending problems on the front page sidebar") ForceLogin = config.GenFlag("behavior.force_authed", false, "Force authentication when accessing website") GoatCounterDomain = config.GenFlag("feature.analytics.goat_prefix", "https://goat.kilonova.ro", "URL prefix for GoatCounter analytics") FeedbackURL = config.GenFlag("feature.frontend.feedback_url", "", "Feedback URL for main page") QuickSearchBox = config.GenFlag("feature.frontend.quick_search", false, "Quick search box on main page") )
Functions ¶
Types ¶
type AttachmentEditorParams ¶
type AuditLogParams ¶
type BlogPostIndexParams ¶
type BlogPostParams ¶
type BlogPostParams struct {
Topbar *PostTopbar
StatementEditor *StatementEditorParams
AttachmentEditor *AttachmentEditorParams
Attachments []*kilonova.Attachment
Statement template.HTML
StatementAtt *kilonova.Attachment
Languages map[string]eval.Language
Variants []*kilonova.StatementVariant
SelectedVariant *kilonova.StatementVariant
}
type ContestInviteParams ¶
type ContestParams ¶
type ContestParams struct {
Topbar *ProblemTopbar
Contest *kilonova.Contest
ContestInvitations []*kilonova.ContestInvitation
MOSSResults []*kilonova.MOSSSubmission
}
type ContestsIndexParams ¶
type DonateParams ¶
type IndexParams ¶
type IndexParams struct {
FutureContests []*kilonova.Contest
RunningContests []*kilonova.Contest
ChildProblemLists []*kilonova.ProblemList
HotProblems []*kilonova.ScoredProblem
MoreProblems bool
PinnedLists []*kilonova.ProblemList
}
type MarkdownParams ¶
type PasswordResetParams ¶
type PasteParams ¶
type PasteParams struct {
Paste *kilonova.SubmissionPaste
FullSub *sudoapi.FullSubmission
}
type PblistParams ¶
type PblistParams struct {
Pblist *kilonova.ProblemList
Open bool
}
type ProblemArchiveParams ¶ added in v0.25.0
type ProblemArchiveParams struct {
Topbar *ProblemTopbar
Tests []*kilonova.Test
Problem *kilonova.Problem
}
type ProblemEditParams ¶
type ProblemEditParams struct {
Problem *kilonova.Problem
Topbar *ProblemTopbar
Checklist *kilonova.ProblemChecklist
AttachmentEditor *AttachmentEditorParams
StatementEditor *StatementEditorParams
}
type ProblemListParams ¶
type ProblemListParams struct {
ProblemList *kilonova.ProblemList
Lists []*kilonova.ProblemList
RootProblemList int
}
type ProblemListProgressParams ¶
type ProblemListProgressParams struct {
ProblemList *sudoapi.FullProblemList
CheckedUser *kilonova.UserBrief
}
type ProblemListingParams ¶
type ProblemParams ¶
type ProblemParams struct {
Topbar *ProblemTopbar
Problem *kilonova.Problem
Attachments []*kilonova.Attachment
Tags []*kilonova.Tag
Submissions *sudoapi.Submissions
Statement template.HTML
Languages map[string]eval.Language
Variants []*kilonova.StatementVariant
SelectedVariant *kilonova.StatementVariant
}
type ProblemSearchParams ¶
type ProblemSearchParams struct {
ProblemList *kilonova.ProblemList
Results []*sudoapi.FullProblem
Groups []*kilonova.TagGroup
GroupTags []*kilonova.Tag
Count int
}
type ProblemTopbar ¶
type ProblemTopbarParams ¶
type ProfileParams ¶
type ProfileParams struct {
ContentUser *kilonova.UserFull
SolvedProblems []*sudoapi.FullProblem
SolvedCount int
AttemptedProblems []*sudoapi.FullProblem
AttemptedCount int
ChangeHistory []*kilonova.UsernameChange
}
type SessionsParams ¶
type StatementEditorParams ¶
type StatementEditorParams struct {
Variants []*kilonova.StatementVariant
Variant *kilonova.StatementVariant
Data string
Att *kilonova.Attachment
APIPrefix string
}
type StatusParams ¶
type SubParams ¶
type SubParams struct {
Submission *kilonova.FullSubmission
}
type SubTaskEditParams ¶
type SubTaskEditParams struct {
Problem *kilonova.Problem
SubTask *kilonova.SubTask
Topbar *ProblemTopbar
// contains filtered or unexported fields
}
func (*SubTaskEditParams) TestInSubTask ¶
func (s *SubTaskEditParams) TestInSubTask(test *kilonova.Test) bool
func (*SubTaskEditParams) TestSubTasks ¶
func (s *SubTaskEditParams) TestSubTasks(id int) string
type TagPageParams ¶
type TestEditParams ¶
type TestEditParams struct {
Problem *kilonova.Problem
Test *kilonova.Test
Topbar *ProblemTopbar
// contains filtered or unexported fields
}
func (*TestEditParams) GetFullTests ¶
func (t *TestEditParams) GetFullTests() testDataType
type VerifiedEmailParams ¶
type Web ¶
type Web struct {
// contains filtered or unexported fields
}
Web is the struct representing this whole package
func (*Web) ProblemEditRouter ¶
Handler is the http handler to be attached The caller should ensure a User and a Problem are attached to the context
func (*Web) SubTaskValidator ¶
func (*Web) ValidateAttachmentID ¶
ValidateAttachmentID makes sure the attachment ID is a valid uint
func (*Web) ValidateBlogPostSlug ¶
ValidateBlogPostSlug makes sure the blog post slug is a valid one
func (*Web) ValidateBlogPostVisible ¶
ValidateBlogPostVisible checks if the post from context is visible from the logged in user
func (*Web) ValidateContestID ¶
ValidateContestID makes sure the contest ID is a valid uint
func (*Web) ValidateContestVisible ¶
ValidateContestVisible checks if the problem from context is visible from the logged in user
func (*Web) ValidateListID ¶
ValidateListID makes sure the list ID is a valid uint
func (*Web) ValidatePasteID ¶
ValidatePasteID puts the ID and the Paste in the router context
func (*Web) ValidateProblemFullyVisible ¶
ValidateProblemFullyVisible checks if the problem from context is FULLY visible from the logged in user
func (*Web) ValidateProblemID ¶
ValidateProblemID makes sure the problem ID is a valid uint
func (*Web) ValidateProblemVisible ¶
ValidateProblemVisible checks if the problem from context is visible from the logged in user
func (*Web) ValidateSubmissionID ¶
ValidateSubmissionID puts the ID and the Submission in the router context