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
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'ruby2ruby'
4
+ gem 'ParseTree'
5
+ gem 'httparty'
6
+ gem 'activesupport'
7
+ gem 'method_source'
8
+ gem 'net-ssh'
9
+ gem 'net-ssh'
10
+ gem 'rspec'
11
+ gem 'memcached'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2012 Craig D Muth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,83 @@
1
+ ## Summary
2
+ This file tells how to install Xiki. See http://xiki.org for a description of Xiki.
3
+
4
+
5
+ __UPDATE DIRECTIONS TO SAY GEM INSTALL BY DEFAULT__
6
+
7
+ ## Step 1: Download Emacs
8
+
9
+ ### On Mac:
10
+ - Try Aquamacs 1.9.1 if you're new to emacs (it's more mac-like)
11
+ - http://aquamacs.org/download-classic.shtml
12
+ - Or
13
+ - http://emacsformacosx.com/emacs-builds/Emacs-22.3-i386-10.5.7.dmg
14
+ - Note: newer mac versions (after 22) have a bug that makes communicating with processes 1000 times slower. Til this is fixed stick with the above versions.
15
+
16
+ ### On Linux:
17
+
18
+ $ sudo apt-get install emacs
19
+
20
+
21
+ ## Step 2: Install the EmacsRuby (el4r) gem
22
+
23
+ $ sudo gem install el4r
24
+ $ gem contents el4r | grep setup.rb # To see which dir to cd to in the next step
25
+ $ cd /Library/Ruby/Gems/1.8/gems/el4r-1.0.4/
26
+ $ ruby setup.rb
27
+ $ cd bin/
28
+ $ ruby -S el4r-rctool -p
29
+ $ sudo ruby -S el4r-rctool -i
30
+
31
+ ## Step 3: Get Xiki from github
32
+ - Option 1: Download as zip
33
+ - Click on the 'ZIP' button on http://github.com/trogdoro/xiki
34
+ - Option 2: Clone repo
35
+ - git clone git@github.com:trogdoro/xiki.git
36
+
37
+
38
+ ## Step 4: Require Xiki in EmacsRuby's config
39
+ - Sample configuration
40
+ - ~/.el4r/init.rb
41
+ | $LOAD_PATH.unshift "/projects/xiki/lib"
42
+ | require 'xiki'
43
+ | Xiki.init
44
+ |
45
+ | KeyBindings.keys # Use default key bindings
46
+ | Styles.use_xiki_color_scheme # Use xiki's color scheme
47
+
48
+
49
+ ## Step 5: Install dependant packages
50
+ - In the xiki dir, run:
51
+ $ bundle install --system
52
+
53
+
54
+ ## Trouble-shooting
55
+ The install is a bit rough at the moment...
56
+
57
+ - If you get an error (and you probably will)
58
+ - If you got partially through the load
59
+ - you will be able to use these keys to trouble-shoot:
60
+ - Option-l to reload xiki and .emacs
61
+ - also use this when you see "el4r-instance is dead"
62
+ - Option-e to look at the latest error
63
+ - It will be Command instead of Option if you're not using Aquamacs
64
+
65
+ - Or you can manually restart emacs (or reload .emacs) and look at the log
66
+ - Named something like: /tmp/el4r......log
67
+ - Go to the end and search backward for the last error
68
+ - probably contains ":Error:"
69
+
70
+ - If you get a "can't find header dir for ruby" error
71
+ $ sudo apt-get install ruby1.8-dev
72
+
73
+ - If you run into trouble installing EmacsRuby
74
+ - See: http://www.rubyist.net/~rubikitch/computer/el4r/index.en.html
75
+ - Click on 'Download / Install / Setup' link
76
+
77
+
78
+ ## Google group
79
+ Join the google group for help with installing, or to chat about whatever or
80
+ share your ideas:
81
+
82
+ http://groups.google.com/group/xiki
83
+
@@ -0,0 +1,8 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ # Define task
5
+ Spec::Rake::SpecTask.new(:spec) do |t|
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # > Summary
5
+ # This file is aliased to /usr/local/bin/xiki, so it can be
6
+ # called from the command line. It exposes xiki menus.
7
+ #
8
+ # > Example
9
+ # $ xiki ip
10
+ # 111.1.1.111
11
+ #
12
+ # To create the alias, see:
13
+ # @xiki/setup/install command/
14
+ #
15
+
16
+ require 'rubygems'
17
+
18
+ # Generate with correct path (see below)
19
+ # xiki_dir = "/projects/xiki/"
20
+ xiki_dir = File.expand_path "#{File.dirname(__FILE__)}/.."
21
+ # p "xiki_dir: #{xiki_dir.inspect}"
22
+
23
+ # $:.unshift xiki_dir #.sub(/\/$/, '')
24
+ $:.unshift "#{xiki_dir}/lib" #.sub(/\/$/, '')
25
+
26
+ # require "#{xiki_dir}/ol"
27
+ require "ol"
28
+ # Ol.line
29
+ require "core_ext"
30
+
31
+ $:.unshift "#{xiki_dir}/etc/command"
32
+ # $:.unshift "#{xiki_dir}etc/command/stubs"
33
+
34
+ require "xiki_command.rb"
35
+ # load "xiki_command.rb"
36
+
37
+ result = XikiCommand.run
38
+ puts result if result != ""
39
+
40
+ exit 0
41
+
42
+ # TODO: Start with template, and when installing, change:
43
+ # - #!.. line to: result of: `which ruby`
44
+ # - xiki_dir to: Xiki.dir
45
+
46
+
@@ -0,0 +1,203 @@
1
+ require 'timeout'
2
+
3
+ #
4
+ # The 'xiki' shell command uses this class to run xiki menus.
5
+ # It tells the xiki process to run menus. It starts the xiki
6
+ # process if it's not running yet, and the process stays alive
7
+ # until the next time the shell command is run.
8
+ #
9
+ class XikiCommand
10
+
11
+ @@dont_show_output = false
12
+ @@initial_request = nil
13
+ def self.pop_initial_request
14
+ tmp = @@initial_request
15
+ @@initial_request = nil # So it doesn't loop
16
+ tmp
17
+ end
18
+
19
+ # Called by the 'xiki' shell command
20
+ def self.run
21
+
22
+ xiki_root = File.expand_path "#{File.dirname(__FILE__)}/../.."
23
+ argv = ARGV
24
+
25
+ if argv.empty?
26
+ puts self.usage
27
+ @@dont_show_output = true
28
+ argv = ['start'] # So it continues on and starts server
29
+ elsif argv.length == 1 && ['status', 'stop', 'restart'].member?(argv[0])
30
+ return self.ctrl argv[0]
31
+ end
32
+
33
+ flags, path = argv.partition{|o| o =~ /^-/}
34
+ path = path.join ' '
35
+
36
+ return self.emacs path if flags.member?("-e") # If -p, just prompt user to type a menu name
37
+
38
+ wasnt_running = false
39
+
40
+ begin
41
+ `mkfifo -m 666 /tmp/xikirequest` if ! File.exists?("/tmp/xikirequest") # Always create first, so they have to be pipes and can't be files
42
+ `mkfifo -m 666 /tmp/xikiresponse` if ! File.exists?("/tmp/xikiresponse")
43
+
44
+ # Try writing to pipe...
45
+
46
+ open("/tmp/xikirequest", 'w+') do |out|
47
+ out.puts path
48
+ out.flush # do this when we're done writing data
49
+ out.close
50
+ end
51
+
52
+ # Try reading from pipe...
53
+
54
+ response = self.get_response
55
+ return response
56
+
57
+ rescue Exception=>e
58
+
59
+ # If error, remember we have to start the process...
60
+
61
+ if e.is_a?(Timeout::Error) || (e.is_a?(Errno::ENOENT) && e.to_s =~ /\/tmp\/xiki/)
62
+ # Seems like process hasn't been started, so keep going
63
+ wasnt_running = true
64
+ else
65
+ Ol << "Unknown error when trying to call pipe!"
66
+ Ol << "#{e.to_s}\n#{e.backtrace.join "\n"}"
67
+ return
68
+ end
69
+ end
70
+
71
+ process_succeeded = false
72
+
73
+ if wasnt_running
74
+
75
+ # Start the process...
76
+
77
+ require 'daemons'
78
+
79
+ begin
80
+
81
+ # Shell out as async to start it instead - don't know fucking how
82
+
83
+ pid_orig = Process.pid
84
+
85
+ @@initial_request = path
86
+ xiki_process = "#{xiki_root}/etc/command/xiki_process.rb"
87
+ Daemons.run xiki_process, :ARGV=>['start'], :monitor=>false, :multiple=>false #, :app_name=>'xiki'
88
+ # Daemons.run '../etc/command/xiki_process.rb', :ARGV=>['start'], :monitor=>false, :multiple=>false #, :app_name=>'xiki'
89
+ # Daemons.run 'etc/process/xiki_process.rb', :ARGV=>['start'], :monitor=>false, :multiple=>false #, :app_name=>'xiki'
90
+ # Daemons.run '../etc/process/xiki_process.rb', :ARGV=>['start'], :monitor=>false, :multiple=>false #, :app_name=>'xiki'
91
+ # Daemons.run 'xiki_daemon.rb', :ARGV=>['start'], :monitor=>false, :multiple=>false #, :app_name=>'xiki'
92
+
93
+ # Aparently this line never gets reached
94
+ "- Started the process, I think."
95
+ rescue SystemExit=>e
96
+ raise SystemExit.new if pid_orig != Process.pid # If new process that started, just exit
97
+
98
+ process_succeeded = true
99
+
100
+ rescue Exception=>e
101
+ puts "- service couldn't start!"
102
+
103
+ #rescue ... <Errno::EACCES: Permission denied - /projects/xiki/etc/command/xiki_process.rb.pid>!
104
+ end
105
+ end
106
+
107
+ if process_succeeded
108
+ puts self.get_response # Get response first time
109
+ end
110
+
111
+ raise SystemExit.new
112
+ end
113
+
114
+ def self.get_response
115
+
116
+ # Simulate timeout error if process not running
117
+ process_running = `ps -e` =~ /xiki_process.rb/
118
+ if ! process_running
119
+ raise Timeout::Error
120
+ end
121
+
122
+ # TODO: what if menu takes longer than 3 seconds to run?
123
+
124
+ # TODO: have process send ACK, so we can make timout short
125
+
126
+ timeout(3) do
127
+ # timeout(0.5) do
128
+ # timeout(1.5) do
129
+ open("/tmp/xikiresponse", "r+") do |response|
130
+
131
+ # old TODO Try using select here, to see if there's data avaliable
132
+ # old IO.select ["/tmp/xikiresponse"]
133
+
134
+ response = response.gets # will block if there's nothing in the pipe
135
+
136
+ response.strip!
137
+ response.gsub! "\036", "\n" # Escape linebreaks as 036 char (record separator)
138
+ response = "" if @@dont_show_output
139
+ response
140
+ end
141
+ end
142
+ end
143
+
144
+ def self.usage
145
+ %`
146
+ > Summary
147
+ This command runs xiki menus, which come from simple files
148
+ found in ~/menus/.
149
+
150
+ > Show all menus
151
+ % xiki all
152
+
153
+ > Examples
154
+ Call 'ip' menu
155
+ % xiki ip
156
+ % xiki animals
157
+ % xiki tables
158
+
159
+ > Open 'ip' menu in emacs
160
+ % xiki -e ip
161
+
162
+ > Run under current dir
163
+ % xiki -e @git
164
+
165
+ > Service
166
+ Xiki automatically runs a service in the backgroundto keep
167
+ things fast.
168
+
169
+ % xiki # With no args, it starts the service.
170
+ % xiki status
171
+ % xiki stop
172
+ % xiki restart
173
+ `.unindent
174
+ end
175
+
176
+ def self.ctrl action
177
+ require 'daemons'
178
+ xiki_root = File.expand_path "#{File.dirname(__FILE__)}/../.."
179
+ xiki_process = "#{xiki_root}/etc/command/xiki_process.rb"
180
+ Daemons.run(xiki_process, :ARGV=>[action])
181
+ ""
182
+ end
183
+
184
+ #
185
+ # Tells emacs to open and display menu.
186
+ #
187
+ def self.emacs menu
188
+
189
+ # Bring emacs to front
190
+
191
+ `open "/Applications/Aquamacs Emacs.app"`
192
+
193
+ ruby = %`Menu.external \\"#{menu}\\"`
194
+ ruby << %`, :dir=>\\"#{Dir.pwd}\\"` if menu =~ /^@/
195
+
196
+ command = %`emacsclient -n -e '(el4r-ruby-eval "#{ruby}")'`
197
+ `#{command}`
198
+
199
+ nil
200
+ end
201
+
202
+ end
203
+
@@ -0,0 +1,52 @@
1
+ # Don't hard-code, generate with script? - or use __file path xiki env var!
2
+ require '/projects/xiki/lib/ol'
3
+ require 'core_ext'
4
+
5
+ require 'menu'
6
+
7
+ require 'launcher'
8
+
9
+ Xiki.init
10
+
11
+ # Make named pipes for input and output
12
+
13
+ class XikiProcess
14
+
15
+ def self.run
16
+
17
+ open('/tmp/xikirequest', 'r+') do |f|
18
+
19
+ open('/tmp/xikiresponse', 'w+') do |response|
20
+ loop do
21
+
22
+ # Read request...
23
+
24
+ path = XikiCommand.pop_initial_request || f.gets
25
+ path.strip!
26
+
27
+ # Invoke menu and send response...
28
+
29
+ menu_output =
30
+ begin
31
+ Menu[path]
32
+ rescue Exception=>e
33
+ "#{e.message}\n#{e.backtrace.join("\n")}"
34
+ end
35
+
36
+ if menu_output.nil?
37
+ menu_output = ""
38
+ end
39
+
40
+ menu_output.gsub! "\n", "\036" # Escape linebreaks as 036 char (record separator)
41
+ response.puts menu_output
42
+ response.flush
43
+ end
44
+ end
45
+ end
46
+
47
+ rescue Exception=>e
48
+ puts "#{e.message}\n#{e.backtrace}"
49
+ end
50
+ end
51
+
52
+ XikiProcess.run
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ load "/projects/xiki/bin/xiki"
@@ -0,0 +1,55 @@
1
+ $(function(){
2
+ xiki_txt = Xiki.unindent($('div[data-xiki=menu]').html());
3
+ // Render jquery mobile interface
4
+
5
+ $('body').html(Xiki.render_mobile_standalone());
6
+
7
+ // Grab children from txt and add menu for each
8
+ var children = Xiki.children(xiki_txt, "");
9
+ var html = Xiki.children_to_html(children);
10
+ // console.log("html:", html)
11
+ console.log(".ui-content:", $(".ui-content").length)
12
+
13
+ $("div[data-role=content]").html(html);
14
+ // $(".ui-content").trigger("create");
15
+
16
+ // $(".ui-page").trigger("create");
17
+
18
+ $(document).bind( "pagebeforechange", function(e, data) {
19
+
20
+ if(typeof data.toPage != "string") return;
21
+
22
+ var hash_orig = data.toPage.replace(/.+?(#|$)/, '');
23
+ var hash = hash_orig.replace(/,/g, '/');
24
+
25
+ Xiki.navigate(e, data, Xiki.children(xiki_txt, hash));
26
+ });
27
+
28
+ // Old
29
+
30
+
31
+
32
+
33
+
34
+
35
+ // $("body").trigger("create");
36
+
37
+ // $('div:eq(0)').html("abc");
38
+ // $('body').html("abc");
39
+
40
+ // $(".ui-content").blink();
41
+
42
+
43
+ // $('body').html(Xiki.render_mobile_standalone());
44
+ // $("div:first").trigger("create");
45
+ // $("div:first").page();
46
+ // $("div:first").blink();
47
+
48
+ // $(".ui-page").page();
49
+ // $(".ui-page").trigger("refresh");
50
+ // $("div[data-role=header]").trigger("create");
51
+ // $(".ui-page").trigger("refresh");
52
+
53
+ // TODO: pass to xiki.children()
54
+ // $('div[data-xiki=menu]').blink();
55
+ })