Multi-size style refresh
I started looking a easy way to test multiple resolution tests. So my current solution.
- Nodejs server Running a simple websocket server
- Start-Stop server bash script
- A refresher page. Used when opened to broadcast a major refresh signal.
- Custom sublime builder command
- A simple snippet for the current page that's under development
1 - Server Must be visible to all browsers + Editor machine
"use strict";
// used for start-stop script
process.title = 'nodejscurrent';
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
fs = require('fs');
app.listen(7777);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
io.sockets.on('connection', function (socket) {
socket.on('do-refresh', function (data) {
socket.broadcast.emit('refresh');
});
io.sockets.on('message', function(data) {
console.log("MSG", data);
});
});
- Start-Stop bash script
#!/bin/bash
ps aux | grep nodejsrefresher | awk '{ system("kill -9 "$2)}'; nodejs server.js
- The refresher page. Must be visible for the sublime-editor
<!-- REFRESHER -->
- Custom sublime builder command
- Create from Tools -> Build System -> New Build System
{
"shell_cmd": "google-chrome http://REFRESHER-VISIBLE-URL/refresh.html"
}
- A simple snippet for the current page that's under development Add in head section. Put the client socket.io.min.js for example in 'static' folder.
Maybe not a perfect solution but works really good for many browser windows + devices. Added in chrome "responsiView" plugin for testing standard resolutions.