diff --git a/changelog/unreleased/zmd-mimetype.md b/changelog/unreleased/zmd-mimetype.md new file mode 100644 index 0000000000..1ac29c28d8 --- /dev/null +++ b/changelog/unreleased/zmd-mimetype.md @@ -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 diff --git a/docs/content/en/docs/config/grpc/services/appprovider/_index.md b/docs/content/en/docs/config/grpc/services/appprovider/_index.md index 69b18917b6..52bed33ef3 100644 --- a/docs/content/en/docs/config/grpc/services/appprovider/_index.md +++ b/docs/content/en/docs/config/grpc/services/appprovider/_index.md @@ -9,7 +9,7 @@ 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 = "" @@ -17,7 +17,7 @@ iopsecret = "" {{% /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 = "" diff --git a/examples/ocmd/ocmd-server-1.toml b/examples/ocmd/ocmd-server-1.toml index 7d4fb4f56b..b37a9b2e62 100644 --- a/examples/ocmd/ocmd-server-1.toml +++ b/examples/ocmd/ocmd-server-1.toml @@ -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" diff --git a/internal/grpc/services/appprovider/appprovider.go b/internal/grpc/services/appprovider/appprovider.go index a3bc5463bb..2aa825f480 100644 --- a/internal/grpc/services/appprovider/appprovider.go +++ b/internal/grpc/services/appprovider/appprovider.go @@ -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" @@ -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 @@ -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 }