-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4882 from cs3org/appprovider-templates
feat: indicate templates for weboffice
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enhancement: Indicate template conversion capabilties on apps | ||
|
||
We added information to the available app providers to indicate which mimetypes can be used for template conversion. | ||
|
||
https://github.com/cs3org/reva/pull/4882 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package appprovider | ||
|
||
import ( | ||
"strings" | ||
|
||
appregistry "github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1" | ||
) | ||
|
||
type TemplateList struct { | ||
Templates map[string][]Template `json:"templates"` | ||
} | ||
|
||
type Template struct { | ||
Extension string `json:"extension"` | ||
MimeType string `json:"mime_type"` | ||
TargetExtension string `json:"target_extension"` | ||
} | ||
|
||
var tl = TemplateList{ | ||
Templates: map[string][]Template{ | ||
"collabora": { | ||
{ | ||
MimeType: "application/vnd.oasis.opendocument.spreadsheet-template", | ||
TargetExtension: "ods", | ||
}, | ||
{ | ||
MimeType: "application/vnd.oasis.opendocument.text-template", | ||
TargetExtension: "odt", | ||
}, | ||
{ | ||
MimeType: "application/vnd.oasis.opendocument.presentation-template", | ||
TargetExtension: "odp", | ||
}, | ||
}, | ||
"onlyoffice": { | ||
{ | ||
MimeType: "application/vnd.ms-word.template.macroenabled.12", | ||
TargetExtension: "docx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.oasis.opendocument.text-template", | ||
TargetExtension: "docx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.template", | ||
TargetExtension: "docx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.oasis.opendocument.spreadsheet-template", | ||
TargetExtension: "xlsx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.ms-excel.template.macroenabled.12", | ||
TargetExtension: "xlsx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.template", | ||
TargetExtension: "xlsx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.oasis.opendocument.presentation-template", | ||
TargetExtension: "pptx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.ms-powerpoint.template.macroenabled.12", | ||
TargetExtension: "pptx", | ||
}, | ||
{ | ||
MimeType: "application/vnd.openxmlformats-officedocument.presentationml.template", | ||
TargetExtension: "pptx", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func addTemplateInfo(mt *appregistry.MimeTypeInfo, apps []*ProviderInfo) { | ||
for _, app := range apps { | ||
if tls, ok := tl.Templates[strings.ToLower(app.Name)]; ok { | ||
for _, tmpl := range tls { | ||
if tmpl.Extension != "" && tmpl.Extension == mt.Ext { | ||
app.TargetExt = tmpl.TargetExtension | ||
continue | ||
} | ||
if tmpl.MimeType == mt.MimeType { | ||
app.TargetExt = tmpl.TargetExtension | ||
} | ||
} | ||
} | ||
} | ||
} |