backtik-red-herring 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +0 -3
- data/app_generators/herring/templates/config.ru +6 -0
- data/lib/herring.rb +1 -1
- data/lib/herring/herring_rack.rb +11 -5
- data/red-herring.gemspec +1 -1
- metadata +1 -1
data/Manifest.txt
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
require 'herring'
|
2
2
|
|
3
|
+
Rack::Herring::HerringRoot = File.dirname(__FILE__)
|
4
|
+
BANNER = <<END
|
5
|
+
********* Loaded **********
|
6
|
+
Running Red v#{Red::VERSION} on Red Herring v#{Herring::VERSION} in debug mode.
|
7
|
+
END
|
3
8
|
use Rack::ShowExceptions
|
4
9
|
run Rack::Herring.new
|
10
|
+
puts BANNER
|
data/lib/herring.rb
CHANGED
data/lib/herring/herring_rack.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rack/request'
|
2
2
|
require 'rack/response'
|
3
3
|
require 'rubygems' rescue nil
|
4
|
+
require 'haml' rescue nil
|
4
5
|
require 'sass' rescue nil
|
5
6
|
require 'red'
|
6
7
|
require 'red/executable'
|
@@ -11,18 +12,23 @@ include Red
|
|
11
12
|
|
12
13
|
module Rack
|
13
14
|
class Herring
|
14
|
-
HerringRoot = ::File.join(::File.dirname(__FILE__),'..')
|
15
15
|
def call(env)
|
16
|
-
req = Request.new(env)
|
17
|
-
Red.init(::File.join(HerringRoot,req.path_info))
|
18
|
-
|
16
|
+
req = Request.new(env)
|
19
17
|
data, headers = case ::File.extname(req.path_info)
|
20
18
|
when '.ajax'
|
21
19
|
update_page(req.POST['red']) if req.post?
|
22
20
|
when '.red'
|
23
|
-
|
21
|
+
Red.init(::File.join(HerringRoot,req.path_info))
|
22
|
+
translated_ruby = translate_to_string_including_ruby(::File.read("#{HerringRoot}#{req.path_info}"))
|
23
|
+
[translated_ruby, {"Content-Type" => "text/js"}]
|
24
24
|
when '.html'
|
25
25
|
[::File.read("#{HerringRoot}#{req.path_info}"), {"Content-Type" => "text/html"}]
|
26
|
+
when /\.(haml|html)/
|
27
|
+
if req.path_info =~ /\.haml(\.html)?$/
|
28
|
+
[Haml::Engine.new(::File.read("#{HerringRoot}#{req.path_info}")).to_html, {"Content-Type" => "text/html"}]
|
29
|
+
else
|
30
|
+
[::File.read("#{HerringRoot}#{req.path_info}"), {"Content-Type" => "text/html"}]
|
31
|
+
end
|
26
32
|
when '.js'
|
27
33
|
[::File.read("#{HerringRoot}#{req.path_info}"), {"Content-Type" => "text/javascript"}]
|
28
34
|
when '.css'
|
data/red-herring.gemspec
CHANGED