Contains the Concourse pipeline definition for building a line-server container
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.

68 lines
1.1 KiB

  1. package main
  2. import (
  3. "bytes"
  4. "io"
  5. "path"
  6. "path/filepath"
  7. "github.com/GeertJohan/go.rice"
  8. "github.com/flosch/pongo2"
  9. )
  10. type Pongo2Loader struct {
  11. box *rice.Box
  12. }
  13. func NewPongo2TemplatesLoader() (*Pongo2Loader, error) {
  14. fs := &Pongo2Loader{}
  15. p2l, err := rice.FindBox("templates")
  16. if err != nil {
  17. return nil, err
  18. }
  19. fs.box = p2l
  20. return fs, nil
  21. }
  22. func (fs *Pongo2Loader) Get(path string) (io.Reader, error) {
  23. myBytes, err := fs.box.Bytes(path)
  24. if err != nil {
  25. return nil, err
  26. }
  27. return bytes.NewReader(myBytes), nil
  28. }
  29. func (fs *Pongo2Loader) Abs(base, name string) string {
  30. me := path.Join(filepath.Dir(base), name)
  31. return me
  32. }
  33. func populateTemplatesMap(tSet *pongo2.TemplateSet, tMap map[string]*pongo2.Template) error {
  34. templates := [...]string{
  35. "index.html",
  36. "404.html",
  37. "401.html",
  38. "oops.html",
  39. "display/audio.html",
  40. "display/image.html",
  41. "display/video.html",
  42. "display/pdf.html",
  43. "display/file.html",
  44. }
  45. for _, tName := range templates {
  46. tpl, err := tSet.FromFile(tName)
  47. if err != nil {
  48. return err
  49. }
  50. tMap[tName] = tpl
  51. }
  52. return nil
  53. }