hoshi 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +9 -6
- data/doc/LICENSE +1 -1
- data/doc/examples/env.cgi +0 -1
- data/lib/hoshi/view/html4_transitional.rb +1 -1
- data/lib/hoshi/view/html5.rb +23 -0
- data/lib/hoshi/view/xhtml1.rb +1 -2
- data/lib/hoshi/view/xhtml1_frameset.rb +2 -2
- data/lib/hoshi/view.rb +4 -0
- metadata +68 -72
- data/doc/README +0 -180
- data/doc/examples/feed.rb +0 -40
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 221a93d1028f8a61613f742d6d260f5678e83b1f
|
4
|
+
data.tar.gz: 10addb7f304cb7fc5f533e77b48fae2442df608a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3e4b240018e7bc059f8eaa810c0c280587df6336645c44a5911d6a8b5fb9f41c44db2f934beb1eb5ec80c8f4375088d436f064b6b54d8bd10a6a4fde3422552
|
7
|
+
data.tar.gz: dc0fb5a542d44f605f9133668c092ef1d03a745c76ef0bd2ed3ccd9528edc53477e4d251a67cd238c62d52fa5654a5b5bed7ed3afe07855821114f077b4b58ad
|
data/Rakefile
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
1
|
+
require 'rubygems/package_task'
|
2
|
+
require 'rdoc/task'
|
4
3
|
|
5
4
|
spec = Gem::Specification.new { |s|
|
6
5
|
s.platform = Gem::Platform::RUBY
|
7
6
|
|
8
7
|
s.author = "Pete Elmore"
|
9
|
-
s.email = "pete
|
8
|
+
s.email = "pete@debu.gs"
|
10
9
|
s.files = Dir["{lib,doc,bin,ext}/**/*"].delete_if {|f|
|
11
10
|
/\/rdoc(\/|$)/i.match f
|
12
11
|
} + %w(Rakefile)
|
@@ -21,10 +20,10 @@ spec = Gem::Specification.new { |s|
|
|
21
20
|
s.summary = "Nice, object-oriented, first-class views."
|
22
21
|
s.homepage = "http://debu.gs/#{s.name}"
|
23
22
|
%w(metaid hpricot).each &s.method(:add_dependency)
|
24
|
-
s.version = '0.
|
23
|
+
s.version = '1.0.0'
|
25
24
|
}
|
26
25
|
|
27
|
-
|
26
|
+
Gem::PackageTask.new(spec) { |pkg|
|
28
27
|
pkg.need_tar_bz2 = true
|
29
28
|
}
|
30
29
|
|
@@ -32,3 +31,7 @@ task(:install => :package) {
|
|
32
31
|
g = "pkg/#{spec.name}-#{spec.version}.gem"
|
33
32
|
system "sudo gem install -l #{g}"
|
34
33
|
}
|
34
|
+
|
35
|
+
task(:test) {
|
36
|
+
system "ruby test/run.rb"
|
37
|
+
}
|
data/doc/LICENSE
CHANGED
data/doc/examples/env.cgi
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'hoshi/view/html'
|
2
|
+
|
3
|
+
class Hoshi::View
|
4
|
+
class HTML5 < HTML
|
5
|
+
dtd! "<!DOCTYPE html>"
|
6
|
+
|
7
|
+
tags *%w(
|
8
|
+
a abbr address area article aside audio b base bb bdi
|
9
|
+
bdo blockquote body button canvas caption cite code col
|
10
|
+
colgroup command data datagrid datalist dd del details
|
11
|
+
dfn div dl dt em embed eventsource fieldset figcaption
|
12
|
+
figure footer form h1 h2 h3 h4 h5 h6 head header hgroup
|
13
|
+
hr html i iframe img input ins kbd keygen label legend
|
14
|
+
li link mark map menu meta meter nav noscript object ol
|
15
|
+
optgroup option output p param pre progress q ruby rp rt
|
16
|
+
s samp script section select small source span strong
|
17
|
+
style sub summary sup table tbody td textarea tfoot th
|
18
|
+
thead time title tr track u ul var video wbr
|
19
|
+
)
|
20
|
+
open_tags *%w(br)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/lib/hoshi/view/xhtml1.rb
CHANGED
@@ -2,8 +2,7 @@ require 'hoshi/view/xhtml'
|
|
2
2
|
|
3
3
|
class Hoshi::View
|
4
4
|
class XHTML1 < XHTML
|
5
|
-
dtd! "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " \
|
6
|
-
"Strict//EN\" " \
|
5
|
+
dtd! "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " \
|
7
6
|
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
8
7
|
tags *%w(a abbr acronym address applet area b base basefont bdo big
|
9
8
|
blockquote body br button caption center cite code col
|
@@ -2,8 +2,8 @@ require 'hoshi/view/xhtml1'
|
|
2
2
|
|
3
3
|
class Hoshi::View
|
4
4
|
class XHTML1Frameset < XHTML1
|
5
|
-
dtd! "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " \
|
6
|
-
"
|
5
|
+
dtd! "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" " \
|
6
|
+
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"
|
7
7
|
tags *%w(a abbr acronym address applet area b base basefont bdo big
|
8
8
|
blockquote body br button caption center cite code col
|
9
9
|
colgroup dd del dfn dir div dl dt em fieldset font form frame
|
data/lib/hoshi/view.rb
CHANGED
@@ -32,6 +32,10 @@ module Hoshi
|
|
32
32
|
names.map { |n| tag n, :none }
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.self_closing_tags *names
|
36
|
+
names.map { |n| tag n, :self }
|
37
|
+
end
|
38
|
+
|
35
39
|
# This method choses, based on the provided doctype, the proper
|
36
40
|
# sub-class of View. Generally, you'll be using this rather than
|
37
41
|
# sub-classing View directly. The doctype argument is case- and
|
metadata
CHANGED
@@ -1,107 +1,103 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoshi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Pete Elmore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: metaid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
17
20
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
26
28
|
name: hpricot
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
27
34
|
type: :runtime
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
version:
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
35
41
|
description:
|
36
|
-
email: pete
|
37
|
-
executables:
|
42
|
+
email: pete@debu.gs
|
43
|
+
executables:
|
38
44
|
- html2hoshi
|
39
45
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
46
|
+
extra_rdoc_files:
|
42
47
|
- doc/LICENSE
|
43
48
|
- doc/TODO
|
44
|
-
|
45
|
-
|
46
|
-
- lib/hoshi
|
47
|
-
- lib/hoshi/
|
48
|
-
- lib/hoshi/view
|
49
|
-
- lib/hoshi/view/html4_transitional.rb
|
50
|
-
- lib/hoshi/view/html4_frameset.rb
|
49
|
+
files:
|
50
|
+
- lib/html2hoshi.rb
|
51
|
+
- lib/hoshi/view.rb
|
52
|
+
- lib/hoshi/tag.rb
|
53
|
+
- lib/hoshi/view-tag-fallback.rb
|
51
54
|
- lib/hoshi/view/xhtml1.rb
|
52
|
-
- lib/hoshi/view/html3.rb
|
53
|
-
- lib/hoshi/view/xhtml1_frameset.rb
|
54
|
-
- lib/hoshi/view/html4.rb
|
55
|
-
- lib/hoshi/view/rss2.rb
|
56
55
|
- lib/hoshi/view/html.rb
|
57
|
-
- lib/hoshi/view/
|
56
|
+
- lib/hoshi/view/html4.rb
|
57
|
+
- lib/hoshi/view/html4_frameset.rb
|
58
|
+
- lib/hoshi/view/xhtml1_frameset.rb
|
59
|
+
- lib/hoshi/view/html5.rb
|
58
60
|
- lib/hoshi/view/xhtml1_strict.rb
|
61
|
+
- lib/hoshi/view/xhtml.rb
|
62
|
+
- lib/hoshi/view/html4_transitional.rb
|
63
|
+
- lib/hoshi/view/xhtml2.rb
|
64
|
+
- lib/hoshi/view/html3.rb
|
65
|
+
- lib/hoshi/view/rss2.rb
|
59
66
|
- lib/hoshi/view/xhtml1_transitional.rb
|
60
|
-
- lib/hoshi/view-tag-fallback.rb
|
61
|
-
- lib/hoshi/monkey_patches.rb
|
62
|
-
- lib/hoshi/view.rb
|
63
|
-
- lib/hoshi/tag.rb
|
64
67
|
- lib/hoshi/view-tag.rb
|
68
|
+
- lib/hoshi/monkey_patches.rb
|
65
69
|
- lib/hoshi.rb
|
66
|
-
-
|
67
|
-
- doc/
|
68
|
-
- doc/TODO
|
69
|
-
- doc/examples
|
70
|
-
- doc/examples/trivial.rb
|
70
|
+
- doc/examples/layouts.rb
|
71
|
+
- doc/examples/inline_tags.rb
|
71
72
|
- doc/examples/blocks.rb
|
72
73
|
- doc/examples/env.cgi
|
73
|
-
- doc/examples/
|
74
|
-
- doc/examples/feed.rb
|
74
|
+
- doc/examples/trivial.rb
|
75
75
|
- doc/examples/rss2.rb
|
76
|
-
- doc/
|
77
|
-
- doc/
|
76
|
+
- doc/LICENSE
|
77
|
+
- doc/TODO
|
78
78
|
- bin/html2hoshi
|
79
79
|
- Rakefile
|
80
|
-
has_rdoc: true
|
81
80
|
homepage: http://debu.gs/hoshi
|
81
|
+
licenses: []
|
82
|
+
metadata: {}
|
82
83
|
post_install_message:
|
83
84
|
rdoc_options: []
|
84
|
-
|
85
|
-
require_paths:
|
85
|
+
require_paths:
|
86
86
|
- lib
|
87
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version:
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
version: "0"
|
98
|
-
version:
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
99
97
|
requirements: []
|
100
|
-
|
101
98
|
rubyforge_project: hoshi-view
|
102
|
-
rubygems_version:
|
99
|
+
rubygems_version: 2.0.3
|
103
100
|
signing_key:
|
104
|
-
specification_version:
|
101
|
+
specification_version: 4
|
105
102
|
summary: Nice, object-oriented, first-class views.
|
106
103
|
test_files: []
|
107
|
-
|
data/doc/README
DELETED
@@ -1,180 +0,0 @@
|
|
1
|
-
= Hoshi
|
2
|
-
|
3
|
-
== Summary
|
4
|
-
|
5
|
-
Hoshi is a library for creating real first-class HTML/XML views. So,
|
6
|
-
unlike template libraries, you can take advantage of mixins,
|
7
|
-
inheritance, and all the other wonderful features of Ruby's object
|
8
|
-
system. There is also support for easy RSS feeds and CGI.
|
9
|
-
|
10
|
-
Hoshi is designed to:
|
11
|
-
* Generate clean HTML/XHTML/XML with minimal effort
|
12
|
-
* Be easy for a coder to use and understand
|
13
|
-
* Take full advantage of Ruby's object sytem
|
14
|
-
* Be more readable and easier to write than bare HTML
|
15
|
-
|
16
|
-
It is semi-modeled after Markaby, but with a much more straightforward
|
17
|
-
implementation and different semantics (e.g., no instance_eval, so scope
|
18
|
-
inside a tag is as expected). Hoshi also allows a tag to follow another
|
19
|
-
tag without requiring any <<, +, or +=.
|
20
|
-
|
21
|
-
== Installation
|
22
|
-
|
23
|
-
You can install via rubygems,
|
24
|
-
|
25
|
-
gem install hoshi
|
26
|
-
|
27
|
-
or by downloading from github (http://github.com/pete/hoshi).
|
28
|
-
|
29
|
-
== Usage
|
30
|
-
|
31
|
-
These examples and more featured in the fabulous doc/examples directory.
|
32
|
-
Also, there is a program included called html2hoshi (and associated
|
33
|
-
lib/html2hoshi.rb; see Hoshi.from_html) that takes HTML as input and
|
34
|
-
converts it to Ruby code using Hoshi.
|
35
|
-
|
36
|
-
=== Class-based
|
37
|
-
|
38
|
-
These should be fairly straightforward:
|
39
|
-
|
40
|
-
require 'hoshi'
|
41
|
-
|
42
|
-
class Trivial < Hoshi::View :html4
|
43
|
-
def show
|
44
|
-
doctype
|
45
|
-
html {
|
46
|
-
head {
|
47
|
-
title "Hello, world!"
|
48
|
-
link :rel => 'stylesheet', :href => '/css/hoshi.css'
|
49
|
-
}
|
50
|
-
|
51
|
-
body {
|
52
|
-
h1 "Hello, world!"
|
53
|
-
p "This is a greeting to the world."
|
54
|
-
}
|
55
|
-
}
|
56
|
-
render
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
puts Trivial.new.show
|
61
|
-
|
62
|
-
You can get a little more complicated:
|
63
|
-
|
64
|
-
require 'hoshi'
|
65
|
-
require 'cgi'
|
66
|
-
|
67
|
-
module Layout
|
68
|
-
def main_page(t)
|
69
|
-
doctype
|
70
|
-
html {
|
71
|
-
head {
|
72
|
-
title t
|
73
|
-
script(:type => 'text/javascript') {
|
74
|
-
raw "alert(\"Hi, I'm some javascript, I suppose.\");"
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
body {
|
79
|
-
h1 t, :class => 'page_title'
|
80
|
-
|
81
|
-
yield
|
82
|
-
}
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
def list_page(t)
|
87
|
-
main_page(t) {
|
88
|
-
ul {
|
89
|
-
yield
|
90
|
-
}
|
91
|
-
}
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
class Fibonacci < Hoshi::View :xhtml1
|
97
|
-
include Layout
|
98
|
-
|
99
|
-
def list_page(n)
|
100
|
-
super("Fibonacci: f(0)..f(#{n})") {
|
101
|
-
fib_upto(n).map { |i| li i.to_s }
|
102
|
-
}
|
103
|
-
CGI.pretty(render)
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
def fib_upto n
|
109
|
-
a = Array.new(n)
|
110
|
-
|
111
|
-
0.upto(n) { |i|
|
112
|
-
a[i] =
|
113
|
-
if i < 2
|
114
|
-
1
|
115
|
-
else
|
116
|
-
a[i - 1] + a[i - 2]
|
117
|
-
end
|
118
|
-
}
|
119
|
-
|
120
|
-
a
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
puts Fibonacci.new.list_page(n)
|
125
|
-
|
126
|
-
=== Block-based
|
127
|
-
|
128
|
-
For simpler cases where you only intend to produce markup, perhaps for use as a templating engine.
|
129
|
-
|
130
|
-
require 'hoshi'
|
131
|
-
|
132
|
-
str = Hoshi::View::HTML4.build {
|
133
|
-
doctype
|
134
|
-
html {
|
135
|
-
head {
|
136
|
-
title "Hello, world!"
|
137
|
-
link :rel => 'stylesheet', :href => '/css/hoshi.css'
|
138
|
-
}
|
139
|
-
|
140
|
-
body {
|
141
|
-
h1 "Hello, world!"
|
142
|
-
p "This is a greeting to the world."
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
puts str
|
148
|
-
|
149
|
-
== Bugs
|
150
|
-
|
151
|
-
There needs to be some work done on correcting the tags.
|
152
|
-
|
153
|
-
== Credits
|
154
|
-
|
155
|
-
Author:
|
156
|
-
Pete Elmore -- (pete.elmore(a)gmail.com)
|
157
|
-
|
158
|
-
Initial Design:
|
159
|
-
Dan Yoder -- (danyoder(a)mac.com)
|
160
|
-
|
161
|
-
Simple block version:
|
162
|
-
Nolan Darilek -- (nolan(a)thewordnerd.info)
|
163
|
-
|
164
|
-
Homie that be lookin' out for my broken deps:
|
165
|
-
Lars Lethonen
|
166
|
-
|
167
|
-
The guys that paid me to do this:
|
168
|
-
AT&T Interactive. (By the way, email me if you want to come work here.)
|
169
|
-
|
170
|
-
Also, I guess I should credit Attractive Eighties Women
|
171
|
-
(http://attractiveeightieswomen.com/), since I was blasting them the
|
172
|
-
whole time I was developing this. Like, over and over. I couldn't stop
|
173
|
-
listening. My friends and family are becoming concerned. I don't feel
|
174
|
-
that I am yet ready to take the first step by admitting there is a
|
175
|
-
problem. Intervention may be required. This paragraph should probably
|
176
|
-
be considered a cry for help.
|
177
|
-
|
178
|
-
== Home page
|
179
|
-
|
180
|
-
http://debu.gs/hoshi
|
data/doc/examples/feed.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'hoshi'
|
5
|
-
|
6
|
-
class Feed < Hoshi::View :html
|
7
|
-
permissive!
|
8
|
-
def show
|
9
|
-
raw "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
10
|
-
raw "<?xml-stylesheet href=\"http://feeds.feedburner.com/~d/styles/rss2full.xsl\" type=\"text/xsl\" media=\"screen\"?>"
|
11
|
-
raw "<?xml-stylesheet href=\"http://feeds.feedburner.com/~d/styles/itemcontent.css\" type=\"text/css\" media=\"screen\"?>"
|
12
|
-
rss("xmlns:wfw"=>"http://wellformedweb.org/CommentAPI/", "xmlns:atom"=>"http://www.w3.org/2005/Atom", "version"=>"2.0", "xmlns:content"=>"http://purl.org/rss/1.0/modules/content/", "xmlns:dc"=>"http://purl.org/dc/elements/1.1/") {
|
13
|
-
channel {
|
14
|
-
title "Debugs"
|
15
|
-
link "http://debu.gs/blog/debugs.rss"
|
16
|
-
description
|
17
|
-
language "en"
|
18
|
-
tag "atom10:link", nil, "href"=>"http://feeds.feedburner.com/debugs", "rel"=>"self", "xmlns:atom10"=>"http://www.w3.org/2005/Atom", "type"=>"application/rss+xml"
|
19
|
-
item {
|
20
|
-
title "Hoshi 0.1.0 Released...Soon"
|
21
|
-
link "http://debu.gs/hoshi-010-released"
|
22
|
-
pubDate "Thu, 06 Nov 2008 00:00:00 +0000"
|
23
|
-
description "Bringing first-class views to Ruby."
|
24
|
-
}
|
25
|
-
item {
|
26
|
-
title "LiveConsole 0.2.0 Released"
|
27
|
-
link "http://debu.gs/liveconsole-020-released"
|
28
|
-
pubDate "Thu, 16 Oct 2008 00:00:00 +0000"
|
29
|
-
description "LiveConsole 0.2.0 released with support for Unix Domain Sockets and arbitrary bindings."
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
render
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
if __FILE__ == $0
|
38
|
-
require 'cgi'
|
39
|
-
puts CGI.pretty(Feed.new.show)
|
40
|
-
end
|