wbzyl-sinatra-static-assets 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +42 -0
- data/VERSION.yml +1 -1
- data/examples/rconfig.ru +7 -14
- data/examples/rsummer/summer.rb +1 -1
- data/examples/rsummer/views/index.erb +3 -0
- data/examples/rsummer/views/layout.erb +0 -6
- data/examples/rwinter/config.ru +5 -11
- data/examples/rwinter/views/index.erb +3 -0
- data/examples/rwinter/views/layout.erb +1 -0
- data/examples/rwinter/{mapp.rb → winter.rb} +4 -4
- metadata +6 -6
- data/examples/rsummer/views/app.erb +0 -3
- data/examples/rwinter/views/mapp.erb +0 -3
data/README.markdown
CHANGED
@@ -130,6 +130,48 @@ Or, if subclassing `Sinatra::Base`, include helpers manually:
|
|
130
130
|
# ...
|
131
131
|
end
|
132
132
|
|
133
|
+
## Dispatching reusable Sinatra applications
|
134
|
+
|
135
|
+
With the latest version of Sinatra it is possible to build
|
136
|
+
reusable Sinatra applications. This means that multiple Sinatra applications
|
137
|
+
can now be run in isolation and co-exist peacefully with other Rack
|
138
|
+
based applications. Subclassing `Sinatra::Base` creates such a
|
139
|
+
reusable application.
|
140
|
+
|
141
|
+
The `example` directory contains two reusable Sinatra applications:
|
142
|
+
*rsummer*, *rwinter* and a rackup file `rconfig.ru` which
|
143
|
+
dispatches these applications to `/summer` and `/rsummer` sub URI.
|
144
|
+
|
145
|
+
require 'rsummer/summer'
|
146
|
+
require 'rwinter/winter'
|
147
|
+
|
148
|
+
map '/summer' do
|
149
|
+
run Sinatra::Summer.new
|
150
|
+
end
|
151
|
+
|
152
|
+
map '/winter' do
|
153
|
+
run Sinatra::Winter.new
|
154
|
+
end
|
155
|
+
|
156
|
+
This rackup file could be used to deploy to virtual host's root.
|
157
|
+
|
158
|
+
<VirtualHost *:80>
|
159
|
+
ServerName hitch.local
|
160
|
+
DocumentRoot /srv/www/hitch.local
|
161
|
+
</VirtualHost>
|
162
|
+
|
163
|
+
Creating required by Passenger directories:
|
164
|
+
|
165
|
+
mkdir /srv/www/hitch.local/{public,tmp}
|
166
|
+
|
167
|
+
and moving `config.ru` into `/srv/www/hitch.local`.
|
168
|
+
|
169
|
+
With everything in place, after restarting Apache2 the applications
|
170
|
+
are accessible from the
|
171
|
+
|
172
|
+
http://hitch.local/summer http://hitch.local/winter
|
173
|
+
|
174
|
+
respectively.
|
133
175
|
|
134
176
|
## Miscellaneous stuff
|
135
177
|
|
data/VERSION.yml
CHANGED
data/examples/rconfig.ru
CHANGED
@@ -1,17 +1,10 @@
|
|
1
|
-
require 'rsummer/
|
2
|
-
require 'rwinter/
|
1
|
+
require 'rsummer/summer'
|
2
|
+
require 'rwinter/winter'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
map '/mapp1' do
|
9
|
-
run Sinatra::Mapp1.new
|
10
|
-
end
|
4
|
+
map '/summer' do
|
5
|
+
run Sinatra::Summer.new
|
6
|
+
end
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
8
|
+
map '/winter' do
|
9
|
+
run Sinatra::Winter.new
|
15
10
|
end
|
16
|
-
|
17
|
-
run Rapp
|
data/examples/rsummer/summer.rb
CHANGED
@@ -3,12 +3,6 @@
|
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
5
5
|
|
6
|
-
<!-- does not work
|
7
|
-
|
8
|
-
<link charset="utf-8" href="/stylesheets/mapp.css" media="screen" rel="stylesheet" type="text/css">
|
9
|
-
|
10
|
-
-->
|
11
|
-
|
12
6
|
<%= stylesheet_link_tag "/stylesheets/mapp.css" %>
|
13
7
|
<%= javascript_script_tag "/javascripts/mapp.js" %>
|
14
8
|
|
data/examples/rwinter/config.ru
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'winter'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
use Rack::Lint
|
3
|
+
use Rack::ShowExceptions
|
4
|
+
use Rack::Lint
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
map '/' do
|
10
|
-
run Sinatra::Mapp2.new
|
11
|
-
end
|
6
|
+
map '/' do
|
7
|
+
run Sinatra::Winter.new
|
12
8
|
end
|
13
|
-
|
14
|
-
run Mapp2
|
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'sinatra/base'
|
4
4
|
|
5
|
-
gem 'sinatra-static-assets'
|
5
|
+
gem 'wbzyl-sinatra-static-assets'
|
6
6
|
require 'sinatra/static_assets'
|
7
7
|
|
8
8
|
module Sinatra
|
9
|
-
class
|
9
|
+
class Winter < Sinatra::Base
|
10
10
|
helpers Sinatra::UrlForHelper
|
11
11
|
helpers Sinatra::StaticAssets
|
12
12
|
|
13
13
|
set :app_file, __FILE__
|
14
14
|
set :static, true
|
15
15
|
|
16
|
-
get '
|
16
|
+
get '/?' do
|
17
17
|
@title = "Tatra Mountains, Dolina Gąsienicowa (1500 m)"
|
18
|
-
erb :
|
18
|
+
erb :index
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wbzyl-sinatra-static-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wlodek Bzyl
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -72,17 +72,17 @@ files:
|
|
72
72
|
- examples/rsummer/public/stylesheets/src/background.png
|
73
73
|
- examples/rsummer/summer.rb
|
74
74
|
- examples/rsummer/tmp/always_restart.txt
|
75
|
-
- examples/rsummer/views/
|
75
|
+
- examples/rsummer/views/index.erb
|
76
76
|
- examples/rsummer/views/layout.erb
|
77
77
|
- examples/rwinter/config.ru
|
78
|
-
- examples/rwinter/mapp.rb
|
79
78
|
- examples/rwinter/public/images/tatry2.jpg
|
80
79
|
- examples/rwinter/public/javascripts/mapp.js
|
81
80
|
- examples/rwinter/public/stylesheets/mapp.css
|
82
81
|
- examples/rwinter/public/stylesheets/src/background.png
|
83
82
|
- examples/rwinter/tmp/always_restart.txt
|
83
|
+
- examples/rwinter/views/index.erb
|
84
84
|
- examples/rwinter/views/layout.erb
|
85
|
-
- examples/rwinter/
|
85
|
+
- examples/rwinter/winter.rb
|
86
86
|
- examples/summer/config.ru
|
87
87
|
- examples/summer/public/images/tatry1.jpg
|
88
88
|
- examples/summer/public/javascripts/app.js
|
@@ -138,5 +138,5 @@ test_files:
|
|
138
138
|
- test/sinatra_static_assets_test.rb
|
139
139
|
- examples/summer/summer.rb
|
140
140
|
- examples/rsummer/summer.rb
|
141
|
-
- examples/rwinter/
|
141
|
+
- examples/rwinter/winter.rb
|
142
142
|
- examples/winter/app2.rb
|