Documentation ¶
Index ¶
- Constants
- func CurrentMillisecond() uint64
- func GetPage(c *gin.Context) int
- func GetRemoteAddr(c *gin.Context) string
- func GitHubUserInfo(accessToken string) (ret map[string]interface{})
- func HacPaiAPI() gin.HandlerFunc
- func ImageSize(imageURL string, width, height int) string
- func IsBot(uaStr string) bool
- func IsDomain(s string) bool
- func IsIP(s string) bool
- func IsReservedPath(path string) bool
- func RandAvatarData() (ret []byte)
- func RandImage() string
- func RandImages(n int) []string
- type MarkdownResult
- type Pagination
- type SessionData
Constants ¶
const ( PathRoot = "/" PathInit = "/start" PathSearch = "/search" PathOpensearch = "/opensearch.xml" PathBlogs = "/blogs" PathConsoleDist = "/console/dist" PathAdmin = "/admin" PathAPI = "/api" PathFavicon = "/favicon.ico" PathTheme = "/theme" PathActivities = "/activities" PathArchives = "/archives" PathArticles = "/articles" PathAuthors = "/authors" PathCategories = "/categories" PathTags = "/tags" PathComments = "/comments" PathAtom = "/atom" PathRSS = "/rss" PathSitemap = "/sitemap.xml" PathChangelogs = "/changelogs" PathRobots = "/robots.txt" PathAPIsSymArticle = "/apis/symphony/article" PathAPIsSymComment = "/apis/symphony/comment" PathPlatInfo = "/plat/info" PathManifest = "/manifest.json" )
Path prefixes.
const ( CodeOk = 0 // OK CodeErr = -1 // general error CodeAuthErr = 2 // unauthenticated request )
Result codes.
const HacPaiURL = "https://hacpai.com"
HacPaiURL is the URL of HacPai community.
Variables ¶
This section is empty.
Functions ¶
func CurrentMillisecond ¶
func CurrentMillisecond() uint64
CurrentMillisecond returns the current time in millisecond.
func GetRemoteAddr ¶ added in v1.1.0
GetRemoteAddr returns remote address of the context.
func GitHubUserInfo ¶ added in v1.8.2
GitHubUserInfo returns GitHub user info specified by the given access token.
func HacPaiAPI ¶
func HacPaiAPI() gin.HandlerFunc
HacPaiAPI is a reverse proxy for https://hacpai.com.
func ImageSize ¶
ImageSize returns image URL of Qiniu image processing style with the specified width and height.
func IsReservedPath ¶
IsReservedPath checks the specified path is a reserved path or not.
func RandAvatarData ¶ added in v1.8.0
func RandAvatarData() (ret []byte)
RandAvatarData returns random avatar image byte array data from Gravatar (http://www.gravatar.com). Sees https://github.com/b3log/pipe/issues/131 for more details.
func RandImage ¶
func RandImage() string
RandImage returns an image URL randomly for article thumbnail. https://github.com/b3log/bing
Types ¶
type MarkdownResult ¶
MarkdownResult represents markdown result.
func Markdown ¶
func Markdown(mdText string) *MarkdownResult
Markdown process the specified markdown text to HTML.
type Pagination ¶
type Pagination struct { CurrentPageNum int `json:"currentPageNum"` PageSize int `json:"pageSize"` PageCount int `json:"pageCount"` WindowSize int `json:"windowSize"` RecordCount int `json:"recordCount"` PageNums []int `json:"pageNums"` NextPageNum int `json:"nextPageNum"` PreviousPageNum int `json:"previousPageNum"` FirstPageNum int `json:"firstPageNum"` LastPageNum int `json:"lastPageNum"` PageURL string `json:"pageURL"` }
Pagination represents pagination info.
func NewPagination ¶
func NewPagination(currentPageNum, pageSize, windowSize, recordCount int) *Pagination
NewPagination creates a new pagination with the specified current page num, page size, window size and record count.
type SessionData ¶
type SessionData struct { UID uint64 // user ID UName string // username UB3Key string // user B3 key URole int // user role UAvatar string // user avatar URL BID uint64 // blog ID BURL string // blog url }
SessionData represents the session.
func GetSession ¶
func GetSession(c *gin.Context) *SessionData
GetSession returns session of the specified context.
func (*SessionData) AvatarURLWithSize ¶
func (sd *SessionData) AvatarURLWithSize(size int) string
AvatarURLWithSize returns avatar URL with the specified size.