mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-05-23 08:30:07 -03:00
Added mymeType.gold
This commit is contained in:
parent
ea819f58c2
commit
b2fe3f69ce
@ -47,10 +47,7 @@ func main() {
|
||||
}
|
||||
|
||||
if relativePath == "." {
|
||||
var buff bytes.Buffer
|
||||
printFile(root, &buff)
|
||||
fmt.Print(buff.String())
|
||||
return nil
|
||||
return printFileAnalysis(root)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
totalLines, sloc := getLines(file, content)
|
||||
totalLines, linesOfCode := getLines(file, string(content))
|
||||
fileType := getFileType(file, content)
|
||||
language := enry.GetLanguage(file, content)
|
||||
mimeType := enry.GetMimeType(language)
|
||||
|
||||
buff.WriteString(fmt.Sprintf("%s: %d lines (%d sloc)\n", filepath.Base(file), totalLines, sloc))
|
||||
buff.WriteString(fmt.Sprintf(" type: %s\n", fileType))
|
||||
buff.WriteString(fmt.Sprintf(" mime type: %s\n", mimeType))
|
||||
buff.WriteString(fmt.Sprintf(" language: %s\n", language))
|
||||
return fmt.Sprintf(
|
||||
`%s: %d lines (%d sloc)
|
||||
type: %s
|
||||
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"))
|
||||
sloc := totalLines - strings.Count(string(content), "\n\n")
|
||||
totalLines := strings.Count(content, "\n")
|
||||
linesOfCode := totalLines - strings.Count(content, "\n\n")
|
||||
|
||||
return totalLines, sloc
|
||||
return totalLines, linesOfCode
|
||||
}
|
||||
|
||||
func getFileType(file string, content []byte) string {
|
||||
switch {
|
||||
case isImage(file):
|
||||
case enry.IsImage(file):
|
||||
return "Image"
|
||||
case enry.IsBinary(content):
|
||||
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) {
|
||||
buff.WriteString(s)
|
||||
buff.WriteByte('\n')
|
||||
|
647
data/mimeType.go
647
data/mimeType.go
@ -5,457 +5,200 @@ package data
|
||||
// Extracted from github/linguist commit: d5c8db3fb91963c4b2762ca2ea2ff7cfac109f68
|
||||
|
||||
var LanguagesMime = map[string]string{
|
||||
"1C Enterprise": "",
|
||||
"ABAP": "",
|
||||
"ABNF": "",
|
||||
"AGS Script": "text/x-c++src",
|
||||
"AMPL": "",
|
||||
"ANTLR": "",
|
||||
"API Blueprint": "",
|
||||
"APL": "text/apl",
|
||||
"ASN.1": "text/x-ttcn-asn",
|
||||
"ASP": "application/x-aspx",
|
||||
"ATS": "",
|
||||
"ActionScript": "",
|
||||
"Ada": "",
|
||||
"Agda": "",
|
||||
"Alloy": "",
|
||||
"Alpine Abuild": "text/x-sh",
|
||||
"Ant Build System": "application/xml",
|
||||
"ApacheConf": "",
|
||||
"Apex": "text/x-java",
|
||||
"Apollo Guidance Computer": "",
|
||||
"AppleScript": "",
|
||||
"Arc": "",
|
||||
"Arduino": "text/x-c++src",
|
||||
"AsciiDoc": "",
|
||||
"AspectJ": "",
|
||||
"Assembly": "",
|
||||
"Augeas": "",
|
||||
"AutoHotkey": "",
|
||||
"AutoIt": "",
|
||||
"Awk": "",
|
||||
"Batchfile": "",
|
||||
"Befunge": "",
|
||||
"Bison": "",
|
||||
"BitBake": "",
|
||||
"Blade": "",
|
||||
"BlitzBasic": "",
|
||||
"BlitzMax": "",
|
||||
"Bluespec": "",
|
||||
"Boo": "",
|
||||
"Brainfuck": "text/x-brainfuck",
|
||||
"Brightscript": "",
|
||||
"Bro": "",
|
||||
"C": "text/x-csrc",
|
||||
"C#": "text/x-csharp",
|
||||
"C++": "text/x-c++src",
|
||||
"C-ObjDump": "",
|
||||
"C2hs Haskell": "text/x-haskell",
|
||||
"CLIPS": "",
|
||||
"CMake": "text/x-cmake",
|
||||
"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": "",
|
||||
"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",
|
||||
"Easybuild": "text/x-python",
|
||||
"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",
|
||||
"GDB": "",
|
||||
"GDScript": "",
|
||||
"GLSL": "",
|
||||
"GN": "text/x-python",
|
||||
"Game Maker Language": "text/x-c++src",
|
||||
"Genie": "",
|
||||
"Genshi": "text/xml",
|
||||
"Gentoo Ebuild": "text/x-sh",
|
||||
"Gentoo Eclass": "text/x-sh",
|
||||
"Gettext Catalog": "",
|
||||
"Gherkin": "",
|
||||
"Glyph": "text/x-tcl",
|
||||
"Gnuplot": "",
|
||||
"Go": "text/x-go",
|
||||
"Golo": "",
|
||||
"Gosu": "",
|
||||
"Grace": "",
|
||||
"Gradle": "",
|
||||
"Grammatical Framework": "text/x-haskell",
|
||||
"Graph Modeling Language": "",
|
||||
"GraphQL": "",
|
||||
"Graphviz (DOT)": "",
|
||||
"Groovy": "text/x-groovy",
|
||||
"Groovy Server Pages": "application/x-jsp",
|
||||
"HCL": "text/x-ruby",
|
||||
"HLSL": "",
|
||||
"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",
|
||||
"Handlebars": "",
|
||||
"Harbour": "",
|
||||
"Haskell": "text/x-haskell",
|
||||
"Haxe": "text/x-haxe",
|
||||
"Hy": "",
|
||||
"HyPhy": "",
|
||||
"IDL": "text/x-idl",
|
||||
"IGOR Pro": "",
|
||||
"INI": "text/x-properties",
|
||||
"IRC log": "text/mirc",
|
||||
"Idris": "",
|
||||
"Inform 7": "",
|
||||
"Inno Setup": "",
|
||||
"Io": "",
|
||||
"Ioke": "",
|
||||
"Isabelle": "",
|
||||
"Isabelle ROOT": "",
|
||||
"J": "",
|
||||
"JFlex": "",
|
||||
"JSON": "application/json",
|
||||
"JSON5": "application/json",
|
||||
"JSONLD": "",
|
||||
"JSONiq": "application/json",
|
||||
"JSX": "text/jsx",
|
||||
"Jasmin": "",
|
||||
"Java": "text/x-java",
|
||||
"Java Server Pages": "application/x-jsp",
|
||||
"JavaScript": "text/javascript",
|
||||
"Jison": "",
|
||||
"Jison Lex": "",
|
||||
"Jolie": "",
|
||||
"Julia": "text/x-julia",
|
||||
"Jupyter Notebook": "application/json",
|
||||
"KRL": "",
|
||||
"KiCad": "",
|
||||
"Kit": "text/html",
|
||||
"Kotlin": "text/x-kotlin",
|
||||
"LFE": "text/x-common-lisp",
|
||||
"LLVM": "",
|
||||
"LOLCODE": "",
|
||||
"LSL": "",
|
||||
"LabVIEW": "text/xml",
|
||||
"Lasso": "",
|
||||
"Latte": "text/x-smarty",
|
||||
"Lean": "",
|
||||
"Less": "text/css",
|
||||
"Lex": "",
|
||||
"LilyPond": "",
|
||||
"Limbo": "",
|
||||
"Linker Script": "",
|
||||
"Linux Kernel Module": "",
|
||||
"Liquid": "",
|
||||
"Literate Agda": "",
|
||||
"Literate CoffeeScript": "",
|
||||
"Literate Haskell": "text/x-literate-haskell",
|
||||
"LiveScript": "text/x-livescript",
|
||||
"Logos": "",
|
||||
"Logtalk": "",
|
||||
"LookML": "text/x-yaml",
|
||||
"LoomScript": "",
|
||||
"Lua": "text/x-lua",
|
||||
"M": "text/x-mumps",
|
||||
"M4": "",
|
||||
"M4Sugar": "",
|
||||
"MAXScript": "",
|
||||
"MQL4": "",
|
||||
"MQL5": "",
|
||||
"MTML": "text/html",
|
||||
"MUF": "text/x-forth",
|
||||
"Makefile": "text/x-cmake",
|
||||
"Mako": "",
|
||||
"Markdown": "text/x-gfm",
|
||||
"Marko": "text/html",
|
||||
"Mask": "",
|
||||
"Mathematica": "text/x-mathematica",
|
||||
"Matlab": "text/x-octave",
|
||||
"Maven POM": "text/xml",
|
||||
"Max": "application/json",
|
||||
"MediaWiki": "",
|
||||
"Mercury": "",
|
||||
"Meson": "",
|
||||
"Metal": "text/x-c++src",
|
||||
"MiniD": "",
|
||||
"Mirah": "text/x-ruby",
|
||||
"Modelica": "text/x-modelica",
|
||||
"Modula-2": "",
|
||||
"Module Management System": "",
|
||||
"Monkey": "",
|
||||
"Moocode": "",
|
||||
"MoonScript": "",
|
||||
"Myghty": "",
|
||||
"NCL": "",
|
||||
"NL": "",
|
||||
"NSIS": "text/x-nsis",
|
||||
"Nemerle": "",
|
||||
"NetLinx": "",
|
||||
"NetLinx+ERB": "",
|
||||
"NetLogo": "text/x-common-lisp",
|
||||
"NewLisp": "text/x-common-lisp",
|
||||
"Nginx": "text/x-nginx-conf",
|
||||
"Nim": "",
|
||||
"Ninja": "",
|
||||
"Nit": "",
|
||||
"Nix": "",
|
||||
"Nu": "text/x-scheme",
|
||||
"NumPy": "text/x-python",
|
||||
"OCaml": "text/x-ocaml",
|
||||
"ObjDump": "",
|
||||
"Objective-C": "text/x-objectivec",
|
||||
"Objective-C++": "text/x-objectivec",
|
||||
"Objective-J": "",
|
||||
"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": "",
|
||||
"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",
|
||||
"Perl 6": "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",
|
||||
}
|
||||
|
@ -70,6 +70,11 @@ const (
|
||||
commitGold = "test_files/commit.gold"
|
||||
commitTestTmplPath = "../assets/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 {
|
||||
@ -218,6 +223,16 @@ func (s *GeneratorTestSuite) TestGenerationFiles() {
|
||||
generate: Commit,
|
||||
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 {
|
||||
@ -227,7 +242,6 @@ func (s *GeneratorTestSuite) TestGenerationFiles() {
|
||||
outPath, err := ioutil.TempFile("/tmp", "generator-test-")
|
||||
assert.NoError(s.T(), err)
|
||||
defer os.Remove(outPath.Name())
|
||||
|
||||
err = test.generate(test.fileToParse, test.samplesDir, outPath.Name(), test.tmplPath, test.tmplName, test.commit)
|
||||
assert.NoError(s.T(), err)
|
||||
out, err := ioutil.ReadFile(outPath.Name())
|
||||
|
@ -2,9 +2,9 @@ package generator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"text/template"
|
||||
|
||||
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 {
|
||||
langMimeMap := make(map[string]string)
|
||||
for lang, info := range languages {
|
||||
langMimeMap[lang] = info.MimeType
|
||||
if len(info.MimeType) != 0 {
|
||||
langMimeMap[lang] = info.MimeType
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
if mime, ok := data.LanguagesMime[language]; ok {
|
||||
return mime
|
||||
|
Loading…
x
Reference in New Issue
Block a user