Skip to content

Commit

Permalink
✨ Update parka to have single commands and properly watch command dir…
Browse files Browse the repository at this point in the history
…ectory
  • Loading branch information
wesen committed May 9, 2024
1 parent 837ba39 commit faf86c0
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 446 deletions.
19 changes: 10 additions & 9 deletions pkg/glazed/handlers/datatables/datatables.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func WithStreamRows(streamRows bool) QueryHandlerOption {
}

var _ handlers.Handler = &QueryHandler{}
var _ echo.HandlerFunc = (&QueryHandler{}).Handle

func (qh *QueryHandler) Handle(c echo.Context) error {
description := qh.cmd.Description()
Expand Down Expand Up @@ -362,41 +363,41 @@ func (qh *QueryHandler) renderTemplate(

func CreateDataTablesHandler(
cmd cmds.GlazeCommand,
path string,
commandPath string,
basePath string,
downloadPath string,
options ...QueryHandlerOption,
) echo.HandlerFunc {
return func(c echo.Context) error {
name := cmd.Description().Name
dateTime := time.Now().Format("2006-01-02--15-04-05")
links := []layout.Link{
{
Href: fmt.Sprintf("%s/download/%s/%s-%s.csv", path, commandPath, dateTime, name),
Href: fmt.Sprintf("%s/%s-%s.csv", downloadPath, dateTime, name),
Text: "Download CSV",
Class: "download",
},
{
Href: fmt.Sprintf("%s/download/%s/%s-%s.json", path, commandPath, dateTime, name),
Href: fmt.Sprintf("%s/%s-%s.json", downloadPath, dateTime, name),
Text: "Download JSON",
Class: "download",
},
{
Href: fmt.Sprintf("%s/download/%s/%s-%s.xlsx", path, commandPath, dateTime, name),
Href: fmt.Sprintf("%s/%s-%s.xlsx", downloadPath, dateTime, name),
Text: "Download Excel",
Class: "download",
},
{
Href: fmt.Sprintf("%s/download/%s/%s-%s.md", path, commandPath, dateTime, name),
Href: fmt.Sprintf("%s/%s-%s.md", downloadPath, dateTime, name),
Text: "Download Markdown",
Class: "download",
},
{
Href: fmt.Sprintf("%s/download/%s/%s-%s.html", path, commandPath, dateTime, name),
Href: fmt.Sprintf("%s/%s-%s.html", downloadPath, dateTime, name),
Text: "Download HTML",
Class: "download",
},
{
Href: fmt.Sprintf("%s/download/%s/%s-%s.txt", path, commandPath, dateTime, name),
Href: fmt.Sprintf("%s/%s-%s.txt", downloadPath, dateTime, name),
Text: "Download Text",
Class: "download",
},
Expand All @@ -405,7 +406,7 @@ func CreateDataTablesHandler(
dt := NewDataTables()
dt.Command = cmd.Description()
dt.Links = links
dt.BasePath = path
dt.BasePath = basePath
dt.JSRendering = true
dt.UseDataTables = false

Expand Down
Loading

0 comments on commit faf86c0

Please sign in to comment.