A webmail client. Forked from https://git.sr.ht/~migadu/alps
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1.1 KiB

  1. // Package exampleplugin is an example Go plugin for alps.
  2. //
  3. // To enable it, import this package from cmd/alps/main.go.
  4. package exampleplugin
  5. import (
  6. "fmt"
  7. "net/http"
  8. "git.sr.ht/~emersion/alps"
  9. alpsbase "git.sr.ht/~emersion/alps/plugins/base"
  10. )
  11. func init() {
  12. p := alps.GoPlugin{Name: "example"}
  13. // Setup a function called when the mailbox view is rendered
  14. p.Inject("mailbox.html", func(ctx *alps.Context, kdata alps.RenderData) error {
  15. data := kdata.(*alpsbase.MailboxRenderData)
  16. fmt.Println("The mailbox view for " + data.Mailbox.Name + " is being rendered")
  17. // Set extra data that can be accessed from the mailbox.html template
  18. data.Extra["Example"] = "Hi from Go"
  19. return nil
  20. })
  21. // Wire up a new route
  22. p.GET("/example", func(ctx *alps.Context) error {
  23. return ctx.String(http.StatusOK, "This is an example page.")
  24. })
  25. // Register a helper function that can be called from templates
  26. p.TemplateFuncs(map[string]interface{}{
  27. "example_and": func(a, b string) string {
  28. return a + " and " + b
  29. },
  30. })
  31. alps.RegisterPluginLoader(p.Loader())
  32. }