xiki 0.5.0a

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.
Files changed (252) hide show
  1. data/Gemfile +11 -0
  2. data/LICENSE +22 -0
  3. data/README.markdown +83 -0
  4. data/Rakefile +8 -0
  5. data/bin/xiki +46 -0
  6. data/etc/command/xiki_command.rb +203 -0
  7. data/etc/command/xiki_process.rb +52 -0
  8. data/etc/command/xiki_wrapper +2 -0
  9. data/etc/js/menu1.js +55 -0
  10. data/etc/js/xiki.js +259 -0
  11. data/etc/logo.png +0 -0
  12. data/etc/presentations/bootstrap.deck +5 -0
  13. data/etc/presentations/databases.deck +41 -0
  14. data/etc/presentations/diffs.deck +23 -0
  15. data/etc/presentations/documentation.deck +14 -0
  16. data/etc/presentations/effects.deck +5 -0
  17. data/etc/presentations/face.deck +297 -0
  18. data/etc/presentations/files.deck +79 -0
  19. data/etc/presentations/icons.deck +22 -0
  20. data/etc/presentations/images.deck +24 -0
  21. data/etc/presentations/key_shortcuts.deck +16 -0
  22. data/etc/presentations/macros.deck +18 -0
  23. data/etc/presentations/menu_classes.deck +44 -0
  24. data/etc/presentations/menu_directories.deck +30 -0
  25. data/etc/presentations/notes.deck +19 -0
  26. data/etc/presentations/other_languages.deck +55 -0
  27. data/etc/presentations/other_wiki_syntaxes.deck +4 -0
  28. data/etc/presentations/piano.deck +5 -0
  29. data/etc/presentations/potential/diffs.deck +38 -0
  30. data/etc/presentations/potential/evolution.deck +18 -0
  31. data/etc/presentations/potential/intro.deck +711 -0
  32. data/etc/presentations/potential/intro1.deck +711 -0
  33. data/etc/presentations/potential/intro2.deck +97 -0
  34. data/etc/presentations/potential/make_mysql_menu.deck +36 -0
  35. data/etc/presentations/potential/ruby_development.deck +17 -0
  36. data/etc/presentations/potential/ui_prototyping.deck +50 -0
  37. data/etc/presentations/potential/web_dev.deck +4 -0
  38. data/etc/presentations/potential/web_development.deck +10 -0
  39. data/etc/presentations/potential/wiki.deck +45 -0
  40. data/etc/presentations/presentations.deck +24 -0
  41. data/etc/presentations/rails_development.deck +29 -0
  42. data/etc/presentations/search_key_shortcuts.deck +37 -0
  43. data/etc/presentations/simplest_possible_ui.deck +37 -0
  44. data/etc/presentations/svg.deck +5 -0
  45. data/etc/presentations/testing.deck +28 -0
  46. data/etc/presentations/the_end.deck +13 -0
  47. data/etc/presentations/type_something_and_double_click.deck +57 -0
  48. data/etc/presentations/type_the_acronym.deck +144 -0
  49. data/etc/presentations/web_browser.deck +56 -0
  50. data/etc/presentations/xiki_command.deck +20 -0
  51. data/etc/presentations/xiki_url.deck +14 -0
  52. data/etc/shark.icns +0 -0
  53. data/etc/shark_script.icns +0 -0
  54. data/etc/snippets/html.notes +7 -0
  55. data/etc/snippets/notes.notes +20 -0
  56. data/etc/snippets/rb.notes +38 -0
  57. data/etc/templates/menu_template.menu +2 -0
  58. data/etc/templates/menu_template.rb +8 -0
  59. data/etc/templates/template.rb +5 -0
  60. data/etc/themes/Dark_Metal.notes +28 -0
  61. data/etc/themes/Orange_Path.notes +15 -0
  62. data/etc/themes/Shiny_Blue.notes +27 -0
  63. data/etc/themes/Shiny_Green.notes +27 -0
  64. data/etc/wrappers/wrapper.js +17 -0
  65. data/etc/wrappers/wrapper.py +20 -0
  66. data/etc/wrappers/wrapper.rb +25 -0
  67. data/lib/block.rb +72 -0
  68. data/lib/bookmarks.rb +352 -0
  69. data/lib/buffers.rb +170 -0
  70. data/lib/clipboard.rb +333 -0
  71. data/lib/code.rb +860 -0
  72. data/lib/code_tree.rb +476 -0
  73. data/lib/color.rb +274 -0
  74. data/lib/console.rb +557 -0
  75. data/lib/control_lock.rb +9 -0
  76. data/lib/control_tab.rb +176 -0
  77. data/lib/core_ext.rb +31 -0
  78. data/lib/cursor.rb +111 -0
  79. data/lib/deletes.rb +65 -0
  80. data/lib/diff_log.rb +297 -0
  81. data/lib/effects.rb +145 -0
  82. data/lib/environment.rb +5 -0
  83. data/lib/file_tree.rb +1875 -0
  84. data/lib/files.rb +334 -0
  85. data/lib/hide.rb +259 -0
  86. data/lib/history.rb +286 -0
  87. data/lib/image.rb +51 -0
  88. data/lib/incrementer.rb +15 -0
  89. data/lib/insert.rb +7 -0
  90. data/lib/irc.rb +22 -0
  91. data/lib/key_bindings.rb +658 -0
  92. data/lib/keys.rb +754 -0
  93. data/lib/launcher.rb +1351 -0
  94. data/lib/line.rb +429 -0
  95. data/lib/links.rb +6 -0
  96. data/lib/location.rb +175 -0
  97. data/lib/macros.rb +48 -0
  98. data/lib/man.rb +19 -0
  99. data/lib/menu.rb +708 -0
  100. data/lib/merb.rb +259 -0
  101. data/lib/message.rb +5 -0
  102. data/lib/meths.rb +56 -0
  103. data/lib/mode.rb +34 -0
  104. data/lib/move.rb +248 -0
  105. data/lib/notes.rb +1000 -0
  106. data/lib/numbers.rb +45 -0
  107. data/lib/ol.rb +203 -0
  108. data/lib/ol_helper.rb +44 -0
  109. data/lib/overlay.rb +167 -0
  110. data/lib/pause_means_space.rb +68 -0
  111. data/lib/php.rb +22 -0
  112. data/lib/projects.rb +21 -0
  113. data/lib/relinquish_exception.rb +2 -0
  114. data/lib/remote.rb +206 -0
  115. data/lib/requirer.rb +46 -0
  116. data/lib/rest_tree.rb +108 -0
  117. data/lib/ruby.rb +57 -0
  118. data/lib/ruby_console.rb +165 -0
  119. data/lib/search.rb +1572 -0
  120. data/lib/search_term.rb +40 -0
  121. data/lib/snippet.rb +68 -0
  122. data/lib/specs.rb +229 -0
  123. data/lib/styles.rb +274 -0
  124. data/lib/svn.rb +682 -0
  125. data/lib/text_util.rb +110 -0
  126. data/lib/tree.rb +1871 -0
  127. data/lib/tree_cursor.rb +87 -0
  128. data/lib/trouble_shooting.rb +27 -0
  129. data/lib/url_tree.rb +11 -0
  130. data/lib/view.rb +1474 -0
  131. data/lib/window.rb +133 -0
  132. data/lib/xiki.rb +404 -0
  133. data/menus/accounts.rb +5 -0
  134. data/menus/address_book.rb +21 -0
  135. data/menus/agenda.rb +28 -0
  136. data/menus/all.rb +5 -0
  137. data/menus/amazon.rb +16 -0
  138. data/menus/app.rb +16 -0
  139. data/menus/applescript.rb +46 -0
  140. data/menus/as.rb +15 -0
  141. data/menus/bookmarklet.rb +63 -0
  142. data/menus/bootstrap.rb +568 -0
  143. data/menus/browse.rb +13 -0
  144. data/menus/browser.rb +78 -0
  145. data/menus/cassandra_db.rb +36 -0
  146. data/menus/chmod.rb +27 -0
  147. data/menus/classes.rb +5 -0
  148. data/menus/coffee_script.rb +35 -0
  149. data/menus/computer.rb +24 -0
  150. data/menus/contacts.rb +5 -0
  151. data/menus/cookies.rb +25 -0
  152. data/menus/couch.rb +184 -0
  153. data/menus/crop.rb +45 -0
  154. data/menus/css.rb +55 -0
  155. data/menus/current.rb +5 -0
  156. data/menus/db.rb +12 -0
  157. data/menus/deck.rb +219 -0
  158. data/menus/dictionary.rb +9 -0
  159. data/menus/dir.rb +8 -0
  160. data/menus/disk.rb +5 -0
  161. data/menus/do.rb +13 -0
  162. data/menus/docs.rb +58 -0
  163. data/menus/dotsies.rb +107 -0
  164. data/menus/edited.rb +18 -0
  165. data/menus/emacs.rb +17 -0
  166. data/menus/enter.rb +13 -0
  167. data/menus/eval.rb +17 -0
  168. data/menus/executable.rb +16 -0
  169. data/menus/filter.rb +46 -0
  170. data/menus/firefox.rb +607 -0
  171. data/menus/foo.rb +30 -0
  172. data/menus/french.rb +7 -0
  173. data/menus/git.rb +185 -0
  174. data/menus/gito.rb +785 -0
  175. data/menus/google.rb +35 -0
  176. data/menus/google_images.rb +11 -0
  177. data/menus/google_patents.rb +10 -0
  178. data/menus/gutenberg.rb +13 -0
  179. data/menus/head.rb +10 -0
  180. data/menus/headings.rb +39 -0
  181. data/menus/html.rb +61 -0
  182. data/menus/icon.rb +40 -0
  183. data/menus/images.menu +2 -0
  184. data/menus/img.rb +15 -0
  185. data/menus/info.rb +9 -0
  186. data/menus/ip.rb +10 -0
  187. data/menus/iterm.rb +36 -0
  188. data/menus/itunes.rb +78 -0
  189. data/menus/javascript.rb +74 -0
  190. data/menus/layout.rb +18 -0
  191. data/menus/local_storage.rb +67 -0
  192. data/menus/ls.rb +19 -0
  193. data/menus/mac.rb +87 -0
  194. data/menus/maps.rb +18 -0
  195. data/menus/matches.rb +18 -0
  196. data/menus/memcache.rb +117 -0
  197. data/menus/mkdir.rb +23 -0
  198. data/menus/mongo.rb +83 -0
  199. data/menus/mysql.rb +294 -0
  200. data/menus/node.rb +88 -0
  201. data/menus/open.rb +19 -0
  202. data/menus/outline.rb +24 -0
  203. data/menus/piano.rb +746 -0
  204. data/menus/postgres.rb +34 -0
  205. data/menus/pre.rb +5 -0
  206. data/menus/python.rb +39 -0
  207. data/menus/rails.rb +160 -0
  208. data/menus/rake.rb +12 -0
  209. data/menus/redmine.rb +168 -0
  210. data/menus/riak_tree.rb +204 -0
  211. data/menus/rss.rb +15 -0
  212. data/menus/safari.rb +11 -0
  213. data/menus/sass.rb +15 -0
  214. data/menus/say.rb +6 -0
  215. data/menus/scale.rb +49 -0
  216. data/menus/serve.rb +78 -0
  217. data/menus/shuffle.rb +24 -0
  218. data/menus/spanish.rb +7 -0
  219. data/menus/standalone.rb +57 -0
  220. data/menus/tail.rb +41 -0
  221. data/menus/technologies.rb +19 -0
  222. data/menus/themes.rb +32 -0
  223. data/menus/thesaurus.rb +13 -0
  224. data/menus/to.rb +24 -0
  225. data/menus/twitter.rb +57 -0
  226. data/menus/wikipedia.rb +34 -0
  227. data/menus/words.rb +11 -0
  228. data/spec/code_tree_spec.rb +59 -0
  229. data/spec/diff_log_spec.rb +40 -0
  230. data/spec/file_tree_spec.rb +102 -0
  231. data/spec/keys_spec.rb +24 -0
  232. data/spec/line_spec.rb +68 -0
  233. data/spec/menu_spec.rb +50 -0
  234. data/spec/ol_spec.rb +98 -0
  235. data/spec/remote_spec.rb +43 -0
  236. data/spec/search_spec.rb +162 -0
  237. data/spec/text_util_spec.rb +119 -0
  238. data/spec/tree_cursor_spec.rb +91 -0
  239. data/spec/tree_spec.rb +955 -0
  240. data/tests/console_test.rb +11 -0
  241. data/tests/couch_db_test.rb +12 -0
  242. data/tests/diff_log_test.rb +43 -0
  243. data/tests/el_mixin.rb +16 -0
  244. data/tests/git_test.rb +95 -0
  245. data/tests/keys_test.rb +19 -0
  246. data/tests/line_test.rb +38 -0
  247. data/tests/merb_test.rb +11 -0
  248. data/tests/redmine_test.rb +50 -0
  249. data/tests/remote_test.rb +31 -0
  250. data/tests/rest_tree_test.rb +70 -0
  251. data/xiki.gemspec +37 -0
  252. metadata +332 -0
@@ -0,0 +1,5 @@
1
+ class Accounts
2
+ def self.menu *args
3
+ Notes.drill '$accounts', *args
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ class AddressBook
2
+ def self.names
3
+ names = Applescript.run "address book", "get the name of every person"
4
+ names.sub! /^\{(.+)\}/, "[\\1]"
5
+ JSON[names]
6
+ end
7
+
8
+ def self.menu key=nil
9
+ return self.names.map{|o| "#{o}/"} if key.nil?
10
+
11
+ # Clean up a bit
12
+ txt = Applescript.run "address book", "get vcard of people whose name is \"#{key}\""
13
+ txt.gsub! /, /, "\n"
14
+ txt.gsub! /:/, ": "
15
+ txt = txt.split("\n").select{|o| o !~ /^"\}|missing value|END: VCARD|VERSION: 3.0|BEGIN: VCARD/}.join("\n")
16
+ txt.gsub! /^/, "- "
17
+
18
+ txt
19
+ end
20
+
21
+ end
@@ -0,0 +1,28 @@
1
+ require 'view'
2
+ require 'line'
3
+ require 'effects'
4
+
5
+
6
+ class Agenda
7
+
8
+ def self.menu *lines
9
+ t = Bookmarks['$t']
10
+
11
+ # If no line, display all of them
12
+ if lines.empty?
13
+ return IO.read(t).grep(/^> \d\d\d\d-\d\d-\d\d: /).sort.reverse.join("").gsub(/^> /, '- ')
14
+ end
15
+
16
+ line = Line.value
17
+
18
+ # If line, jump to it in $t
19
+ find = Line.value.sub /^[ -]+/, ''
20
+ View.open t
21
+ View.to_top
22
+ Search.forward "^. #{$el.regexp_quote(find)}"
23
+ Line.to_left
24
+ View.recenter_top
25
+ Effects.blink(:what=>:line)
26
+
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ class All
2
+ def self.menu
3
+ Launcher.menu_keys.map{|o| "<< #{o.gsub '_', ' '}/"}.join("\n")
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'view'
2
+ require 'effects'
3
+
4
+ class Amazon
5
+
6
+ def self.menu line=nil
7
+ # If no arg, prompt to type something
8
+
9
+ return Keys.prompt "Type something to search on amazon" if line.nil?
10
+
11
+ # If arg, look it up
12
+
13
+ Firefox.url "http://www.amazon.com/s?field-keywords=#{line}"
14
+ nil
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ #
2
+ # Shows each OS X app, and lets you launch them.
3
+ #
4
+ class App
5
+ def self.menu name=nil
6
+
7
+ if ! name
8
+ txt = Dir.new("/Applications/").entries.select{|o| o !~ /^\./}.map{|o| "#{o[/(.+)\.app$/, 1]}/"}
9
+ return txt
10
+ end
11
+
12
+ command = "open \"/Applications/#{name}.app\""
13
+ Console.sync command
14
+ nil
15
+ end
16
+ end
@@ -0,0 +1,46 @@
1
+ class Applescript
2
+
3
+ # def self.menu *command
4
+ def self.menu
5
+ %`
6
+ > Pass in applescript
7
+ | tell application "iTunes" to playpause
8
+ - .api/
9
+ | Run applescript
10
+ @ Applescript.run 'tell application "iTunes" to playpause'
11
+ |
12
+ | Shortcut to wrap "tell" in block
13
+ @ Applescript.run "iTunes", "playpause"
14
+ - .docs/
15
+ > Examples
16
+ | Applescript.run "iTunes", "playpause"
17
+ `
18
+ end
19
+
20
+ def self.menu_after output, *args
21
+
22
+ return output if output # If menu handled it, just return
23
+
24
+ command = ENV['txt']
25
+ result = self.run command
26
+
27
+ ".flash - ran it!"
28
+ end
29
+
30
+ def self.run txt, command=nil
31
+
32
+ # If 2nd arg passed, treat first as app
33
+ if command.present?
34
+
35
+ txt = "
36
+ tell application \"#{txt}\"
37
+ #{command}
38
+ end tell
39
+ ".unindent
40
+
41
+ return $el.do_applescript txt
42
+ end
43
+
44
+ $el.do_applescript txt
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ class As
2
+ def self.menu
3
+ %`
4
+ > Summary
5
+ | Keys shortcuts that start with "to+" (ctrl-t) such as to+end.
6
+ |
7
+ - frequent/
8
+ | as+clipboard: Copy (after doing Control-space on the other side)
9
+ | as+kill: Cut (after doing Control-space on the other side)
10
+ | as+bookmark: remember this file as a bookmark
11
+ - others/
12
+ | TODO
13
+ `
14
+ end
15
+ end
@@ -0,0 +1,63 @@
1
+ class Bookmarklet
2
+ def self.menu
3
+
4
+ %`
5
+ | // Customize this js code and then click "create"
6
+ | alert('hi')
7
+ - .create/
8
+ - docs/
9
+ > Summary
10
+ | Use this menu to create bookmarklets. A bookmarklet is a bookmark (in
11
+ | a web browser) that runs javascript code to do something interesting.
12
+ |
13
+ | After you modify the javascript (which can be multiple lines)
14
+ | and click "create", you will see instructions in the browser.
15
+ |
16
+ > jQuery
17
+ | The generated bookmarklet will automatically reqire jQuery if your
18
+ | script contains the string "$(" anywhere.
19
+ `
20
+ end
21
+
22
+ def self.create name=nil, options={}
23
+
24
+ if name.nil?
25
+ return View.prompt "Give your bookmarklet a name"
26
+ end
27
+
28
+ txt = Tree.siblings :before=>1
29
+ txt = txt.select{|o| o =~ /^\|/} # We only want quoted ones
30
+
31
+ txt = txt.join("\n").gsub(/^\| ?/, '')
32
+
33
+ txt.gsub! '"', "%22"
34
+ txt.gsub!(/(^| +)\/\/.+/, "")
35
+
36
+ if txt =~ /\$\(/ # If it uses the $ var, include jquery
37
+ txt = Javascript.wrap_jquery_load txt
38
+ end
39
+
40
+ html = %`
41
+ <title>Bookmarklet</title>
42
+ <p>Click the link to try it out. Then drag the link to your toolbar to create a bookmarklet:</p>
43
+
44
+ <a href="javascript:
45
+ (function(){
46
+ #{txt}
47
+ })()
48
+ ">#{name}</a>
49
+ `.unindent
50
+
51
+ File.open("/tmp/bookmarklet.html", "w") { |f| f << html }
52
+
53
+ Firefox.url "file:///tmp/bookmarklet.html"
54
+
55
+ Applescript.run "Firefox", "activate"
56
+
57
+ "
58
+ | Go to the browser to save the boomarklet
59
+ "
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,568 @@
1
+ class Bootstrap
2
+ def self.menu_after *args
3
+ return if args[0] # If menu outputted something, just return
4
+
5
+ self.content *args[1..-1]
6
+ end
7
+
8
+ def self.menu
9
+ %`
10
+ <= .make a page/
11
+ - examples/
12
+ - layouts/
13
+ - hello world/
14
+ - @bootstrap/
15
+ - project name/Sharkathon
16
+ - h1/Sharks
17
+ - p/They have fins and other cool stuff.
18
+ - hero unit/
19
+ - @bootstrap/
20
+ - project name/Sharkathon
21
+ - hero/
22
+ - h1/Sharks
23
+ - p/They have fins and other cool stuff.
24
+ - h1/Do you?
25
+ - p/Didn't think so.
26
+ - 2 columns/
27
+ - @bootstrap/
28
+ - row/
29
+ - span6/
30
+ - h1/random
31
+ - p/lorem ipsum...
32
+ - span6/
33
+ - h1/random
34
+ - p/ipsum dolor...
35
+ - 3 columns/
36
+ - @bootstrap/
37
+ - row/
38
+ - span4/
39
+ - h1/random
40
+ - p/lorem ipsum...
41
+ - span4/
42
+ - h1/random
43
+ - p/ipsum dolor...
44
+ - span4/
45
+ - h1/random
46
+ - p/dolor sit...
47
+ - with icons/
48
+ - @bootstrap/
49
+ - hero/
50
+ - h1/Sharks
51
+ - p/lorem...
52
+ - row/
53
+ - span6/
54
+ - h1 icon/random
55
+ - p/ipsum dolor sit...
56
+ - span6/
57
+ - h1 icon/random
58
+ - p/dolor sit lorem...
59
+ - row/
60
+ - span4/
61
+ - h1 icon/random
62
+ - p/lorem ipsum...
63
+ - span4/
64
+ - h1 icon/random
65
+ - p/ipsum dolor...
66
+ - span4/
67
+ - h1 icon/random
68
+ - p/sit lorem...
69
+ - shorthand/
70
+ - @bootstrap/
71
+ - hero/
72
+ > Shorthand
73
+ p/Lines starting with ">" at left margin will have rows and spans auto-wrapped around them.
74
+
75
+ > o random
76
+ lorem...
77
+ > o random
78
+ lorem...
79
+
80
+ > o random
81
+ lorem...
82
+ > o random
83
+ lorem...
84
+ > o random
85
+ lorem...
86
+ - with styled hero/
87
+ - @bootstrap/
88
+ - hero/
89
+ - h1/Sharks
90
+ - p/lorem...
91
+ - h1/random
92
+ - p/sit lorem ipsum dolor...
93
+ - style/
94
+ | .hero-unit {
95
+ | background-color: #9D261D;
96
+ | color: #fff;
97
+ | text-shadow: 2px 2px 2px #333;
98
+ | border-radius: 20px;
99
+ | }
100
+ - modified navbar/
101
+ - @bootstrap/
102
+ - navbar/
103
+ | <img src="http://xiki.org/images/bootstrap_icon.png">
104
+ | <style>.navbar .container { padding: 1px 30px 0px; }</style>
105
+ - h1/random
106
+ - p/sit lorem ipsum dolor...
107
+ - components/
108
+ - buttons/
109
+ - @bootstrap/
110
+ - h1/Buttons
111
+ - p/
112
+ <a class="btn" href="">Hi</a>
113
+ <a class="btn btn-primary" href="">Hi</a>
114
+ <a class="btn btn-info" href="">Hi</a>
115
+ <a class="btn btn-success" href="">Hi</a>
116
+ <a class="btn btn-warning" href="">Hi</a>
117
+ <a class="btn btn-danger" href="">Hi</a>
118
+ <a class="btn btn-inverse" href="">Hi</a>
119
+ - p/
120
+ <a class="btn btn-large" href="">Hi</a>
121
+ <a class="btn btn-large btn-success" href="">Hi</a>
122
+ <a class="btn btn-small" href="">Hi</a>
123
+ <a class="btn btn-mini" href="">Hi</a>
124
+ <a class="btn disabled" href="">Hi</a>
125
+ - icons/
126
+ - with headings/
127
+ - @bootstrap/
128
+ p/
129
+ - h3/random
130
+ - h1 icon/Info
131
+ - h1 icon/Info
132
+ p/
133
+ - h3/Specific
134
+ - h1/
135
+ - icon/043_group
136
+ Info
137
+ - h1/
138
+ - icon/051_eye_open
139
+ Info
140
+ - all/
141
+ - container/
142
+ - icon/
143
+ - small icons/
144
+ - container/
145
+ - h2/Icons
146
+ - p/
147
+ <i class="icon-user"></i>
148
+ <i class="icon-bullhorn"></i>
149
+ <i class="icon-glass"></i>
150
+ <i class="icon-music"></i>
151
+ <i class="icon-search"></i>
152
+ <i class="icon-envelope"></i>
153
+ <i class="icon-heart"></i>
154
+ <i class="icon-star"></i>
155
+ - p/
156
+ <a class="btn" href=""><i class="icon-glass"></i> Glass</a>
157
+ <a class="btn btn-primary" href=""><i class="icon-search"></i> Search</a>
158
+ <a class="btn btn-danger" href=""><i class="icon-music"></i> Music</a>
159
+ - forms/
160
+ - basics/
161
+ - @bootstrap/
162
+ | <form class="well">
163
+ | <label>Label name</label>
164
+ | <input type="text" class="span3" placeholder="Type something?">
165
+ | <span class="help-block">Example block-level help text here.</span>
166
+ | <label class="checkbox">
167
+ | <input type="checkbox"> Check me out
168
+ | </label>
169
+ | <button type="submit" class="btn">Submit</button>
170
+ | </form>
171
+ - search/
172
+ - @bootstrap/
173
+ | <form class="well form-search">
174
+ | <input type="text" class="input-medium search-query">
175
+ | <button type="submit" class="btn">Search</button>
176
+ | </form>
177
+ - inline/
178
+ - @bootstrap/
179
+ | <form class="well form-inline">
180
+ | <input type="text" class="input-small" placeholder="Email">
181
+ | <input type="password" class="input-small" placeholder="Password">
182
+ | <label class="checkbox">
183
+ | <input type="checkbox"> Remember me
184
+ | </label>
185
+ | <button type="submit" class="btn">Sign in</button>
186
+ | </form>
187
+ - horizontal/
188
+ - @bootstrap/
189
+ | <form class="form-horizontal">
190
+ | <fieldset>
191
+ | <legend>Legend text</legend>
192
+ | <div class="control-group">
193
+ | <label class="control-label" for="input01">Text input</label>
194
+ | <div class="controls">
195
+ | <input type="text" class="input-xlarge" id="input01">
196
+ | <p class="help-block">Supporting help text</p>
197
+ | </div>
198
+ | </div>
199
+ | </fieldset>
200
+ | </form>
201
+ - code/
202
+ - @bootstrap/
203
+ - pre/
204
+ | class Clam
205
+ | def hi
206
+ | "hello"
207
+ | end
208
+ | end
209
+ - p/Hey <code>you</code> there.
210
+ - carousel/
211
+ - @bootstrap/
212
+ - <div id="myCarousel" class="carousel slide">
213
+ - <div class="carousel-inner">
214
+ <div class="active item">
215
+ dolor...
216
+ <div class="item">
217
+ ipsum...
218
+ <div class="item">
219
+ sit...
220
+ <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
221
+ <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
222
+ - script/
223
+ $('.carousel').carousel({
224
+ interval: 2000
225
+ })
226
+ - docs/
227
+ > Summary
228
+ | Generate a good looking html page using Twitter's Bootstrap.
229
+
230
+ > How to do it
231
+ | Expand the 'container' menu to build, or start with the
232
+ | 'example' menu.
233
+ |
234
+ | @bootstrap/
235
+ | h1/Example Heading
236
+
237
+ > Bootstrap site
238
+ @http://twitter.github.com/bootstrap/
239
+ @http://twitter.github.com/bootstrap/base-css.html
240
+ @http://twitter.github.com/bootstrap/examples.html
241
+ `
242
+ end
243
+
244
+ @@bg = ['#eee', '#555', '#999', '#9D261D', '#369', '#096']
245
+
246
+ @@tags = {
247
+ "container"=>"div class='container'",
248
+ "row"=>"div class='row'",
249
+ "hero"=>"div class='hero-unit'",
250
+ "h1 icon"=>"h1",
251
+ }
252
+
253
+ @@filler = {
254
+ "project name"=>"Welcome",
255
+ "h1"=>"random",
256
+ "h1 icon"=>"random",
257
+ "p"=>"lorem ipsum...",
258
+ }
259
+
260
+ @@icons = [
261
+ '000_glass', '001_leaf', '002_dog', '003_user', '004_girl', '005_car', '006_user_add', '007_user_remove', '008_film', '009_magic', '010_envelope', '011_camera', '012_heart', '013_beach_umbrella', '014_train', '015_print', '016_bin', '017_music', '018_note', '019_cogwheel', '020_home', '021_snowflake', '022_fire', '023_cogwheels', '024_parents', '025_binoculars', '026_road', '027_search', '028_cars', '029_notes_2', '030_pencil', '031_bus', '032_wifi_alt', '033_luggage', '034_old_man', '035_woman', '036_file', '037_credit', '038_airplane', '039_notes', '040_stats', '041_charts', '042_pie_chart', '043_group', '044_keys', '045_calendar', '046_router', '047_camera_small', '048_dislikes', '049_star', '050_link', '051_eye_open', '052_eye_close', '053_alarm', '054_clock', '055_stopwatch', '056_projector', '057_history', '058_truck', '059_cargo', '060_compass', '061_keynote', '062_attach', '063_power', '064_lightbulb', '065_tag', '066_tags', '067_cleaning', '068_ruller', '069_gift', '070_umbrella', '071_book', '072_bookmark', '073_signal', '074_cup', '075_stroller', '076_headphones', '077_headset', '078_warning_sign', '079_signal', '080_retweet', '081_refresh', '082_roundabout', '083_random', '084_heat', '085_repeat', '086_display', '087_log_book', '088_adress_book', '089_magnet', '090_table', '091_adjust', '092_tint', '093_crop', '094_vector_path_square', '095_vector_path_circle', '096_vector_path_polygon', '097_vector_path_line', '098_vector_path_curve', '099_vector_path_all',
262
+
263
+ # Less interesting ones - don't show
264
+
265
+ '100_font', '101_italic', '102_bold', '103_text_underline', '104_text_strike', '105_text_height', '106_text_width', '107_text_resize', '108_left_indent', '109_right_indent', '110_align_left', '111_align_center', '112_align_right', '113_justify', '114_list', '115_text_smaller', '116_text_bigger', '117_embed', '118_embed_close', '119_adjust', '120_message_full', '121_message_empty', '122_message_in', '123_message_out', '124_message_plus', '125_message_minus', '126_message_ban', '127_message_flag', '128_message_lock', '129_message_new', '130_inbox', '131_inbox_plus', '132_inbox_minus', '133_inbox_lock', '134_inbox_in', '135_inbox_out', '136_computer_locked', '137_computer_service', '138_computer_proces', '139_phone', '140_database_lock', '141_database_plus', '142_database_minus', '143_database_ban', '144_folder_open', '145_folder_plus', '146_folder_minus', '147_folder_lock', '148_folder_flag', '149_folder_new', '150_check', '151_edit', '152_new_window', '153_more_windows', '154_show_big_thumbnails', '155_show_thumbnails', '156_show_thumbnails_with_lines', '157_show_lines', '158_playlist', '159_picture', '160_imac', '161_macbook', '162_ipad', '163_iphone', '164_iphone_transfer', '165_iphone_exchange', '166_ipod', '167_ipod_shuffle', '168_ear_plugs', '169_albums', '170_step_backward', '171_fast_backward', '172_rewind', '173_play', '174_pause', '175_stop', '176_forward', '177_fast_forward', '178_step_forward', '179_eject', '180_facetime_video', '181_download_alt', '182_mute', '183_volume_down', '184_volume_up', '185_screenshot', '186_move', '187_more', '188_brightness_reduce', '189_brightness_increase', '190_circle_plus', '191_circle_minus', '192_circle_remove', '193_circle_ok', '194_circle_question_mark', '195_circle_info', '196_circle_exclamation_mark', '197_remove', '198_ok', '199_ban',
266
+
267
+
268
+ ]
269
+
270
+ @@random = ["Info", "Facts", "B. S.", "Why?", "History", "Traits", "Story", "What?", "Happy"]
271
+ @@random_index = 0
272
+
273
+ def self.make_a_page
274
+
275
+ siblings = Tree.siblings :cross_blank_lines=>1
276
+
277
+ # If just 3 siblings, contiune as usual
278
+
279
+ # If more siblings
280
+ CodeTree.do_kill_indented
281
+ txt = ['project name/Foo', 'hero/', 'row/', 'style/'].map{|o| "- #{o}\n"}.join('')
282
+ Line.previous
283
+ Tree << txt
284
+
285
+ nil # Means we're handling collapse ourself
286
+ end
287
+
288
+ def self.content *args
289
+ prefix = Keys.prefix :clear=>1
290
+
291
+ # If not expandable or open+, render in browser
292
+
293
+ if prefix == "open" || Line !~ /\/$/ || Line =~ /^ *\|/
294
+ orig = Location.new
295
+
296
+ Tree.to_root
297
+
298
+ txt = Tree.children :cross_blank_lines=>1
299
+ orig.go
300
+ txt = txt.unindent
301
+
302
+ txt = self.process txt
303
+
304
+ return Browser.html txt
305
+ end
306
+
307
+ last = args.last
308
+ if filler = @@filler[last]
309
+ Line.add_slash :txt=>filler, :left=>1
310
+ elsif last == "icon"
311
+ @@icons
312
+ elsif last == 'style'
313
+ "
314
+ | .hero-unit {
315
+ | background-color: #9D261D; /* #eee #555 #999 #9D261D #369 #096 */
316
+ | background: -moz-linear-gradient(top, #111, #444);
317
+ | background: -webkit-linear-gradient(top, #111, #444);
318
+ | color: #fff;
319
+ | text-shadow: 2px 2px 2px #333;
320
+ | border-radius: 20px;
321
+ | }
322
+ "
323
+ elsif args == ['row']
324
+ ['span4/', 'span6/', 'span12/']
325
+ elsif args == ['hero']
326
+ ['h1/Info', 'p/lorem ipsum...']
327
+ else
328
+ ['h1/random', 'p/lorem ipsum...', 'h1 icon/random', 'icon/']
329
+ end
330
+
331
+ end
332
+
333
+ def initialize txt
334
+ @txt = txt
335
+ end
336
+
337
+ #
338
+ # If any >... lines at left margin, interpret them as h1's and assume
339
+ # we want to auto-wrap in row/spanN/ items.
340
+ #
341
+ # If any >... lines indented, just wrap in h1.
342
+ #
343
+ def self.expand_wiki_headings txt
344
+
345
+ # Always simply wrap >... lines that are indented...
346
+ txt.gsub! /( +)> /, "\\1h1/"
347
+
348
+ return if txt !~ /^> / # If no >... lines at left margin, we're done (because only they have are meant to be wrapped)
349
+
350
+ # Pre-process to deal with >... lines...
351
+
352
+ row_i = 0
353
+ row_hash = {0=>0} # example: 0=>2, 1=>2
354
+ lines = txt.split "\n"
355
+
356
+ # Preprocess to see how many spans there will be for each row...
357
+
358
+ no_h1_yet = true
359
+ lines.each do |l|
360
+ if l =~ /^> / # If >..., increase count in hash
361
+ row_hash[row_i] += 1
362
+ no_h1_yet = false
363
+ elsif no_h1_yet # Leave items before first >... alone
364
+ next
365
+ elsif l =~ /^$/
366
+ row_i += 1
367
+ row_hash[row_i] = 0
368
+ end
369
+ end
370
+
371
+ # Go through each, wrapping and adding h1/ and p/
372
+
373
+ txt.replace ""
374
+
375
+ no_h1_yet = true
376
+ row_i = 0
377
+ lines.each do |l|
378
+ if l =~ /^> (\w )?(.+)/ # If >..., increase count in hash
379
+ icon, heading = $1, $2
380
+ width = 12 / row_hash[row_i]
381
+ txt << "row/\n" if no_h1_yet # If first unindented >..., add initial row
382
+ no_h1_yet = false
383
+ next txt.<< " span#{width}/\n h1 #{icon.strip}/#{heading}\n" if icon
384
+ txt << " span#{width}/\n h1/#{heading}\n"
385
+ elsif no_h1_yet # Leave items before first >... alone
386
+ txt << "#{l}\n"
387
+ next
388
+ elsif l =~ /^$/
389
+ row_i += 1
390
+ txt << "row/\n"
391
+ else # Content, so add paragraph
392
+ txt << " p/#{l}\n"
393
+ end
394
+ end
395
+
396
+ end
397
+
398
+ def to_html
399
+
400
+ # Pre-process the text
401
+
402
+ project_name = @txt.slice!(/[ +-]*project name\/(.*)\n/)
403
+
404
+ # Remove |#... comments
405
+ @txt.gsub! /^ *\|# .+\n/, ''
406
+
407
+ Bootstrap.expand_wiki_headings @txt
408
+
409
+ # Wrap "- container/" around all, unless already a container
410
+ if @txt !~ /^ *([+-] )?container\// && @txt !~ /^ *([+-] )?<div.+class=.container\b/
411
+ @txt.gsub!(/^/, ' ')
412
+ @txt = "- container/\n#{@txt}"
413
+ end
414
+
415
+ @project_name = project_name ? project_name[/\/(.+)/, 1] : "Welcome"
416
+
417
+ @html = Tree.to_html @txt # Convert to html
418
+
419
+ # Expand out tags into actual html...
420
+
421
+ # Expand out spanN tags.
422
+
423
+ @html.gsub!(/<(\/?)span(\d+)>/) do |o|
424
+ slash, number = $1, $2
425
+ slash.any? ?
426
+ "</div>" :
427
+ "<div class='span#{number}'>"
428
+ end
429
+
430
+ # Add random icons in <h1 icon> tags.
431
+
432
+ @html.gsub!(/<h1 (\w+)>/) { |o| "<h1> #{Bootstrap.icon_tag @@icons[rand(93)]}" }
433
+
434
+ # Make all lines within <icon> tags become icons.
435
+
436
+ @html.gsub!(/( *)<icon>\n(.+?) *<\/icon>\n/m) do |o|
437
+ indent, txt = $1, $2
438
+ txt.gsub(/ *(.+)/) do |o|
439
+ name = $1
440
+ "#{indent}#{Bootstrap.icon_tag name}"
441
+ end
442
+ end
443
+
444
+ # Pull out certain tags, so they can be used elsewhere.
445
+
446
+ @navbar = @html.slice!(/ *<navbar>\n(.+?) *<\/navbar>\n/m)
447
+
448
+ @scripts = ""
449
+ # If pull out multiple script tags
450
+ @html.gsub!(/ *(<script>\n.+?<\/script>\n)/m) do
451
+ @scripts << $1
452
+ ""
453
+ end
454
+
455
+ # Expand out predictable fake html tags
456
+
457
+ @html.gsub!(/<(.+?)>/) do |o|
458
+ tag = $1
459
+ slash = tag.slice! /^\//
460
+ tag = @@tags[tag]
461
+ next o if ! tag
462
+ tag = tag.sub(/ .+/, '') if slash
463
+ "<#{slash}#{tag}>"
464
+ end
465
+
466
+ @@random_index = rand(@@random.length)
467
+ @html.gsub!(/^( *)random$/i) do
468
+ indent = $1
469
+ "#{indent}#{@@random[(@@random_index += 1) % @@random.length]}"
470
+ end
471
+
472
+ @html
473
+ end
474
+
475
+
476
+
477
+ def self.icon_tag name
478
+ "<img class='bs-icon' src='http://www.freeiconsweb.com/Icons-show/glyphicons_free-png/glyphicons_#{name}.png'>"
479
+ end
480
+
481
+ def wrap_html_page
482
+ navbar = @navbar || " <a class='brand' href='#'>#{@project_name}</a>"
483
+
484
+ result = %`
485
+ <!DOCTYPE html>
486
+ <html lang="en">
487
+ <head>
488
+ <meta charset="utf-8">
489
+ <title>#{@project_name}</title>
490
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
491
+ <meta name="description" content="">
492
+ <meta name="author" content="">
493
+
494
+ <!-- Le styles -->
495
+ <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
496
+ <style>
497
+ body {
498
+ padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
499
+ }
500
+ </style>
501
+ <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">
502
+
503
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
504
+ <!--[if lt IE 9]>
505
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
506
+ <![endif]-->
507
+
508
+ <!-- Le fav and touch icons -->
509
+ <link rel="shortcut icon" href="http://twitter.github.com/bootstrap/assets/ico/favicon.ico">
510
+ <link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png">
511
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png">
512
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png">
513
+ <link rel="apple-touch-icon-precomposed" href="http://twitter.github.com/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png">
514
+ </head>
515
+
516
+ <body>
517
+
518
+ <div class="navbar navbar-fixed-top">
519
+ <div class="navbar-inner">
520
+ <div class="container">
521
+ #{navbar}
522
+ </div>
523
+ </div>
524
+ </div>
525
+ `.unindent
526
+
527
+ if @html =~ /class='hero-unit'/
528
+ bg = @@bg[rand @@bg.length]
529
+ bg_is_light = bg =~ /^#[a-f][a-f][a-f]$/
530
+ fg = bg_is_light ? '#000' : '#fff' # Black if light color
531
+ shadow = bg_is_light ? '#999' : '#333' # Black if light color
532
+ result += %`
533
+ <style>
534
+ .hero-unit {
535
+ background-color: #{bg};
536
+ color: #{fg};
537
+ text-shadow: 2px 2px 2px #{shadow};
538
+ border-radius: 20px;
539
+ }
540
+ </style>
541
+ `.unindent.gsub(/^/, ' ')
542
+ end
543
+
544
+ result += @html.gsub(/^/, ' ')
545
+
546
+ result += %`
547
+ <!-- Le javascript
548
+ ================================================== -->
549
+ <!-- Placed at the end of the document so the pages load faster -->
550
+ <script src="http://twitter.github.com/bootstrap/assets/js/jquery.js"></script>
551
+ <script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script>
552
+
553
+ #{@scripts}
554
+
555
+ </body>
556
+ </html>
557
+ `.gsub(/^ /, '')
558
+
559
+ result
560
+ end
561
+
562
+ def self.process txt
563
+ bootstrap = Bootstrap.new txt
564
+ bootstrap.to_html
565
+ bootstrap.wrap_html_page
566
+ end
567
+
568
+ end