Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Prevent browsers from caching old codemirror when it is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Oct 22, 2013
1 parent f1f4304 commit 3c0afe6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
Expand Up @@ -26,8 +26,8 @@
<link type="text/css" rel="stylesheet"
href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic"/>

<script src="codemirror-compressed.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="codemirror.css"/>
<script src="codemirror/codemirror-compressed-3.16.cache.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="codemirror/codemirror-3.16.cache.css"/>

<script src="diff_match_patch/javascript/diff_match_patch.js"
type="text/javascript"></script>
Expand Down
Expand Up @@ -10,8 +10,8 @@
<link rel="stylesheet" href="images/fontello/css/fontello.css"/>
<link rel="stylesheet" href="../stylesheet/menu.css"/>

<script src="codemirror-compressed.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="codemirror.css"/>
<script src="codemirror/codemirror-compressed-3.16.cache.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="codemirror/codemirror-3.16.cache.css"/>

<script src="diff_match_patch/javascript/diff_match_patch.js"
type="text/javascript"></script>
Expand Down
@@ -0,0 +1,36 @@
The codemirror version number is incorporated in the filename to enable
correct caching in browsers.

When updating codemirror, be sure to change the filenames for
codemirror-*.cache.css and codemirror-compressed-*.cache.js and the
references to them in Application.xhtml and Dummy.html.


Recipe for codemirror-compressed.js:

codemirror-compressed.js is generated at http://codemirror.net/doc/compress.html
includes:
- codemirror.js
- css.js
- htmlmixed.js
- javascript.js
- xml.js
- runmode.js
- searchcursor.js (to enable highlight search term within codemirror"
- overlay.js (to support visible space)

added following custom code when generating the codemirror-compressed.js (to support visible space):

CodeMirror.defineMode("visibleSpace", function(config, parserConfig) {
var visibleSpaceOverlay = {
token: function(stream, state) {
var ch = stream.next();
if (ch == " ") {
return "space";
} else {
return null;
}
}
};
return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "htmlmixed"), visibleSpaceOverlay);
});

0 comments on commit 3c0afe6

Please sign in to comment.