fancyviews 1.1 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -4
- data/fancyviews.gemspec +3 -2
- data/lib/sinatra/fancyviews.rb +21 -6
- data/test/html4.rb +33 -0
- data/test/{test.rb → html5.rb} +0 -0
- metadata +4 -3
data/Rakefile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
task :default => :test
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
%w(html4 html5).each do |version|
|
4
|
+
desc "Run example test app for #{version}"
|
5
|
+
task "test_#{version}" do
|
6
|
+
dir = File.dirname(__FILE__)
|
7
|
+
system "cd #{dir} && ruby test/#{version}.rb -p 2222"
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
11
|
begin
|
data/fancyviews.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "fancyviews"
|
3
3
|
s.rubyforge_project = 'fancyviews'
|
4
|
-
s.version = "1.
|
4
|
+
s.version = "1.3"
|
5
5
|
s.summary = "Fancy Views"
|
6
6
|
s.description = "Fancy Views"
|
7
7
|
s.email = "myles@myles.id.au"
|
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
Rakefile
|
13
13
|
fancyviews.gemspec
|
14
14
|
lib/sinatra/fancyviews.rb
|
15
|
-
test/
|
15
|
+
test/html4.rb
|
16
|
+
test/html5.rb
|
16
17
|
]
|
17
18
|
s.add_dependency("sinatra", [">= 0.9.1.1"])
|
18
19
|
s.add_dependency("haml", [">= 2.2"])
|
data/lib/sinatra/fancyviews.rb
CHANGED
@@ -78,16 +78,31 @@ module Sinatra
|
|
78
78
|
eng = Sass::Engine.new(imported + "\n" + sass, :attribute_syntax => :normal)
|
79
79
|
"\n/* -- #{name} -- */\n" + eng.render
|
80
80
|
end.join
|
81
|
-
|
82
|
-
|
81
|
+
|
82
|
+
style_tag(rendered_styles, options[:media])
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
|
+
def style_tag(styles, media=nil)
|
86
|
+
capture_haml do
|
87
|
+
haml_tag(:style, styles, :type => ("text/css" if haml_format != :html5), :media => media)
|
88
|
+
end.strip
|
89
|
+
end
|
90
|
+
|
85
91
|
# renders all the scripts captured by the :script filter
|
86
92
|
def scripts
|
87
|
-
|
93
|
+
script_tag(fancyviews.included_scripts.map do |name, js|
|
88
94
|
"\n/* -- #{name} -- */\n" + js
|
89
|
-
end.join
|
90
|
-
|
95
|
+
end.join)
|
96
|
+
end
|
97
|
+
|
98
|
+
def script_tag(scripts)
|
99
|
+
capture_haml do
|
100
|
+
haml_tag(:script, scripts, :type => ("text/javascript" if haml_format != :html5))
|
101
|
+
end.strip
|
102
|
+
end
|
103
|
+
|
104
|
+
def haml_format
|
105
|
+
(options.haml && options.haml[:format]) || :xhtml
|
91
106
|
end
|
92
107
|
|
93
108
|
def fancyviews
|
data/test/html4.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra'
|
3
|
+
require File.dirname(__FILE__) + '/../lib/sinatra/fancyviews'
|
4
|
+
|
5
|
+
set :haml, :format => :html4
|
6
|
+
|
7
|
+
get('/') { page :home }
|
8
|
+
|
9
|
+
__END__
|
10
|
+
|
11
|
+
@@layout
|
12
|
+
!!!
|
13
|
+
%head
|
14
|
+
%title FancyTest
|
15
|
+
= styles :media => "screen, projection"
|
16
|
+
%body
|
17
|
+
= yield
|
18
|
+
= scripts
|
19
|
+
|
20
|
+
@@home
|
21
|
+
:style
|
22
|
+
body
|
23
|
+
:background-color goldenrod
|
24
|
+
|
25
|
+
:script
|
26
|
+
if (document.getElementsByTagName('style')[0].type != "text/css")
|
27
|
+
alert("Style tag doesn't have type = 'text/css'");
|
28
|
+
else if (document.getElementsByTagName('style')[0].media != "screen, projection")
|
29
|
+
alert("Style tag doesn't have media = 'screen, projection'");
|
30
|
+
else if (document.getElementsByTagName('script')[0].type != "text/javascript")
|
31
|
+
alert("Script tag doesn't have type = 'text/javascript'");
|
32
|
+
else
|
33
|
+
alert("All good!");
|
data/test/{test.rb → html5.rb}
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancyviews
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myles Byrne
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-03 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -44,7 +44,8 @@ files:
|
|
44
44
|
- Rakefile
|
45
45
|
- fancyviews.gemspec
|
46
46
|
- lib/sinatra/fancyviews.rb
|
47
|
-
- test/
|
47
|
+
- test/html4.rb
|
48
|
+
- test/html5.rb
|
48
49
|
has_rdoc: false
|
49
50
|
homepage:
|
50
51
|
post_install_message:
|