Documentation ¶
Index ¶
- Constants
- Variables
- func CeilInt(a, b int) int
- func ClearSession(cookStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request)
- func FileServer(r chi.Router, path string, root http.FileSystem) error
- func GetLoginUserId(sessStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request) (int, error)
- func HttpError(msg string, err error, w http.ResponseWriter, code int)
- func IsLogin(sessStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request) bool
- func IsRegisterdPage(url *url.URL, r *chi.Mux) bool
- type AppState
- type ArticlePageType
- type ArticleResource
- func (ar *ArticleResource) BlockRegions(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) BlockRegionsPage(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Delete(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) DeletePage(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) FormPage(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) HistoryPage(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Item(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) List(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) React(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Recover(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) ReplyPage(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Routes() http.Handler
- func (ar *ArticleResource) Save(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Share(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Submit(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) SubmitReply(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Subscribe(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) ToggleFadeOut(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) ToggleHideHistory(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) ToggleLock(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Update(w http.ResponseWriter, r *http.Request)
- func (ar *ArticleResource) Vote(w http.ResponseWriter, r *http.Request)
- type AuthType
- type GithubTokenResponse
- type GithubUserInfo
- type GoogleTokenResponse
- type GoogleUserInfo
- type MainResource
- func (mr *MainResource) About(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) CategoryArticleList(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) CategoryList(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) CategorySubscribe(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) Guide(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) Login(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) LoginAuthCallback(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) LoginAuthCallbackGithub(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) LoginDebug(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) LoginPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) LoginWithOAuth(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) Logout(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) MessageList(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) Register(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) RegisterPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) ResendVerifyEmail(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) ResetPassword(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) ResetPasswordPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) RetrievePassword(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) RetrievePasswordPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) Routes() http.Handler
- func (mr *MainResource) SaveAccountSettings(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) SaveUISettings(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) SettingsAccountPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) SettingsPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) SettingsUIPage(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) VerifyRegister(w http.ResponseWriter, r *http.Request)
- func (mr *MainResource) VerifyRegisterPage(w http.ResponseWriter, r *http.Request)
- type ManageResource
- func (mr *ManageResource) ActivityList(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) PermissionCreatePage(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) PermissionListPage(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) PermissionSubmit(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) RoleCreatePage(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) RoleEditPage(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) RoleEditSubmit(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) RoleListPage(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) RoleSubmit(w http.ResponseWriter, r *http.Request)
- func (mr *ManageResource) Routes() http.Handler
- func (mr *ManageResource) TrashPage(w http.ResponseWriter, r *http.Request)
- type MessagePageData
- type MessageQueryData
- type MessageStatus
- type PermissionPageType
- type RSSResource
- type Region
- type Renderer
- func (rd *Renderer) CheckPermit(r *http.Request, module, action string) bool
- func (rd *Renderer) Error(msg string, err error, w http.ResponseWriter, r *http.Request, code int)
- func (rd *Renderer) Forbidden(err error, w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) GetLoginedUserData(r *http.Request) *model.User
- func (rd *Renderer) GetLoginedUserId(w http.ResponseWriter, r *http.Request) int
- func (rd *Renderer) GetPaginationData(r *http.Request) (int, int)
- func (rd *Renderer) Local(id string, data ...any) string
- func (rd *Renderer) NotFound(w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) Render(w http.ResponseWriter, r *http.Request, name string, data *model.PageData)
- func (rd *Renderer) SavePrevPage(w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) ServerError(w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) ServerErrorp(msg string, err error, w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) Session(name string, w http.ResponseWriter, r *http.Request) *Session
- func (rd *Renderer) ToLogin(w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) ToPrevPage(w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) ToRefererUrl(w http.ResponseWriter, r *http.Request)
- func (rd *Renderer) ToTargetUrl(w http.ResponseWriter, r *http.Request)
- type RoleFormPageData
- type RoleFormPageType
- type Session
- type SettingsPageData
- type SettingsPageKey
- type TipStatus
- type TurnstileVerifyResult
- type UserResource
- func (ur *UserResource) Ban(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) BanPage(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) EditUserProfilePage(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) ItemPage(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) List(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) Routes() http.Handler
- func (ur *UserResource) SetRole(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) SetRolePage(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) Unban(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) UnbanPage(w http.ResponseWriter, r *http.Request)
- func (ur *UserResource) UpdateUserProfile(w http.ResponseWriter, r *http.Request)
Constants ¶
View Source
const ( ArticlePageDel ArticlePageType = "del" ArticlePageReply = "reply" ArticlePageDetail = "detail" ArticlePageBlockRegions = "block_regions" )
View Source
const ( MessageStatusUnread MessageStatus = "unread" MessageStatusRead = "read" MessageStatusAll = "all" )
View Source
const ( AuthTypeGoogle AuthType = "google" AuthTypeGithub = "github" AuthTypeMicrosoft = "microsoft" )
View Source
const ( DefaultPage int = 1 DefaultPageSize int = 50 )
View Source
const DefaultReplyPageSize = 50
View Source
const PGErrUniqueViolation = "23505"
https://www.postgresql.org/docs/current/errcodes-appendix.html
Variables ¶
View Source
var ( // ErrCodeVerifyExpired = errors.New("verification code is expired") ErrCodeVerifyIncorrect = errors.New("verification code is incorrect") )
View Source
var MessageStatusMap = map[MessageStatus]bool{ MessageStatusUnread: true, MessageStatusRead: true, MessageStatusAll: true, }
View Source
var TipStatusStr = map[TipStatus]string{ TipStatusDeleteSuccess: "Successfully deleted.", TipStatusDeleteFailed: "Failed to delete", }
Functions ¶
func ClearSession ¶
func ClearSession(cookStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request)
func FileServer ¶
func FileServer(r chi.Router, path string, root http.FileSystem) error
func GetLoginUserId ¶
func GetLoginUserId(sessStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request) (int, error)
func IsLogin ¶
func IsLogin(sessStore *sessions.CookieStore, w http.ResponseWriter, r *http.Request) bool
func IsRegisterdPage ¶
Types ¶
type ArticlePageType ¶
type ArticlePageType string
type ArticleResource ¶
type ArticleResource struct { *Renderer // contains filtered or unexported fields }
func NewArticleResource ¶
func NewArticleResource(renderer *Renderer) *ArticleResource
func (*ArticleResource) BlockRegions ¶
func (ar *ArticleResource) BlockRegions(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) BlockRegionsPage ¶
func (ar *ArticleResource) BlockRegionsPage(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Delete ¶
func (ar *ArticleResource) Delete(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) DeletePage ¶
func (ar *ArticleResource) DeletePage(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) FormPage ¶
func (ar *ArticleResource) FormPage(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) HistoryPage ¶
func (ar *ArticleResource) HistoryPage(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Item ¶
func (ar *ArticleResource) Item(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) List ¶
func (ar *ArticleResource) List(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) React ¶
func (ar *ArticleResource) React(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Recover ¶
func (ar *ArticleResource) Recover(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) ReplyPage ¶
func (ar *ArticleResource) ReplyPage(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Routes ¶
func (ar *ArticleResource) Routes() http.Handler
func (*ArticleResource) Save ¶
func (ar *ArticleResource) Save(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Share ¶
func (ar *ArticleResource) Share(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Submit ¶
func (ar *ArticleResource) Submit(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) SubmitReply ¶
func (ar *ArticleResource) SubmitReply(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Subscribe ¶
func (ar *ArticleResource) Subscribe(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) ToggleFadeOut ¶
func (ar *ArticleResource) ToggleFadeOut(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) ToggleHideHistory ¶
func (ar *ArticleResource) ToggleHideHistory(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) ToggleLock ¶
func (ar *ArticleResource) ToggleLock(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Update ¶
func (ar *ArticleResource) Update(w http.ResponseWriter, r *http.Request)
func (*ArticleResource) Vote ¶
func (ar *ArticleResource) Vote(w http.ResponseWriter, r *http.Request)
type GithubTokenResponse ¶
type GithubUserInfo ¶
type GoogleTokenResponse ¶
type GoogleUserInfo ¶
type MainResource ¶
type MainResource struct { *Renderer // contains filtered or unexported fields }
func NewMainResource ¶
func NewMainResource(renderer *Renderer, ar *ArticleResource) *MainResource
func (*MainResource) About ¶
func (mr *MainResource) About(w http.ResponseWriter, r *http.Request)
func (*MainResource) CategoryArticleList ¶
func (mr *MainResource) CategoryArticleList(w http.ResponseWriter, r *http.Request)
func (*MainResource) CategoryList ¶
func (mr *MainResource) CategoryList(w http.ResponseWriter, r *http.Request)
func (*MainResource) CategorySubscribe ¶
func (mr *MainResource) CategorySubscribe(w http.ResponseWriter, r *http.Request)
func (*MainResource) Guide ¶
func (mr *MainResource) Guide(w http.ResponseWriter, r *http.Request)
func (*MainResource) Login ¶
func (mr *MainResource) Login(w http.ResponseWriter, r *http.Request)
func (*MainResource) LoginAuthCallback ¶
func (mr *MainResource) LoginAuthCallback(w http.ResponseWriter, r *http.Request)
func (*MainResource) LoginAuthCallbackGithub ¶
func (mr *MainResource) LoginAuthCallbackGithub(w http.ResponseWriter, r *http.Request)
func (*MainResource) LoginDebug ¶
func (mr *MainResource) LoginDebug(w http.ResponseWriter, r *http.Request)
func (*MainResource) LoginPage ¶
func (mr *MainResource) LoginPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) LoginWithOAuth ¶
func (mr *MainResource) LoginWithOAuth(w http.ResponseWriter, r *http.Request)
func (*MainResource) Logout ¶
func (mr *MainResource) Logout(w http.ResponseWriter, r *http.Request)
func (*MainResource) MessageList ¶
func (mr *MainResource) MessageList(w http.ResponseWriter, r *http.Request)
func (*MainResource) Register ¶
func (mr *MainResource) Register(w http.ResponseWriter, r *http.Request)
func (*MainResource) RegisterPage ¶
func (mr *MainResource) RegisterPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) ResendVerifyEmail ¶
func (mr *MainResource) ResendVerifyEmail(w http.ResponseWriter, r *http.Request)
func (*MainResource) ResetPassword ¶
func (mr *MainResource) ResetPassword(w http.ResponseWriter, r *http.Request)
func (*MainResource) ResetPasswordPage ¶
func (mr *MainResource) ResetPasswordPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) RetrievePassword ¶
func (mr *MainResource) RetrievePassword(w http.ResponseWriter, r *http.Request)
func (*MainResource) RetrievePasswordPage ¶
func (mr *MainResource) RetrievePasswordPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) Routes ¶
func (mr *MainResource) Routes() http.Handler
func (*MainResource) SaveAccountSettings ¶
func (mr *MainResource) SaveAccountSettings(w http.ResponseWriter, r *http.Request)
func (*MainResource) SaveUISettings ¶
func (mr *MainResource) SaveUISettings(w http.ResponseWriter, r *http.Request)
func (*MainResource) SettingsAccountPage ¶
func (mr *MainResource) SettingsAccountPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) SettingsPage ¶
func (mr *MainResource) SettingsPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) SettingsUIPage ¶
func (mr *MainResource) SettingsUIPage(w http.ResponseWriter, r *http.Request)
func (*MainResource) VerifyRegister ¶
func (mr *MainResource) VerifyRegister(w http.ResponseWriter, r *http.Request)
func (*MainResource) VerifyRegisterPage ¶
func (mr *MainResource) VerifyRegisterPage(w http.ResponseWriter, r *http.Request)
type ManageResource ¶
type ManageResource struct { *Renderer // contains filtered or unexported fields }
func NewManageResource ¶
func NewManageResource(renderer *Renderer, ur *UserResource) *ManageResource
func (*ManageResource) ActivityList ¶
func (mr *ManageResource) ActivityList(w http.ResponseWriter, r *http.Request)
func (*ManageResource) PermissionCreatePage ¶
func (mr *ManageResource) PermissionCreatePage(w http.ResponseWriter, r *http.Request)
func (*ManageResource) PermissionListPage ¶
func (mr *ManageResource) PermissionListPage(w http.ResponseWriter, r *http.Request)
func (*ManageResource) PermissionSubmit ¶
func (mr *ManageResource) PermissionSubmit(w http.ResponseWriter, r *http.Request)
func (*ManageResource) RoleCreatePage ¶
func (mr *ManageResource) RoleCreatePage(w http.ResponseWriter, r *http.Request)
func (*ManageResource) RoleEditPage ¶
func (mr *ManageResource) RoleEditPage(w http.ResponseWriter, r *http.Request)
func (*ManageResource) RoleEditSubmit ¶
func (mr *ManageResource) RoleEditSubmit(w http.ResponseWriter, r *http.Request)
func (*ManageResource) RoleListPage ¶
func (mr *ManageResource) RoleListPage(w http.ResponseWriter, r *http.Request)
func (*ManageResource) RoleSubmit ¶
func (mr *ManageResource) RoleSubmit(w http.ResponseWriter, r *http.Request)
func (*ManageResource) Routes ¶
func (mr *ManageResource) Routes() http.Handler
func (*ManageResource) TrashPage ¶
func (mr *ManageResource) TrashPage(w http.ResponseWriter, r *http.Request)
type MessagePageData ¶
type MessagePageData struct { List []*model.Message Query *MessageQueryData }
type MessageQueryData ¶
type MessageQueryData struct { Tab string // contains filtered or unexported fields }
type MessageStatus ¶
type MessageStatus string
type PermissionPageType ¶
type PermissionPageType string
const ( PermissionPageList PermissionPageType = "list" PermissionPageCreate = "create" )
type RSSResource ¶
type RSSResource struct { *Renderer // contains filtered or unexported fields }
func NewRSSResource ¶
func NewRSSResource(renderer *Renderer, ar *ArticleResource) *RSSResource
func (*RSSResource) Atom ¶
func (rr *RSSResource) Atom(w http.ResponseWriter, r *http.Request)
func (*RSSResource) Routes ¶
func (rr *RSSResource) Routes() http.Handler
type Region ¶
{{- $regions := list "mainland_china" "us" "in" -}} {{- $regionsMap := dict "mainland_china" (local "MainlandChina") "us" (local "UnitedStates") "in" (local "India") -}}
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer( tmpl *template.Template, sessStore *sessions.CookieStore, router *chi.Mux, store *store.Store, sp *bluemonday.Policy, ic *i18nc.I18nCustom, srv *service.Service, rdb *redis.Client, dmp *diffmatchpatch.DiffMatchPatch, ) *Renderer
func (*Renderer) CheckPermit ¶
func (*Renderer) GetLoginedUserData ¶
func (*Renderer) GetLoginedUserId ¶
func (*Renderer) GetPaginationData ¶
func (*Renderer) SavePrevPage ¶
func (rd *Renderer) SavePrevPage(w http.ResponseWriter, r *http.Request)
func (*Renderer) ServerError ¶
func (rd *Renderer) ServerError(w http.ResponseWriter, r *http.Request)
func (*Renderer) ServerErrorp ¶
func (*Renderer) ToPrevPage ¶
func (rd *Renderer) ToPrevPage(w http.ResponseWriter, r *http.Request)
func (*Renderer) ToRefererUrl ¶
func (rd *Renderer) ToRefererUrl(w http.ResponseWriter, r *http.Request)
func (*Renderer) ToTargetUrl ¶
func (rd *Renderer) ToTargetUrl(w http.ResponseWriter, r *http.Request)
type RoleFormPageData ¶
type RoleFormPageData struct { Role *model.Role RolePermissionIdList []int PermissionList []*model.PermissionListItem PageType RoleFormPageType }
type RoleFormPageType ¶
type RoleFormPageType string
const ( RoleFormPageAdd RoleFormPageType = "add" RoleFormPageEdit = "edit" )
type Session ¶
func (*Session) GetStringValue ¶
type SettingsPageData ¶
type SettingsPageData struct { PageKey SettingsPageKey AccountData *model.User LanguageOptions []*model.OptionItem ArticleSortTabList []model.ArticleSortType ReplySortTabList []model.ArticleSortType SortTabNames map[model.ArticleSortType]string }
type SettingsPageKey ¶
type SettingsPageKey string
const ( SettingsPageKeyUI SettingsPageKey = "ui" SettingsPageKeyAccount = "account" )
type TurnstileVerifyResult ¶
type TurnstileVerifyResult struct {
Success bool `json:"success"`
}
type UserResource ¶
type UserResource struct { *Renderer // contains filtered or unexported fields }
func NewUserResource ¶
func NewUserResource(renderer *Renderer) *UserResource
func (*UserResource) Ban ¶
func (ur *UserResource) Ban(w http.ResponseWriter, r *http.Request)
func (*UserResource) BanPage ¶
func (ur *UserResource) BanPage(w http.ResponseWriter, r *http.Request)
func (*UserResource) EditUserProfilePage ¶
func (ur *UserResource) EditUserProfilePage(w http.ResponseWriter, r *http.Request)
func (*UserResource) ItemPage ¶
func (ur *UserResource) ItemPage(w http.ResponseWriter, r *http.Request)
func (*UserResource) List ¶
func (ur *UserResource) List(w http.ResponseWriter, r *http.Request)
func (*UserResource) Routes ¶
func (ur *UserResource) Routes() http.Handler
func (*UserResource) SetRole ¶
func (ur *UserResource) SetRole(w http.ResponseWriter, r *http.Request)
func (*UserResource) SetRolePage ¶
func (ur *UserResource) SetRolePage(w http.ResponseWriter, r *http.Request)
func (*UserResource) Unban ¶
func (ur *UserResource) Unban(w http.ResponseWriter, r *http.Request)
func (*UserResource) UnbanPage ¶
func (ur *UserResource) UnbanPage(w http.ResponseWriter, r *http.Request)
func (*UserResource) UpdateUserProfile ¶
func (ur *UserResource) UpdateUserProfile(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.