Merge pull request #412 from xwiki-labs/downloadFiles

Download files
This commit is contained in:
ansuz
2019-08-08 15:35:09 +02:00
committed by GitHub
14 changed files with 123 additions and 118 deletions

View File

@@ -6,141 +6,141 @@ define([
// mode language (extension)
var list = Modes.list = [
"APL apl .apl",
"ASCII-Armor asciiarmor",
"ASN.1 asn.1",
"ASCII-Armor asciiarmor .asc",
"ASN.1 asn.1 .asn1",
"Asterisk asterisk",
"Brainfuck brainfuck .b",
"C text/x-csrc .c",
"C text/x-c++src .cpp",
"C-like clike",
"Clojure clojure",
"CMake cmake",
"COBOL cobol",
"CoffeeScript coffeescript",
"Common_Lisp commonlisp",
"Crystal crystal",
"C-like clike .c",
"Clojure clojure .clj",
"CMake cmake _", /* no extension */
"COBOL cobol .cbl",
"CoffeeScript coffeescript .coffee",
"Common_Lisp commonlisp .lisp",
"Crystal crystal .cr",
"CSS css .css",
"Cypher cypher",
"D d",
"Dart dart",
"Diff diff",
"Django django",
"Dockerfile dockerfile",
"DTD dtd",
"Dylan dylan",
"EBNF ebnf",
"ECL ecl",
"Eiffel eiffel",
"Cypher cypher .cypher",
"D d .d",
"Dart dart .dart",
"Diff diff .diff",
"Django django .py",
"Dockerfile dockerfile _", /* no extension */
"DTD dtd .dtd",
"Dylan dylan .dylan",
"EBNF ebnf .ebnf",
"ECL ecl .ecl",
"Eiffel eiffel .e",
"Elm elm .elm",
"Erlang erlang",
"Factor factor",
"FCL fcl",
"Forth forth",
"Fortran fortran",
"GAS gas",
"Gherkin gherkin",
"Go go",
"Groovy groovy",
"Haml haml",
"Handlebars handlebars",
"Erlang erlang .erl",
"Factor factor .factor",
"FCL fcl .fcl",
"Forth forth .fs",
"Fortran fortran .f90",
"GAS gas .gas",
"Gherkin gherkin .feature",
"Go go .go",
"Groovy groovy .groovy",
"Haml haml .haml",
"Handlebars handlebars .hbs",
"Haskell haskell .hs",
"Haskell-Literate haskell-literate",
"Haxe haxe",
"Haskell-Literate haskell-literate .lhs",
"Haxe haxe .hx",
"HTML htmlmixed .html",
"HTTP http",
"IDL idl",
"JADE jade",
"HTTP http _", /* no extension */
"IDL idl .idl",
"JADE jade .jade",
"Java text/x-java .java",
"JavaScript javascript .js",
"Jinja2 jinja2",
"Jinja2 jinja2 .j2",
"JSX jsx .jsx",
"Julia julia",
"LiveScript livescript",
"Lua lua",
"Julia julia .jl",
"LiveScript livescript .ls",
"Lua lua .lua",
"Markdown gfm .md",
//"markdown markdown .md",
"Mathematica mathematica",
"mIRC mirc",
"ML mllike",
"Modelica modelica",
"MscGen mscgen",
"MUMPS mumps",
"Nginx nginx",
"NSIS nsis",
"N-Triples ntriples",
"Mathematica mathematica .nb",
"mIRC mirc .irc",
"ML mllike _", /* no extension */
"Modelica modelica .mo",
"MscGen mscgen .mscgen",
"MUMPS mumps .m",
"Nginx nginx .conf",
"NSIS nsis .nsi",
"N-Triples ntriples .nq",
"Objective-C text/x-objectivec .m",
"Octave octave",
"Octave octave .m",
"Org-mode orgmode .org",
"Oz oz",
"Pascal pascal",
"PEG.js pegjs",
"Perl perl",
"PHP php",
"Pig pig",
"PowerShell powershell",
"Properties properties",
"Protocol_Buffers protobuf",
"Puppet puppet",
"Oz oz .oz",
"Pascal pascal .pas",
"PEG.js pegjs .pegjs",
"Perl perl .pl",
"PHP php .php",
"Pig pig .pig",
"PowerShell powershell .ps1",
"Properties properties .properties",
"Protocol_Buffers protobuf .proto",
"Puppet puppet .pp",
"Python python .py",
"Q q",
"R r",
"RPM rpm",
"RST rst",
"Ruby ruby",
"Rust rust",
"Sass sass",
"Q q .q",
"R r .r",
"RPM rpm .rpm",
"RST rst .rst",
"Ruby ruby .rb",
"Rust rust .rs",
"Sass sass .sass",
"Scheme scheme .scm",
"Shell shell .sh",
"Sieve sieve",
"Slim slim",
"Smalltalk smalltalk",
"Smarty smarty",
"Solr solr",
"Soy soy",
"SPARQL sparql",
"Spreadsheet spreadsheet",
"SQL sql",
"sTeX stex",
"Stylus stylus",
"Swift swift",
"Tcl tcl",
"Sieve sieve .sieve",
"Slim slim .slim",
"Smalltalk smalltalk _", /* no extension */
"Smarty smarty _", /* no extension */
"Solr solr _", /* no extension */
"Soy soy .soy",
"SPARQL sparql .rq",
"Spreadsheet spreadsheet .xls",
"SQL sql .sql",
"sTeX stex .stex",
"Stylus stylus .styl",
"Swift swift .swift",
"Tcl tcl .tcl",
"Text text .txt",
"Textile textile",
"TiddlyWiki tiddlywiki",
"Tiki tiki",
"TOML toml",
"Tornado tornado",
"troff troff",
"Textile textile .textile",
"TiddlyWiki tiddlywiki .tw",
"Tiki tiki _", /* no extension */
"TOML toml .toml",
"Tornado tornado .tornado",
"troff troff .troff",
"TTCN ttcn",
"TTCN-cfg ttcn-cfg",
"Turtle turtle",
"Twig twig",
"Visual_Basic vb",
"VBScript vbscript",
"Velocity velocity",
"Verilog verilog",
"VHDL vhdl",
"Vue vue",
"XML xml",
"Turtle turtle .ttl",
"Twig twig .twig",
"Visual_Basic vb .vb",
"VBScript vbscript .vbs",
"Velocity velocity .vm",
"Verilog verilog .v",
"VHDL vhdl .vhdl",
"Vue vue .vue",
"XML xml .xml",
//"xwiki xwiki21",
"XQuery xquery",
"XQuery xquery .xquery",
"YAML yaml .yaml",
"YAML_Frontmatter yaml-frontmatter",
"Z80 z80"
"YAML_Frontmatter yaml-frontmatter _", /* no extension */
"Z80 z80 .z80"
].map(function (line) {
var kv = line.split(/\s/);
return {
language: kv[0].replace(/_/g, ' '),
mode: kv[1],
ext: kv[2],
ext: kv[2] === '_' ? '' : kv[2],
};
});
Modes.extensionOf = function (mode) {
var ext = '';
var ext;
list.some(function (o) {
if (o.mode !== mode) { return; }
ext = o.ext || '';
ext = o.ext;
return true;
});
return ext;

View File

@@ -401,7 +401,7 @@ define([
var ext = (typeof(extension) === 'function') ? extension() : extension;
var suggestion = title.suggestTitle('cryptpad-document');
UI.prompt(Messages.exportPrompt,
Util.fixFileName(suggestion) + '.' + ext, function (filename)
Util.fixFileName(suggestion) + ext, function (filename)
{
if (!(typeof(filename) === 'string' && filename)) { return; }
if (async) {
@@ -454,7 +454,7 @@ define([
return;
}
if (!mediaTagEmbedder) { console.log('mediaTagEmbedder missing'); return; }
if (data.type !== 'file') { console.log('unhandled embed type ' + data.type); return; }
if (data.type !== 'file') { console.log('unhandled embed type ' + data.type); return; }
var privateDat = cpNfInner.metadataMgr.getPrivateData();
var origin = privateDat.fileHost || privateDat.origin;
var src = data.src = origin + data.src;

View File

@@ -39,7 +39,8 @@ define([
};
module.getContentExtension = function (mode) {
return (Modes.extensionOf(mode) || '.txt').slice(1);
var ext = Modes.extensionOf(mode);
return ext !== undefined ? ext : '.txt';
};
module.fileExporter = function (content) {
return new Blob([ content ], { type: 'text/plain;charset=utf-8' });