Question

I am trying to create simple rack app with static pages.

The structure of my app:

public
 |-index.html
 |-css
   |-skins
     |-blue
       |-blue.css
     |-yellow
      |-yellow.css
     ....many more...
 |-js
   |-bootstrap
      |-aide
       |-abide.js
   ...many more...
config.ru
Gemfile

My config.ru file

use Rack::Static,
  :urls => ["/images", "/js", "/css"],
  :root => "public"
run lambda { |env|
  [
    200,
    {
      'Content-Type'  => 'text/html',
      'Cache-Control' => 'public, max-age=86400'
    },
    File.open('public/index.html', File::RDONLY)
  ]
}

The problem is that inside each folder "js", "css" I have hundreds of subdirectories and files and don't what to specify them manually. Can I load all subfoldres at once?

EDIT

With above configuration, when I ran rackup and pointed browser to localhost:9292. I ve just seen white screen loading. I thought that problem could be that subdirectories aren't loaded. But after I ve looked into log I found that my assets are being loaded in infinite loop and that's why app doesn't respond.

like

127.0.0.1 - - [24/Jan/2014 14:35:01] "GET /js/gmap3.min.js?_=1390559355618 HTTP/1.1" 200 29735 0.0015
127.0.0.1 - - [24/Jan/2014 14:35:01] "GET /js/waypoints.min.js?_=1390559355619 HTTP/1.1" 200 8044 0.0012
127.0.0.1 - - [24/Jan/2014 14:35:01] "GET /js/bootstrap/tab.js?_=1390559355620 HTTP/1.1" 200 3420 0.0009

All assets are loaded with 200 success status. I don't have any additional specific configurations. Gemfile is

source 'https://rubygems.org'

gem 'mail'
gem 'rack'
Was it helpful?

Solution

A correct index.html source could be a solution.

To debug what is happening, you can try to load your index.html with only one specific JS/Css file and temporary comment in all others to make sure you don't repeats you self.

Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top