Skip to content

Commit

Permalink
Fix the issue of browser cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
agreatfool committed Sep 13, 2016
1 parent 1411411 commit 292adba
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ If you want to use some other version:

* clone the repo
* replace the editor in ./swagger-editor
* Add codes below into the bottom of file ***swagger-editor/index.html***
* npm install .

```javascript
<script type="text/javascript">
$("document").ready(function() {
setTimeout(function() {
var fileMenuTimer = setInterval(function() {
// open file menu
var fileMenu = $("#fileMenu");
if (fileMenu.length) {
clearInterval(fileMenuTimer);
fileMenu.click();

// open example selector
var exampleButton = $("#open-example");
var exampleButtonTimer = setInterval(function() {
if (exampleButton.length) {
clearInterval(exampleButtonTimer);
exampleButton.click();

// click open button
setTimeout(function() {
$(".modal-large .btn-primary").click();
}, 1000);
}
}, 300);
}
}, 300);
}, 1000);
});
</script>
```

Done, just use it.
2 changes: 1 addition & 1 deletion bin/swagger2pdf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ try {

// start http server serving the editor site
var httpServerSpawned = false;
var httpServerProcess = libCp.spawn(httpServerPath, [editorPath, '-p 19849']);
var httpServerProcess = libCp.spawn(httpServerPath, [editorPath, '-p 19849', '-c -1']);
httpServerProcess.stdout.on('data', function(data) {
console.log(data.toString());
httpServerSpawned = true;
Expand Down
5 changes: 3 additions & 2 deletions src/electron_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var electron = require('electron');
var app = electron.app;
var BrowserWindow = electron.BrowserWindow;

app.commandLine.appendSwitch('--disable-http-cache');
app.on('ready', function() {
var win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: false }});
win.loadURL('http://127.0.0.1:19849');
win.loadURL('http://127.0.0.1:19849', { "extraHeaders" : "pragma: no-cache\n" });
win.webContents.on("did-finish-load", function() {
console.log('Swagger editor loaded');
setTimeout(function() {
Expand All @@ -19,6 +20,6 @@ app.on('ready', function() {
win.destroy();
})
});
}, 3000);
}, 5000);
});
});
41 changes: 40 additions & 1 deletion swagger-editor/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
<!doctype html><meta charset="utf-8"><title>Swagger Editor</title><meta name="description" content="Swagger Editor"><meta name="viewport" content="width=device-width"><link rel="icon" type="image/png" href="./images/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="./images/favicon-16x16.png" sizes="16x16"><link rel="stylesheet" href="styles/main.css"><link rel="stylesheet" href="styles/branding.css"><div class="total-wrapper" ui-view></div><script src="scripts/vendor.js"></script><script src="scripts/scripts.js"></script><script src="scripts/branding.js"></script>
<!doctype html>
<meta charset="utf-8"><title>Swagger Editor</title>
<meta name="description" content="Swagger Editor">
<meta name="viewport" content="width=device-width">
<link rel="icon" type="image/png" href="./images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="./images/favicon-16x16.png" sizes="16x16">
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/branding.css">
<div class="total-wrapper" ui-view></div>
<script src="scripts/vendor.js"></script>
<script src="scripts/scripts.js"></script>
<script src="scripts/branding.js"></script>
<script type="text/javascript">
$("document").ready(function() {
setTimeout(function() {
var fileMenuTimer = setInterval(function() {
// open file menu
var fileMenu = $("#fileMenu");
if (fileMenu.length) {
clearInterval(fileMenuTimer);
fileMenu.click();

// open example selector
var exampleButton = $("#open-example");
var exampleButtonTimer = setInterval(function() {
if (exampleButton.length) {
clearInterval(exampleButtonTimer);
exampleButton.click();

// click open button
setTimeout(function() {
$(".modal-large .btn-primary").click();
}, 1000);
}
}, 300);
}
}, 300);
}, 1000);
});
</script>

0 comments on commit 292adba

Please sign in to comment.