Skip to content

Commit

Permalink
Add support for a custom CodiMD mimetype (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern authored Oct 8, 2020
1 parent 48f922a commit 3645f8b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/zmd-mimetype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: add support for custom CodiMD mimetype

The new mimetype is associated with the `.zmd` file extension.

https://github.com/cs3org/reva/pull/1233
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ description: >
# _struct: config_

{{% dir name="iopsecret" type="string" default="" %}}
The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L58)
The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L62)
{{< highlight toml >}}
[grpc.services.appprovider]
iopsecret = ""
{{< /highlight >}}
{{% /dir %}}

{{% dir name="wopiurl" type="string" default="" %}}
The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L59)
The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L63)
{{< highlight toml >}}
[grpc.services.appprovider]
wopiurl = ""
Expand Down
4 changes: 4 additions & 0 deletions examples/ocmd/ocmd-server-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ driver = "demo"
iopsecret = "testsecret"
wopiurl = "http://0.0.0.0:8880/"

[grpc.services.appprovider.mimetypes]
".zmd" = "application/compressed-markdown"

[grpc.services.appregistry]
driver = "static"

[grpc.services.appregistry.static.rules]
"text/plain" = "localhost:19000"
"text/markdown" = "localhost:19000"
"application/compressed-markdown" = "localhost:19000"
"application/vnd.oasis.opendocument.text" = "localhost:19000"
"application/vnd.oasis.opendocument.spreadsheet" = "localhost:19000"
"application/vnd.oasis.opendocument.presentation" = "localhost:19000"
Expand Down
11 changes: 10 additions & 1 deletion internal/grpc/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/cs3org/reva/pkg/app"
"github.com/cs3org/reva/pkg/app/provider/demo"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/mime"
"github.com/cs3org/reva/pkg/rgrpc"
"github.com/cs3org/reva/pkg/rgrpc/status"
"github.com/cs3org/reva/pkg/rhttp"
Expand All @@ -57,16 +58,18 @@ type config struct {
Demo map[string]interface{} `mapstructure:"demo"`
IopSecret string `mapstructure:"iopsecret" docs:";The iopsecret used to connect to the wopiserver."`
WopiURL string `mapstructure:"wopiurl" docs:";The wopiserver's URL."`
MimeTypes map[string]string `mapstructure:"mimetypes"`
}

// New creates a new AppProviderService
func New(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error) {

c, err := parseConfig(m)
if err != nil {
return nil, err
}

registerMimeTypes(c.MimeTypes)

provider, err := getProvider(c)
if err != nil {
return nil, err
Expand All @@ -88,6 +91,12 @@ func parseConfig(m map[string]interface{}) (*config, error) {
return c, nil
}

func registerMimeTypes(mimes map[string]string) {
for k, v := range mimes {
mime.RegisterMime(k, v)
}
}

func (s *service) Close() error {
return nil
}
Expand Down

0 comments on commit 3645f8b

Please sign in to comment.