mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 16:40:08 -03:00
Added mymeType.gold
This commit is contained in:
parent
ea819f58c2
commit
b2fe3f69ce
@ -47,10 +47,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if relativePath == "." {
|
if relativePath == "." {
|
||||||
var buff bytes.Buffer
|
return printFileAnalysis(root)
|
||||||
printFile(root, &buff)
|
|
||||||
fmt.Print(buff.String())
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
@ -155,33 +152,36 @@ func printPercents(out map[string][]string, buff *bytes.Buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printFile(file string, buff *bytes.Buffer) {
|
func printFileAnalysis(file string) string {
|
||||||
content, err := ioutil.ReadFile(file)
|
content, err := ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
totalLines, sloc := getLines(file, content)
|
totalLines, linesOfCode := getLines(file, string(content))
|
||||||
fileType := getFileType(file, content)
|
fileType := getFileType(file, content)
|
||||||
language := enry.GetLanguage(file, content)
|
language := enry.GetLanguage(file, content)
|
||||||
mimeType := enry.GetMimeType(language)
|
mimeType := enry.GetMimeType(language)
|
||||||
|
|
||||||
buff.WriteString(fmt.Sprintf("%s: %d lines (%d sloc)\n", filepath.Base(file), totalLines, sloc))
|
return fmt.Sprintf(
|
||||||
buff.WriteString(fmt.Sprintf(" type: %s\n", fileType))
|
`%s: %d lines (%d sloc)
|
||||||
buff.WriteString(fmt.Sprintf(" mime type: %s\n", mimeType))
|
type: %s
|
||||||
buff.WriteString(fmt.Sprintf(" language: %s\n", language))
|
mime_type: %s
|
||||||
|
language: %s
|
||||||
|
`,
|
||||||
|
filepath.Base(file), totalLines, linesOfCode, fileType, mimeType, language)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLines(file string, content []byte) (int, int) {
|
func getLines(file string, content string) (int, int) {
|
||||||
|
|
||||||
totalLines := bytes.Count(content, []byte("\n"))
|
totalLines := strings.Count(content, "\n")
|
||||||
sloc := totalLines - strings.Count(string(content), "\n\n")
|
linesOfCode := totalLines - strings.Count(content, "\n\n")
|
||||||
|
|
||||||
return totalLines, sloc
|
return totalLines, linesOfCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFileType(file string, content []byte) string {
|
func getFileType(file string, content []byte) string {
|
||||||
switch {
|
switch {
|
||||||
case isImage(file):
|
case enry.IsImage(file):
|
||||||
return "Image"
|
return "Image"
|
||||||
case enry.IsBinary(content):
|
case enry.IsBinary(content):
|
||||||
return "Binary"
|
return "Binary"
|
||||||
@ -190,15 +190,6 @@ func getFileType(file string, content []byte) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isImage(file string) bool {
|
|
||||||
index := strings.LastIndex(file, ".")
|
|
||||||
extension := file[index:]
|
|
||||||
if extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".gif" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeStringLn(s string, buff *bytes.Buffer) {
|
func writeStringLn(s string, buff *bytes.Buffer) {
|
||||||
buff.WriteString(s)
|
buff.WriteString(s)
|
||||||
buff.WriteByte('\n')
|
buff.WriteByte('\n')
|
||||||
|
647
data/mimeType.go
647
data/mimeType.go
@ -5,457 +5,200 @@ package data
|
|||||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||||
|
|
||||||
var LanguagesMime = map[string]string{
|
var LanguagesMime = map[string]string{
|
||||||
"1C Enterprise": "",
|
"AGS Script": "text/x-c++src",
|
||||||
"ABAP": "",
|
"APL": "text/apl",
|
||||||
"ABNF": "",
|
"ASN.1": "text/x-ttcn-asn",
|
||||||
"AGS Script": "text/x-c++src",
|
"ASP": "application/x-aspx",
|
||||||
"AMPL": "",
|
"Alpine Abuild": "text/x-sh",
|
||||||
"ANTLR": "",
|
"Ant Build System": "application/xml",
|
||||||
"API Blueprint": "",
|
"Apex": "text/x-java",
|
||||||
"APL": "text/apl",
|
"Arduino": "text/x-c++src",
|
||||||
"ASN.1": "text/x-ttcn-asn",
|
"Brainfuck": "text/x-brainfuck",
|
||||||
"ASP": "application/x-aspx",
|
"C": "text/x-csrc",
|
||||||
"ATS": "",
|
"C#": "text/x-csharp",
|
||||||
"ActionScript": "",
|
"C++": "text/x-c++src",
|
||||||
"Ada": "",
|
"C2hs Haskell": "text/x-haskell",
|
||||||
"Agda": "",
|
"CMake": "text/x-cmake",
|
||||||
"Alloy": "",
|
"COBOL": "text/x-cobol",
|
||||||
"Alpine Abuild": "text/x-sh",
|
"COLLADA": "text/xml",
|
||||||
"Ant Build System": "application/xml",
|
"CSON": "text/x-coffeescript",
|
||||||
"ApacheConf": "",
|
"CSS": "text/css",
|
||||||
"Apex": "text/x-java",
|
"ChucK": "text/x-java",
|
||||||
"Apollo Guidance Computer": "",
|
"Clojure": "text/x-clojure",
|
||||||
"AppleScript": "",
|
"Closure Templates": "text/x-soy",
|
||||||
"Arc": "",
|
"CoffeeScript": "text/x-coffeescript",
|
||||||
"Arduino": "text/x-c++src",
|
"Common Lisp": "text/x-common-lisp",
|
||||||
"AsciiDoc": "",
|
"Component Pascal": "text/x-pascal",
|
||||||
"AspectJ": "",
|
"Crystal": "text/x-crystal",
|
||||||
"Assembly": "",
|
"Cuda": "text/x-c++src",
|
||||||
"Augeas": "",
|
"Cycript": "text/javascript",
|
||||||
"AutoHotkey": "",
|
"Cython": "text/x-cython",
|
||||||
"AutoIt": "",
|
"D": "text/x-d",
|
||||||
"Awk": "",
|
"DTrace": "text/x-csrc",
|
||||||
"Batchfile": "",
|
"Dart": "application/dart",
|
||||||
"Befunge": "",
|
"Diff": "text/x-diff",
|
||||||
"Bison": "",
|
"Dockerfile": "text/x-dockerfile",
|
||||||
"BitBake": "",
|
"Dylan": "text/x-dylan",
|
||||||
"Blade": "",
|
"EBNF": "text/x-ebnf",
|
||||||
"BlitzBasic": "",
|
"ECL": "text/x-ecl",
|
||||||
"BlitzMax": "",
|
"EQ": "text/x-csharp",
|
||||||
"Bluespec": "",
|
"Eagle": "text/xml",
|
||||||
"Boo": "",
|
"Easybuild": "text/x-python",
|
||||||
"Brainfuck": "text/x-brainfuck",
|
"Ecere Projects": "application/json",
|
||||||
"Brightscript": "",
|
"Eiffel": "text/x-eiffel",
|
||||||
"Bro": "",
|
"Elm": "text/x-elm",
|
||||||
"C": "text/x-csrc",
|
"Emacs Lisp": "text/x-common-lisp",
|
||||||
"C#": "text/x-csharp",
|
"EmberScript": "text/x-coffeescript",
|
||||||
"C++": "text/x-c++src",
|
"Erlang": "text/x-erlang",
|
||||||
"C-ObjDump": "",
|
"F#": "text/x-fsharp",
|
||||||
"C2hs Haskell": "text/x-haskell",
|
"Factor": "text/x-factor",
|
||||||
"CLIPS": "",
|
"Forth": "text/x-forth",
|
||||||
"CMake": "text/x-cmake",
|
"Fortran": "text/x-fortran",
|
||||||
"COBOL": "text/x-cobol",
|
|
||||||
"COLLADA": "text/xml",
|
|
||||||
"CSON": "text/x-coffeescript",
|
|
||||||
"CSS": "text/css",
|
|
||||||
"CSV": "",
|
|
||||||
"CWeb": "",
|
|
||||||
"Cap'n Proto": "",
|
|
||||||
"CartoCSS": "",
|
|
||||||
"Ceylon": "",
|
|
||||||
"Chapel": "",
|
|
||||||
"Charity": "",
|
|
||||||
"ChucK": "text/x-java",
|
|
||||||
"Cirru": "",
|
|
||||||
"Clarion": "",
|
|
||||||
"Clean": "",
|
|
||||||
"Click": "",
|
|
||||||
"Clojure": "text/x-clojure",
|
|
||||||
"Closure Templates": "text/x-soy",
|
|
||||||
"CoffeeScript": "text/x-coffeescript",
|
|
||||||
"ColdFusion": "",
|
|
||||||
"ColdFusion CFC": "",
|
|
||||||
"Common Lisp": "text/x-common-lisp",
|
|
||||||
"Component Pascal": "text/x-pascal",
|
|
||||||
"Cool": "",
|
|
||||||
"Coq": "",
|
|
||||||
"Cpp-ObjDump": "",
|
|
||||||
"Creole": "",
|
|
||||||
"Crystal": "text/x-crystal",
|
|
||||||
"Csound": "",
|
|
||||||
"Csound Document": "",
|
|
||||||
"Csound Score": "",
|
|
||||||
"Cuda": "text/x-c++src",
|
|
||||||
"Cycript": "text/javascript",
|
|
||||||
"Cython": "text/x-cython",
|
|
||||||
"D": "text/x-d",
|
|
||||||
"D-ObjDump": "",
|
|
||||||
"DIGITAL Command Language": "",
|
|
||||||
"DM": "",
|
|
||||||
"DNS Zone": "",
|
|
||||||
"DTrace": "text/x-csrc",
|
|
||||||
"Darcs Patch": "",
|
|
||||||
"Dart": "application/dart",
|
|
||||||
"Diff": "text/x-diff",
|
|
||||||
"Dockerfile": "text/x-dockerfile",
|
|
||||||
"Dogescript": "",
|
|
||||||
"Dylan": "text/x-dylan",
|
|
||||||
"E": "",
|
|
||||||
"EBNF": "text/x-ebnf",
|
|
||||||
"ECL": "text/x-ecl",
|
|
||||||
"ECLiPSe": "",
|
|
||||||
"EJS": "",
|
|
||||||
"EQ": "text/x-csharp",
|
|
||||||
"Eagle": "text/xml",
|
|
||||||
"Easybuild": "text/x-python",
|
|
||||||
"Ecere Projects": "application/json",
|
|
||||||
"Eiffel": "text/x-eiffel",
|
|
||||||
"Elixir": "",
|
|
||||||
"Elm": "text/x-elm",
|
|
||||||
"Emacs Lisp": "text/x-common-lisp",
|
|
||||||
"EmberScript": "text/x-coffeescript",
|
|
||||||
"Erlang": "text/x-erlang",
|
|
||||||
"F#": "text/x-fsharp",
|
|
||||||
"FLUX": "",
|
|
||||||
"Factor": "text/x-factor",
|
|
||||||
"Fancy": "",
|
|
||||||
"Fantom": "",
|
|
||||||
"Filebench WML": "",
|
|
||||||
"Filterscript": "",
|
|
||||||
"Formatted": "",
|
|
||||||
"Forth": "text/x-forth",
|
|
||||||
"Fortran": "text/x-fortran",
|
|
||||||
"FreeMarker": "",
|
|
||||||
"Frege": "",
|
|
||||||
"G-code": "",
|
|
||||||
"GAMS": "",
|
|
||||||
"GAP": "",
|
|
||||||
"GCC Machine Description": "text/x-common-lisp",
|
"GCC Machine Description": "text/x-common-lisp",
|
||||||
"GDB": "",
|
"GN": "text/x-python",
|
||||||
"GDScript": "",
|
"Game Maker Language": "text/x-c++src",
|
||||||
"GLSL": "",
|
"Genshi": "text/xml",
|
||||||
"GN": "text/x-python",
|
"Gentoo Ebuild": "text/x-sh",
|
||||||
"Game Maker Language": "text/x-c++src",
|
"Gentoo Eclass": "text/x-sh",
|
||||||
"Genie": "",
|
"Glyph": "text/x-tcl",
|
||||||
"Genshi": "text/xml",
|
"Go": "text/x-go",
|
||||||
"Gentoo Ebuild": "text/x-sh",
|
"Grammatical Framework": "text/x-haskell",
|
||||||
"Gentoo Eclass": "text/x-sh",
|
"Groovy": "text/x-groovy",
|
||||||
"Gettext Catalog": "",
|
"Groovy Server Pages": "application/x-jsp",
|
||||||
"Gherkin": "",
|
"HCL": "text/x-ruby",
|
||||||
"Glyph": "text/x-tcl",
|
"HTML": "text/html",
|
||||||
"Gnuplot": "",
|
"HTML+Django": "text/x-django",
|
||||||
"Go": "text/x-go",
|
"HTML+ECR": "text/html",
|
||||||
"Golo": "",
|
"HTML+EEX": "text/html",
|
||||||
"Gosu": "",
|
"HTML+ERB": "application/x-erb",
|
||||||
"Grace": "",
|
"HTML+PHP": "application/x-httpd-php",
|
||||||
"Gradle": "",
|
"HTTP": "message/http",
|
||||||
"Grammatical Framework": "text/x-haskell",
|
"Hack": "application/x-httpd-php",
|
||||||
"Graph Modeling Language": "",
|
"Haml": "text/x-haml",
|
||||||
"GraphQL": "",
|
"Haskell": "text/x-haskell",
|
||||||
"Graphviz (DOT)": "",
|
"Haxe": "text/x-haxe",
|
||||||
"Groovy": "text/x-groovy",
|
"IDL": "text/x-idl",
|
||||||
"Groovy Server Pages": "application/x-jsp",
|
"INI": "text/x-properties",
|
||||||
"HCL": "text/x-ruby",
|
"IRC log": "text/mirc",
|
||||||
"HLSL": "",
|
"JSON": "application/json",
|
||||||
"HTML": "text/html",
|
"JSON5": "application/json",
|
||||||
"HTML+Django": "text/x-django",
|
"JSONiq": "application/json",
|
||||||
"HTML+ECR": "text/html",
|
"JSX": "text/jsx",
|
||||||
"HTML+EEX": "text/html",
|
"Java": "text/x-java",
|
||||||
"HTML+ERB": "application/x-erb",
|
"Java Server Pages": "application/x-jsp",
|
||||||
"HTML+PHP": "application/x-httpd-php",
|
"JavaScript": "text/javascript",
|
||||||
"HTTP": "message/http",
|
"Julia": "text/x-julia",
|
||||||
"Hack": "application/x-httpd-php",
|
"Jupyter Notebook": "application/json",
|
||||||
"Haml": "text/x-haml",
|
"Kit": "text/html",
|
||||||
"Handlebars": "",
|
"Kotlin": "text/x-kotlin",
|
||||||
"Harbour": "",
|
"LFE": "text/x-common-lisp",
|
||||||
"Haskell": "text/x-haskell",
|
"LabVIEW": "text/xml",
|
||||||
"Haxe": "text/x-haxe",
|
"Latte": "text/x-smarty",
|
||||||
"Hy": "",
|
"Less": "text/css",
|
||||||
"HyPhy": "",
|
"Literate Haskell": "text/x-literate-haskell",
|
||||||
"IDL": "text/x-idl",
|
"LiveScript": "text/x-livescript",
|
||||||
"IGOR Pro": "",
|
"LookML": "text/x-yaml",
|
||||||
"INI": "text/x-properties",
|
"Lua": "text/x-lua",
|
||||||
"IRC log": "text/mirc",
|
"M": "text/x-mumps",
|
||||||
"Idris": "",
|
"MTML": "text/html",
|
||||||
"Inform 7": "",
|
"MUF": "text/x-forth",
|
||||||
"Inno Setup": "",
|
"Makefile": "text/x-cmake",
|
||||||
"Io": "",
|
"Markdown": "text/x-gfm",
|
||||||
"Ioke": "",
|
"Marko": "text/html",
|
||||||
"Isabelle": "",
|
"Mathematica": "text/x-mathematica",
|
||||||
"Isabelle ROOT": "",
|
"Matlab": "text/x-octave",
|
||||||
"J": "",
|
"Maven POM": "text/xml",
|
||||||
"JFlex": "",
|
"Max": "application/json",
|
||||||
"JSON": "application/json",
|
"Metal": "text/x-c++src",
|
||||||
"JSON5": "application/json",
|
"Mirah": "text/x-ruby",
|
||||||
"JSONLD": "",
|
"Modelica": "text/x-modelica",
|
||||||
"JSONiq": "application/json",
|
"NSIS": "text/x-nsis",
|
||||||
"JSX": "text/jsx",
|
"NetLogo": "text/x-common-lisp",
|
||||||
"Jasmin": "",
|
"NewLisp": "text/x-common-lisp",
|
||||||
"Java": "text/x-java",
|
"Nginx": "text/x-nginx-conf",
|
||||||
"Java Server Pages": "application/x-jsp",
|
"Nu": "text/x-scheme",
|
||||||
"JavaScript": "text/javascript",
|
"NumPy": "text/x-python",
|
||||||
"Jison": "",
|
"OCaml": "text/x-ocaml",
|
||||||
"Jison Lex": "",
|
"Objective-C": "text/x-objectivec",
|
||||||
"Jolie": "",
|
"Objective-C++": "text/x-objectivec",
|
||||||
"Julia": "text/x-julia",
|
"OpenCL": "text/x-csrc",
|
||||||
"Jupyter Notebook": "application/json",
|
"OpenRC runscript": "text/x-sh",
|
||||||
"KRL": "",
|
"Oz": "text/x-oz",
|
||||||
"KiCad": "",
|
"PHP": "application/x-httpd-php",
|
||||||
"Kit": "text/html",
|
"PLSQL": "text/x-plsql",
|
||||||
"Kotlin": "text/x-kotlin",
|
"PLpgSQL": "text/x-sql",
|
||||||
"LFE": "text/x-common-lisp",
|
"Pascal": "text/x-pascal",
|
||||||
"LLVM": "",
|
"Perl": "text/x-perl",
|
||||||
"LOLCODE": "",
|
"Perl 6": "text/x-perl",
|
||||||
"LSL": "",
|
"Pic": "text/troff",
|
||||||
"LabVIEW": "text/xml",
|
"Pod": "text/x-perl",
|
||||||
"Lasso": "",
|
"PowerShell": "application/x-powershell",
|
||||||
"Latte": "text/x-smarty",
|
"Protocol Buffer": "text/x-protobuf",
|
||||||
"Lean": "",
|
"Public Key": "application/pgp",
|
||||||
"Less": "text/css",
|
"Pug": "text/x-pug",
|
||||||
"Lex": "",
|
"Puppet": "text/x-puppet",
|
||||||
"LilyPond": "",
|
"PureScript": "text/x-haskell",
|
||||||
"Limbo": "",
|
"Python": "text/x-python",
|
||||||
"Linker Script": "",
|
"R": "text/x-rsrc",
|
||||||
"Linux Kernel Module": "",
|
"RAML": "text/x-yaml",
|
||||||
"Liquid": "",
|
"RHTML": "application/x-erb",
|
||||||
"Literate Agda": "",
|
"RMarkdown": "text/x-gfm",
|
||||||
"Literate CoffeeScript": "",
|
"RPM Spec": "text/x-rpm-spec",
|
||||||
"Literate Haskell": "text/x-literate-haskell",
|
"Reason": "text/x-rustsrc",
|
||||||
"LiveScript": "text/x-livescript",
|
"Roff": "text/troff",
|
||||||
"Logos": "",
|
"Rouge": "text/x-clojure",
|
||||||
"Logtalk": "",
|
"Ruby": "text/x-ruby",
|
||||||
"LookML": "text/x-yaml",
|
"Rust": "text/x-rustsrc",
|
||||||
"LoomScript": "",
|
"SAS": "text/x-sas",
|
||||||
"Lua": "text/x-lua",
|
"SCSS": "text/x-scss",
|
||||||
"M": "text/x-mumps",
|
"SPARQL": "application/sparql-query",
|
||||||
"M4": "",
|
"SQL": "text/x-sql",
|
||||||
"M4Sugar": "",
|
"SQLPL": "text/x-sql",
|
||||||
"MAXScript": "",
|
"SRecode Template": "text/x-common-lisp",
|
||||||
"MQL4": "",
|
"SVG": "text/xml",
|
||||||
"MQL5": "",
|
"Sage": "text/x-python",
|
||||||
"MTML": "text/html",
|
"SaltStack": "text/x-yaml",
|
||||||
"MUF": "text/x-forth",
|
"Sass": "text/x-sass",
|
||||||
"Makefile": "text/x-cmake",
|
"Scala": "text/x-scala",
|
||||||
"Mako": "",
|
"Scheme": "text/x-scheme",
|
||||||
"Markdown": "text/x-gfm",
|
"Shell": "text/x-sh",
|
||||||
"Marko": "text/html",
|
"ShellSession": "text/x-sh",
|
||||||
"Mask": "",
|
"Slim": "text/x-slim",
|
||||||
"Mathematica": "text/x-mathematica",
|
"Smalltalk": "text/x-stsrc",
|
||||||
"Matlab": "text/x-octave",
|
"Smarty": "text/x-smarty",
|
||||||
"Maven POM": "text/xml",
|
"Squirrel": "text/x-c++src",
|
||||||
"Max": "application/json",
|
"Standard ML": "text/x-ocaml",
|
||||||
"MediaWiki": "",
|
"Sublime Text Config": "text/javascript",
|
||||||
"Mercury": "",
|
"Swift": "text/x-swift",
|
||||||
"Meson": "",
|
"SystemVerilog": "text/x-systemverilog",
|
||||||
"Metal": "text/x-c++src",
|
"TOML": "text/x-toml",
|
||||||
"MiniD": "",
|
"Tcl": "text/x-tcl",
|
||||||
"Mirah": "text/x-ruby",
|
"Tcsh": "text/x-sh",
|
||||||
"Modelica": "text/x-modelica",
|
"TeX": "text/x-stex",
|
||||||
"Modula-2": "",
|
"Terra": "text/x-lua",
|
||||||
"Module Management System": "",
|
"Textile": "text/x-textile",
|
||||||
"Monkey": "",
|
"Turtle": "text/turtle",
|
||||||
"Moocode": "",
|
"Twig": "text/x-twig",
|
||||||
"MoonScript": "",
|
"TypeScript": "application/typescript",
|
||||||
"Myghty": "",
|
"Unified Parallel C": "text/x-csrc",
|
||||||
"NCL": "",
|
"Unity3D Asset": "text/x-yaml",
|
||||||
"NL": "",
|
"Uno": "text/x-csharp",
|
||||||
"NSIS": "text/x-nsis",
|
"UnrealScript": "text/x-java",
|
||||||
"Nemerle": "",
|
"VHDL": "text/x-vhdl",
|
||||||
"NetLinx": "",
|
"Verilog": "text/x-verilog",
|
||||||
"NetLinx+ERB": "",
|
"Visual Basic": "text/x-vb",
|
||||||
"NetLogo": "text/x-common-lisp",
|
"Volt": "text/x-d",
|
||||||
"NewLisp": "text/x-common-lisp",
|
"WebAssembly": "text/x-common-lisp",
|
||||||
"Nginx": "text/x-nginx-conf",
|
"WebIDL": "text/x-webidl",
|
||||||
"Nim": "",
|
"XC": "text/x-csrc",
|
||||||
"Ninja": "",
|
"XML": "text/xml",
|
||||||
"Nit": "",
|
"XPages": "text/xml",
|
||||||
"Nix": "",
|
"XProc": "text/xml",
|
||||||
"Nu": "text/x-scheme",
|
"XQuery": "application/xquery",
|
||||||
"NumPy": "text/x-python",
|
"XS": "text/x-csrc",
|
||||||
"OCaml": "text/x-ocaml",
|
"XSLT": "text/xml",
|
||||||
"ObjDump": "",
|
"YAML": "text/x-yaml",
|
||||||
"Objective-C": "text/x-objectivec",
|
"edn": "text/x-clojure",
|
||||||
"Objective-C++": "text/x-objectivec",
|
"reStructuredText": "text/x-rst",
|
||||||
"Objective-J": "",
|
"wisp": "text/x-clojure",
|
||||||
"Omgrofl": "",
|
|
||||||
"Opa": "",
|
|
||||||
"Opal": "",
|
|
||||||
"OpenCL": "text/x-csrc",
|
|
||||||
"OpenEdge ABL": "",
|
|
||||||
"OpenRC runscript": "text/x-sh",
|
|
||||||
"OpenSCAD": "",
|
|
||||||
"OpenType Feature File": "",
|
|
||||||
"Org": "",
|
|
||||||
"Ox": "",
|
|
||||||
"Oxygene": "",
|
|
||||||
"Oz": "text/x-oz",
|
|
||||||
"P4": "",
|
|
||||||
"PAWN": "",
|
|
||||||
"PHP": "application/x-httpd-php",
|
|
||||||
"PLSQL": "text/x-plsql",
|
|
||||||
"PLpgSQL": "text/x-sql",
|
|
||||||
"POV-Ray SDL": "",
|
|
||||||
"Pan": "",
|
|
||||||
"Papyrus": "",
|
|
||||||
"Parrot": "",
|
|
||||||
"Parrot Assembly": "",
|
|
||||||
"Parrot Internal Representation": "",
|
|
||||||
"Pascal": "text/x-pascal",
|
|
||||||
"Pep8": "",
|
|
||||||
"Perl": "text/x-perl",
|
|
||||||
"Perl 6": "text/x-perl",
|
|
||||||
"Pic": "text/troff",
|
|
||||||
"Pickle": "",
|
|
||||||
"PicoLisp": "",
|
|
||||||
"PigLatin": "",
|
|
||||||
"Pike": "",
|
|
||||||
"Pod": "text/x-perl",
|
|
||||||
"PogoScript": "",
|
|
||||||
"Pony": "",
|
|
||||||
"PostScript": "",
|
|
||||||
"PowerBuilder": "",
|
|
||||||
"PowerShell": "application/x-powershell",
|
|
||||||
"Processing": "",
|
|
||||||
"Prolog": "",
|
|
||||||
"Propeller Spin": "",
|
|
||||||
"Protocol Buffer": "text/x-protobuf",
|
|
||||||
"Public Key": "application/pgp",
|
|
||||||
"Pug": "text/x-pug",
|
|
||||||
"Puppet": "text/x-puppet",
|
|
||||||
"Pure Data": "",
|
|
||||||
"PureBasic": "",
|
|
||||||
"PureScript": "text/x-haskell",
|
|
||||||
"Python": "text/x-python",
|
|
||||||
"Python console": "",
|
|
||||||
"Python traceback": "",
|
|
||||||
"QML": "",
|
|
||||||
"QMake": "",
|
|
||||||
"R": "text/x-rsrc",
|
|
||||||
"RAML": "text/x-yaml",
|
|
||||||
"RDoc": "",
|
|
||||||
"REALbasic": "",
|
|
||||||
"REXX": "",
|
|
||||||
"RHTML": "application/x-erb",
|
|
||||||
"RMarkdown": "text/x-gfm",
|
|
||||||
"RPM Spec": "text/x-rpm-spec",
|
|
||||||
"RUNOFF": "",
|
|
||||||
"Racket": "",
|
|
||||||
"Ragel": "",
|
|
||||||
"Rascal": "",
|
|
||||||
"Raw token data": "",
|
|
||||||
"Reason": "text/x-rustsrc",
|
|
||||||
"Rebol": "",
|
|
||||||
"Red": "",
|
|
||||||
"Redcode": "",
|
|
||||||
"Regular Expression": "",
|
|
||||||
"Ren'Py": "",
|
|
||||||
"RenderScript": "",
|
|
||||||
"Ring": "",
|
|
||||||
"RobotFramework": "",
|
|
||||||
"Roff": "text/troff",
|
|
||||||
"Rouge": "text/x-clojure",
|
|
||||||
"Ruby": "text/x-ruby",
|
|
||||||
"Rust": "text/x-rustsrc",
|
|
||||||
"SAS": "text/x-sas",
|
|
||||||
"SCSS": "text/x-scss",
|
|
||||||
"SMT": "",
|
|
||||||
"SPARQL": "application/sparql-query",
|
|
||||||
"SQF": "",
|
|
||||||
"SQL": "text/x-sql",
|
|
||||||
"SQLPL": "text/x-sql",
|
|
||||||
"SRecode Template": "text/x-common-lisp",
|
|
||||||
"STON": "",
|
|
||||||
"SVG": "text/xml",
|
|
||||||
"Sage": "text/x-python",
|
|
||||||
"SaltStack": "text/x-yaml",
|
|
||||||
"Sass": "text/x-sass",
|
|
||||||
"Scala": "text/x-scala",
|
|
||||||
"Scaml": "",
|
|
||||||
"Scheme": "text/x-scheme",
|
|
||||||
"Scilab": "",
|
|
||||||
"Self": "",
|
|
||||||
"ShaderLab": "",
|
|
||||||
"Shell": "text/x-sh",
|
|
||||||
"ShellSession": "text/x-sh",
|
|
||||||
"Shen": "",
|
|
||||||
"Slash": "",
|
|
||||||
"Slim": "text/x-slim",
|
|
||||||
"Smali": "",
|
|
||||||
"Smalltalk": "text/x-stsrc",
|
|
||||||
"Smarty": "text/x-smarty",
|
|
||||||
"SourcePawn": "",
|
|
||||||
"Spline Font Database": "",
|
|
||||||
"Squirrel": "text/x-c++src",
|
|
||||||
"Stan": "",
|
|
||||||
"Standard ML": "text/x-ocaml",
|
|
||||||
"Stata": "",
|
|
||||||
"Stylus": "",
|
|
||||||
"SubRip Text": "",
|
|
||||||
"Sublime Text Config": "text/javascript",
|
|
||||||
"SuperCollider": "",
|
|
||||||
"Swift": "text/x-swift",
|
|
||||||
"SystemVerilog": "text/x-systemverilog",
|
|
||||||
"TI Program": "",
|
|
||||||
"TLA": "",
|
|
||||||
"TOML": "text/x-toml",
|
|
||||||
"TXL": "",
|
|
||||||
"Tcl": "text/x-tcl",
|
|
||||||
"Tcsh": "text/x-sh",
|
|
||||||
"TeX": "text/x-stex",
|
|
||||||
"Tea": "",
|
|
||||||
"Terra": "text/x-lua",
|
|
||||||
"Text": "",
|
|
||||||
"Textile": "text/x-textile",
|
|
||||||
"Thrift": "",
|
|
||||||
"Turing": "",
|
|
||||||
"Turtle": "text/turtle",
|
|
||||||
"Twig": "text/x-twig",
|
|
||||||
"Type Language": "",
|
|
||||||
"TypeScript": "application/typescript",
|
|
||||||
"Unified Parallel C": "text/x-csrc",
|
|
||||||
"Unity3D Asset": "text/x-yaml",
|
|
||||||
"Unix Assembly": "",
|
|
||||||
"Uno": "text/x-csharp",
|
|
||||||
"UnrealScript": "text/x-java",
|
|
||||||
"UrWeb": "",
|
|
||||||
"VCL": "",
|
|
||||||
"VHDL": "text/x-vhdl",
|
|
||||||
"Vala": "",
|
|
||||||
"Verilog": "text/x-verilog",
|
|
||||||
"Vim script": "",
|
|
||||||
"Visual Basic": "text/x-vb",
|
|
||||||
"Volt": "text/x-d",
|
|
||||||
"Vue": "",
|
|
||||||
"Wavefront Material": "",
|
|
||||||
"Wavefront Object": "",
|
|
||||||
"Web Ontology Language": "",
|
|
||||||
"WebAssembly": "text/x-common-lisp",
|
|
||||||
"WebIDL": "text/x-webidl",
|
|
||||||
"World of Warcraft Addon Data": "",
|
|
||||||
"X10": "",
|
|
||||||
"XC": "text/x-csrc",
|
|
||||||
"XCompose": "",
|
|
||||||
"XML": "text/xml",
|
|
||||||
"XPages": "text/xml",
|
|
||||||
"XProc": "text/xml",
|
|
||||||
"XQuery": "application/xquery",
|
|
||||||
"XS": "text/x-csrc",
|
|
||||||
"XSLT": "text/xml",
|
|
||||||
"Xojo": "",
|
|
||||||
"Xtend": "",
|
|
||||||
"YAML": "text/x-yaml",
|
|
||||||
"YANG": "",
|
|
||||||
"Yacc": "",
|
|
||||||
"Zephir": "",
|
|
||||||
"Zimpl": "",
|
|
||||||
"desktop": "",
|
|
||||||
"eC": "",
|
|
||||||
"edn": "text/x-clojure",
|
|
||||||
"fish": "",
|
|
||||||
"mupad": "",
|
|
||||||
"nesC": "",
|
|
||||||
"ooc": "",
|
|
||||||
"reStructuredText": "text/x-rst",
|
|
||||||
"wisp": "text/x-clojure",
|
|
||||||
"xBase": "",
|
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,11 @@ const (
|
|||||||
commitGold = "test_files/commit.gold"
|
commitGold = "test_files/commit.gold"
|
||||||
commitTestTmplPath = "../assets/commit.go.tmpl"
|
commitTestTmplPath = "../assets/commit.go.tmpl"
|
||||||
commitTestTmplName = "commit.go.tmpl"
|
commitTestTmplName = "commit.go.tmpl"
|
||||||
|
|
||||||
|
// mime test
|
||||||
|
mimeTypeGold = "test_files/mimeType.gold"
|
||||||
|
mimeTypeTestTmplPath = "../assets/mimeType.go.tmpl"
|
||||||
|
mimeTypeTestTmplName = "mimeType.go.tmpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GeneratorTestSuite struct {
|
type GeneratorTestSuite struct {
|
||||||
@ -218,6 +223,16 @@ func (s *GeneratorTestSuite) TestGenerationFiles() {
|
|||||||
generate: Commit,
|
generate: Commit,
|
||||||
wantOut: commitGold,
|
wantOut: commitGold,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "MimeType()",
|
||||||
|
fileToParse: filepath.Join(s.tmpLinguist, languagesFile),
|
||||||
|
samplesDir: "",
|
||||||
|
tmplPath: mimeTypeTestTmplPath,
|
||||||
|
tmplName: mimeTypeTestTmplName,
|
||||||
|
commit: commit,
|
||||||
|
generate: MimeType,
|
||||||
|
wantOut: mimeTypeGold,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
@ -227,7 +242,6 @@ func (s *GeneratorTestSuite) TestGenerationFiles() {
|
|||||||
outPath, err := ioutil.TempFile("/tmp", "generator-test-")
|
outPath, err := ioutil.TempFile("/tmp", "generator-test-")
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
defer os.Remove(outPath.Name())
|
defer os.Remove(outPath.Name())
|
||||||
|
|
||||||
err = test.generate(test.fileToParse, test.samplesDir, outPath.Name(), test.tmplPath, test.tmplName, test.commit)
|
err = test.generate(test.fileToParse, test.samplesDir, outPath.Name(), test.tmplPath, test.tmplName, test.commit)
|
||||||
assert.NoError(s.T(), err)
|
assert.NoError(s.T(), err)
|
||||||
out, err := ioutil.ReadFile(outPath.Name())
|
out, err := ioutil.ReadFile(outPath.Name())
|
||||||
|
@ -2,9 +2,9 @@ package generator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html/template"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@ -33,7 +33,9 @@ func MimeType(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit strin
|
|||||||
func buildLanguageMimeMap(languages map[string]*languageInfo) map[string]string {
|
func buildLanguageMimeMap(languages map[string]*languageInfo) map[string]string {
|
||||||
langMimeMap := make(map[string]string)
|
langMimeMap := make(map[string]string)
|
||||||
for lang, info := range languages {
|
for lang, info := range languages {
|
||||||
langMimeMap[lang] = info.MimeType
|
if len(info.MimeType) != 0 {
|
||||||
|
langMimeMap[lang] = info.MimeType
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return langMimeMap
|
return langMimeMap
|
||||||
|
203
internal/code-generator/generator/test_files/mimeType.gold
Normal file
203
internal/code-generator/generator/test_files/mimeType.gold
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
package data
|
||||||
|
|
||||||
|
// CODE GENERATED AUTOMATICALLY WITH gopkg.in/src-d/enry.v1/internal/code-generator
|
||||||
|
// THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
|
// Extracted from github/linguist commit: b6460f8ed6b249281ada099ca28bd8f1230b8892
|
||||||
|
|
||||||
|
var LanguagesMime = map[string]string{
|
||||||
|
"AGS Script": "text/x-c++src",
|
||||||
|
"APL": "text/apl",
|
||||||
|
"ASN.1": "text/x-ttcn-asn",
|
||||||
|
"ASP": "application/x-aspx",
|
||||||
|
"Alpine Abuild": "text/x-sh",
|
||||||
|
"Ant Build System": "application/xml",
|
||||||
|
"Apex": "text/x-java",
|
||||||
|
"Arduino": "text/x-c++src",
|
||||||
|
"Brainfuck": "text/x-brainfuck",
|
||||||
|
"C": "text/x-csrc",
|
||||||
|
"C#": "text/x-csharp",
|
||||||
|
"C++": "text/x-c++src",
|
||||||
|
"C2hs Haskell": "text/x-haskell",
|
||||||
|
"CMake": "text/x-cmake",
|
||||||
|
"COBOL": "text/x-cobol",
|
||||||
|
"COLLADA": "text/xml",
|
||||||
|
"CSON": "text/x-coffeescript",
|
||||||
|
"CSS": "text/css",
|
||||||
|
"ChucK": "text/x-java",
|
||||||
|
"Clojure": "text/x-clojure",
|
||||||
|
"Closure Templates": "text/x-soy",
|
||||||
|
"CoffeeScript": "text/x-coffeescript",
|
||||||
|
"Common Lisp": "text/x-common-lisp",
|
||||||
|
"Component Pascal": "text/x-pascal",
|
||||||
|
"Crystal": "text/x-crystal",
|
||||||
|
"Cuda": "text/x-c++src",
|
||||||
|
"Cycript": "text/javascript",
|
||||||
|
"Cython": "text/x-cython",
|
||||||
|
"D": "text/x-d",
|
||||||
|
"DTrace": "text/x-csrc",
|
||||||
|
"Dart": "application/dart",
|
||||||
|
"Diff": "text/x-diff",
|
||||||
|
"Dockerfile": "text/x-dockerfile",
|
||||||
|
"Dylan": "text/x-dylan",
|
||||||
|
"EBNF": "text/x-ebnf",
|
||||||
|
"ECL": "text/x-ecl",
|
||||||
|
"EQ": "text/x-csharp",
|
||||||
|
"Eagle": "text/xml",
|
||||||
|
"Ecere Projects": "application/json",
|
||||||
|
"Eiffel": "text/x-eiffel",
|
||||||
|
"Elm": "text/x-elm",
|
||||||
|
"Emacs Lisp": "text/x-common-lisp",
|
||||||
|
"EmberScript": "text/x-coffeescript",
|
||||||
|
"Erlang": "text/x-erlang",
|
||||||
|
"F#": "text/x-fsharp",
|
||||||
|
"Factor": "text/x-factor",
|
||||||
|
"Forth": "text/x-forth",
|
||||||
|
"Fortran": "text/x-fortran",
|
||||||
|
"GCC Machine Description": "text/x-common-lisp",
|
||||||
|
"GN": "text/x-python",
|
||||||
|
"Game Maker Language": "text/x-c++src",
|
||||||
|
"Genshi": "text/xml",
|
||||||
|
"Gentoo Ebuild": "text/x-sh",
|
||||||
|
"Gentoo Eclass": "text/x-sh",
|
||||||
|
"Glyph": "text/x-tcl",
|
||||||
|
"Go": "text/x-go",
|
||||||
|
"Grammatical Framework": "text/x-haskell",
|
||||||
|
"Groovy": "text/x-groovy",
|
||||||
|
"Groovy Server Pages": "application/x-jsp",
|
||||||
|
"HCL": "text/x-ruby",
|
||||||
|
"HTML": "text/html",
|
||||||
|
"HTML+Django": "text/x-django",
|
||||||
|
"HTML+ECR": "text/html",
|
||||||
|
"HTML+EEX": "text/html",
|
||||||
|
"HTML+ERB": "application/x-erb",
|
||||||
|
"HTML+PHP": "application/x-httpd-php",
|
||||||
|
"HTTP": "message/http",
|
||||||
|
"Hack": "application/x-httpd-php",
|
||||||
|
"Haml": "text/x-haml",
|
||||||
|
"Haskell": "text/x-haskell",
|
||||||
|
"Haxe": "text/x-haxe",
|
||||||
|
"IDL": "text/x-idl",
|
||||||
|
"INI": "text/x-properties",
|
||||||
|
"IRC log": "text/mirc",
|
||||||
|
"JSON": "application/json",
|
||||||
|
"JSON5": "application/json",
|
||||||
|
"JSONiq": "application/json",
|
||||||
|
"JSX": "text/jsx",
|
||||||
|
"Java": "text/x-java",
|
||||||
|
"Java Server Pages": "application/x-jsp",
|
||||||
|
"JavaScript": "text/javascript",
|
||||||
|
"Julia": "text/x-julia",
|
||||||
|
"Jupyter Notebook": "application/json",
|
||||||
|
"Kit": "text/html",
|
||||||
|
"Kotlin": "text/x-kotlin",
|
||||||
|
"LFE": "text/x-common-lisp",
|
||||||
|
"LabVIEW": "text/xml",
|
||||||
|
"Latte": "text/x-smarty",
|
||||||
|
"Less": "text/css",
|
||||||
|
"Literate Haskell": "text/x-literate-haskell",
|
||||||
|
"LiveScript": "text/x-livescript",
|
||||||
|
"LookML": "text/x-yaml",
|
||||||
|
"Lua": "text/x-lua",
|
||||||
|
"M": "text/x-mumps",
|
||||||
|
"MTML": "text/html",
|
||||||
|
"MUF": "text/x-forth",
|
||||||
|
"Makefile": "text/x-cmake",
|
||||||
|
"Markdown": "text/x-gfm",
|
||||||
|
"Marko": "text/html",
|
||||||
|
"Mathematica": "text/x-mathematica",
|
||||||
|
"Matlab": "text/x-octave",
|
||||||
|
"Maven POM": "text/xml",
|
||||||
|
"Max": "application/json",
|
||||||
|
"Metal": "text/x-c++src",
|
||||||
|
"Mirah": "text/x-ruby",
|
||||||
|
"Modelica": "text/x-modelica",
|
||||||
|
"NSIS": "text/x-nsis",
|
||||||
|
"NetLogo": "text/x-common-lisp",
|
||||||
|
"NewLisp": "text/x-common-lisp",
|
||||||
|
"Nginx": "text/x-nginx-conf",
|
||||||
|
"Nu": "text/x-scheme",
|
||||||
|
"NumPy": "text/x-python",
|
||||||
|
"OCaml": "text/x-ocaml",
|
||||||
|
"Objective-C": "text/x-objectivec",
|
||||||
|
"Objective-C++": "text/x-objectivec",
|
||||||
|
"OpenCL": "text/x-csrc",
|
||||||
|
"OpenRC runscript": "text/x-sh",
|
||||||
|
"Oz": "text/x-oz",
|
||||||
|
"PHP": "application/x-httpd-php",
|
||||||
|
"PLSQL": "text/x-plsql",
|
||||||
|
"PLpgSQL": "text/x-sql",
|
||||||
|
"Pascal": "text/x-pascal",
|
||||||
|
"Perl": "text/x-perl",
|
||||||
|
"Perl6": "text/x-perl",
|
||||||
|
"Pic": "text/troff",
|
||||||
|
"Pod": "text/x-perl",
|
||||||
|
"PowerShell": "application/x-powershell",
|
||||||
|
"Protocol Buffer": "text/x-protobuf",
|
||||||
|
"Public Key": "application/pgp",
|
||||||
|
"Pug": "text/x-pug",
|
||||||
|
"Puppet": "text/x-puppet",
|
||||||
|
"PureScript": "text/x-haskell",
|
||||||
|
"Python": "text/x-python",
|
||||||
|
"R": "text/x-rsrc",
|
||||||
|
"RAML": "text/x-yaml",
|
||||||
|
"RHTML": "application/x-erb",
|
||||||
|
"RMarkdown": "text/x-gfm",
|
||||||
|
"RPM Spec": "text/x-rpm-spec",
|
||||||
|
"Reason": "text/x-rustsrc",
|
||||||
|
"Roff": "text/troff",
|
||||||
|
"Rouge": "text/x-clojure",
|
||||||
|
"Ruby": "text/x-ruby",
|
||||||
|
"Rust": "text/x-rustsrc",
|
||||||
|
"SAS": "text/x-sas",
|
||||||
|
"SCSS": "text/x-scss",
|
||||||
|
"SPARQL": "application/sparql-query",
|
||||||
|
"SQL": "text/x-sql",
|
||||||
|
"SQLPL": "text/x-sql",
|
||||||
|
"SRecode Template": "text/x-common-lisp",
|
||||||
|
"SVG": "text/xml",
|
||||||
|
"Sage": "text/x-python",
|
||||||
|
"SaltStack": "text/x-yaml",
|
||||||
|
"Sass": "text/x-sass",
|
||||||
|
"Scala": "text/x-scala",
|
||||||
|
"Scheme": "text/x-scheme",
|
||||||
|
"Shell": "text/x-sh",
|
||||||
|
"ShellSession": "text/x-sh",
|
||||||
|
"Slim": "text/x-slim",
|
||||||
|
"Smalltalk": "text/x-stsrc",
|
||||||
|
"Smarty": "text/x-smarty",
|
||||||
|
"Squirrel": "text/x-c++src",
|
||||||
|
"Standard ML": "text/x-ocaml",
|
||||||
|
"Sublime Text Config": "text/javascript",
|
||||||
|
"Swift": "text/x-swift",
|
||||||
|
"SystemVerilog": "text/x-systemverilog",
|
||||||
|
"TOML": "text/x-toml",
|
||||||
|
"Tcl": "text/x-tcl",
|
||||||
|
"Tcsh": "text/x-sh",
|
||||||
|
"TeX": "text/x-stex",
|
||||||
|
"Terra": "text/x-lua",
|
||||||
|
"Textile": "text/x-textile",
|
||||||
|
"Turtle": "text/turtle",
|
||||||
|
"Twig": "text/x-twig",
|
||||||
|
"TypeScript": "application/typescript",
|
||||||
|
"Unified Parallel C": "text/x-csrc",
|
||||||
|
"Unity3D Asset": "text/x-yaml",
|
||||||
|
"Uno": "text/x-csharp",
|
||||||
|
"UnrealScript": "text/x-java",
|
||||||
|
"VHDL": "text/x-vhdl",
|
||||||
|
"Verilog": "text/x-verilog",
|
||||||
|
"Visual Basic": "text/x-vb",
|
||||||
|
"Volt": "text/x-d",
|
||||||
|
"WebAssembly": "text/x-common-lisp",
|
||||||
|
"WebIDL": "text/x-webidl",
|
||||||
|
"XC": "text/x-csrc",
|
||||||
|
"XML": "text/xml",
|
||||||
|
"XPages": "text/xml",
|
||||||
|
"XProc": "text/xml",
|
||||||
|
"XQuery": "application/xquery",
|
||||||
|
"XS": "text/x-csrc",
|
||||||
|
"XSLT": "text/xml",
|
||||||
|
"YAML": "text/x-yaml",
|
||||||
|
"edn": "text/x-clojure",
|
||||||
|
"reStructuredText": "text/x-rst",
|
||||||
|
"wisp": "text/x-clojure",
|
||||||
|
}
|
9
utils.go
9
utils.go
@ -53,6 +53,15 @@ func IsDocumentation(path string) bool {
|
|||||||
return data.DocumentationMatchers.Match(path)
|
return data.DocumentationMatchers.Match(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsImage(file string) bool {
|
||||||
|
index := strings.LastIndex(file, ".")
|
||||||
|
extension := file[index:]
|
||||||
|
if extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".gif" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func GetMimeType(language string) string {
|
func GetMimeType(language string) string {
|
||||||
if mime, ok := data.LanguagesMime[language]; ok {
|
if mime, ok := data.LanguagesMime[language]; ok {
|
||||||
return mime
|
return mime
|
||||||
|
Loading…
x
Reference in New Issue
Block a user