no longer require go-bindata, which was abandoned
however, go 1.16 is now required (it is quite ancient anyway at this point)
This commit is contained in:
parent
ff1eba5b42
commit
6c5add0b2c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
dist
|
dist
|
||||||
server/memelibrary/assets.go
|
|
||||||
|
|
|
@ -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.
|
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:
|
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`
|
`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.)
|
||||||
|
|
|
@ -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/...
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
||||||
module github.com/mattermost/mattermost-plugin-memes
|
module github.com/mattermost/mattermost-plugin-memes
|
||||||
|
|
||||||
go 1.12
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||||
|
|
31
server/memelibrary/assets.go
Normal file
31
server/memelibrary/assets.go
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -132,7 +132,6 @@ func serveTemplatePNG(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
plugin.MattermostPlugin
|
plugin.MattermostPlugin
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue