From 3de90213976a649aeb9b1e5539104c53252ece23 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Mon, 29 Jul 2019 14:30:42 +0200 Subject: [PATCH 1/5] Add missing file extensions for code donwload --- www/common/modes.js | 196 ++++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/www/common/modes.js b/www/common/modes.js index ffed08b17..668a00e1a 100644 --- a/www/common/modes.js +++ b/www/common/modes.js @@ -6,127 +6,127 @@ 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 { From 3e918ec1cf76adff741109b9c5ee4d8add4625f1 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Mon, 29 Jul 2019 16:30:48 +0200 Subject: [PATCH 2/5] Fix issues of no file extension for pad export --- www/code/export.js | 2 +- www/common/modes.js | 24 ++++++++++++------------ www/common/sframe-app-framework.js | 4 ++-- www/common/sframe-common-codemirror.js | 3 ++- www/kanban/export.js | 4 +++- www/kanban/inner.js | 2 +- www/pad/export.js | 2 +- www/pad/inner.js | 2 +- www/poll/export.js | 4 +++- www/settings/make-backup.js | 2 +- www/slide/export.js | 2 +- www/whiteboard/export.js | 2 +- www/whiteboard/inner.js | 2 +- 13 files changed, 30 insertions(+), 25 deletions(-) diff --git a/www/code/export.js b/www/code/export.js index 23d689361..04616a192 100644 --- a/www/code/export.js +++ b/www/code/export.js @@ -8,7 +8,7 @@ define([ module.main = function (userDoc, cb) { var mode = userDoc.highlightMode || 'gfm'; var content = userDoc.content; - module.type = SFCodeMirror.getContentExtension(mode); + module.ext = SFCodeMirror.getContentExtension(mode); cb(SFCodeMirror.fileExporter(content)); }; diff --git a/www/common/modes.js b/www/common/modes.js index 668a00e1a..6d005da30 100644 --- a/www/common/modes.js +++ b/www/common/modes.js @@ -14,7 +14,7 @@ define([ "C text/x-c++src .cpp", "C-like clike .c", "Clojure clojure .clj", - "CMake cmake", /* no extension */ + "CMake cmake _", /* no extension */ "COBOL cobol .cbl", "CoffeeScript coffeescript .coffee", "Common_Lisp commonlisp .lisp", @@ -25,7 +25,7 @@ define([ "Dart dart .dart", "Diff diff .diff", "Django django .py", - "Dockerfile dockerfile", /* no extension */ + "Dockerfile dockerfile _", /* no extension */ "DTD dtd .dtd", "Dylan dylan .dylan", "EBNF ebnf .ebnf", @@ -47,7 +47,7 @@ define([ "Haskell-Literate haskell-literate .lhs", "Haxe haxe .hx", "HTML htmlmixed .html", - "HTTP http", /* no extension */ + "HTTP http _", /* no extension */ "IDL idl .idl", "JADE jade .jade", "Java text/x-java .java", @@ -61,7 +61,7 @@ define([ //"markdown markdown .md", "Mathematica mathematica .nb", "mIRC mirc .irc", - "ML mllike", /* no extension */ + "ML mllike _", /* no extension */ "Modelica modelica .mo", "MscGen mscgen .mscgen", "MUMPS mumps .m", @@ -93,9 +93,9 @@ define([ "Shell shell .sh", "Sieve sieve .sieve", "Slim slim .slim", - "Smalltalk smalltalk", /* no extension */ - "Smarty smarty", /* no extension */ - "Solr solr", /* no extension */ + "Smalltalk smalltalk _", /* no extension */ + "Smarty smarty _", /* no extension */ + "Solr solr _", /* no extension */ "Soy soy .soy", "SPARQL sparql .rq", "Spreadsheet spreadsheet .xls", @@ -107,7 +107,7 @@ define([ "Text text .txt", "Textile textile .textile", "TiddlyWiki tiddlywiki .tw", - "Tiki tiki", /* no extension */ + "Tiki tiki _", /* no extension */ "TOML toml .toml", "Tornado tornado .tornado", "troff troff .troff", @@ -125,22 +125,22 @@ define([ //"xwiki xwiki21", "XQuery xquery .xquery", "YAML yaml .yaml", - "YAML_Frontmatter yaml-frontmatter", /* no extension */ + "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; diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index af856d1d7..e2a0bd0a2 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -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; diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 8a0e2de63..ca39717ad 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -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' }); diff --git a/www/kanban/export.js b/www/kanban/export.js index 2240031fe..9ee770ac7 100644 --- a/www/kanban/export.js +++ b/www/kanban/export.js @@ -2,7 +2,9 @@ // Pads from the code app will be exported using this format instead of plain text. define([ ], function () { - var module = {}; + var module = { + ext: '.json' + }; module.main = function (userDoc, cb) { var content = userDoc.content; diff --git a/www/kanban/inner.js b/www/kanban/inner.js index 29a4d9c88..609e5ac31 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -367,7 +367,7 @@ define([ }); } - framework.setFileExporter('json', function () { + framework.setFileExporter('.json', function () { return new Blob([JSON.stringify(kanban.getBoardsJSON(), 0, 2)], { type: 'application/json', }); diff --git a/www/pad/export.js b/www/pad/export.js index 263593a54..d1deef146 100644 --- a/www/pad/export.js +++ b/www/pad/export.js @@ -5,7 +5,7 @@ define([ '/bower_components/nthen/index.js', ], function ($, Util, Hyperjson, nThen) { var module = { - type: 'html' + ext: '.html' }; var exportMediaTags = function (inner, cb) { diff --git a/www/pad/inner.js b/www/pad/inner.js index 9b56e56bb..f201b8720 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -786,7 +786,7 @@ define([ }); }, true); - framework.setFileExporter(Exporter.type, function (cb) { + framework.setFileExporter(Exporter.ext, function (cb) { Exporter.main(inner, cb); }, true); diff --git a/www/poll/export.js b/www/poll/export.js index 2b915cced..e080ec9b4 100644 --- a/www/poll/export.js +++ b/www/poll/export.js @@ -3,7 +3,9 @@ define([ '/customize/messages.js', ], function (Messages) { - var module = {}; + var module = { + ext: '.csv' + }; var copyObject = function (obj) { return JSON.parse(JSON.stringify(obj)); diff --git a/www/settings/make-backup.js b/www/settings/make-backup.js index 3e2876598..674eaba68 100644 --- a/www/settings/make-backup.js +++ b/www/settings/make-backup.js @@ -34,7 +34,7 @@ define([ var path = '/' + type + '/export.js'; require([path], function (Exporter) { Exporter.main(json, function (data) { - result.ext = '.' + Exporter.type; + result.ext = Exporter.ext || ''; result.data = data; cb(result); }); diff --git a/www/slide/export.js b/www/slide/export.js index 814950306..4e76f041d 100644 --- a/www/slide/export.js +++ b/www/slide/export.js @@ -4,7 +4,7 @@ define([ '/common/sframe-common-codemirror.js', ], function (SFCodeMirror) { var module = { - type: 'md' + ext: '.md' }; module.main = function (userDoc, cb) { diff --git a/www/whiteboard/export.js b/www/whiteboard/export.js index e9f68e311..d3ea70f37 100644 --- a/www/whiteboard/export.js +++ b/www/whiteboard/export.js @@ -14,7 +14,7 @@ define([ var canvas = new Fabric.Canvas(canvas_node); var content = userDoc.content; canvas.loadFromJSON(content, function () { - module.type = 'svg'; + module.ext = '.svg'; cb(canvas.toSVG()); }); }; diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index 18a66a635..1c1e5c563 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -415,7 +415,7 @@ define([ setEditable(!locked); }); - framework.setFileExporter('png', function (cb) { + framework.setFileExporter('.png', function (cb) { $canvas[0].toBlob(function (blob) { cb(blob); }); From 3bd09d986e3a478fe90ecc0ec23baf1fef798d8a Mon Sep 17 00:00:00 2001 From: ClemDee Date: Mon, 29 Jul 2019 16:36:49 +0200 Subject: [PATCH 3/5] Fix slides extension to .md when exported from /slide --- www/slide/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/slide/inner.js b/www/slide/inner.js index 1be2e5f3b..b5171d94f 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -538,7 +538,7 @@ define([ editor.on('change', framework.localChange); - framework.setFileExporter(CodeMirror.getContentExtension, CodeMirror.fileExporter); + framework.setFileExporter(".md", CodeMirror.fileExporter); framework.setFileImporter({}, CodeMirror.fileImporter); framework.start(); From 38b414bbe1ae0f6235badd9579770ea456e3f4e9 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Mon, 29 Jul 2019 16:46:52 +0200 Subject: [PATCH 4/5] Fix folder metadata appearing as folder in downloaded drive zip --- www/settings/make-backup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/settings/make-backup.js b/www/settings/make-backup.js index 674eaba68..b86f1f3b2 100644 --- a/www/settings/make-backup.js +++ b/www/settings/make-backup.js @@ -163,12 +163,12 @@ define([ var existingNames = []; Object.keys(root).forEach(function (k) { var el = root[k]; - if (typeof el === "object") { + if (typeof el === "object" && el.metadata !== true) { // if folder var fName = getUnique(sanitize(k), '', existingNames); existingNames.push(fName.toLowerCase()); return void makeFolder(ctx, el, zip.folder(fName), fd); } - if (ctx.data.sharedFolders[el]) { + if (ctx.data.sharedFolders[el]) { // if shared folder var sfData = ctx.sf[el].metadata; var sfName = getUnique(sanitize(sfData.title || 'Folder'), '', existingNames); existingNames.push(sfName.toLowerCase()); From dee3ae406a728cc031522a74f59a5edbb57eb38d Mon Sep 17 00:00:00 2001 From: ClemDee Date: Tue, 30 Jul 2019 10:11:20 +0200 Subject: [PATCH 5/5] Fix whiteboard export to .png from the app --- www/whiteboard/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index 1c1e5c563..b0b382314 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -419,7 +419,7 @@ define([ $canvas[0].toBlob(function (blob) { cb(blob); }); - }); + }, true); framework.setNormalizer(function (c) { return {