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.

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