Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a custom CodiMD mimetype #1233

Merged
merged 6 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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