Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export static HTML+CSS+JS from Rails

When creating static apps I often start a new Rails app. This makes quite some things easier, like compilation (Coffeescript, SCSS), minimization (JS, CSS) and browser limitations (the page is being served from localhost:3000 so external sources can be loaded etc.).

At the end I want to export the app so I can put it online. Then I just need the HTML+CSS+JS. One can go and pluck the files out manually, but there probably is an easier way for this.

So: is there a tool that stores the compiled, minimized HTML+CSS+JS files from a Rails app?

like image 510
TTT Avatar asked Jul 01 '13 19:07

TTT


3 Answers

If you just want to basically copy the website as it will be rendered by rails (and there is no need for server side code execution), you could just mirror the rails-website using

wget --page-requisites --convert-links http://URL-to-Start

However, this will only download those files that are referenced from the entry URL, so you might need to run it on all sub-URLs individually.

Source: Download a working local copy of a webpage

like image 130
Dennis Guse Avatar answered Sep 30 '22 20:09

Dennis Guse


Agree with Screenmutt. I've tried a couple of the ones mentioned but have had most success with:

http://middlemanapp.com/

Does pretty much everything you are asking for and let's you export to static HTML.

install:

gem install middleman

create project:

middleman init my_new_project (or even better with template --template=html5)

run in local server for live edits:

bundle exec middleman

dump static code:

bundle exec middleman build
like image 45
user2065855 Avatar answered Sep 30 '22 22:09

user2065855


Perhaps you can 'scrape' the HTML from the localhost serving it?

There seem to be some tools for downloading sites in general... You can probably limit them to download resources from localhost:3000 only.

  • http://www.httrack.com/
  • http://www.linuxjournal.com/content/downloading-entire-web-site-wget
like image 26
noio Avatar answered Sep 30 '22 20:09

noio