(c *Collection, isOwner, postPage bool, cfg *config.Config)
| 44 | ) |
| 45 | |
| 46 | func (p *Post) handlePremiumContent(c *Collection, isOwner, postPage bool, cfg *config.Config) { |
| 47 | if c.Monetization != "" { |
| 48 | // User has Web Monetization enabled, so split content if it exists |
| 49 | spl := strings.Index(p.Content, shortCodePaid) |
| 50 | p.IsPaid = spl > -1 |
| 51 | if postPage { |
| 52 | // We're viewing the individual post |
| 53 | if isOwner { |
| 54 | p.Content = strings.Replace(p.Content, shortCodePaid, "\n\n"+`<p class="split">Your subscriber content begins here.</p>`+"\n\n", 1) |
| 55 | } else { |
| 56 | if spl > -1 { |
| 57 | p.Content = p.Content[:spl+len(shortCodePaid)] |
| 58 | p.Content = strings.Replace(p.Content, shortCodePaid, "\n\n"+`<p class="split">Continue reading with a <strong>Coil</strong> membership.</p>`+"\n\n", 1) |
| 59 | } |
| 60 | } |
| 61 | } else { |
| 62 | // We've viewing the post on the collection landing |
| 63 | if spl > -1 { |
| 64 | baseURL := c.CanonicalURL() |
| 65 | if isOwner { |
| 66 | baseURL = "/" + c.Alias + "/" |
| 67 | } |
| 68 | |
| 69 | p.Content = p.Content[:spl+len(shortCodePaid)] |
| 70 | p.HTMLExcerpt = template.HTML(applyMarkdown([]byte(p.Content[:spl]), baseURL, cfg)) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func (p *Post) formatContent(cfg *config.Config, c *Collection, isOwner bool, isPostPage bool) { |
| 77 | baseURL := c.CanonicalURL() |
no test coverage detected