Upgraded to latest aero version
This commit is contained in:
@ -1,10 +0,0 @@
|
||||
package utils
|
||||
|
||||
import "github.com/aerogo/aero"
|
||||
|
||||
// AllowEmbed allows the page to be called by the browser extension.
|
||||
func AllowEmbed(ctx *aero.Context, response string) string {
|
||||
// This is a bit of a hack.
|
||||
// ctx.SetResponseHeader("X-Frame-Options", "ALLOW-FROM chrome-extension://hjfcooigdelogjmniiahfiilcefdlpha/options.html")
|
||||
return response
|
||||
}
|
@ -6,8 +6,8 @@ import (
|
||||
|
||||
// GetContainerClass returns the class for the "container" element.
|
||||
// In the browser extension it will get the "embedded" class.
|
||||
func GetContainerClass(ctx *aero.Context) string {
|
||||
if ctx.URI() == "/extension/embed" {
|
||||
func GetContainerClass(ctx aero.Context) string {
|
||||
if ctx.Path() == "/extension/embed" {
|
||||
return "embedded"
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// GetUser returns the logged in user for the given context.
|
||||
func GetUser(ctx *aero.Context) *arn.User {
|
||||
func GetUser(ctx aero.Context) *arn.User {
|
||||
return arn.GetUserFromContext(ctx)
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
)
|
||||
|
||||
// SmartRedirect automatically adds the /_ prefix to the URI if required.
|
||||
func SmartRedirect(ctx *aero.Context, uri string) string {
|
||||
func SmartRedirect(ctx aero.Context, uri string) error {
|
||||
// Redirect
|
||||
prefix := ""
|
||||
|
||||
if strings.HasPrefix(ctx.URI(), "/_") {
|
||||
if strings.HasPrefix(ctx.Path(), "/_") {
|
||||
prefix = "/_"
|
||||
}
|
||||
|
||||
return ctx.Redirect(prefix + uri)
|
||||
return ctx.Redirect(http.StatusFound, prefix+uri)
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// Handler returns a function that renders the history of any object.
|
||||
func Handler(render func(interface{}, []*arn.EditLogEntry, *arn.User) string, typeNames ...string) func(ctx *aero.Context) string {
|
||||
return func(ctx *aero.Context) string {
|
||||
func Handler(render func(interface{}, []*arn.EditLogEntry, *arn.User) string, typeNames ...string) func(ctx aero.Context) error {
|
||||
return func(ctx aero.Context) error {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
obj, err := arn.DB.Get(typeNames[0], id)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// NextIndex calculates the next index and sends HTTP header
|
||||
func NextIndex(ctx *aero.Context, allElementsLength int, elementsPerScroll int, index int) int {
|
||||
func NextIndex(ctx aero.Context, allElementsLength int, elementsPerScroll int, index int) int {
|
||||
nextIndex := index + elementsPerScroll
|
||||
|
||||
if nextIndex >= allElementsLength {
|
||||
@ -15,7 +15,7 @@ func NextIndex(ctx *aero.Context, allElementsLength int, elementsPerScroll int,
|
||||
}
|
||||
|
||||
// Send the index for the next request
|
||||
ctx.Response().Header().Set("X-LoadMore-Index", strconv.Itoa(nextIndex))
|
||||
ctx.Response().SetHeader("X-LoadMore-Index", strconv.Itoa(nextIndex))
|
||||
|
||||
return nextIndex
|
||||
}
|
||||
|
Reference in New Issue
Block a user