Skip to content

Commit

Permalink
Scripting and UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleu committed Sep 4, 2023
1 parent 63f82e2 commit ba899b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/lib/scripting/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
package scripting

import (
"context"
"path/filepath"
"strings"

"github.com/samber/lo"

"github.com/kyleu/npn/app/lib/filesystem"
"github.com/kyleu/npn/app/lib/filter"
"github.com/kyleu/npn/app/lib/search/result"
"github.com/kyleu/npn/app/util"
)

Expand Down Expand Up @@ -67,3 +70,14 @@ func (s *Service) Size(scr string) int {
}
return int(st.Size)
}

func (s *Service) SearchScripts(ctx context.Context, ps filter.ParamSet, q string, logger util.Logger) (result.Results, error) {

Check warning on line 74 in app/lib/scripting/service.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
return lo.FilterMap(s.ListScripts(logger), func(fn string, _ int) (*result.Result, bool) {
scr, _ := s.LoadScript(fn, logger)
res := result.NewResult("script", fn, "/admin/scripting/"+fn, fn, "file-code", scr, scr, q)
if len(res.Matches) > 0 {
return res, true
}
return nil, false
}), nil
}

0 comments on commit ba899b5

Please sign in to comment.