How can I use live reload in a public-facing ruby server? - ruby

I'm using the livereload plugin for guard in combination with the chrome extension. It's working nicely and my browser refreshes whenever a source file is changed.
It seems like Meteor has this functionality without requiring a chrome extension. Is there any similar library for the ruby world, to hot-push ui changes?

Instead of using the browser plugin, use Rack::LiveReload. It will send events to the browser via web sockets and cause the browser to reload when watched changes occur.

Related

Serving a prototype page in Wakanda 2.4+

Currently using Wakanda 1.1.3 with a mostly Angular4 on client side, yet, a few prototype pages persist from
our initial project. Provided we make the necessary file structure, module, login and syntax changes for v2,
will Wakanda v2.4+ serve our older prototype pages?
If so, is there anything special or unique that we need to do to get a prototype page to load?
You can save the WAF files (JS & CSS) generated by the v1.1.3 runtime for each prototype page.
Open your prototype page in a browser.
Open the browser console.
Save both waf~css and waf~js files.
Hard link these files in your prototype page.
This should be enough to run on Wakanda v.2.6.0

Prevent Firefox from caching localhost?

I've been curious to try switching to Firefox Quantum from Chrome, but for web development have hit a major obstacle that I have not been able to easily resolve –– it's caching my localhost files so when I attempt to load various ember applications at localhost:4200 I end up viewing a cached application different than the one that is currently running.
Is there a way to disable caching for localhost in Firefox? And/or how to developers normally work with Firefox in this regard?
And/or how to developers normally work with Firefox in this regard?
I tend to use CTRL + F5 to do hard reload (ignores cache). Pretty standard for all browsers.
Since there is no native way to configure for individual domains, you could write a Browser Extension that can intercept responses via the webRequest API (see for example onHeadersReceived) by overriding cache headers for a selected domain (you may even be able to find one already in existence).
Or simply configure settings in developer tools to ignore cache when toolbox is open:
There is also the Forget Button that can be dragged into the toolbar from customize.
Set the HTTP Cache-Control response header to max-age=0 in your application.

Prevent caching of any data in my browser for mobile hybrid app.

I host my app on the browser and I using a wrapper to load it on the mobile phone. I have huge problem with cashing data, anytime I make a change in the code, or different user log in I have to delete the app and install it again so I can see my changes. What should be done so I prevent caching .
I tried things that I read in this site about it but still I have the same issue.
I also save some data in the local storage browser

Clearing session in Firefox for every request made (Watir issue)

I'm developing a screen scraping robot that uses Watir (ruby) to crawl specific web searches.
Watir is used as the search results are delivered in pages, only available via AJAX requests.
My issue is now that to perform a new search, the browser has to be shut down in order for the search session to be cleared - otherwise the initial search overrule the change in the GET parameters.
Is it somehow possible to force Firefox to clear sessions on every request made?
Additionally, does anyone have experience solving these kind of issues via Watir?
If the session is maintained via cookies in your firefox browser then it's possible.
All you have to remove the cookies from your firefox cookies repository before it starts.
Firefox stores its cookies at (as of in my ubuntu and mac)
~/.mozilla/firefox/12wwonrk.default/cookies.sqlite [in ubuntu]
or
~/Library/Application Support/Firefox/Profiles/eox4ghka.default/cookies.sqlite [in mac]
(prior Firefox 3 it was cookies.txt instead sqlite)
If you can truncate the sqlite (or the txt) then the cookies will no longer be there.
As you are running Watir you are most probably using ruby. So, if you can run these commands through system or %x[] (or compatible commands through sqlite gem/lib) before Watir::Browser.new statement, hopefully you'll be done.
./sqlite3 path/to/cookies.sqlite
DELETE FROM moz_cookies;
.quit
If you want to use Watir, you can mess with profiles as described at http://watirwebdriver.com/. Most browsers seem to get their own profile for each new instance by default.

Can you deploy Watir on Heroku to generate HTML Snapshots? If so, how?

I would like to generate HTML Snapshots using Watir, hosted on Heroku.
Google's Full Specification for Making AJAX Applications Crawlable suggests using HTMLUnit... see How do I create an HTML snapshot? point #3.
HtmlUnit is a Java-only headless browser emulator; and unfortunately jRuby is not an option on Heroku. So HtmlUnit is ruled out (to my knowledge).
If you're interested I have another question open regarding HtmlUnit as a service hosted on Google App Engine...
Making AJAX Applications Crawlable? How to build a simple web service on Google App Engine to produce HTML Snapshots? ... still waiting on a proven example/answer.
Yes you can
Use Watir with PhantomJS, which is headless
browser = Watir::Browser.new :phantomjs
To use PhantomJS on Heroku, you'll need to use a Heroku PhantomJS buildpack
Troelskin's answer is incorrect. There are ways to run "headless" browsers with Watir, which do not require a "full desktop environment". Having said that, I do not know which method may be appropriate on Heroku.
Other "headless" automation options (if you are using Ruby) are Mechanize with Open-Uri, along with (optional) Nokogiri.
No. You need a full desktop environment to run watir. Heroku doesn't provide you with that.
You could use a service such as Amazon EC2

Resources