Skip to content

Commit

Permalink
Bootstrap channel export plugin
Browse files Browse the repository at this point in the history
- Delete the webapp directory, as for now, we only need the server part
- Adapt plugin.json and regenerates server/manifest.go
- Add mattermost-plugin-api dependency
- Adapt README from the starter template
  • Loading branch information
agarciamontoro committed Mar 16, 2020
1 parent 05e0077 commit afbe545
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 16,598 deletions.
53 changes: 6 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
# Plugin Starter Template [![CircleCI branch](https://img.shields.io/circleci/project/github/mattermost/mattermost-plugin-starter-template/master.svg)](https://circleci.com/gh/mattermost/mattermost-plugin-starter-template)
# Mattermost Channel Export Plugin

This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.

To learn more about plugins, see [our plugin documentation](https://developers.mattermost.com/extend/plugins/).
This plugin allows channel export into a human readable format.

## Getting Started
Use GitHub's template feature to make a copy of this repository by clicking the "Use this template" button then clone outside of `$GOPATH`.

Alternatively shallow clone the repository to a directory outside of `$GOPATH` matching your plugin name:
Clone the repository to a directory outside of `$GOPATH`
```
git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template com.example.my-plugin
git clone https://github.com/agarciamontoro/mattermost-plugin-channel-export.git
```

Note that this project uses [Go modules](https://github.com/golang/go/wiki/Modules). Be sure to locate the project outside of `$GOPATH`, or allow the use of Go modules within your `$GOPATH` with an `export GO111MODULE=on`.

Edit `plugin.json` with your `id`, `name`, and `description`:
```
{
"id": "com.example.my-plugin",
"name": "My Plugin",
"description": "A plugin to enhance Mattermost."
}
```

Build your plugin:
Build the plugin:
```
make
```

This will produce a single plugin file (with support for multiple architectures) for upload to your Mattermost server:

```
dist/com.example.my-plugin.tar.gz
dist/com.mattermost.plugin-channel-export
```

There is a build target to automate deploying and enabling the plugin to your server, but it requires login credentials:
Expand All @@ -52,32 +40,3 @@ make deploy
Alternatively, if you are running your `mattermost-server` out of a sibling directory by the same name, use the `deploy` target alone to unpack the files into the right directory. You will need to restart your server and manually enable your plugin.

In production, deploy and upload your plugin via the [System Console](https://about.mattermost.com/default-plugin-uploads).

## Q&A

### How do I make a server-only or web app-only plugin?

Simply delete the `server` or `webapp` folders and remove the corresponding sections from `plugin.json`. The build scripts will skip the missing portions automatically.

### How do I include assets in the plugin bundle?

Place them into the `assets` directory. To use an asset at runtime, build the path to your asset and open as a regular file:

```go
bundlePath, err := p.API.GetBundlePath()
if err != nil {
return errors.Wrap(err, "failed to get bundle path")
}

profileImage, err := ioutil.ReadFile(filepath.Join(bundlePath, "assets", "profile_image.png"))
if err != nil {
return errors.Wrap(err, "failed to read profile image")
}

if appErr := p.API.SetProfileImage(userID, profileImage); appErr != nil {
return errors.Wrap(err, "failed to set profile image")
}
```

### How do I build the plugin with unminified JavaScript?
Use `make debug-dist` and `make debug-deploy` in place of `make dist` and `make deploy` to configure webpack to generate unminified Javascript.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/mattermost/mattermost-plugin-starter-template
go 1.12

require (
github.com/mattermost/mattermost-server/v5 v5.20.0
github.com/mattermost/mattermost-plugin-api v0.0.9
github.com/mattermost/mattermost-server/v5 v5.3.2-0.20200313113657-e2883bfe5f37
github.com/mholt/archiver/v3 v3.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1
Expand Down
232 changes: 173 additions & 59 deletions go.sum

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "com.mattermost.plugin-starter-template",
"name": "Plugin Starter Template",
"description": "This plugin serves as a starting point for writing a Mattermost plugin.",
"id": "com.mattermost.plugin-channel-export",
"name": "Channel Export",
"description": "This plugin allows channel export into a human readable format.",
"version": "0.1.0",
"min_server_version": "5.12.0",
"server": {
Expand All @@ -11,9 +11,6 @@
"windows-amd64": "server/dist/plugin-windows-amd64.exe"
}
},
"webapp": {
"bundle_path": "webapp/dist/main.js"
},
"settings_schema": {
"header": "",
"footer": "",
Expand Down
9 changes: 3 additions & 6 deletions server/manifest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit afbe545

Please sign in to comment.