Browse Source

Add text/asciidoc mimetype

Ref https://docs.asciidoctor.org/asciidoc/latest/faq/#whats-the-media-type-aka-mime-type-for-asciidoc

This is step 1 towards allowing editing of AsciiDoc files in Nextcloud.
Step 2 is adding support in https://github.com/nextcloud/text.

Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com>
Bjørn Forsman 1 year ago
parent
commit
582f07c8fc
2 changed files with 15 additions and 0 deletions
  1. 13 0
      lib/private/Repair/RepairMimeTypes.php
  2. 2 0
      resources/config/mimetypemapping.dist.json

+ 13 - 0
lib/private/Repair/RepairMimeTypes.php

@@ -106,6 +106,15 @@ class RepairMimeTypes implements IRepairStep {
 		return $count;
 	}
 
+	private function introduceAsciidocType() {
+		$updatedMimetypes = [
+			'adoc' => 'text/asciidoc',
+			'asciidoc' => 'text/asciidoc',
+		];
+
+		return $this->updateMimetypes($updatedMimetypes);
+	}
+
 	private function introduceImageTypes() {
 		$updatedMimetypes = [
 			'jp2' => 'image/jp2',
@@ -273,5 +282,9 @@ class RepairMimeTypes implements IRepairStep {
 		if (version_compare($ocVersionFromBeforeUpdate, '25.0.0.2', '<') && $this->introduceOnlyofficeFormType()) {
 			$out->info('Fixed ONLYOFFICE Forms OpenXML mime types');
 		}
+
+		if (version_compare($ocVersionFromBeforeUpdate, '26.0.0.1', '<') && $this->introduceAsciidocType()) {
+			$out->info('Fixed AsciiDoc mime types');
+		}
 	}
 }

+ 2 - 0
resources/config/mimetypemapping.dist.json

@@ -10,9 +10,11 @@
 	"3gp": ["video/3gpp"],
 	"7z": ["application/x-7z-compressed"],
 	"accdb": ["application/msaccess"],
+	"adoc": ["text/asciidoc", "text/plain"],
 	"ai": ["application/illustrator"],
 	"apk": ["application/vnd.android.package-archive"],
 	"arw": ["image/x-dcraw"],
+	"asciidoc": ["text/asciidoc", "text/plain"],
 	"avi": ["video/x-msvideo"],
 	"bash": ["text/x-shellscript"],
 	"bat": ["application/x-msdos-program"],