Documentation ¶
Index ¶
- Constants
- Variables
- func AbsolutePath(p string) (string, error)
- func AddMember(account, password string) error
- func Asset(p string, cdn string) string
- func CopyFile(dstName, srcName string) (written int64, err error)
- func CrawlByChrome(urlstr string) (b []byte, err error)
- func CrawlHtml2Markdown(urlstr string, contType int, force bool, intelligence int, diySelector string, ...) (cont string, err error)
- func DealUri(po *PageOptions, requestURI string)
- func Decode(value string, r interface{}) error
- func Encode(value interface{}) (string, error)
- func ExecuteViewPathTemplate(tplName string, data interface{}) (string, error)
- func FileExists(name string) bool
- func FormatBytes(size int64) string
- func GetPagerHtml(requestURI string, pageIndex, pageSize, totalCount int) html.HTML
- func GetPagerLinks(po *PageOptions, requestURI string) (int, int, orm.RawSeter, html.HTML)
- func GetPagesInfo(tableName string, currentpage int, pagesize int, conditions string) (int, int, orm.RawSeter)
- func GetTextFromHtml(htmlStr string) (txt string)
- func GitClone(url, folder string) error
- func InMap(maps map[int]bool, key int) (ret bool)
- func JoinURI(elem ...string) string
- func Krand(size int, kind int) []byte
- func ModifyPassword(account, oldPassword, newPassword string) error
- func NewPaginations(rollPage, totalRows, listRows, currentPage int, urlPrefix string, ...) html1.HTML
- func ParseTitleFromMdHtml(html string) (title string)
- func PasswordHash(pass string) (string, error)
- func PasswordVerify(hashing string, pass string) (bool, error)
- func RenderDocumentById(id int)
- func Round(val float64, places int) float64
- func ScoreFloat(score int) string
- func SegWord(str interface{}) (wds string)
- func SendMail(conf *conf.SmtpConf, subject, email string, body string) error
- func ShowImg(img string, style ...string) (url string)
- func ValidLDAPLogin(password string) (result bool, err error)
- type BooksLock
- type PageOptions
Constants ¶
View Source
const ( KC_RAND_KIND_NUM = 0 // 纯数字 KC_RAND_KIND_LOWER = 1 // 小写字母 KC_RAND_KIND_UPPER = 2 // 大写字母 KC_RAND_KIND_ALL = 3 // 数字、大小写字母 )
View Source
const ( StoreLocal string = "local" StoreOss string = "oss" )
更多存储类型有待扩展
Variables ¶
View Source
var ( BooksRelease = BooksLock{Books: make(map[int]bool)} BooksGenerate = BooksLock{Books: make(map[int]bool)} )
View Source
var ( Segmenter sego.Segmenter //BasePath, _ = filepath.Abs(filepath.Dir(os.Args[0])) BasePath, _ = os.Getwd() StoreType string = beego.AppConfig.String("store_type") //存储类型 )
分词器
Functions ¶
func AbsolutePath ¶
func CrawlHtml2Markdown ¶
func CrawlHtml2Markdown(urlstr string, contType int, force bool, intelligence int, diySelector string, headers ...map[string]string) (cont string, err error)
采集HTML并把相对链接和相对图片 内容类型,contType:0表示markdown,1表示html,2表示文本 force:是否是强力采集 intelligence:是否是智能提取,智能提取,使用html2article,否则提取body diySelecter:自定义选择器 注意:由于参数问题,采集并下载图片的话,在headers中加上key为"project"的字段,值为文档项目的标识
func ExecuteViewPathTemplate ¶
ExecuteViewPathTemplate 执行指定的模板并返回执行结果. @param tplName 模板文件路径
func FileExists ¶
FileExists reports whether the named file or directory exists.
func FormatBytes ¶
func GetPagerHtml ¶
func GetPagerLinks ¶
*
- 返回总记录条数,总页数,当前页面数据,分页html
- 根据分页选项,生成分页连接 下面是一个实例: func (this *MainController) Test() { var po util.PageOptions po.EnablePreNexLink = true po.EnableFirstLastLink = true po.LinkItemCount = 7 po.TableName = "help_topic" cp, _ := this.GetInt("pno") po.CurrentPage = int(cp) _,_,_ pager := util.GetPagerLinks(&po, this.Ctx) this.Data["Email"] = html.HTML(pager) this.TplName = "test.html" }
func GetPagesInfo ¶
func GetPagesInfo(tableName string, currentpage int, pagesize int, conditions string) (int, int, orm.RawSeter)
*
- 分页函数,适用任何表
- 返回 总记录条数,总页数,以及当前请求的数据RawSeter,调用中需要"rs.QueryRows(&tblog)"就行了 --tblog是一个Tb_log对象
- 参数:表名,当前页数,页面大小,条件(查询条件,格式为 " and name='zhifeiya' and age=12 ")
func NewPaginations ¶
func NewPaginations(rollPage, totalRows, listRows, currentPage int, urlPrefix string, urlSuffix string, urlParams ...interface{}) html1.HTML
分页函数(这个分页函数不具有通用性) rollPage:展示分页的个数 totalRows:总记录 currentPage:每页显示记录数 urlPrefix:url链接前缀 urlParams:url键值对参数
func ParseTitleFromMdHtml ¶
从md的html文件中提取文章标题(从h1-h6)
func ValidLDAPLogin ¶
Types ¶
type PageOptions ¶
type PageOptions struct { TableName string //表名 -----------------[必填] Conditions string //条件 CurrentPage int //当前页 ,默认1 每次分页,必须在前台设置新的页数,不设置始终默认1.在控制器中使用方式:cp, _ := this.GetInt("pno") po.CurrentPage = int(cp) PageSize int //页面大小,默认20 LinkItemCount int //生成A标签的个数 默认10个 Href string //A标签的链接地址 ---------[不需要设置] ParamName string //参数名称 默认是pno FirstPageText string //首页文字 默认"首页" LastPageText string //尾页文字 默认"尾页" PrePageText string //上一页文字 默认"上一页" NextPageText string //下一页文字 默认"下一页" EnableFirstLastLink bool //是否启用首尾连接 默认false 建议开启 EnablePreNexLink bool //是否启用上一页,下一页连接 默认false 建议开启 TotalPages int }
Click to show internal directories.
Click to hide internal directories.