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 ContestParams
- type ContestsIndexParams
- type DonateParams
- type IndexParams
- type MarkdownParams
- type PasswordResetParams
- type PasteParams
- type PblistParams
- type PostTopbar
- type ProblemEditParams
- type ProblemListParams
- type ProblemListProgressParams
- type ProblemListingParams
- type ProblemParams
- type ProblemSearchParams
- type ProblemTopbar
- type ProblemTopbarParams
- type ProfileParams
- type ReqContext
- type SimpleParams
- 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]("frontent.donation.frontpage_nag", true, "Donations front page notification") MainPageLogin = config.GenFlag[bool]("feature.frontend.main_page_login", false, "Login modal on front page") )
var ( CCDisclaimer = config.GenFlag("feature.frontend.cc_disclaimer", true, "CC disclaimer in footer") 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") ForceLogin = config.GenFlag("behavior.force_authed", false, "Force authentication when accessing website") )
Functions ¶
Types ¶
type AttachmentEditorParams ¶
type AuditLogParams ¶
type AuditLogParams struct { Ctx *ReqContext Logs []*kilonova.AuditLog Page int NumPages int }
type BlogPostIndexParams ¶
type BlogPostParams ¶
type BlogPostParams struct { Ctx *ReqContext Topbar *PostTopbar StatementEditor *StatementEditorParams AttachmentEditor *AttachmentEditorParams Attachments []*kilonova.Attachment Statement template.HTML StatementAtt *kilonova.Attachment Languages map[string]eval.Language Variants []*kilonova.StatementVariant SelectedLang string SelectedFormat string }
type ContestParams ¶
type ContestParams struct { Ctx *ReqContext Topbar *ProblemTopbar Contest *kilonova.Contest }
type ContestsIndexParams ¶
type ContestsIndexParams struct { Ctx *ReqContext Contests []*kilonova.Contest }
type DonateParams ¶
type IndexParams ¶
type IndexParams struct { Ctx *ReqContext FutureContests []*kilonova.Contest RunningContests []*kilonova.Contest ChildProblemLists []*kilonova.ProblemList HotProblems []*kilonova.ScoredProblem MoreProblems bool PinnedLists []*kilonova.ProblemList }
type MarkdownParams ¶
type MarkdownParams struct { Ctx *ReqContext Markdown template.HTML Title string }
type PasswordResetParams ¶
type PasswordResetParams struct { Ctx *ReqContext User *kilonova.UserFull RequestID string }
type PasteParams ¶
type PasteParams struct { Ctx *ReqContext Paste *kilonova.SubmissionPaste FullSub *sudoapi.FullSubmission }
type PblistParams ¶
type PblistParams struct { Pblist *kilonova.ProblemList Open bool }
type ProblemEditParams ¶
type ProblemEditParams struct { Ctx *ReqContext Problem *kilonova.Problem Topbar *ProblemTopbar Checklist *kilonova.ProblemChecklist AttachmentEditor *AttachmentEditorParams StatementEditor *StatementEditorParams }
type ProblemListParams ¶
type ProblemListParams struct { Ctx *ReqContext ProblemList *kilonova.ProblemList Lists []*kilonova.ProblemList RootProblemList int }
type ProblemListProgressParams ¶
type ProblemListProgressParams struct { Ctx *ReqContext ProblemList *sudoapi.FullProblemList CheckedUser *kilonova.UserBrief }
type ProblemListingParams ¶
type ProblemListingParams struct { Problems []*kilonova.ScoredProblem ShowScore bool ShowPublished bool ContestIDScore int }
type ProblemParams ¶
type ProblemParams struct { Ctx *ReqContext 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 SelectedLang string SelectedFormat string }
type ProblemSearchParams ¶
type ProblemSearchParams struct { Ctx *ReqContext Results []*sudoapi.FullProblem Groups []*kilonova.TagGroup GroupTags []*kilonova.Tag Count int }
type ProblemTopbar ¶
type ProblemTopbarParams ¶
type ProblemTopbarParams struct { Ctx *ReqContext Topbar *ProblemTopbar Languages map[string]eval.Language Problem *kilonova.Problem }
type ProfileParams ¶
type ProfileParams struct { Ctx *ReqContext ContentUser *kilonova.UserFull SolvedProblems []*sudoapi.FullProblem SolvedCount int AttemptedProblems []*sudoapi.FullProblem AttemptedCount int ChangeHistory []*kilonova.UsernameChange }
type ReqContext ¶
func GenContext ¶
func GenContext(r *http.Request) *ReqContext
type SimpleParams ¶
type SimpleParams struct {
Ctx *ReqContext
}
type StatementEditorParams ¶
type StatementEditorParams struct { Lang string Data string Att *kilonova.Attachment APIPrefix string }
type StatusParams ¶
type StatusParams struct { Ctx *ReqContext Code int Message string }
type SubParams ¶
type SubParams struct { Ctx *ReqContext Submission *kilonova.FullSubmission }
type SubTaskEditParams ¶
type SubTaskEditParams struct { Ctx *ReqContext 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 TagPageParams struct { Ctx *ReqContext Tag *kilonova.Tag RelevantTags []*kilonova.Tag Problems []*kilonova.ScoredProblem }
type TestEditParams ¶
type TestEditParams struct { Ctx *ReqContext Problem *kilonova.Problem Test *kilonova.Test Topbar *ProblemTopbar // contains filtered or unexported fields }
func (*TestEditParams) GetFullTests ¶
func (t *TestEditParams) GetFullTests() testDataType
type VerifiedEmailParams ¶
type VerifiedEmailParams struct { Ctx *ReqContext ContentUser *kilonova.UserBrief }
type Web ¶
type Web struct {
// contains filtered or unexported fields
}
Web is the struct representing this whole package
func (*Web) ProblemEditRouter ¶
func (rt *Web) ProblemEditRouter(r chi.Router)
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