diff --git a/.gitignore b/.gitignore index ab5460b..1521c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ dist -server/memelibrary/assets.go diff --git a/README.md b/README.md index fa31990..8a745ab 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,8 @@ In Mattermost 5.15 and earlier, follow these steps: Read our documentation about the [Developer Workflow](https://developers.mattermost.com/extend/plugins/developer-workflow/) and [Developer Setup](https://developers.mattermost.com/extend/plugins/developer-setup/) for more information about developing and extending plugins. -Run `make memelibrary` to bundle up the meme assets (images, fonts, etc.). - For convenience, you can run the plugin from your terminal to preview an image for a given input. For example, on macOS, you can run the following to generate the above meme and open it in Preview: `go run server/plugin.go -out demo.jpg 'memes. memes everywhere' && open demo.jpg` -This is especially useful when adding or modifying memes as you can quickly modify assets, `make memelibrary`, and preview the result using the above command. (See the files in ` memelibrary/assets` to get started with that.) +This is especially useful when adding or modifying memes as you can quickly modify assets, and preview the result using the above command. (See the files in ` memelibrary/assets` to get started with that.) diff --git a/build/custom.mk b/build/custom.mk deleted file mode 100644 index 78d2d48..0000000 --- a/build/custom.mk +++ /dev/null @@ -1,7 +0,0 @@ -# Include custom targets and environment variables here - -.DEFAULT_GOAL := all - -memelibrary: $(shell find server/memelibrary/assets) - env GO111MODULE=off $(GO) get github.com/jteeuwen/go-bindata/... - $(GOPATH)/bin/go-bindata -o server/memelibrary/assets.go -pkg memelibrary -prefix server/memelibrary/assets/ -ignore '(^|/)\..*' server/memelibrary/assets/... diff --git a/go.mod b/go.mod index ad80ee0..1d413f1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mattermost/mattermost-plugin-memes -go 1.12 +go 1.16 require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 diff --git a/server/memelibrary/assets.go b/server/memelibrary/assets.go new file mode 100644 index 0000000..7d38ae8 --- /dev/null +++ b/server/memelibrary/assets.go @@ -0,0 +1,31 @@ +package memelibrary + +import ( + "embed" + "path" +) + +//go:embed assets +var content embed.FS + +func AssetDir(name string) ([]string, error) { + entries, err := content.ReadDir(path.Join("assets", name)) + if err != nil { + return nil, err + } + + files := make([]string, len(entries)) + for i, entry := range entries { + files[i] = entry.Name() + } + + return files, nil +} + +func MustAsset(name string) []byte { + data, err := content.ReadFile(path.Join("assets", name)) + if err != nil { + panic(err) + } + return data +} diff --git a/server/plugin.go b/server/plugin.go index 1e2f298..2cd49fa 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -132,7 +132,6 @@ func serveTemplatePNG(w http.ResponseWriter, r *http.Request) { } } - type Plugin struct { plugin.MattermostPlugin