Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cribjs-editor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
cribjs-editor
Commits
b043a615
Commit
b043a615
authored
Jul 17, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use External Mimetype library to identify mimetypes properly
parent
097e1705
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
776 additions
and
25 deletions
+776
-25
gadget/gadget_cribjs_page_save_load.html
gadget/gadget_cribjs_page_save_load.html
+1
-0
gadget/gadget_cribjs_page_save_load.js
gadget/gadget_cribjs_page_save_load.js
+11
-13
gadget/gadget_landing_cribjs.html
gadget/gadget_landing_cribjs.html
+1
-0
gadget/gadget_landing_cribjs.js
gadget/gadget_landing_cribjs.js
+6
-12
lib/mimetype.js
lib/mimetype.js
+757
-0
No files found.
gadget/gadget_cribjs_page_save_load.html
View file @
b043a615
...
...
@@ -10,6 +10,7 @@
<script
src=
"../lib/renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jszip.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/FileSaver.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/mimetype.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/webtorrent.min.js"
type=
"text/javascript"
></script>
<script
src=
"./gadget_global.js"
type=
"text/javascript"
></script>
...
...
gadget/gadget_cribjs_page_save_load.js
View file @
b043a615
/*global window, rJS, loopEventListener, RSVP, console, document, saveAs, WebTorrent,
File, setInterval, clearInterval*/
File, setInterval, clearInterval
, mimeType
*/
/*jslint nomen: true, indent: 2, maxerr: 3*/
(
function
(
window
,
rJS
,
loopEventListener
,
JSZip
,
FileSaver
,
WebTorrent
)
{
(
function
(
window
,
rJS
,
loopEventListener
,
JSZip
,
FileSaver
,
WebTorrent
,
mimeType
)
{
"
use strict
"
;
function
getExtension
(
url
)
{
...
...
@@ -260,16 +261,10 @@
return
zipEntry
.
async
(
'
blob
'
);
})
.
push
(
function
(
result
)
{
if
(
end_url
.
endsWith
(
"
.js
"
))
{
// This is a ugly hack as mimetype needs to be correct for JS
result
=
result
.
slice
(
0
,
result
.
size
,
"
application/javascript
"
);
}
else
if
(
end_url
.
endsWith
(
"
.html
"
))
{
// This is a ugly hack as mimetype needs to be correct for JS
result
=
result
.
slice
(
0
,
result
.
size
,
"
text/html
"
);
}
else
if
(
end_url
.
endsWith
(
"
.css
"
))
{
// This is a ugly hack as mimetype needs to be correct for JS
result
=
result
.
slice
(
0
,
result
.
size
,
"
text/css
"
);
}
var
guessed_type
=
mimeType
.
lookup
(
end_url
,
false
,
"
application/octet-stream
"
);
result
=
result
.
slice
(
0
,
result
.
size
,
guessed_type
);
return
gadget
.
crib_sw_put
(
end_url
,
{
blob
:
result
});
})
);
...
...
@@ -282,6 +277,9 @@
})
.
push
(
function
()
{
logFunction
(
gadget
,
"
Loaded
"
+
url_number
+
"
files at
"
+
Date
());
},
function
(
e
)
{
console
.
error
(
e
);
logFunction
(
gadget
,
"
ERROR:</br>
"
+
e
.
toString
());
});
}
...
...
@@ -367,4 +365,4 @@
return
RSVP
.
all
(
promise_list
);
});
});
}(
window
,
rJS
,
loopEventListener
,
JSZip
,
FileSaver
,
WebTorrent
));
\ No newline at end of file
}(
window
,
rJS
,
loopEventListener
,
JSZip
,
FileSaver
,
WebTorrent
,
mimeType
));
\ No newline at end of file
gadget/gadget_landing_cribjs.html
View file @
b043a615
...
...
@@ -9,6 +9,7 @@
<script
src=
"../lib/rsvp.js"
></script>
<script
src=
"../lib/renderjs.js"
></script>
<script
src=
"../lib/jszip.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/mimetype.js"
type=
"text/javascript"
></script>
<script
src=
"./gadget_landing_cribjs.js"
></script>
</head>
<body>
...
...
gadget/gadget_landing_cribjs.js
View file @
b043a615
/*jslint browser: true, indent: 2, maxlen: 80*/
/*globals RSVP, rJS,
location, console, fetch, Promise*/
(
function
(
window
,
document
,
RSVP
,
rJS
,
location
,
console
,
JSZip
)
{
(
function
(
window
,
document
,
RSVP
,
rJS
,
location
,
console
,
JSZip
,
mimeType
)
{
"
use strict
"
;
function
getExtension
(
url
)
{
...
...
@@ -38,16 +38,10 @@
return
zipEntry
.
async
(
'
blob
'
);
})
.
push
(
function
(
result
)
{
if
(
end_url
.
endsWith
(
"
.js
"
))
{
// This is a ugly hack as mimetype needs to be correct for JS
result
=
result
.
slice
(
0
,
result
.
size
,
"
application/javascript
"
);
}
else
if
(
end_url
.
endsWith
(
"
.html
"
))
{
// This is a ugly hack as mimetype needs to be correct for JS
result
=
result
.
slice
(
0
,
result
.
size
,
"
text/html
"
);
}
else
if
(
end_url
.
endsWith
(
"
.css
"
))
{
// This is a ugly hack as mimetype needs to be correct for JS
result
=
result
.
slice
(
0
,
result
.
size
,
"
text/css
"
);
}
var
guessed_type
=
mimeType
.
lookup
(
end_url
,
false
,
"
application/octet-stream
"
);
result
=
result
.
slice
(
0
,
result
.
size
,
guessed_type
);
return
gadget
.
crib_sw_put
(
end_url
,
{
blob
:
result
});
})
);
...
...
@@ -113,4 +107,4 @@
return
this
.
getSetting
(
argument_list
[
0
],
argument_list
[
1
]);
});
}(
window
,
document
,
RSVP
,
rJS
,
location
,
console
,
JSZip
));
\ No newline at end of file
}(
window
,
document
,
RSVP
,
rJS
,
location
,
console
,
JSZip
,
mimeType
));
\ No newline at end of file
lib/mimetype.js
0 → 100644
View file @
b043a615
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment