MCPcopy Index your code
hub / github.com/TruthHun/BookStack / AutoTitle

Method AutoTitle

models/document.go:702–716  ·  view source on GitHub ↗
(identify interface{}, defaultTitle ...string)

Source from the content-addressed store, hash-verified

700}
701
702func (m *Document) AutoTitle(identify interface{}, defaultTitle ...string) (title string) {
703 if len(defaultTitle) > 0 {
704 title = defaultTitle[0]
705 }
706 d := NewDocument()
707 sqlQuery := "select document_id from md_documents where identify = ? or document_id = ? limit 1"
708 orm.NewOrm().Raw(sqlQuery, identify, identify).QueryRow(&d)
709 if d.DocumentId > 0 {
710 tmpTitle := strings.TrimSpace(utils.ParseTitleFromMdHtml(mdtil.Md2html(NewDocumentStore().GetFiledById(d.DocumentId, "markdown"))))
711 if tmpTitle != "" {
712 title = tmpTitle
713 }
714 }
715 return
716}
717
718// markdown 文档拆分
719func (m *Document) SplitMarkdownAndStore(seg string, markdown string, docId int) (err error) {

Callers 1

sortBySummaryMethod · 0.80

Calls 4

ParseTitleFromMdHtmlFunction · 0.92
NewDocumentFunction · 0.85
NewDocumentStoreFunction · 0.85
GetFiledByIdMethod · 0.80

Tested by

no test coverage detected