Compare commits
42 commits
dependabot
...
develop
Author | SHA1 | Date | |
---|---|---|---|
|
72fa575fee | ||
|
01e239e657 | ||
|
79ab0a3786 | ||
|
188b41ef53 | ||
|
c249abdb10 | ||
|
2b79ab0313 | ||
|
db66a885fb | ||
|
79a66ff140 | ||
|
4601951bbf | ||
|
e1db89311d | ||
|
f7966996d7 | ||
|
a7fa19f2e4 | ||
|
7b5d583b76 | ||
|
b765c02166 | ||
|
0f9c32161c | ||
|
63963b6b19 | ||
|
d9deb29730 | ||
|
e65b73dc73 | ||
|
0be229cdaa | ||
|
4504617c1a | ||
|
17039e620e | ||
|
fbf505cff0 | ||
|
3966f9fa40 | ||
|
387ddac892 | ||
|
e3b94d7fb5 | ||
|
121a21d900 | ||
|
eab66ee5fc | ||
|
83e0a57338 | ||
|
b643e0520f | ||
|
b7de165b76 | ||
|
f49c0b1c4c | ||
|
2fcd45819f | ||
|
d06077c432 | ||
|
5b6d17c9b9 | ||
|
c046dd04e7 | ||
|
6d57d9d6a1 | ||
|
7fbf49a0f0 | ||
|
76818287d6 | ||
|
5198add7aa | ||
|
d159e0a1ca | ||
|
b0b06ec945 | ||
|
1d89dea72e |
25 changed files with 525 additions and 84 deletions
18
Makefile
18
Makefile
|
@ -41,6 +41,12 @@ build-darwin: deps
|
||||||
fi
|
fi
|
||||||
xgo --targets=darwin/amd64, -dest build/ $(LDFLAGS) -tags='netgo sqlite' -go go-1.21.x -out writefreely -pkg ./cmd/writefreely .
|
xgo --targets=darwin/amd64, -dest build/ $(LDFLAGS) -tags='netgo sqlite' -go go-1.21.x -out writefreely -pkg ./cmd/writefreely .
|
||||||
|
|
||||||
|
build-darwin-arm64: deps
|
||||||
|
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GOCMD) install src.techknowlogick.com/xgo@latest; \
|
||||||
|
fi
|
||||||
|
xgo --targets=darwin/arm64, -dest build/ $(LDFLAGS) -tags='netgo sqlite' -go go-1.21.x -out writefreely -pkg ./cmd/writefreely .
|
||||||
|
|
||||||
build-arm6: deps
|
build-arm6: deps
|
||||||
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
$(GOCMD) install src.techknowlogick.com/xgo@latest; \
|
$(GOCMD) install src.techknowlogick.com/xgo@latest; \
|
||||||
|
@ -83,9 +89,9 @@ install : build
|
||||||
|
|
||||||
release : clean ui
|
release : clean ui
|
||||||
mkdir -p $(BUILDPATH)
|
mkdir -p $(BUILDPATH)
|
||||||
cp -r templates $(BUILDPATH)
|
rsync -av --exclude=".*" templates $(BUILDPATH)
|
||||||
cp -r pages $(BUILDPATH)
|
rsync -av --exclude=".*" pages $(BUILDPATH)
|
||||||
cp -r static $(BUILDPATH)
|
rsync -av --exclude=".*" static $(BUILDPATH)
|
||||||
rm -r $(BUILDPATH)/static/local
|
rm -r $(BUILDPATH)/static/local
|
||||||
scripts/invalidate-css.sh $(BUILDPATH)
|
scripts/invalidate-css.sh $(BUILDPATH)
|
||||||
mkdir $(BUILDPATH)/keys
|
mkdir $(BUILDPATH)/keys
|
||||||
|
@ -109,6 +115,10 @@ release : clean ui
|
||||||
mv build/$(BINARY_NAME)-darwin-10.12-amd64 $(BUILDPATH)/$(BINARY_NAME)
|
mv build/$(BINARY_NAME)-darwin-10.12-amd64 $(BUILDPATH)/$(BINARY_NAME)
|
||||||
tar -cvzf $(BINARY_NAME)_$(GITREV)_macos_amd64.tar.gz -C build $(BINARY_NAME)
|
tar -cvzf $(BINARY_NAME)_$(GITREV)_macos_amd64.tar.gz -C build $(BINARY_NAME)
|
||||||
rm $(BUILDPATH)/$(BINARY_NAME)
|
rm $(BUILDPATH)/$(BINARY_NAME)
|
||||||
|
$(MAKE) build-darwin-arm64
|
||||||
|
mv build/$(BINARY_NAME)-darwin-arm64 $(BUILDPATH)/$(BINARY_NAME)
|
||||||
|
tar -cvzf $(BINARY_NAME)_$(GITREV)_macos_arm64.tar.gz -C build $(BINARY_NAME)
|
||||||
|
rm $(BUILDPATH)/$(BINARY_NAME)
|
||||||
$(MAKE) build-windows
|
$(MAKE) build-windows
|
||||||
mv build/$(BINARY_NAME)-windows-4.0-amd64.exe $(BUILDPATH)/$(BINARY_NAME).exe
|
mv build/$(BINARY_NAME)-windows-4.0-amd64.exe $(BUILDPATH)/$(BINARY_NAME).exe
|
||||||
cd build; zip -r ../$(BINARY_NAME)_$(GITREV)_windows_amd64.zip ./$(BINARY_NAME)
|
cd build; zip -r ../$(BINARY_NAME)_$(GITREV)_windows_amd64.zip ./$(BINARY_NAME)
|
||||||
|
@ -145,5 +155,5 @@ clean :
|
||||||
-rm -rf tmp
|
-rm -rf tmp
|
||||||
cd less/; $(MAKE) clean $(MFLAGS)
|
cd less/; $(MAKE) clean $(MFLAGS)
|
||||||
|
|
||||||
force_look :
|
force_look :
|
||||||
true
|
true
|
||||||
|
|
|
@ -69,6 +69,7 @@ For common platforms, start with our [pre-built binaries](https://github.com/wri
|
||||||
You can also find WriteFreely in these package repositories, thanks to our wonderful community!
|
You can also find WriteFreely in these package repositories, thanks to our wonderful community!
|
||||||
|
|
||||||
* [Arch User Repository](https://aur.archlinux.org/packages/writefreely/)
|
* [Arch User Repository](https://aur.archlinux.org/packages/writefreely/)
|
||||||
|
* [Nanos Repository](https://repo.ops.city/v2/packages/eyberg/writefreely/show)
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
@ -86,4 +87,4 @@ Before contributing anything, please read our [Contributing Guide](https://githu
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright © 2018-2022 [Musing Studio LLC](https://musing.studio) and contributing authors. Licensed under the [AGPL](https://github.com/writefreely/writefreely/blob/develop/LICENSE).
|
Copyright © 2018-2025 [Musing Studio LLC](https://musing.studio) and contributing authors. Licensed under the [AGPL](https://github.com/writefreely/writefreely/blob/develop/LICENSE).
|
||||||
|
|
33
account.go
33
account.go
|
@ -13,7 +13,7 @@ package writefreely
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mailgun/mailgun-go"
|
"github.com/writefreely/writefreely/mailer"
|
||||||
"github.com/writefreely/writefreely/spam"
|
"github.com/writefreely/writefreely/spam"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1378,13 +1378,19 @@ func handleResetPasswordInit(app *App, w http.ResponseWriter, r *http.Request) e
|
||||||
|
|
||||||
func emailPasswordReset(app *App, toEmail, token string) error {
|
func emailPasswordReset(app *App, toEmail, token string) error {
|
||||||
// Send email
|
// Send email
|
||||||
gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate)
|
mlr, err := mailer.New(app.cfg.Email)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
footerPara := "Didn't request this password reset? Your account is still safe, and you can safely ignore this email."
|
footerPara := "Didn't request this password reset? Your account is still safe, and you can safely ignore this email."
|
||||||
|
|
||||||
plainMsg := fmt.Sprintf("We received a request to reset your password on %s. Please click the following link to continue (or copy and paste it into your browser): %s/reset?t=%s\n\n%s", app.cfg.App.SiteName, app.cfg.App.Host, token, footerPara)
|
plainMsg := fmt.Sprintf("We received a request to reset your password on %s. Please click the following link to continue (or copy and paste it into your browser): %s/reset?t=%s\n\n%s", app.cfg.App.SiteName, app.cfg.App.Host, token, footerPara)
|
||||||
m := mailgun.NewMessage(app.cfg.App.SiteName+" <noreply-password@"+app.cfg.Email.Domain+">", "Reset Your "+app.cfg.App.SiteName+" Password", plainMsg, fmt.Sprintf("<%s>", toEmail))
|
m, err := mlr.NewMessage(app.cfg.App.SiteName+" <noreply-password@"+app.cfg.Email.Domain+">", "Reset Your "+app.cfg.App.SiteName+" Password", plainMsg, fmt.Sprintf("<%s>", toEmail))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
m.AddTag("Password Reset")
|
m.AddTag("Password Reset")
|
||||||
m.SetHtml(fmt.Sprintf(`<html>
|
m.SetHTML(fmt.Sprintf(`<html>
|
||||||
<body style="font-family:Lora, 'Palatino Linotype', Palatino, Baskerville, 'Book Antiqua', 'New York', 'DejaVu serif', serif; font-size: 100%%; margin:1em 2em;">
|
<body style="font-family:Lora, 'Palatino Linotype', Palatino, Baskerville, 'Book Antiqua', 'New York', 'DejaVu serif', serif; font-size: 100%%; margin:1em 2em;">
|
||||||
<div style="margin:0 auto; max-width: 40em; font-size: 1.2em;">
|
<div style="margin:0 auto; max-width: 40em; font-size: 1.2em;">
|
||||||
<h1 style="font-size:1.75em"><a style="text-decoration:none;color:#000;" href="%s">%s</a></h1>
|
<h1 style="font-size:1.75em"><a style="text-decoration:none;color:#000;" href="%s">%s</a></h1>
|
||||||
|
@ -1394,8 +1400,7 @@ func emailPasswordReset(app *App, toEmail, token string) error {
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`, app.cfg.App.Host, app.cfg.App.SiteName, app.cfg.App.SiteName, app.cfg.App.Host, token, footerPara))
|
</html>`, app.cfg.App.Host, app.cfg.App.SiteName, app.cfg.App.SiteName, app.cfg.App.Host, token, footerPara))
|
||||||
_, _, err := gun.Send(m)
|
return mlr.Send(m)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loginViaEmail(app *App, alias, redirectTo string) error {
|
func loginViaEmail(app *App, alias, redirectTo string) error {
|
||||||
|
@ -1424,15 +1429,21 @@ func loginViaEmail(app *App, alias, redirectTo string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate)
|
mlr, err := mailer.New(app.cfg.Email)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
toEmail := u.EmailClear(app.keys)
|
toEmail := u.EmailClear(app.keys)
|
||||||
footerPara := "This link will only work once and expires in 15 minutes. Didn't ask us to log in? You can safely ignore this email."
|
footerPara := "This link will only work once and expires in 15 minutes. Didn't ask us to log in? You can safely ignore this email."
|
||||||
|
|
||||||
plainMsg := fmt.Sprintf("Log in to %s here: %s/login?to=%s&with=%s\n\n%s", app.cfg.App.SiteName, app.cfg.App.Host, redirectTo, t, footerPara)
|
plainMsg := fmt.Sprintf("Log in to %s here: %s/login?to=%s&with=%s\n\n%s", app.cfg.App.SiteName, app.cfg.App.Host, redirectTo, t, footerPara)
|
||||||
m := mailgun.NewMessage(app.cfg.App.SiteName+" <noreply-login@"+app.cfg.Email.Domain+">", "Log in to "+app.cfg.App.SiteName, plainMsg, fmt.Sprintf("<%s>", toEmail))
|
m, err := mlr.NewMessage(app.cfg.App.SiteName+" <noreply-login@"+app.cfg.Email.Domain+">", "Log in to "+app.cfg.App.SiteName, plainMsg, fmt.Sprintf("<%s>", toEmail))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
m.AddTag("Email Login")
|
m.AddTag("Email Login")
|
||||||
|
|
||||||
m.SetHtml(fmt.Sprintf(`<html>
|
m.SetHTML(fmt.Sprintf(`<html>
|
||||||
<body style="font-family:Lora, 'Palatino Linotype', Palatino, Baskerville, 'Book Antiqua', 'New York', 'DejaVu serif', serif; font-size: 100%%; margin:1em 2em;">
|
<body style="font-family:Lora, 'Palatino Linotype', Palatino, Baskerville, 'Book Antiqua', 'New York', 'DejaVu serif', serif; font-size: 100%%; margin:1em 2em;">
|
||||||
<div style="margin:0 auto; max-width: 40em; font-size: 1.2em;">
|
<div style="margin:0 auto; max-width: 40em; font-size: 1.2em;">
|
||||||
<h1 style="font-size:1.75em"><a style="text-decoration:none;color:#000;" href="%s">%s</a></h1>
|
<h1 style="font-size:1.75em"><a style="text-decoration:none;color:#000;" href="%s">%s</a></h1>
|
||||||
|
@ -1441,9 +1452,7 @@ func loginViaEmail(app *App, alias, redirectTo string) error {
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`, app.cfg.App.Host, app.cfg.App.SiteName, app.cfg.App.Host, redirectTo, t, app.cfg.App.SiteName, footerPara))
|
</html>`, app.cfg.App.Host, app.cfg.App.SiteName, app.cfg.App.Host, redirectTo, t, app.cfg.App.SiteName, footerPara))
|
||||||
_, _, err = gun.Send(m)
|
return mlr.Send(m)
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveTempInfo(app *App, key, val string, r *http.Request, w http.ResponseWriter) error {
|
func saveTempInfo(app *App, key, val string, r *http.Request, w http.ResponseWriter) error {
|
||||||
|
|
|
@ -201,7 +201,7 @@ func handleFetchCollectionOutbox(app *App, w http.ResponseWriter, r *http.Reques
|
||||||
ocp := activitystreams.NewOrderedCollectionPage(accountRoot, "outbox", res.TotalPosts, p)
|
ocp := activitystreams.NewOrderedCollectionPage(accountRoot, "outbox", res.TotalPosts, p)
|
||||||
ocp.OrderedItems = []interface{}{}
|
ocp.OrderedItems = []interface{}{}
|
||||||
|
|
||||||
posts, err := app.db.GetPosts(app.cfg, c, p, false, true, false)
|
posts, err := app.db.GetPosts(app.cfg, c, p, false, true, false, "")
|
||||||
for _, pp := range *posts {
|
for _, pp := range *posts {
|
||||||
pp.Collection = res
|
pp.Collection = res
|
||||||
o := pp.ActivityObject(app)
|
o := pp.ActivityObject(app)
|
||||||
|
@ -436,6 +436,17 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request
|
||||||
a.AppendObject(f.Raw())
|
a.AppendObject(f.Raw())
|
||||||
_, to = f.GetActor(0)
|
_, to = f.GetActor(0)
|
||||||
obj := f.Raw().GetObjectIRI(0)
|
obj := f.Raw().GetObjectIRI(0)
|
||||||
|
if obj == nil {
|
||||||
|
if debugging {
|
||||||
|
log.Error("GetObjectIRI on Follow for actor is empty; trying object")
|
||||||
|
}
|
||||||
|
ao := f.Raw().GetObject(0)
|
||||||
|
if ao == nil {
|
||||||
|
log.Error("Fell back to GetObject and none parsed, so no actor ID! Follow request probably FAILED!")
|
||||||
|
} else {
|
||||||
|
obj = ao.GetId()
|
||||||
|
}
|
||||||
|
}
|
||||||
a.AppendActor(obj)
|
a.AppendActor(obj)
|
||||||
|
|
||||||
// First get actor information
|
// First get actor information
|
||||||
|
|
2
admin.go
2
admin.go
|
@ -208,7 +208,7 @@ func handleViewAdminUsers(app *App, u *User, w http.ResponseWriter, r *http.Requ
|
||||||
|
|
||||||
p.Flashes, _ = getSessionFlashes(app, w, r, nil)
|
p.Flashes, _ = getSessionFlashes(app, w, r, nil)
|
||||||
p.TotalUsers = app.db.GetAllUsersCount()
|
p.TotalUsers = app.db.GetAllUsersCount()
|
||||||
ttlPages := p.TotalUsers / adminUsersPerPage
|
ttlPages := (p.TotalUsers - 1) / adminUsersPerPage + 1
|
||||||
p.TotalPages = []int{}
|
p.TotalPages = []int{}
|
||||||
for i := 1; i <= int(ttlPages); i++ {
|
for i := 1; i <= int(ttlPages); i++ {
|
||||||
p.TotalPages = append(p.TotalPages, i)
|
p.TotalPages = append(p.TotalPages, i)
|
||||||
|
|
21
app.go
21
app.go
|
@ -46,9 +46,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
staticDir = "static"
|
staticDir = "static"
|
||||||
assumedTitleLen = 80
|
assumedTitleLen = 80
|
||||||
postsPerPage = 10
|
postsPerPage = 10
|
||||||
|
postsPerArchPage = 40
|
||||||
|
|
||||||
serverSoftware = "WriteFreely"
|
serverSoftware = "WriteFreely"
|
||||||
softwareURL = "https://writefreely.org"
|
softwareURL = "https://writefreely.org"
|
||||||
|
@ -428,15 +429,11 @@ func Initialize(apper Apper, debug bool) (*App, error) {
|
||||||
|
|
||||||
initActivityPub(apper.App())
|
initActivityPub(apper.App())
|
||||||
|
|
||||||
if apper.App().cfg.Email.Domain != "" || apper.App().cfg.Email.MailgunPrivate != "" {
|
if apper.App().cfg.Email.Enabled() {
|
||||||
if apper.App().cfg.Email.Domain == "" {
|
log.Info("Starting publish jobs queue...")
|
||||||
log.Error("[FAILED] Starting publish jobs queue: no [letters]domain config value set.")
|
go startPublishJobsQueue(apper.App())
|
||||||
} else if apper.App().cfg.Email.MailgunPrivate == "" {
|
} else {
|
||||||
log.Error("[FAILED] Starting publish jobs queue: no [letters]mailgun_private config value set.")
|
log.Error("[FAILED] Starting publish jobs queue: no email provider is configured.")
|
||||||
} else {
|
|
||||||
log.Info("Starting publish jobs queue...")
|
|
||||||
go startPublishJobsQueue(apper.App())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle local timeline, if enabled
|
// Handle local timeline, if enabled
|
||||||
|
|
|
@ -608,7 +608,7 @@ func fetchCollectionPosts(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ps, err := app.db.GetPosts(app.cfg, c, page, isCollOwner, false, false)
|
ps, err := app.db.GetPosts(app.cfg, c, page, isCollOwner, false, false, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -828,15 +828,18 @@ func checkUserForCollection(app *App, cr *collectionReq, r *http.Request, isPost
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDisplayCollection(c *Collection, cr *collectionReq, page int) *DisplayCollection {
|
func newDisplayCollection(c *Collection, cr *collectionReq, page int) (*DisplayCollection, error) {
|
||||||
coll := &DisplayCollection{
|
coll := &DisplayCollection{
|
||||||
CollectionObj: NewCollectionObj(c),
|
CollectionObj: NewCollectionObj(c),
|
||||||
CurrentPage: page,
|
CurrentPage: page,
|
||||||
Prefix: cr.prefix,
|
Prefix: cr.prefix,
|
||||||
IsTopLevel: isSingleUser,
|
IsTopLevel: isSingleUser,
|
||||||
}
|
}
|
||||||
c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner)
|
err := c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner)
|
||||||
return coll
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return coll, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCollectionPage returns the collection page as an int. If the parsed page value is not
|
// getCollectionPage returns the collection page as an int. If the parsed page value is not
|
||||||
|
@ -881,16 +884,29 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
// Serve ActivityStreams data now, if requested
|
// Serve ActivityStreams data now, if requested
|
||||||
if IsActivityPubRequest(r) {
|
if IsActivityPubRequest(r) {
|
||||||
ac := c.PersonObject()
|
ac := c.PersonObject()
|
||||||
ac.Context = []interface{}{activitystreams.Namespace}
|
|
||||||
setCacheControl(w, apCacheTime)
|
setCacheControl(w, apCacheTime)
|
||||||
return impart.RenderActivityJSON(w, ac, http.StatusOK)
|
return impart.RenderActivityJSON(w, ac, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch extra data about the Collection
|
// Fetch extra data about the Collection
|
||||||
// TODO: refactor out this logic, shared in collection.go:fetchCollection()
|
// TODO: refactor out this logic, shared in collection.go:fetchCollection()
|
||||||
coll := newDisplayCollection(c, cr, page)
|
coll, err := newDisplayCollection(c, cr, page)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
coll.TotalPages = int(math.Ceil(float64(coll.TotalPosts) / float64(coll.Format.PostsPerPage())))
|
var ct PostType
|
||||||
|
if isArchiveView(r) {
|
||||||
|
ct = postArch
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: this number will be off when user has pinned posts but isn't a Pro user
|
||||||
|
ppp := coll.Format.PostsPerPage()
|
||||||
|
if ct == postArch {
|
||||||
|
ppp = postsPerArchPage
|
||||||
|
}
|
||||||
|
|
||||||
|
coll.TotalPages = int(math.Ceil(float64(coll.TotalPosts) / float64(ppp)))
|
||||||
if coll.TotalPages > 0 && page > coll.TotalPages {
|
if coll.TotalPages > 0 && page > coll.TotalPages {
|
||||||
redirURL := fmt.Sprintf("/page/%d", coll.TotalPages)
|
redirURL := fmt.Sprintf("/page/%d", coll.TotalPages)
|
||||||
if !app.cfg.App.SingleUser {
|
if !app.cfg.App.SingleUser {
|
||||||
|
@ -899,7 +915,7 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
return impart.HTTPError{http.StatusFound, redirURL}
|
return impart.HTTPError{http.StatusFound, redirURL}
|
||||||
}
|
}
|
||||||
|
|
||||||
coll.Posts, _ = app.db.GetPosts(app.cfg, c, page, cr.isCollOwner, false, false)
|
coll.Posts, _ = app.db.GetPosts(app.cfg, c, page, cr.isCollOwner, false, false, "")
|
||||||
|
|
||||||
// Serve collection
|
// Serve collection
|
||||||
displayPage := CollectionPage{
|
displayPage := CollectionPage{
|
||||||
|
@ -958,6 +974,9 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
collTmpl := "collection"
|
collTmpl := "collection"
|
||||||
if app.cfg.App.Chorus {
|
if app.cfg.App.Chorus {
|
||||||
collTmpl = "chorus-collection"
|
collTmpl = "chorus-collection"
|
||||||
|
} else if isArchiveView(r) {
|
||||||
|
displayPage.NavSuffix = "/archive/"
|
||||||
|
collTmpl = "collection-archive"
|
||||||
}
|
}
|
||||||
err = templates[collTmpl].ExecuteTemplate(w, "collection", displayPage)
|
err = templates[collTmpl].ExecuteTemplate(w, "collection", displayPage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -984,6 +1003,10 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isArchiveView(r *http.Request) bool {
|
||||||
|
return strings.HasSuffix(r.RequestURI, "/archive/") || mux.Vars(r)["archive"] == "archive"
|
||||||
|
}
|
||||||
|
|
||||||
func handleViewMention(app *App, w http.ResponseWriter, r *http.Request) error {
|
func handleViewMention(app *App, w http.ResponseWriter, r *http.Request) error {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
handle := vars["handle"]
|
handle := vars["handle"]
|
||||||
|
@ -1019,7 +1042,7 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
coll := newDisplayCollection(c, cr, page)
|
coll, _ := newDisplayCollection(c, cr, page)
|
||||||
|
|
||||||
taggedPostIDs, err := app.db.GetAllPostsTaggedIDs(c, tag, cr.isCollOwner)
|
taggedPostIDs, err := app.db.GetAllPostsTaggedIDs(c, tag, cr.isCollOwner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1117,7 +1140,7 @@ func handleViewCollectionLang(app *App, w http.ResponseWriter, r *http.Request)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
coll := newDisplayCollection(c, cr, page)
|
coll, _ := newDisplayCollection(c, cr, page)
|
||||||
coll.Language = lang
|
coll.Language = lang
|
||||||
coll.NavSuffix = fmt.Sprintf("/lang:%s", lang)
|
coll.NavSuffix = fmt.Sprintf("/lang:%s", lang)
|
||||||
|
|
||||||
|
|
|
@ -171,8 +171,17 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
EmailCfg struct {
|
EmailCfg struct {
|
||||||
|
// SMTP configuration values
|
||||||
|
Host string `ini:"smtp_host"`
|
||||||
|
Port int `ini:"smtp_port"`
|
||||||
|
Username string `ini:"smtp_username"`
|
||||||
|
Password string `ini:"smtp_password"`
|
||||||
|
EnableStartTLS bool `ini:"smtp_enable_start_tls"`
|
||||||
|
|
||||||
|
// Mailgun configuration values
|
||||||
Domain string `ini:"domain"`
|
Domain string `ini:"domain"`
|
||||||
MailgunPrivate string `ini:"mailgun_private"`
|
MailgunPrivate string `ini:"mailgun_private"`
|
||||||
|
MailgunEurope bool `ini:"mailgun_europe"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config holds the complete configuration for running a writefreely instance
|
// Config holds the complete configuration for running a writefreely instance
|
||||||
|
@ -242,7 +251,8 @@ func (ac *AppCfg) LandingPath() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc EmailCfg) Enabled() bool {
|
func (lc EmailCfg) Enabled() bool {
|
||||||
return lc.Domain != "" && lc.MailgunPrivate != ""
|
return (lc.Domain != "" && lc.MailgunPrivate != "") ||
|
||||||
|
lc.Username != "" && lc.Password != "" && lc.Host != "" && lc.Port > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac AppCfg) SignupPath() string {
|
func (ac AppCfg) SignupPath() string {
|
||||||
|
|
34
database.go
34
database.go
|
@ -19,6 +19,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/writeas/monday"
|
||||||
|
|
||||||
"github.com/go-sql-driver/mysql"
|
"github.com/go-sql-driver/mysql"
|
||||||
"github.com/writeas/web-core/silobridge"
|
"github.com/writeas/web-core/silobridge"
|
||||||
wf_db "github.com/writefreely/writefreely/db"
|
wf_db "github.com/writefreely/writefreely/db"
|
||||||
|
@ -116,8 +118,8 @@ type writestore interface {
|
||||||
ClaimPosts(cfg *config.Config, userID int64, collAlias string, posts *[]ClaimPostRequest) (*[]ClaimPostResult, error)
|
ClaimPosts(cfg *config.Config, userID int64, collAlias string, posts *[]ClaimPostRequest) (*[]ClaimPostResult, error)
|
||||||
|
|
||||||
GetPostLikeCounts(postID string) (int64, error)
|
GetPostLikeCounts(postID string) (int64, error)
|
||||||
GetPostsCount(c *CollectionObj, includeFuture bool)
|
GetPostsCount(c *CollectionObj, includeFuture bool) error
|
||||||
GetPosts(cfg *config.Config, c *Collection, page int, includeFuture, forceRecentFirst, includePinned bool) (*[]PublicPost, error)
|
GetPosts(cfg *config.Config, c *Collection, page int, includeFuture, forceRecentFirst, includePinned bool, contentType PostType) (*[]PublicPost, error)
|
||||||
GetAllPostsTaggedIDs(c *Collection, tag string, includeFuture bool) ([]string, error)
|
GetAllPostsTaggedIDs(c *Collection, tag string, includeFuture bool) ([]string, error)
|
||||||
GetPostsTagged(cfg *config.Config, c *Collection, tag string, page int, includeFuture bool) (*[]PublicPost, error)
|
GetPostsTagged(cfg *config.Config, c *Collection, tag string, page int, includeFuture bool) (*[]PublicPost, error)
|
||||||
|
|
||||||
|
@ -1258,7 +1260,7 @@ func (db *datastore) GetPostLikeCounts(postID string) (int64, error) {
|
||||||
// GetPostsCount modifies the CollectionObj to include the correct number of
|
// GetPostsCount modifies the CollectionObj to include the correct number of
|
||||||
// standard (non-pinned) posts. It will return future posts if `includeFuture`
|
// standard (non-pinned) posts. It will return future posts if `includeFuture`
|
||||||
// is true.
|
// is true.
|
||||||
func (db *datastore) GetPostsCount(c *CollectionObj, includeFuture bool) {
|
func (db *datastore) GetPostsCount(c *CollectionObj, includeFuture bool) error {
|
||||||
var count int64
|
var count int64
|
||||||
timeCondition := ""
|
timeCondition := ""
|
||||||
if !includeFuture {
|
if !includeFuture {
|
||||||
|
@ -1271,16 +1273,18 @@ func (db *datastore) GetPostsCount(c *CollectionObj, includeFuture bool) {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
log.Error("Failed selecting from collections: %v", err)
|
log.Error("Failed selecting from collections: %v", err)
|
||||||
c.TotalPosts = 0
|
c.TotalPosts = 0
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.TotalPosts = int(count)
|
c.TotalPosts = int(count)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPosts retrieves all posts for the given Collection.
|
// GetPosts retrieves all posts for the given Collection.
|
||||||
// It will return future posts if `includeFuture` is true.
|
// It will return future posts if `includeFuture` is true.
|
||||||
// It will include only standard (non-pinned) posts unless `includePinned` is true.
|
// It will include only standard (non-pinned) posts unless `includePinned` is true.
|
||||||
// TODO: change includeFuture to isOwner, since that's how it's used
|
// TODO: change includeFuture to isOwner, since that's how it's used
|
||||||
func (db *datastore) GetPosts(cfg *config.Config, c *Collection, page int, includeFuture, forceRecentFirst, includePinned bool) (*[]PublicPost, error) {
|
func (db *datastore) GetPosts(cfg *config.Config, c *Collection, page int, includeFuture, forceRecentFirst, includePinned bool, contentType PostType) (*[]PublicPost, error) {
|
||||||
collID := c.ID
|
collID := c.ID
|
||||||
|
|
||||||
cf := c.NewFormat()
|
cf := c.NewFormat()
|
||||||
|
@ -1294,6 +1298,9 @@ func (db *datastore) GetPosts(cfg *config.Config, c *Collection, page int, inclu
|
||||||
if page == 0 {
|
if page == 0 {
|
||||||
start = 0
|
start = 0
|
||||||
pagePosts = 1000
|
pagePosts = 1000
|
||||||
|
} else if contentType == postArch {
|
||||||
|
pagePosts = postsPerArchPage
|
||||||
|
start = page*pagePosts - pagePosts
|
||||||
}
|
}
|
||||||
|
|
||||||
limitStr := ""
|
limitStr := ""
|
||||||
|
@ -1308,6 +1315,7 @@ func (db *datastore) GetPosts(cfg *config.Config, c *Collection, page int, inclu
|
||||||
if !includePinned {
|
if !includePinned {
|
||||||
pinnedCondition = "AND pinned_position IS NULL"
|
pinnedCondition = "AND pinned_position IS NULL"
|
||||||
}
|
}
|
||||||
|
// FUTURE: handle different post contentType's here
|
||||||
rows, err := db.Query("SELECT "+postCols+" FROM posts WHERE collection_id = ? "+pinnedCondition+" "+timeCondition+" ORDER BY created "+order+limitStr, collID)
|
rows, err := db.Query("SELECT "+postCols+" FROM posts WHERE collection_id = ? "+pinnedCondition+" "+timeCondition+" ORDER BY created "+order+limitStr, collID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed selecting from posts: %v", err)
|
log.Error("Failed selecting from posts: %v", err)
|
||||||
|
@ -1328,7 +1336,13 @@ func (db *datastore) GetPosts(cfg *config.Config, c *Collection, page int, inclu
|
||||||
p.augmentContent(c)
|
p.augmentContent(c)
|
||||||
p.formatContent(cfg, c, includeFuture, false)
|
p.formatContent(cfg, c, includeFuture, false)
|
||||||
|
|
||||||
posts = append(posts, p.processPost())
|
pubPost := p.processPost()
|
||||||
|
if contentType == postArch {
|
||||||
|
// Overwrite DisplayDate with special Archive page version
|
||||||
|
loc := monday.FuzzyLocale(pubPost.Language.String)
|
||||||
|
pubPost.DisplayDate = monday.Format(pubPost.Created, monday.LongNoYrFormatsByLocale[loc], loc)
|
||||||
|
}
|
||||||
|
posts = append(posts, pubPost)
|
||||||
}
|
}
|
||||||
err = rows.Err()
|
err = rows.Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2001,7 +2015,7 @@ func (db *datastore) GetMeStats(u *User) userMeStats {
|
||||||
|
|
||||||
func (db *datastore) GetTotalCollections() (collCount int64, err error) {
|
func (db *datastore) GetTotalCollections() (collCount int64, err error) {
|
||||||
err = db.QueryRow(`
|
err = db.QueryRow(`
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM collections c
|
FROM collections c
|
||||||
LEFT JOIN users u ON u.id = c.owner_id
|
LEFT JOIN users u ON u.id = c.owner_id
|
||||||
WHERE u.status = 0`).Scan(&collCount)
|
WHERE u.status = 0`).Scan(&collCount)
|
||||||
|
@ -3127,10 +3141,10 @@ func (db *datastore) GetEmailSubscribers(collID int64, reqConfirmed bool) ([]*Em
|
||||||
if reqConfirmed {
|
if reqConfirmed {
|
||||||
cond = " AND confirmed = 1"
|
cond = " AND confirmed = 1"
|
||||||
}
|
}
|
||||||
rows, err := db.Query(`SELECT s.id, collection_id, user_id, s.email, u.email, subscribed, token, confirmed, allow_export
|
rows, err := db.Query(`SELECT s.id, collection_id, user_id, s.email, u.email, subscribed, token, confirmed, allow_export
|
||||||
FROM emailsubscribers s
|
FROM emailsubscribers s
|
||||||
LEFT JOIN users u
|
LEFT JOIN users u
|
||||||
ON u.id = user_id
|
ON u.id = user_id
|
||||||
WHERE collection_id = ?`+cond+`
|
WHERE collection_id = ?`+cond+`
|
||||||
ORDER BY subscribed DESC`, collID)
|
ORDER BY subscribed DESC`, collID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
37
email.go
37
email.go
|
@ -14,6 +14,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/writefreely/writefreely/mailer"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -21,7 +22,6 @@ import (
|
||||||
|
|
||||||
"github.com/aymerick/douceur/inliner"
|
"github.com/aymerick/douceur/inliner"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/mailgun/mailgun-go"
|
|
||||||
stripmd "github.com/writeas/go-strip-markdown/v2"
|
stripmd "github.com/writeas/go-strip-markdown/v2"
|
||||||
"github.com/writeas/impart"
|
"github.com/writeas/impart"
|
||||||
"github.com/writeas/web-core/data"
|
"github.com/writeas/web-core/data"
|
||||||
|
@ -307,8 +307,14 @@ Originally published on ` + p.Collection.DisplayTitle() + ` (` + p.Collection.Ca
|
||||||
|
|
||||||
Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/unsubscribe/%recipient.id%?t=%recipient.token%`
|
Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/unsubscribe/%recipient.id%?t=%recipient.token%`
|
||||||
|
|
||||||
gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate)
|
mlr, err := mailer.New(app.cfg.Email)
|
||||||
m := mailgun.NewMessage(p.Collection.DisplayTitle()+" <"+p.Collection.Alias+"@"+app.cfg.Email.Domain+">", stripmd.Strip(p.DisplayTitle()), plainMsg)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m, err := mlr.NewMessage(p.Collection.DisplayTitle()+" <"+p.Collection.Alias+"@"+app.cfg.Email.Domain+">", stripmd.Strip(p.DisplayTitle()), plainMsg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
replyTo := app.db.GetCollectionAttribute(collID, collAttrLetterReplyTo)
|
replyTo := app.db.GetCollectionAttribute(collID, collAttrLetterReplyTo)
|
||||||
if replyTo != "" {
|
if replyTo != "" {
|
||||||
m.SetReplyTo(replyTo)
|
m.SetReplyTo(replyTo)
|
||||||
|
@ -405,13 +411,13 @@ Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/un
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
m.SetHtml(html)
|
m.SetHTML(html)
|
||||||
|
|
||||||
log.Info("[email] Adding %d recipient(s)", len(subs))
|
log.Info("[email] Adding %d recipient(s)", len(subs))
|
||||||
for _, s := range subs {
|
for _, s := range subs {
|
||||||
e := s.FinalEmail(app.keys)
|
e := s.FinalEmail(app.keys)
|
||||||
log.Info("[email] Adding %s", e)
|
log.Info("[email] Adding %s", e)
|
||||||
err = m.AddRecipientAndVariables(e, map[string]interface{}{
|
err = m.AddRecipientAndVariables(e, map[string]string{
|
||||||
"id": s.ID,
|
"id": s.ID,
|
||||||
"to": e,
|
"to": e,
|
||||||
"token": s.Token,
|
"token": s.Token,
|
||||||
|
@ -421,8 +427,8 @@ Sent to %recipient.to%. Unsubscribe: ` + p.Collection.CanonicalURL() + `email/un
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res, _, err := gun.Send(m)
|
err = mlr.Send(m)
|
||||||
log.Info("[email] Send result: %s", res)
|
log.Info("[email] Email sent")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Unable to send post email: %v", err)
|
log.Error("Unable to send post email: %v", err)
|
||||||
return err
|
return err
|
||||||
|
@ -437,17 +443,23 @@ func sendSubConfirmEmail(app *App, c *Collection, email, subID, token string) er
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send email
|
// Send email
|
||||||
gun := mailgun.NewMailgun(app.cfg.Email.Domain, app.cfg.Email.MailgunPrivate)
|
mlr, err := mailer.New(app.cfg.Email)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
plainMsg := "Confirm your subscription to " + c.DisplayTitle() + ` (` + c.CanonicalURL() + `) to start receiving future posts. Simply click the following link (or copy and paste it into your browser):
|
plainMsg := "Confirm your subscription to " + c.DisplayTitle() + ` (` + c.CanonicalURL() + `) to start receiving future posts. Simply click the following link (or copy and paste it into your browser):
|
||||||
|
|
||||||
` + c.CanonicalURL() + "email/confirm/" + subID + "?t=" + token + `
|
` + c.CanonicalURL() + "email/confirm/" + subID + "?t=" + token + `
|
||||||
|
|
||||||
If you didn't subscribe to this site or you're not sure why you're getting this email, you can delete it. You won't be subscribed or receive any future emails.`
|
If you didn't subscribe to this site or you're not sure why you're getting this email, you can delete it. You won't be subscribed or receive any future emails.`
|
||||||
m := mailgun.NewMessage(c.DisplayTitle()+" <"+c.Alias+"@"+app.cfg.Email.Domain+">", "Confirm your subscription to "+c.DisplayTitle(), plainMsg, fmt.Sprintf("<%s>", email))
|
m, err := mlr.NewMessage(c.DisplayTitle()+" <"+c.Alias+"@"+app.cfg.Email.Domain+">", "Confirm your subscription to "+c.DisplayTitle(), plainMsg, fmt.Sprintf("<%s>", email))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
m.AddTag("Email Verification")
|
m.AddTag("Email Verification")
|
||||||
|
|
||||||
m.SetHtml(`<html>
|
m.SetHTML(`<html>
|
||||||
<body style="font-family:Lora, 'Palatino Linotype', Palatino, Baskerville, 'Book Antiqua', 'New York', 'DejaVu serif', serif; font-size: 100%%; margin:1em 2em;">
|
<body style="font-family:Lora, 'Palatino Linotype', Palatino, Baskerville, 'Book Antiqua', 'New York', 'DejaVu serif', serif; font-size: 100%%; margin:1em 2em;">
|
||||||
<div style="font-size: 1.2em;">
|
<div style="font-size: 1.2em;">
|
||||||
<p>Confirm your subscription to <a href="` + c.CanonicalURL() + `">` + c.DisplayTitle() + `</a> to start receiving future posts:</p>
|
<p>Confirm your subscription to <a href="` + c.CanonicalURL() + `">` + c.DisplayTitle() + `</a> to start receiving future posts:</p>
|
||||||
|
@ -456,7 +468,10 @@ If you didn't subscribe to this site or you're not sure why you're getting this
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`)
|
</html>`)
|
||||||
gun.Send(m)
|
err = mlr.Send(m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ func compileFullExport(app *App, u *User) *ExportUser {
|
||||||
var collObjs []CollectionObj
|
var collObjs []CollectionObj
|
||||||
for _, c := range *colls {
|
for _, c := range *colls {
|
||||||
co := &CollectionObj{Collection: c}
|
co := &CollectionObj{Collection: c}
|
||||||
co.Posts, err = app.db.GetPosts(app.cfg, &c, 0, true, false, true)
|
co.Posts, err = app.db.GetPosts(app.cfg, &c, 0, true, false, true, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("unable to get collection posts: %v", err)
|
log.Error("unable to get collection posts: %v", err)
|
||||||
}
|
}
|
||||||
|
|
2
feed.go
2
feed.go
|
@ -67,7 +67,7 @@ func ViewFeed(app *App, w http.ResponseWriter, req *http.Request) error {
|
||||||
if tag != "" {
|
if tag != "" {
|
||||||
coll.Posts, _ = app.db.GetPostsTagged(app.cfg, c, tag, 1, false)
|
coll.Posts, _ = app.db.GetPostsTagged(app.cfg, c, tag, 1, false)
|
||||||
} else {
|
} else {
|
||||||
coll.Posts, _ = app.db.GetPosts(app.cfg, c, 1, false, true, false)
|
coll.Posts, _ = app.db.GetPosts(app.cfg, c, 1, false, true, false, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
author := ""
|
author := ""
|
||||||
|
|
7
go.mod
7
go.mod
|
@ -27,7 +27,7 @@ require (
|
||||||
github.com/mailgun/mailgun-go v2.0.0+incompatible
|
github.com/mailgun/mailgun-go v2.0.0+incompatible
|
||||||
github.com/manifoldco/promptui v0.9.0
|
github.com/manifoldco/promptui v0.9.0
|
||||||
github.com/mattn/go-sqlite3 v1.14.21
|
github.com/mattn/go-sqlite3 v1.14.21
|
||||||
github.com/microcosm-cc/bluemonday v1.0.26
|
github.com/microcosm-cc/bluemonday v1.0.27
|
||||||
github.com/mitchellh/go-wordwrap v1.0.1
|
github.com/mitchellh/go-wordwrap v1.0.1
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
|
||||||
github.com/onsi/ginkgo v1.16.4 // indirect
|
github.com/onsi/ginkgo v1.16.4 // indirect
|
||||||
|
@ -53,6 +53,8 @@ require (
|
||||||
golang.org/x/net v0.30.0
|
golang.org/x/net v0.30.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require github.com/xhit/go-simple-mail/v2 v2.16.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.as/core/socks v1.0.0 // indirect
|
code.as/core/socks v1.0.0 // indirect
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
|
@ -67,7 +69,7 @@ require (
|
||||||
github.com/go-fed/httpsig v0.1.1-0.20200204213531-0ef28562fabe // indirect
|
github.com/go-fed/httpsig v0.1.1-0.20200204213531-0ef28562fabe // indirect
|
||||||
github.com/gofrs/uuid v3.3.0+incompatible // indirect
|
github.com/gofrs/uuid v3.3.0+incompatible // indirect
|
||||||
github.com/gologme/log v1.2.0 // indirect
|
github.com/gologme/log v1.2.0 // indirect
|
||||||
github.com/gorilla/css v1.0.0 // indirect
|
github.com/gorilla/css v1.0.1 // indirect
|
||||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||||
github.com/gosimple/unidecode v1.0.1 // indirect
|
github.com/gosimple/unidecode v1.0.1 // indirect
|
||||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||||
|
@ -82,6 +84,7 @@ require (
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||||
|
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 // indirect
|
||||||
github.com/writeas/go-writeas/v2 v2.0.2 // indirect
|
github.com/writeas/go-writeas/v2 v2.0.2 // indirect
|
||||||
github.com/writeas/openssl-go v1.0.0 // indirect
|
github.com/writeas/openssl-go v1.0.0 // indirect
|
||||||
github.com/writeas/slug v1.2.0 // indirect
|
github.com/writeas/slug v1.2.0 // indirect
|
||||||
|
|
11
go.sum
11
go.sum
|
@ -79,8 +79,9 @@ github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI=
|
github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI=
|
||||||
github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
|
github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
|
||||||
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
|
||||||
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
||||||
|
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||||
|
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||||
github.com/gorilla/feeds v1.1.2 h1:pxzZ5PD3RJdhFH2FsJJ4x6PqMqbgFk1+Vez4XWBW8Iw=
|
github.com/gorilla/feeds v1.1.2 h1:pxzZ5PD3RJdhFH2FsJJ4x6PqMqbgFk1+Vez4XWBW8Iw=
|
||||||
github.com/gorilla/feeds v1.1.2/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
|
github.com/gorilla/feeds v1.1.2/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
|
||||||
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||||
|
@ -132,8 +133,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
|
||||||
github.com/mattn/go-sqlite3 v1.14.21 h1:IXocQLOykluc3xPE0Lvy8FtggMz1G+U3mEjg+0zGizc=
|
github.com/mattn/go-sqlite3 v1.14.21 h1:IXocQLOykluc3xPE0Lvy8FtggMz1G+U3mEjg+0zGizc=
|
||||||
github.com/mattn/go-sqlite3 v1.14.21/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
github.com/mattn/go-sqlite3 v1.14.21/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
|
github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
|
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
|
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
||||||
|
@ -177,6 +178,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 h1:PM5hJF7HVfNWmCjMdEfbuOBNXSVF2cMFGgQTPdKCbwM=
|
||||||
|
github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns=
|
||||||
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
|
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
|
||||||
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
|
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
|
||||||
github.com/writeas/activity v0.1.2 h1:Y12B5lIrabfqKE7e7HFCWiXrlfXljr9tlkFm2mp7DgY=
|
github.com/writeas/activity v0.1.2 h1:Y12B5lIrabfqKE7e7HFCWiXrlfXljr9tlkFm2mp7DgY=
|
||||||
|
@ -212,6 +215,8 @@ github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b h1:h3NzB8OZ5
|
||||||
github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b/go.mod h1:T2UVVzt+R5KSSZe2xRSytnwc2M9AoDegi7foeIsik+M=
|
github.com/writefreely/go-gopher v0.0.0-20220429181814-40127126f83b/go.mod h1:T2UVVzt+R5KSSZe2xRSytnwc2M9AoDegi7foeIsik+M=
|
||||||
github.com/writefreely/go-nodeinfo v1.2.0 h1:La+YbTCvmpTwFhBSlebWDDL81N88Qf/SCAvRLR7F8ss=
|
github.com/writefreely/go-nodeinfo v1.2.0 h1:La+YbTCvmpTwFhBSlebWDDL81N88Qf/SCAvRLR7F8ss=
|
||||||
github.com/writefreely/go-nodeinfo v1.2.0/go.mod h1:UTvE78KpcjYOlRHupZIiSEFcXHioTXuacCbHU+CAcPg=
|
github.com/writefreely/go-nodeinfo v1.2.0/go.mod h1:UTvE78KpcjYOlRHupZIiSEFcXHioTXuacCbHU+CAcPg=
|
||||||
|
github.com/xhit/go-simple-mail/v2 v2.16.0 h1:ouGy/Ww4kuaqu2E2UrDw7SvLaziWTB60ICLkIkNVccA=
|
||||||
|
github.com/xhit/go-simple-mail/v2 v2.16.0/go.mod h1:b7P5ygho6SYE+VIqpxA6QkYfv4teeyG4MKqB3utRu98=
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
|
|
@ -111,7 +111,7 @@ func handleGopherCollection(app *App, w gopher.ResponseWriter, r *gopher.Request
|
||||||
w.WriteInfo(c.Description)
|
w.WriteInfo(c.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
posts, err := app.db.GetPosts(app.cfg, c, 0, false, false, false)
|
posts, err := app.db.GetPosts(app.cfg, c, 0, false, false, false, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ body {
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: #111;
|
color: #111;
|
||||||
|
|
||||||
h1, header h2 {
|
h1, header h2 {
|
||||||
a {
|
a {
|
||||||
color: @headerTextColor;
|
color: @headerTextColor;
|
||||||
|
@ -672,6 +672,26 @@ body#collection article, body#subpage article {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#wrapper.archive {
|
||||||
|
h1 {
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
|
||||||
|
li {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
line-height: 1.4;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
body#post article {
|
body#post article {
|
||||||
p.badge {
|
p.badge {
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
|
@ -1101,7 +1121,7 @@ li {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.errors {
|
ul.errors {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
text-indent: 0;
|
text-indent: 0;
|
||||||
li.urgent {
|
li.urgent {
|
||||||
|
@ -1637,4 +1657,4 @@ p#emailsub {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-left: 0.25em;
|
margin-left: 0.25em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ body {
|
||||||
&:hover {
|
&:hover {
|
||||||
.opacity(1);
|
.opacity(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.6em;
|
font-size: 1.6em;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ body {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
article, pre, .hljs {
|
article, pre, .hljs, #wrapper.archive ul {
|
||||||
padding: 0.5em 2rem 1.5em;
|
padding: 0.5em 2rem 1.5em;
|
||||||
}
|
}
|
||||||
body#post article, pre, .hljs {
|
body#post article, pre, .hljs {
|
||||||
|
|
181
mailer/mailer.go
Normal file
181
mailer/mailer.go
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2024 Musing Studio LLC.
|
||||||
|
*
|
||||||
|
* This file is part of WriteFreely.
|
||||||
|
*
|
||||||
|
* WriteFreely is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, included
|
||||||
|
* in the LICENSE file in this source code package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package mailer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/mailgun/mailgun-go"
|
||||||
|
"github.com/writeas/web-core/log"
|
||||||
|
"github.com/writefreely/writefreely/config"
|
||||||
|
mail "github.com/xhit/go-simple-mail/v2"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// Mailer holds configurations for the preferred mailing provider.
|
||||||
|
Mailer struct {
|
||||||
|
smtp *mail.SMTPServer
|
||||||
|
mailGun *mailgun.MailgunImpl
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message holds the email contents and metadata for the preferred mailing provider.
|
||||||
|
Message struct {
|
||||||
|
mgMsg *mailgun.Message
|
||||||
|
smtpMsg *SmtpMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
SmtpMessage struct {
|
||||||
|
from string
|
||||||
|
replyTo string
|
||||||
|
subject string
|
||||||
|
recipients []Recipient
|
||||||
|
html string
|
||||||
|
text string
|
||||||
|
}
|
||||||
|
|
||||||
|
Recipient struct {
|
||||||
|
email string
|
||||||
|
vars map[string]string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// New creates a new Mailer from the instance's config.EmailCfg, returning an error if not properly configured.
|
||||||
|
func New(eCfg config.EmailCfg) (*Mailer, error) {
|
||||||
|
m := &Mailer{}
|
||||||
|
if eCfg.Domain != "" && eCfg.MailgunPrivate != "" {
|
||||||
|
m.mailGun = mailgun.NewMailgun(eCfg.Domain, eCfg.MailgunPrivate)
|
||||||
|
if eCfg.MailgunEurope {
|
||||||
|
m.mailGun.SetAPIBase("https://api.eu.mailgun.net/v3")
|
||||||
|
}
|
||||||
|
} else if eCfg.Username != "" && eCfg.Password != "" && eCfg.Host != "" && eCfg.Port > 0 {
|
||||||
|
m.smtp = mail.NewSMTPClient()
|
||||||
|
m.smtp.Host = eCfg.Host
|
||||||
|
m.smtp.Port = eCfg.Port
|
||||||
|
m.smtp.Username = eCfg.Username
|
||||||
|
m.smtp.Password = eCfg.Password
|
||||||
|
if eCfg.EnableStartTLS {
|
||||||
|
m.smtp.Encryption = mail.EncryptionSTARTTLS
|
||||||
|
}
|
||||||
|
// To allow sending multiple email
|
||||||
|
m.smtp.KeepAlive = true
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("no email provider is configured")
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMessage creates a new Message from the given parameters.
|
||||||
|
func (m *Mailer) NewMessage(from, subject, text string, to ...string) (*Message, error) {
|
||||||
|
msg := &Message{}
|
||||||
|
if m.mailGun != nil {
|
||||||
|
msg.mgMsg = m.mailGun.NewMessage(from, subject, text, to...)
|
||||||
|
} else if m.smtp != nil {
|
||||||
|
msg.smtpMsg = &SmtpMessage{
|
||||||
|
from: from,
|
||||||
|
replyTo: "",
|
||||||
|
subject: subject,
|
||||||
|
recipients: make([]Recipient, len(to)),
|
||||||
|
html: "",
|
||||||
|
text: text,
|
||||||
|
}
|
||||||
|
for _, r := range to {
|
||||||
|
msg.smtpMsg.recipients = append(msg.smtpMsg.recipients, Recipient{r, make(map[string]string)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return msg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetHTML sets the body of the message.
|
||||||
|
func (m *Message) SetHTML(html string) {
|
||||||
|
if m.smtpMsg != nil {
|
||||||
|
m.smtpMsg.html = html
|
||||||
|
} else if m.mgMsg != nil {
|
||||||
|
m.mgMsg.SetHtml(html)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Message) SetReplyTo(replyTo string) {
|
||||||
|
if m.smtpMsg != nil {
|
||||||
|
m.smtpMsg.replyTo = replyTo
|
||||||
|
} else {
|
||||||
|
m.mgMsg.SetReplyTo(replyTo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTag attaches a tag to the Message for providers that support it.
|
||||||
|
func (m *Message) AddTag(tag string) {
|
||||||
|
if m.mgMsg != nil {
|
||||||
|
m.mgMsg.AddTag(tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Message) AddRecipientAndVariables(r string, vars map[string]string) error {
|
||||||
|
if m.smtpMsg != nil {
|
||||||
|
m.smtpMsg.recipients = append(m.smtpMsg.recipients, Recipient{r, vars})
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
varsInterfaces := make(map[string]interface{}, len(vars))
|
||||||
|
for k, v := range vars {
|
||||||
|
varsInterfaces[k] = v
|
||||||
|
}
|
||||||
|
return m.mgMsg.AddRecipientAndVariables(r, varsInterfaces)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send sends the given message via the preferred provider.
|
||||||
|
func (m *Mailer) Send(msg *Message) error {
|
||||||
|
if m.smtp != nil {
|
||||||
|
client, err := m.smtp.Connect()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
emailSent := false
|
||||||
|
for _, r := range msg.smtpMsg.recipients {
|
||||||
|
customMsg := mail.NewMSG()
|
||||||
|
customMsg.SetFrom(msg.smtpMsg.from)
|
||||||
|
if msg.smtpMsg.replyTo != "" {
|
||||||
|
customMsg.SetReplyTo(msg.smtpMsg.replyTo)
|
||||||
|
}
|
||||||
|
customMsg.SetSubject(msg.smtpMsg.subject)
|
||||||
|
customMsg.AddTo(r.email)
|
||||||
|
cText := msg.smtpMsg.text
|
||||||
|
cHtml := msg.smtpMsg.html
|
||||||
|
for v, value := range r.vars {
|
||||||
|
placeHolder := fmt.Sprintf("%%recipient.%s%%", v)
|
||||||
|
cText = strings.ReplaceAll(cText, placeHolder, value)
|
||||||
|
cHtml = strings.ReplaceAll(cHtml, placeHolder, value)
|
||||||
|
}
|
||||||
|
customMsg.SetBody(mail.TextHTML, cHtml)
|
||||||
|
customMsg.AddAlternative(mail.TextPlain, cText)
|
||||||
|
e := customMsg.Error
|
||||||
|
if e == nil {
|
||||||
|
e = customMsg.Send(client)
|
||||||
|
}
|
||||||
|
if e == nil {
|
||||||
|
emailSent = true
|
||||||
|
} else {
|
||||||
|
log.Error("Unable to send email to %s: %v", r.email, e)
|
||||||
|
err = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !emailSent {
|
||||||
|
// only send an error if no email could be sent (to avoid retry of successfully sent emails)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if m.mailGun != nil {
|
||||||
|
_, _, err := m.mailGun.Send(msg.mgMsg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
10
posts.go
10
posts.go
|
@ -49,6 +49,12 @@ const (
|
||||||
postIDLen = 10
|
postIDLen = 10
|
||||||
|
|
||||||
postMetaDateFormat = "2006-01-02 15:04:05"
|
postMetaDateFormat = "2006-01-02 15:04:05"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PostType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
postArch PostType = "archive"
|
||||||
|
|
||||||
shortCodePaid = "<!--paid-->"
|
shortCodePaid = "<!--paid-->"
|
||||||
)
|
)
|
||||||
|
@ -1510,6 +1516,10 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error
|
||||||
// User tried to access blog feed without a trailing slash, and
|
// User tried to access blog feed without a trailing slash, and
|
||||||
// there's no post with a slug "feed"
|
// there's no post with a slug "feed"
|
||||||
return impart.HTTPError{http.StatusFound, c.CanonicalURL() + "feed/"}
|
return impart.HTTPError{http.StatusFound, c.CanonicalURL() + "feed/"}
|
||||||
|
} else if slug == "archive" {
|
||||||
|
// User tried to access blog Archive without a trailing slash, and
|
||||||
|
// there's no post with a slug "archive"
|
||||||
|
return impart.HTTPError{http.StatusFound, c.CanonicalURL() + "archive/"}
|
||||||
}
|
}
|
||||||
|
|
||||||
po := &Post{
|
po := &Post{
|
||||||
|
|
|
@ -159,12 +159,12 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
|
||||||
// Handle posts
|
// Handle posts
|
||||||
write.HandleFunc("/api/posts", handler.All(newPost)).Methods("POST")
|
write.HandleFunc("/api/posts", handler.All(newPost)).Methods("POST")
|
||||||
posts := write.PathPrefix("/api/posts/").Subrouter()
|
posts := write.PathPrefix("/api/posts/").Subrouter()
|
||||||
|
posts.HandleFunc("/claim", handler.All(addPost)).Methods("POST")
|
||||||
|
posts.HandleFunc("/disperse", handler.All(dispersePost)).Methods("POST")
|
||||||
posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.AllReader(fetchPost)).Methods("GET")
|
posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.AllReader(fetchPost)).Methods("GET")
|
||||||
posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.All(existingPost)).Methods("POST", "PUT")
|
posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.All(existingPost)).Methods("POST", "PUT")
|
||||||
posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.All(deletePost)).Methods("DELETE")
|
posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.All(deletePost)).Methods("DELETE")
|
||||||
posts.HandleFunc("/{post:[a-zA-Z0-9]+}/{property}", handler.AllReader(fetchPostProperty)).Methods("GET")
|
posts.HandleFunc("/{post:[a-zA-Z0-9]+}/{property}", handler.AllReader(fetchPostProperty)).Methods("GET")
|
||||||
posts.HandleFunc("/claim", handler.All(addPost)).Methods("POST")
|
|
||||||
posts.HandleFunc("/disperse", handler.All(dispersePost)).Methods("POST")
|
|
||||||
|
|
||||||
write.HandleFunc("/auth/signup", handler.Web(handleWebSignup, UserLevelNoneRequired)).Methods("POST")
|
write.HandleFunc("/auth/signup", handler.Web(handleWebSignup, UserLevelNoneRequired)).Methods("POST")
|
||||||
write.HandleFunc("/auth/login", handler.Web(webLogin, UserLevelNoneRequired)).Methods("POST")
|
write.HandleFunc("/auth/login", handler.Web(webLogin, UserLevelNoneRequired)).Methods("POST")
|
||||||
|
@ -221,6 +221,8 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
|
||||||
func RouteCollections(handler *Handler, r *mux.Router) {
|
func RouteCollections(handler *Handler, r *mux.Router) {
|
||||||
r.HandleFunc("/logout", handler.Web(handleLogOutCollection, UserLevelOptional))
|
r.HandleFunc("/logout", handler.Web(handleLogOutCollection, UserLevelOptional))
|
||||||
r.HandleFunc("/page/{page:[0-9]+}", handler.Web(handleViewCollection, UserLevelReader))
|
r.HandleFunc("/page/{page:[0-9]+}", handler.Web(handleViewCollection, UserLevelReader))
|
||||||
|
r.HandleFunc("/archive/", handler.Web(handleViewCollection, UserLevelReader))
|
||||||
|
r.HandleFunc("/{archive:archive}/page/{page:[0-9]+}", handler.Web(handleViewCollection, UserLevelReader))
|
||||||
r.HandleFunc("/lang:{lang:[a-z]{2}}", handler.Web(handleViewCollectionLang, UserLevelOptional))
|
r.HandleFunc("/lang:{lang:[a-z]{2}}", handler.Web(handleViewCollectionLang, UserLevelOptional))
|
||||||
r.HandleFunc("/lang:{lang:[a-z]{2}}/page/{page:[0-9]+}", handler.Web(handleViewCollectionLang, UserLevelOptional))
|
r.HandleFunc("/lang:{lang:[a-z]{2}}/page/{page:[0-9]+}", handler.Web(handleViewCollectionLang, UserLevelOptional))
|
||||||
r.HandleFunc("/tag:{tag}", handler.Web(handleViewCollectionTag, UserLevelReader))
|
r.HandleFunc("/tag:{tag}", handler.Web(handleViewCollectionTag, UserLevelReader))
|
||||||
|
|
|
@ -66,7 +66,7 @@ func handleViewSitemap(app *App, w http.ResponseWriter, r *http.Request) error {
|
||||||
host = c.CanonicalURL()
|
host = c.CanonicalURL()
|
||||||
|
|
||||||
sm := buildSitemap(host, pre)
|
sm := buildSitemap(host, pre)
|
||||||
posts, err := app.db.GetPosts(app.cfg, c, 0, false, false, false)
|
posts, err := app.db.GetPosts(app.cfg, c, 0, false, false, false, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error getting posts: %v", err)
|
log.Error("Error getting posts: %v", err)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ func initTemplate(parentDir, name string) {
|
||||||
filepath.Join(parentDir, templatesDir, "base.tmpl"),
|
filepath.Join(parentDir, templatesDir, "base.tmpl"),
|
||||||
filepath.Join(parentDir, templatesDir, "user", "include", "silenced.tmpl"),
|
filepath.Join(parentDir, templatesDir, "user", "include", "silenced.tmpl"),
|
||||||
}
|
}
|
||||||
if name == "collection" || name == "collection-tags" || name == "chorus-collection" || name == "read" {
|
if name == "collection" || name == "collection-tags" || name == "collection-archive" || name == "chorus-collection" || name == "read" {
|
||||||
// These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl"
|
// These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl"
|
||||||
files = append(files, filepath.Join(parentDir, templatesDir, "include", "posts.tmpl"))
|
files = append(files, filepath.Join(parentDir, templatesDir, "include", "posts.tmpl"))
|
||||||
}
|
}
|
||||||
if name == "chorus-collection" || name == "chorus-collection-post" {
|
if name == "chorus-collection" || name == "chorus-collection-post" {
|
||||||
files = append(files, filepath.Join(parentDir, templatesDir, "user", "include", "header.tmpl"))
|
files = append(files, filepath.Join(parentDir, templatesDir, "user", "include", "header.tmpl"))
|
||||||
}
|
}
|
||||||
if name == "collection" || name == "collection-tags" || name == "collection-post" || name == "post" || name == "chorus-collection" || name == "chorus-collection-post" {
|
if name == "collection" || name == "collection-tags" || name == "collection-archive" || name == "collection-post" || name == "post" || name == "chorus-collection" || name == "chorus-collection-post" {
|
||||||
files = append(files, filepath.Join(parentDir, templatesDir, "include", "post-render.tmpl"))
|
files = append(files, filepath.Join(parentDir, templatesDir, "include", "post-render.tmpl"))
|
||||||
}
|
}
|
||||||
templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles(files...))
|
templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles(files...))
|
||||||
|
|
118
templates/collection-archive.tmpl
Normal file
118
templates/collection-archive.tmpl
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
{{define "collection"}}<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>Archive — {{.Collection.DisplayTitle}}</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="/css/write.css" />
|
||||||
|
{{if .CustomCSS}}<link rel="stylesheet" type="text/css" href="/local/custom.css" />{{end}}
|
||||||
|
<link rel="shortcut icon" href="/favicon.ico" />
|
||||||
|
<link rel="canonical" href="{{.CanonicalURL}}">
|
||||||
|
{{if gt .CurrentPage 1}}<link rel="prev" href="{{.PrevPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">{{end}}
|
||||||
|
{{if lt .CurrentPage .TotalPages}}<link rel="next" href="{{.NextPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">{{end}}
|
||||||
|
{{if not .IsPrivate}}<link rel="alternate" type="application/rss+xml" title="{{.DisplayTitle}} » Feed" href="{{.CanonicalURL}}feed/" />{{end}}
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
<meta name="generator" content="WriteFreely">
|
||||||
|
<meta name="description" content="{{.PlainDescription}}">
|
||||||
|
<meta itemprop="name" content="{{.DisplayTitle}}">
|
||||||
|
<meta itemprop="description" content="{{.PlainDescription}}">
|
||||||
|
<meta name="twitter:card" content="summary">
|
||||||
|
<meta name="twitter:title" content="{{.DisplayTitle}}">
|
||||||
|
<meta name="twitter:image" content="{{.AvatarURL}}">
|
||||||
|
<meta name="twitter:description" content="{{.PlainDescription}}">
|
||||||
|
<meta property="og:title" content="{{.DisplayTitle}}" />
|
||||||
|
<meta property="og:site_name" content="{{.DisplayTitle}}" />
|
||||||
|
<meta property="og:type" content="article" />
|
||||||
|
<meta property="og:url" content="{{.CanonicalURL}}" />
|
||||||
|
<meta property="og:description" content="{{.PlainDescription}}" />
|
||||||
|
<meta property="og:image" content="{{.AvatarURL}}">
|
||||||
|
{{template "collection-meta" .}}
|
||||||
|
{{if .StyleSheet}}<style type="text/css">{{.StyleSheetDisplay}}</style>{{end}}
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body id="subpage">
|
||||||
|
|
||||||
|
<div id="overlay"></div>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<h1 dir="{{.Direction}}" id="blog-title"><a href="{{if .IsTopLevel}}/{{else}}/{{.Collection.Alias}}/{{end}}" class="h-card p-author">{{.Collection.DisplayTitle}}</a></h1>
|
||||||
|
<nav>
|
||||||
|
{{if .PinnedPosts}}
|
||||||
|
{{range .PinnedPosts}}<a class="pinned" href="{{if $.IsOwner}}/{{$.Collection.Alias}}/{{.Slug.String}}{{else}}{{.CanonicalURL}}{{end}}">{{.DisplayTitle}}</a>{{end}}
|
||||||
|
{{end}}
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{{if .Posts -}}
|
||||||
|
<section id="wrapper" class="archive" itemscope itemtype="http://schema.org/Blog">
|
||||||
|
{{- else -}}
|
||||||
|
<div id="wrapper" class="archive">
|
||||||
|
{{- end}}
|
||||||
|
|
||||||
|
<h1>Archive</h1>
|
||||||
|
|
||||||
|
{{if .Flash}}
|
||||||
|
<div class="alert success flash">
|
||||||
|
<p>{{.Flash}}</p>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{{ $curYear := 0 }}
|
||||||
|
{{ range $el := .Posts }}
|
||||||
|
{{if ne $curYear .Created.Year}}<li class="year">{{.Created.Year}}</li>{{ $curYear = .Created.Year }}{{end}}
|
||||||
|
<li>
|
||||||
|
{{if .HasTitleLink -}}
|
||||||
|
{{.HTMLTitleArrow}}
|
||||||
|
{{- else -}}
|
||||||
|
<a href="{{if $.SingleUser}}/{{else}}/{{$.Alias}}/{{end}}{{.Slug.String}}" itemprop="url" class="u-url">
|
||||||
|
{{- if .DisplayTitle -}}
|
||||||
|
{{- .DisplayTitle -}}
|
||||||
|
{{- else -}}
|
||||||
|
(Untitled)
|
||||||
|
{{end}}
|
||||||
|
</a>
|
||||||
|
{{- end}}
|
||||||
|
{{if .IsScheduled}}[Scheduled]{{end}}
|
||||||
|
{{if $.Format.ShowDates -}}
|
||||||
|
<time class="dt-published" datetime="{{.Created8601}}" pubdate itemprop="datePublished" content="{{.Created}}">
|
||||||
|
{{- if .HasTitleLink -}}
|
||||||
|
<a href="{{if $.SingleUser}}/{{else}}/{{$.Alias}}/{{end}}{{.Slug.String}}" itemprop="url">
|
||||||
|
{{- end -}}
|
||||||
|
{{.DisplayDate}}
|
||||||
|
{{- if .HasTitleLink -}}
|
||||||
|
{{- if .IsPaid}}{{template "paid-badge" (dict "CDNHost" $.CDNHost)}}{{end -}}</a>
|
||||||
|
{{- end -}}
|
||||||
|
</time>
|
||||||
|
{{- else -}}
|
||||||
|
{{- if .HasTitleLink -}}
|
||||||
|
<a href="{{if $.SingleUser}}/{{else}}/{{$.Alias}}/{{end}}{{.Slug.String}}" itemprop="url">view</a>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end}}
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{template "paging" .}}
|
||||||
|
|
||||||
|
{{if .Posts}}</section>{{else}}</div>{{end}}
|
||||||
|
|
||||||
|
{{if .ShowFooterBranding }}
|
||||||
|
<footer>
|
||||||
|
<hr />
|
||||||
|
<nav dir="ltr">
|
||||||
|
{{if not .SingleUser}}<a class="home pubd" href="/">{{.SiteName}}</a> · {{end}}powered by <a style="margin-left:0" href="https://writefreely.org">writefreely</a>
|
||||||
|
</nav>
|
||||||
|
</footer>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
{{if .CanShowScript}}
|
||||||
|
{{range .ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
|
||||||
|
{{if .Collection.Script}}<script type="text/javascript">{{.ScriptDisplay}}</script>{{end}}
|
||||||
|
{{end}}
|
||||||
|
<script src="/js/localdate.js"></script>
|
||||||
|
</html>{{end}}
|
|
@ -56,7 +56,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ if and .IsOwner .IsFound }}<span class="views" dir="ltr"><strong>{{largeNumFmt .Views}}</strong> {{pluralize "view" "views" .Views}}</span>
|
{{ if and .IsOwner .IsFound }}<span class="views" dir="ltr"><strong>{{largeNumFmt .Views}}</strong> {{pluralize "view" "views" .Views}}</span>
|
||||||
{{if .Likes}}<span class="views" dir="ltr"><strong>{{largeNumFmt .Likes}}</strong> {{pluralize "like" "likes" .Likes}}</span>{{end}}
|
{{if .Likes}}<span class="views" dir="ltr"><strong>{{largeNumFmt .Likes}}</strong> {{pluralize "like" "likes" .Likes}}</span>{{end}}
|
||||||
<a class="xtra-feature" href="/{{if not .SingleUser}}{{.Collection.Alias}}/{{end}}{{.Slug.String}}/edit" dir="{{.Direction}}">Edit</a>
|
<a href="/{{if not .SingleUser}}{{.Collection.Alias}}/{{end}}{{.Slug.String}}/edit" dir="{{.Direction}}">Edit</a>
|
||||||
{{if .IsPinned}}<a class="xtra-feature unpin" href="/{{.Collection.Alias}}/{{.Slug.String}}/unpin" dir="{{.Direction}}" onclick="unpinPost(event, '{{.ID}}')">Unpin</a>{{end}}
|
{{if .IsPinned}}<a class="xtra-feature unpin" href="/{{.Collection.Alias}}/{{.Slug.String}}/unpin" dir="{{.Direction}}" onclick="unpinPost(event, '{{.ID}}')">Unpin</a>{{end}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -61,4 +61,16 @@
|
||||||
<a class="read-more" href="{{$.CanonicalURL}}{{.Slug.String}}">{{localstr "Read more..." .Language.String}}</a>{{else}}<div {{if .Language}}lang="{{.Language.String}}"{{end}} dir="{{.Direction}}" class="book e-content">{{if and (and (not $.IsOwner) (not $.Format.ShowDates)) (not .Title.String)}}<a class="hidden action" href="{{if $.IsOwner}}/{{$.Alias}}/{{.Slug.String}}{{else}}{{$.CanonicalURL}}{{.Slug.String}}{{end}}">view</a>{{end}}{{.HTMLContent}}</div>{{end}}</article>{{ end }}
|
<a class="read-more" href="{{$.CanonicalURL}}{{.Slug.String}}">{{localstr "Read more..." .Language.String}}</a>{{else}}<div {{if .Language}}lang="{{.Language.String}}"{{end}} dir="{{.Direction}}" class="book e-content">{{if and (and (not $.IsOwner) (not $.Format.ShowDates)) (not .Title.String)}}<a class="hidden action" href="{{if $.IsOwner}}/{{$.Alias}}/{{.Slug.String}}{{else}}{{$.CanonicalURL}}{{.Slug.String}}{{end}}">view</a>{{end}}{{.HTMLContent}}</div>{{end}}</article>{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{define "paid-badge"}}<img class="paid" alt="Paid article" src="/img/paidarticle.svg" /> {{end}}
|
{{define "paid-badge"}}<img class="paid" alt="Paid article" src="/img/paidarticle.svg" /> {{end}}
|
||||||
|
|
||||||
|
{{define "paging"}}
|
||||||
|
{{if gt .TotalPages 1}}<nav id="paging" class="content-container clearfix">
|
||||||
|
{{if or (and .Format.Ascending (le .CurrentPage .TotalPages)) (isRTL .Direction)}}
|
||||||
|
{{if gt .CurrentPage 1}}<a href="{{.PrevPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">⇠ {{if and .Format.Ascending (le .CurrentPage .TotalPages)}}Previous{{else}}Newer{{end}}</a>{{end}}
|
||||||
|
{{if lt .CurrentPage .TotalPages}}<a style="float:right;" href="{{.NextPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">{{if and .Format.Ascending (lt .CurrentPage .TotalPages)}}Next{{else}}Older{{end}} ⇢</a>{{end}}
|
||||||
|
{{else}}
|
||||||
|
{{if lt .CurrentPage .TotalPages}}<a href="{{.NextPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">⇠ Older</a>{{end}}
|
||||||
|
{{if gt .CurrentPage 1}}<a style="float:right;" href="{{.PrevPageURL .Prefix .NavSuffix .CurrentPage .IsTopLevel}}">Newer ⇢</a>{{end}}
|
||||||
|
{{end}}
|
||||||
|
</nav>{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue