soywiki 0.7.0 → 0.7.1
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/Gemfile +1 -0
- data/README.markdown +8 -17
- data/Rakefile +10 -15
- data/lib/page_template.html.haml +4 -1
- data/lib/soywiki/html.rb +13 -3
- data/lib/soywiki.rb +10 -4
- data/soywiki.gemspec +1 -0
- metadata +16 -39
- data/website/.gitignore +0 -1
- data/website/bottom.markdown +0 -0
- data/website/gen.rb +0 -19
- data/website/images-soywiki/expand.png +0 -0
- data/website/images-soywiki/expand.xcf +0 -0
- data/website/images-soywiki/page-select.png +0 -0
- data/website/images-soywiki/page-select.xcf +0 -0
- data/website/images-soywiki/search.png +0 -0
- data/website/images-soywiki/search.xcf +0 -0
- data/website/images-soywiki/sm-expand.png +0 -0
- data/website/images-soywiki/sm-page-select.png +0 -0
- data/website/images-soywiki/sm-search.png +0 -0
- data/website/lightbox2/css/lightbox.css +0 -27
- data/website/lightbox2/images/bullet.gif +0 -0
- data/website/lightbox2/images/close.gif +0 -0
- data/website/lightbox2/images/closelabel.gif +0 -0
- data/website/lightbox2/images/donate-button.gif +0 -0
- data/website/lightbox2/images/download-icon.gif +0 -0
- data/website/lightbox2/images/image-1.jpg +0 -0
- data/website/lightbox2/images/loading.gif +0 -0
- data/website/lightbox2/images/nextlabel.gif +0 -0
- data/website/lightbox2/images/prevlabel.gif +0 -0
- data/website/lightbox2/images/thumb-1.jpg +0 -0
- data/website/lightbox2/index.html +0 -63
- data/website/lightbox2/js/builder.js +0 -136
- data/website/lightbox2/js/effects.js +0 -1122
- data/website/lightbox2/js/lightbox.js +0 -498
- data/website/lightbox2/js/prototype.js +0 -4221
- data/website/lightbox2/js/scriptaculous.js +0 -58
- data/website/soywiki-template.html +0 -80
- data/website/stylesheets-vmail/960.css +0 -1
- data/website/stylesheets-vmail/reset.css +0 -1
- data/website/stylesheets-vmail/site.css +0 -67
- data/website/stylesheets-vmail/syntax-colors.css +0 -33
- data/website/stylesheets-vmail/text.css +0 -1
- data/website/top.screenshots +0 -5
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -4,6 +4,8 @@ SoyWiki turns Vim into a powerful, lean, and fast wiki. It's got all the
|
|
4
4
|
protein of a more conventional wiki, but less saturated fat and no
|
5
5
|
cholesterol.
|
6
6
|
|
7
|
+
[screenshots]
|
8
|
+
|
7
9
|
A quick overview of SoyWiki's characteristics and features:
|
8
10
|
|
9
11
|
* flat text files
|
@@ -71,9 +73,6 @@ If you run into any PATH errors, try the following: Install the RVM
|
|
71
73
|
Version Manager, then install Ruby 1.9.2 through RVM, and then run `gem
|
72
74
|
install soywiki`. This should solve any installation issues.
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
76
|
If you ever want to uninstall SoyWiki from your system, execute this command:
|
78
77
|
|
79
78
|
gem uninstall soywiki
|
@@ -441,6 +440,7 @@ dreams within dreams.
|
|
441
440
|
## Exporting to HTML
|
442
441
|
|
443
442
|
* `soywiki --html`
|
443
|
+
* `soywiki --html --markdown`
|
444
444
|
|
445
445
|
Want to share your wiki with non-Vim-users? You can export your wiki
|
446
446
|
into a directory of HTML pages. Type `soywiki --html` from the root
|
@@ -448,22 +448,13 @@ directory of your wiki.
|
|
448
448
|
|
449
449
|
Aside from WikiWords, SoyWiki uses no markup system whatsoever. You can
|
450
450
|
write your content in whatever markup system you want, or no markup
|
451
|
-
system at all.
|
452
|
-
just wraps your content in <pre> tags after turning your WikiWords
|
453
|
-
into hyperlinks, so no markup system is really necessary.
|
454
|
-
|
455
|
-
HTML export is no-frills and basic. Hopefully, someday, SoyWiki will be
|
456
|
-
able to
|
457
|
-
|
458
|
-
* sport an alternative web interface that is as cool as [TiddlyWiki's][tiddly] and [GTDTiddlyWiki's][gtd]
|
459
|
-
* let you specify a markup system for rendering the HTML version of your content
|
460
|
-
* come bundled with a Sinatra application that translates wiki pages into web pages upon request
|
451
|
+
system at all.
|
461
452
|
|
462
|
-
|
463
|
-
|
453
|
+
By default, the HTML export feature just wraps your content in
|
454
|
+
<pre> tags after turning your WikiWords into hyperlinks.
|
464
455
|
|
465
|
-
If you want to
|
466
|
-
|
456
|
+
If instead you want to write your pages using Markdown, you can process
|
457
|
+
Markdown by adding the `--markdown` flag.
|
467
458
|
|
468
459
|
|
469
460
|
## Extra macros
|
data/Rakefile
CHANGED
@@ -30,29 +30,24 @@ end
|
|
30
30
|
desc "build and push website"
|
31
31
|
task :web => :build_webpage do
|
32
32
|
puts "Building and pushing website"
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
desc "build website locally"
|
39
|
-
task :build_web_locally => :build_webpage do
|
40
|
-
Dir.chdir("website") do
|
41
|
-
`open soywiki.html`
|
33
|
+
Dir.chdir "../project-webpages" do
|
34
|
+
`scp out/soywiki.html zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
35
|
+
`rsync -avz out/images-soywiki zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
36
|
+
`rsync -avz out/stylesheets zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
37
|
+
`rsync -avz out/lightbox2 zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
42
38
|
end
|
39
|
+
`open http://danielchoi.com/software/soywiki.html`
|
43
40
|
end
|
44
41
|
|
45
42
|
desc "build webpage"
|
46
43
|
task :build_webpage do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
File.open('soywiki.html', 'w') {|f| f.puts html}
|
44
|
+
`cp README.markdown ../project-webpages/src/soywiki.README.markdown`
|
45
|
+
Dir.chdir "../project-webpages" do
|
46
|
+
puts `ruby gen.rb soywiki #{Soywiki::VERSION}`
|
47
|
+
#`open out/soywiki.html`
|
52
48
|
end
|
53
49
|
end
|
54
50
|
|
55
|
-
|
56
51
|
desc "Run tests"
|
57
52
|
task :test do
|
58
53
|
$:.unshift File.expand_path("test")
|
data/lib/page_template.html.haml
CHANGED
data/lib/soywiki/html.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'haml'
|
2
|
+
require 'rdiscount'
|
2
3
|
module Soywiki
|
3
4
|
module Html
|
4
5
|
|
@@ -29,11 +30,18 @@ module Soywiki
|
|
29
30
|
|
30
31
|
def self.generate_page(text, namespace, pages, namespaces)
|
31
32
|
title = text.split("\n")[0]
|
32
|
-
body =
|
33
|
+
body = if @markdown
|
34
|
+
RDiscount.new(text.split("\n")[1..-1].join("\n").strip)
|
35
|
+
else
|
36
|
+
process(text.split("\n")[1..-1].join("\n").strip)
|
37
|
+
end
|
38
|
+
|
33
39
|
Haml::Engine.new(PAGE_TEMPLATE).render(nil, :body => body,
|
34
40
|
:title => title,
|
35
41
|
:namespace => namespace,
|
36
|
-
:namespaces => namespaces,
|
42
|
+
:namespaces => namespaces,
|
43
|
+
:pages => pages,
|
44
|
+
:markdown => @markdown)
|
37
45
|
end
|
38
46
|
|
39
47
|
|
@@ -82,7 +90,9 @@ module Soywiki
|
|
82
90
|
# puts "=> Writing #{outfile}"
|
83
91
|
end
|
84
92
|
|
85
|
-
def self.export
|
93
|
+
def self.export(markdown)
|
94
|
+
@markdown = markdown
|
95
|
+
|
86
96
|
`rm -rf #{HTML_DIR}/*`
|
87
97
|
namespaces = Dir["*"].select {|f|
|
88
98
|
File.directory?(f) && f != HTML_DIR
|
data/lib/soywiki.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'string_ext'
|
2
2
|
|
3
3
|
module Soywiki
|
4
|
-
VERSION = '0.7.
|
4
|
+
VERSION = '0.7.1'
|
5
5
|
WIKI_WORD = /\b([a-z][\w_]+\.)?[A-Z][a-z]+[A-Z]\w*\b/
|
6
6
|
HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
|
7
7
|
|
@@ -22,7 +22,13 @@ called main/HomePage.
|
|
22
22
|
END
|
23
23
|
exit
|
24
24
|
elsif ARGV.first == '--html'
|
25
|
-
|
25
|
+
if ARGV[1] == '--markdown'
|
26
|
+
puts "Exporting html using markdown"
|
27
|
+
self.html_export(true)
|
28
|
+
else
|
29
|
+
puts "Exporting html"
|
30
|
+
self.html_export
|
31
|
+
end
|
26
32
|
exit
|
27
33
|
elsif ARGV.first == '--install-plugin'
|
28
34
|
require 'erb'
|
@@ -39,9 +45,9 @@ END
|
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
|
-
def self.html_export
|
48
|
+
def self.html_export(markdown=false)
|
43
49
|
require 'soywiki/html'
|
44
|
-
Html.export
|
50
|
+
Html.export(markdown)
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
data/soywiki.gemspec
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Choi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-26 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -30,6 +30,19 @@ dependencies:
|
|
30
30
|
version: "0"
|
31
31
|
type: :runtime
|
32
32
|
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rdiscount
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
33
46
|
description: A personal and collaborative wiki for Vim users
|
34
47
|
email:
|
35
48
|
- dhchoi@gmail.com
|
@@ -63,42 +76,6 @@ files:
|
|
63
76
|
- lib/soywiki/html.rb
|
64
77
|
- lib/string_ext.rb
|
65
78
|
- soywiki.gemspec
|
66
|
-
- website/.gitignore
|
67
|
-
- website/bottom.markdown
|
68
|
-
- website/gen.rb
|
69
|
-
- website/images-soywiki/expand.png
|
70
|
-
- website/images-soywiki/expand.xcf
|
71
|
-
- website/images-soywiki/page-select.png
|
72
|
-
- website/images-soywiki/page-select.xcf
|
73
|
-
- website/images-soywiki/search.png
|
74
|
-
- website/images-soywiki/search.xcf
|
75
|
-
- website/images-soywiki/sm-expand.png
|
76
|
-
- website/images-soywiki/sm-page-select.png
|
77
|
-
- website/images-soywiki/sm-search.png
|
78
|
-
- website/lightbox2/css/lightbox.css
|
79
|
-
- website/lightbox2/images/bullet.gif
|
80
|
-
- website/lightbox2/images/close.gif
|
81
|
-
- website/lightbox2/images/closelabel.gif
|
82
|
-
- website/lightbox2/images/donate-button.gif
|
83
|
-
- website/lightbox2/images/download-icon.gif
|
84
|
-
- website/lightbox2/images/image-1.jpg
|
85
|
-
- website/lightbox2/images/loading.gif
|
86
|
-
- website/lightbox2/images/nextlabel.gif
|
87
|
-
- website/lightbox2/images/prevlabel.gif
|
88
|
-
- website/lightbox2/images/thumb-1.jpg
|
89
|
-
- website/lightbox2/index.html
|
90
|
-
- website/lightbox2/js/builder.js
|
91
|
-
- website/lightbox2/js/effects.js
|
92
|
-
- website/lightbox2/js/lightbox.js
|
93
|
-
- website/lightbox2/js/prototype.js
|
94
|
-
- website/lightbox2/js/scriptaculous.js
|
95
|
-
- website/soywiki-template.html
|
96
|
-
- website/stylesheets-vmail/960.css
|
97
|
-
- website/stylesheets-vmail/reset.css
|
98
|
-
- website/stylesheets-vmail/site.css
|
99
|
-
- website/stylesheets-vmail/syntax-colors.css
|
100
|
-
- website/stylesheets-vmail/text.css
|
101
|
-
- website/top.screenshots
|
102
79
|
has_rdoc: true
|
103
80
|
homepage: http://danielchoi.com/software/soywiki.html
|
104
81
|
licenses: []
|
data/website/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
images-original/
|
data/website/bottom.markdown
DELETED
File without changes
|
data/website/gen.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'rdiscount'
|
2
|
-
require 'liquid'
|
3
|
-
|
4
|
-
module Webpage
|
5
|
-
def self.generate(version)
|
6
|
-
screenshots = RDiscount.new(File.read("top.screenshots")).to_html
|
7
|
-
readme = File.expand_path("../../README.markdown", __FILE__)
|
8
|
-
raise "No README" unless File.size?(readme)
|
9
|
-
md = File.read(readme).split(/^\s*$/)
|
10
|
-
insert_before = md.grep(/^A quick overview of/)
|
11
|
-
insert_at = md.index insert_before.first
|
12
|
-
md.insert(insert_at, screenshots)
|
13
|
-
md = md.join("\n\n")
|
14
|
-
# for some reason markdown inserts extra blank lines
|
15
|
-
content = RDiscount.new(md).to_html.gsub(/\n\n{3,}/, "\n\n")
|
16
|
-
template = File.read("soywiki-template.html")
|
17
|
-
out = Liquid::Template.parse(template).render 'content' => content, 'timestamp' => Time.now.to_i, 'version' => version
|
18
|
-
end
|
19
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#lightbox{ position: absolute; left: 0; width: 100%; z-index: 100; text-align: center; line-height: 0;}
|
2
|
-
#lightbox img{ width: auto; height: auto;}
|
3
|
-
#lightbox a img{ border: none; }
|
4
|
-
|
5
|
-
#outerImageContainer{ position: relative; background-color: #fff; width: 250px; height: 250px; margin: 0 auto; }
|
6
|
-
#imageContainer{ padding: 10px; }
|
7
|
-
|
8
|
-
#loading{ position: absolute; top: 40%; left: 0%; height: 25%; width: 100%; text-align: center; line-height: 0; }
|
9
|
-
#hoverNav{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; }
|
10
|
-
#imageContainer>#hoverNav{ left: 0;}
|
11
|
-
#hoverNav a{ outline: none;}
|
12
|
-
|
13
|
-
#prevLink, #nextLink{ width: 49%; height: 100%; background-image: url(data:image/gif;base64,AAAA); /* Trick IE into showing hover */ display: block; }
|
14
|
-
#prevLink { left: 0; float: left;}
|
15
|
-
#nextLink { right: 0; float: right;}
|
16
|
-
#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; }
|
17
|
-
#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; }
|
18
|
-
|
19
|
-
#imageDataContainer{ font: 10px Verdana, Helvetica, sans-serif; background-color: #fff; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100% ; }
|
20
|
-
|
21
|
-
#imageData{ padding:0 10px; color: #666; }
|
22
|
-
#imageData #imageDetails{ width: 70%; float: left; text-align: left; }
|
23
|
-
#imageData #caption{ font-weight: bold; }
|
24
|
-
#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; }
|
25
|
-
#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; outline: none;}
|
26
|
-
|
27
|
-
#overlay{ position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px; background-color: #000; }
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,63 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
4
|
-
<head>
|
5
|
-
|
6
|
-
<title>Lightbox JS v2.0 | Test Page</title>
|
7
|
-
|
8
|
-
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
|
9
|
-
|
10
|
-
<script src="js/prototype.js" type="text/javascript"></script>
|
11
|
-
<script src="js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
|
12
|
-
<script src="js/lightbox.js" type="text/javascript"></script>
|
13
|
-
|
14
|
-
<style type="text/css">
|
15
|
-
body{ color: #333; font: 13px 'Lucida Grande', Verdana, sans-serif; }
|
16
|
-
</style>
|
17
|
-
|
18
|
-
</head>
|
19
|
-
<body>
|
20
|
-
|
21
|
-
|
22
|
-
<h1><a href="http://www.lokeshdhakar.com/projects/lightbox2/">Lightbox JS <em>v2.04</em></a></h1>
|
23
|
-
<p><a href="http://www.lokeshdhakar.com">by Lokesh Dhakar</a></p>
|
24
|
-
|
25
|
-
<h2>Example</h2>
|
26
|
-
|
27
|
-
<a href="images/image-1.jpg" rel="lightbox"><img src="images/thumb-1.jpg" width="100" height="40" alt="" /></a>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<h2>How to Use:</h2>
|
33
|
-
<h3>Part 1 - Setup</h3>
|
34
|
-
<ol>
|
35
|
-
<li>Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header.
|
36
|
-
<pre><code><script type="text/javascript" src="js/prototype.js"></script>
|
37
|
-
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
|
38
|
-
<script type="text/javascript" src="js/lightbox.js"></script>
|
39
|
-
</code></pre>
|
40
|
-
</li>
|
41
|
-
<li>Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).
|
42
|
-
<pre><code><link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
|
43
|
-
</code></pre>
|
44
|
-
</li>
|
45
|
-
<li>Check the CSS and make sure the referenced <code>prevlabel.gif</code> and <code>nextlabel.gif</code> files are in the right location. Also, make sure the <code>loading.gif</code> and <code>closelabel.gif</code> files as referenced near the top of the <code>lightbox.js</code> file are in the right location.</li>
|
46
|
-
</ol>
|
47
|
-
<h3>Part 2 - Activate</h3>
|
48
|
-
<ol>
|
49
|
-
<li>Add a <code>rel="lightbox"</code> attribute to any link tag to activate the lightbox. For example:
|
50
|
-
<pre><code><a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
|
51
|
-
</code></pre>
|
52
|
-
<em>Optional: </em>Use the <code>title</code> attribute if you want to show a caption. </li>
|
53
|
-
<li>If you have a set of related images that you would like to group, follow step one but additionally include a group name between square brackets in the rel attribute. For example:
|
54
|
-
<pre><code><a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
|
55
|
-
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
|
56
|
-
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
|
57
|
-
</code></pre>
|
58
|
-
No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!</li>
|
59
|
-
</ol>
|
60
|
-
|
61
|
-
|
62
|
-
</body>
|
63
|
-
</html>
|
@@ -1,136 +0,0 @@
|
|
1
|
-
// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
|
2
|
-
|
3
|
-
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
4
|
-
//
|
5
|
-
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
6
|
-
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
7
|
-
|
8
|
-
var Builder = {
|
9
|
-
NODEMAP: {
|
10
|
-
AREA: 'map',
|
11
|
-
CAPTION: 'table',
|
12
|
-
COL: 'table',
|
13
|
-
COLGROUP: 'table',
|
14
|
-
LEGEND: 'fieldset',
|
15
|
-
OPTGROUP: 'select',
|
16
|
-
OPTION: 'select',
|
17
|
-
PARAM: 'object',
|
18
|
-
TBODY: 'table',
|
19
|
-
TD: 'table',
|
20
|
-
TFOOT: 'table',
|
21
|
-
TH: 'table',
|
22
|
-
THEAD: 'table',
|
23
|
-
TR: 'table'
|
24
|
-
},
|
25
|
-
// note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
|
26
|
-
// due to a Firefox bug
|
27
|
-
node: function(elementName) {
|
28
|
-
elementName = elementName.toUpperCase();
|
29
|
-
|
30
|
-
// try innerHTML approach
|
31
|
-
var parentTag = this.NODEMAP[elementName] || 'div';
|
32
|
-
var parentElement = document.createElement(parentTag);
|
33
|
-
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
|
34
|
-
parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
|
35
|
-
} catch(e) {}
|
36
|
-
var element = parentElement.firstChild || null;
|
37
|
-
|
38
|
-
// see if browser added wrapping tags
|
39
|
-
if(element && (element.tagName.toUpperCase() != elementName))
|
40
|
-
element = element.getElementsByTagName(elementName)[0];
|
41
|
-
|
42
|
-
// fallback to createElement approach
|
43
|
-
if(!element) element = document.createElement(elementName);
|
44
|
-
|
45
|
-
// abort if nothing could be created
|
46
|
-
if(!element) return;
|
47
|
-
|
48
|
-
// attributes (or text)
|
49
|
-
if(arguments[1])
|
50
|
-
if(this._isStringOrNumber(arguments[1]) ||
|
51
|
-
(arguments[1] instanceof Array) ||
|
52
|
-
arguments[1].tagName) {
|
53
|
-
this._children(element, arguments[1]);
|
54
|
-
} else {
|
55
|
-
var attrs = this._attributes(arguments[1]);
|
56
|
-
if(attrs.length) {
|
57
|
-
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
|
58
|
-
parentElement.innerHTML = "<" +elementName + " " +
|
59
|
-
attrs + "></" + elementName + ">";
|
60
|
-
} catch(e) {}
|
61
|
-
element = parentElement.firstChild || null;
|
62
|
-
// workaround firefox 1.0.X bug
|
63
|
-
if(!element) {
|
64
|
-
element = document.createElement(elementName);
|
65
|
-
for(attr in arguments[1])
|
66
|
-
element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
|
67
|
-
}
|
68
|
-
if(element.tagName.toUpperCase() != elementName)
|
69
|
-
element = parentElement.getElementsByTagName(elementName)[0];
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
// text, or array of children
|
74
|
-
if(arguments[2])
|
75
|
-
this._children(element, arguments[2]);
|
76
|
-
|
77
|
-
return element;
|
78
|
-
},
|
79
|
-
_text: function(text) {
|
80
|
-
return document.createTextNode(text);
|
81
|
-
},
|
82
|
-
|
83
|
-
ATTR_MAP: {
|
84
|
-
'className': 'class',
|
85
|
-
'htmlFor': 'for'
|
86
|
-
},
|
87
|
-
|
88
|
-
_attributes: function(attributes) {
|
89
|
-
var attrs = [];
|
90
|
-
for(attribute in attributes)
|
91
|
-
attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
|
92
|
-
'="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'"') + '"');
|
93
|
-
return attrs.join(" ");
|
94
|
-
},
|
95
|
-
_children: function(element, children) {
|
96
|
-
if(children.tagName) {
|
97
|
-
element.appendChild(children);
|
98
|
-
return;
|
99
|
-
}
|
100
|
-
if(typeof children=='object') { // array can hold nodes and text
|
101
|
-
children.flatten().each( function(e) {
|
102
|
-
if(typeof e=='object')
|
103
|
-
element.appendChild(e)
|
104
|
-
else
|
105
|
-
if(Builder._isStringOrNumber(e))
|
106
|
-
element.appendChild(Builder._text(e));
|
107
|
-
});
|
108
|
-
} else
|
109
|
-
if(Builder._isStringOrNumber(children))
|
110
|
-
element.appendChild(Builder._text(children));
|
111
|
-
},
|
112
|
-
_isStringOrNumber: function(param) {
|
113
|
-
return(typeof param=='string' || typeof param=='number');
|
114
|
-
},
|
115
|
-
build: function(html) {
|
116
|
-
var element = this.node('div');
|
117
|
-
$(element).update(html.strip());
|
118
|
-
return element.down();
|
119
|
-
},
|
120
|
-
dump: function(scope) {
|
121
|
-
if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
|
122
|
-
|
123
|
-
var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
|
124
|
-
"BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
|
125
|
-
"FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
|
126
|
-
"KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
|
127
|
-
"PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
|
128
|
-
"TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
|
129
|
-
|
130
|
-
tags.each( function(tag){
|
131
|
-
scope[tag] = function() {
|
132
|
-
return Builder.node.apply(Builder, [tag].concat($A(arguments)));
|
133
|
-
}
|
134
|
-
});
|
135
|
-
}
|
136
|
-
}
|