MCPcopy Index your code
hub / github.com/writefreely/writefreely / Summary

Method Summary

posts.go:244–265  ·  view source on GitHub ↗

Summary gives a shortened summary of the post based on the post's title, especially for display in a longer list of posts. It extracts a summary for posts in the Title\n\nBody format, returning nothing if the entire was short enough that the extracted title == extracted summary.

()

Source from the content-addressed store, hash-verified

242// posts in the Title\n\nBody format, returning nothing if the entire was short
243// enough that the extracted title == extracted summary.
244func (p Post) Summary() string {
245 if p.Content == "" {
246 return ""
247 }
248 p.Content = stripHTMLWithoutEscaping(p.Content)
249 // and Markdown
250 p.Content = stripmd.StripOptions(p.Content, stripmd.Options{SkipImages: true})
251
252 title := p.Title.String
253 var desc string
254 if title == "" {
255 // No title, so generate one
256 title = friendlyPostTitle(p.Content, p.ID)
257 desc = postDescription(p.Content, title, p.ID)
258 if desc == title {
259 return ""
260 }
261 return desc
262 }
263
264 return shortPostDescription(p.Content)
265}
266
267func (p Post) SummaryHTML() template.HTML {
268 return template.HTML(p.Summary())

Callers 2

SummaryHTMLMethod · 0.95
TestPostSummaryFunction · 0.80

Calls 4

stripHTMLWithoutEscapingFunction · 0.85
friendlyPostTitleFunction · 0.85
postDescriptionFunction · 0.85
shortPostDescriptionFunction · 0.85

Tested by 1

TestPostSummaryFunction · 0.64