Cleanup
This commit is contained in:
parent
3a3a89ef0e
commit
453f6cdbb0
14
email.go
14
email.go
@ -1,14 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// HTMLEmailRenderer uses pixy templates to render the HTML for our emails.
|
||||
type HTMLEmailRenderer struct{}
|
||||
|
||||
// Notification renders a notification email.
|
||||
func (writer *HTMLEmailRenderer) Notification(notification *arn.Notification) string {
|
||||
return components.NotificationEmail(notification)
|
||||
}
|
8
main.go
8
main.go
@ -12,6 +12,8 @@ import (
|
||||
"github.com/animenotifier/notify.moe/graphql"
|
||||
"github.com/animenotifier/notify.moe/middleware"
|
||||
"github.com/animenotifier/notify.moe/pages"
|
||||
"github.com/animenotifier/notify.moe/utils/htmlemail"
|
||||
"github.com/animenotifier/notify.moe/utils/https"
|
||||
"github.com/animenotifier/notify.moe/utils/routetests"
|
||||
)
|
||||
|
||||
@ -32,7 +34,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.ContentSecurityPolicy.Set("font-src", "https: data:")
|
||||
|
||||
// Security
|
||||
configureHTTPS(app)
|
||||
https.Configure(app)
|
||||
|
||||
// Assets
|
||||
assets.Configure(app)
|
||||
@ -41,7 +43,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
pages.Configure(app)
|
||||
|
||||
// Rewrite
|
||||
app.Rewrite(rewrite)
|
||||
app.Rewrite(pages.Rewrite)
|
||||
|
||||
// Middleware
|
||||
app.Use(
|
||||
@ -82,7 +84,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
})
|
||||
|
||||
// Emails
|
||||
arn.HTMLEmailRenderer = &HTMLEmailRenderer{}
|
||||
arn.HTMLEmailRenderer = &htmlemail.Renderer{}
|
||||
|
||||
// Check that this is the server
|
||||
if !arn.Node.IsServer() && !arn.IsTest() {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/pages/index/amvroutes"
|
||||
"github.com/animenotifier/notify.moe/pages/index/animeroutes"
|
||||
@ -48,3 +50,29 @@ func Configure(app *aero.Application) {
|
||||
// app.Get("/database", database.Get)
|
||||
// app.Get("/api/select/:data-type/where/:field/is/:field-value", database.Select)
|
||||
}
|
||||
|
||||
// Rewrite will rewrite the path before routing happens.
|
||||
func Rewrite(ctx aero.RewriteContext) {
|
||||
requestURI := ctx.Path()
|
||||
|
||||
// User profiles
|
||||
if strings.HasPrefix(requestURI, "/+") {
|
||||
newURI := "/user/"
|
||||
userName := requestURI[2:]
|
||||
ctx.SetPath(newURI + userName)
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(requestURI, "/_/+") {
|
||||
newURI := "/_/user/"
|
||||
userName := requestURI[4:]
|
||||
ctx.SetPath(newURI + userName)
|
||||
return
|
||||
}
|
||||
|
||||
// Analytics
|
||||
if requestURI == "/dark-flame-master" {
|
||||
ctx.SetPath("/api/new/analytics")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
33
rewrite.go
33
rewrite.go
@ -1,33 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
)
|
||||
|
||||
// rewrite will rewrite certain routes
|
||||
func rewrite(ctx aero.RewriteContext) {
|
||||
requestURI := ctx.Path()
|
||||
|
||||
// User profiles
|
||||
if strings.HasPrefix(requestURI, "/+") {
|
||||
newURI := "/user/"
|
||||
userName := requestURI[2:]
|
||||
ctx.SetPath(newURI + userName)
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(requestURI, "/_/+") {
|
||||
newURI := "/_/user/"
|
||||
userName := requestURI[4:]
|
||||
ctx.SetPath(newURI + userName)
|
||||
return
|
||||
}
|
||||
|
||||
// Analytics
|
||||
if requestURI == "/dark-flame-master" {
|
||||
ctx.SetPath("/api/new/analytics")
|
||||
return
|
||||
}
|
||||
}
|
14
utils/htmlemail/Renderer.go
Normal file
14
utils/htmlemail/Renderer.go
Normal file
@ -0,0 +1,14 @@
|
||||
package htmlemail
|
||||
|
||||
import (
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Renderer uses pixy templates to render the HTML for our emails.
|
||||
type Renderer struct{}
|
||||
|
||||
// Notification renders a notification email.
|
||||
func (writer *Renderer) Notification(notification *arn.Notification) string {
|
||||
return components.NotificationEmail(notification)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package https
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -9,7 +9,8 @@ import (
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
func configureHTTPS(app *aero.Application) {
|
||||
// Configure loads the certificates.
|
||||
func Configure(app *aero.Application) {
|
||||
fullCertPath := path.Join(arn.Root, "security", "fullchain.pem")
|
||||
fullKeyPath := path.Join(arn.Root, "security", "privkey.pem")
|
||||
|
Loading…
Reference in New Issue
Block a user