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.

71 lines
1.1 KiB

9 years ago
  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. "paste.html",
  37. "API.html",
  38. "404.html",
  39. "401.html",
  40. "oops.html",
  41. "display/audio.html",
  42. "display/image.html",
  43. "display/video.html",
  44. "display/pdf.html",
  45. "display/bin.html",
  46. "display/md.html",
  47. "display/file.html",
  48. }
  49. for _, tName := range templates {
  50. tpl, err := tSet.FromFile(tName)
  51. if err != nil {
  52. return err
  53. }
  54. tMap[tName] = tpl
  55. }
  56. return nil
  57. }