bivouac 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/README +6 -7
  2. data/bin/bivouac +1 -1
  3. data/doc/rdoc/classes/BivouacHelpers/BaseView.html +178 -0
  4. data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
  5. data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +305 -0
  6. data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
  7. data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
  8. data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
  9. data/doc/rdoc/classes/BivouacHelpers.html +117 -0
  10. data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
  11. data/doc/rdoc/created.rid +1 -0
  12. data/doc/rdoc/files/AUTHORS.html +109 -0
  13. data/doc/rdoc/files/COPYING.html +533 -0
  14. data/doc/rdoc/files/README.html +427 -0
  15. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/base_rb.html +109 -0
  16. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +109 -0
  17. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +109 -0
  18. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +113 -0
  19. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +113 -0
  20. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/tooltip_rb.html +109 -0
  21. data/doc/rdoc/index.html +10 -0
  22. data/doc/rdoc/permalink.gif +0 -0
  23. data/doc/rdoc/rdoc-style.css +106 -0
  24. data/doc/rdoc/rubyfr.png +0 -0
  25. data/examples/bivouac_sample/Rakefile +48 -0
  26. data/examples/bivouac_sample/app/bivouac_sample.rb +15 -7
  27. data/examples/bivouac_sample/app/controllers/index.rb +2 -2
  28. data/examples/bivouac_sample/app/controllers/sound.rb +10 -0
  29. data/examples/bivouac_sample/app/helpers/_helpers.rb +6 -3
  30. data/examples/bivouac_sample/app/views/sound.rb +16 -0
  31. data/examples/bivouac_sample/config/environment.rb +5 -2
  32. data/examples/bivouac_sample/config/postamble.rb +89 -18
  33. data/examples/bivouac_sample/public/javascripts/builder.js +12 -7
  34. data/examples/bivouac_sample/public/javascripts/controls.js +485 -355
  35. data/examples/bivouac_sample/public/javascripts/dragdrop.js +82 -52
  36. data/examples/bivouac_sample/public/javascripts/effects.js +361 -329
  37. data/examples/bivouac_sample/public/javascripts/prototype.js +2826 -1120
  38. data/examples/bivouac_sample/public/javascripts/scriptaculous.js +15 -8
  39. data/examples/bivouac_sample/public/javascripts/slider.js +40 -43
  40. data/examples/bivouac_sample/public/javascripts/sound.js +55 -0
  41. data/examples/bivouac_sample/public/javascripts/unittest.js +16 -12
  42. data/examples/bivouac_sample/public/sound/sword.mp3 +0 -0
  43. data/examples/bivouac_sample/script/console +6 -0
  44. data/examples/bivouac_sample/script/plugin +3 -0
  45. data/examples/bivouac_sample/script/server +2 -1
  46. data/examples/bivouac_sample/test/test_sound.rb +15 -0
  47. data/lib/bivouac/helpers/view/goh/sound.rb +38 -0
  48. data/lib/bivouac/template/application/helpers_goh.rb +2 -0
  49. data/lib/bivouac/template/static/builder.js +12 -7
  50. data/lib/bivouac/template/static/controls.js +485 -355
  51. data/lib/bivouac/template/static/dragdrop.js +82 -52
  52. data/lib/bivouac/template/static/effects.js +361 -329
  53. data/lib/bivouac/template/static/prototype.js +2826 -1120
  54. data/lib/bivouac/template/static/scriptaculous.js +15 -8
  55. data/lib/bivouac/template/static/slider.js +40 -43
  56. data/lib/bivouac/template/static/sound.js +55 -0
  57. data/lib/bivouac/template/static/unittest.js +16 -12
  58. metadata +45 -2
@@ -1,7 +1,7 @@
1
1
  module BivouacSample::Controllers
2
- class Root < R '/', '/index'
2
+ class Index < R '/', '/index'
3
3
  def get
4
- render :index
4
+ redirect Public, "index.html"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ module BivouacSample::Controllers
2
+ class Sound < R '/sound'
3
+ def get
4
+ render :sound
5
+ end
6
+ def post
7
+ render :sound
8
+ end
9
+ end
10
+ end
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # Project BivouacSample
3
3
  #
4
- # Created using bivouac on Mon Sep 10 21:47:54 +0200 2007.
5
- # Copyright (c) 2007 __My__. All rights reserved.
4
+ # Created using bivouac on Sun Mar 23 20:30:14 +0100 2008.
5
+ # Copyright (c) 2008 __My__. All rights reserved.
6
6
  #
7
7
  # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
8
8
  # USE script/generate helper my_helper
@@ -12,6 +12,7 @@ require 'bivouac/helpers/view/goh/html'
12
12
  require 'bivouac/helpers/view/goh/form'
13
13
  require 'bivouac/helpers/view/goh/scriptaculous'
14
14
  require 'bivouac/helpers/view/goh/javascript'
15
+ require 'bivouac/helpers/view/goh/sound'
15
16
  require 'bivouac/helpers/view/goh/tooltip'
16
17
 
17
18
  helpers = [
@@ -20,6 +21,8 @@ helpers = [
20
21
  BivouacHelpers::FormView,
21
22
  BivouacHelpers::ScriptAculoUsView,
22
23
  BivouacHelpers::JavaScriptView,
24
+ BivouacHelpers::SoundView,
23
25
  BivouacHelpers::TooltipView
24
- ]
26
+ ] + viewHelperModule
27
+
25
28
  BivouacSample.module_eval "class Mab < Markaby::Builder; include #{helpers.join(', ')}; end"
@@ -0,0 +1,16 @@
1
+ module BivouacSample::Views
2
+ def sound
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ end
7
+ body do
8
+ h1 "Sound"
9
+ a "play sound (parallel)", :href => "#", :onclick => play_sound_js( "sound/sword.mp3" ); br
10
+ a "play sound (overwrite)", :href => "#", :onclick => play_sound_js( "sound/sword.mp3", :replace => true ); br
11
+ a "Mute", :href => "#", :onclick => disable_sound_js
12
+ a "Enable sounds", :href => "#", :onclick => enable_sound_js
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # Project BivouacSample
3
3
  #
4
- # Created using bivouac on Mon Sep 10 21:47:54 +0200 2007.
5
- # Copyright (c) 2007 __My__. All rights reserved.
4
+ # Created using bivouac on Sun Mar 23 20:30:12 +0100 2008.
5
+ # Copyright (c) 2008 __My__. All rights reserved.
6
6
  #
7
7
 
8
8
  require 'ostruct'
@@ -20,6 +20,9 @@ module Bivouac
20
20
  # Application port
21
21
  :port => 3301,
22
22
 
23
+ # Database configuration
24
+ :db => {:database=>"db/bivouac_sample.db", :adapter=>"sqlite3"},
25
+
23
26
  # Name of the application
24
27
  # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
25
28
  :appname => "BivouacSample",
@@ -1,23 +1,43 @@
1
1
  #
2
2
  # Project BivouacSample
3
3
  #
4
- # Created using bivouac on Mon Sep 10 21:47:54 +0200 2007.
5
- # Copyright (c) 2007 __My__. All rights reserved.
4
+ # Created using bivouac on Sun Mar 23 20:30:13 +0100 2008.
5
+ # Copyright (c) 2008 __My__. All rights reserved.
6
6
  #
7
7
 
8
+ windows_process = false
9
+ if /Windows/.match( ENV['OS'] )
10
+ begin
11
+ require 'win32/process'
12
+ windows_process = true
13
+ rescue LoadError => e
14
+ warn "`win32-process' is not installed!"
15
+ end
16
+ end
17
+
8
18
  require 'simple-daemon'
9
19
 
10
20
  DIRNAME = File.expand_path( File.dirname(__FILE__) )
11
- SimpleDaemon::WorkingDirectory = DIRNAME + "/../log/"
21
+ SimpleDaemon::WORKING_DIRECTORY = DIRNAME + "/../log/"
22
+
12
23
  class BivouacSampleDaemon < SimpleDaemon::Base
13
24
  @@server = nil
25
+ @@use = nil
26
+
27
+ def self.use=(x)
28
+ @@use=x
29
+ end
14
30
 
15
31
  def self.start
16
32
  config = Bivouac::Environment.new( )
17
33
 
18
- BivouacSample::Models::Base.establish_connection :adapter => 'sqlite3', :database => DIRNAME + "/../db/BivouacSample.db"
34
+ database_connection = config.environment.db
35
+ if database_connection[:adapter] =~ /sqlite/
36
+ database_connection[:database] = DIRNAME + "/../" + database_connection[:database]
37
+ end
38
+ BivouacSample::Models::Base.establish_connection database_connection
19
39
  BivouacSample::Models::Base.logger = Logger.new(DIRNAME + "/../log/BivouacSample.log")
20
- # BivouacSample::Models::Base.threaded_connections = false
40
+ # -- DON'T WORK WITH RAILS 2 -- # BivouacSample::Models::Base.threaded_connections = false
21
41
  BivouacSample.create if BivouacSample.respond_to? :create
22
42
 
23
43
  trap(:INT) do
@@ -25,11 +45,22 @@ class BivouacSampleDaemon < SimpleDaemon::Base
25
45
  end
26
46
 
27
47
  begin
28
- require 'mongrel/camping'
48
+ if @@use.nil?
49
+ begin
50
+ require 'thin'
51
+
52
+ Rack::Handler::Thin.run Rack::Adapter::Camping.new( BivouacSample ), :Host => config.environment.address, :Port => config.environment.port
53
+ puts "** BivouacSample is running at http://#{config.environment.address}:#{config.environment.port}"
54
+ rescue LoadError
55
+ require 'mongrel/camping'
29
56
 
30
- @@server = Mongrel::Camping.start( config.environment.address, config.environment.port, "/", BivouacSample)
31
- puts "** BivouacSample is running at http://#{config.environment.address}:#{config.environment.port}"
32
- @@server.run.join
57
+ @@server = Mongrel::Camping.start( config.environment.address, config.environment.port, "/", BivouacSample)
58
+ puts "** BivouacSample is running at http://#{config.environment.address}:#{config.environment.port}"
59
+ @@server.run.join
60
+ end
61
+ else
62
+ raise LoadError, "I want to use WEBrick please!"
63
+ end
33
64
  rescue LoadError => e
34
65
  require 'webrick/httpserver'
35
66
  require 'camping/webrick'
@@ -37,6 +68,7 @@ class BivouacSampleDaemon < SimpleDaemon::Base
37
68
  @@server = WEBrick::HTTPServer.new :BindAddress => config.environment.address, :Port => config.environment.port
38
69
  puts "** BivouacSample is running at http://#{config.environment.address}:#{config.environment.port}"
39
70
  @@server.mount "/", WEBrick::CampingHandler, BivouacSample
71
+ @@server.start
40
72
  end
41
73
  end
42
74
 
@@ -50,13 +82,52 @@ class BivouacSampleDaemon < SimpleDaemon::Base
50
82
  end
51
83
  end
52
84
 
53
- deamonize = ARGV.shift
54
- case deamonize
55
- when '-d'
56
- BivouacSampleDaemon.daemonize
57
- when '-h'
58
- puts "script/server [-d start|stop|restart] [-h]"
59
- exit
60
- else
61
- BivouacSampleDaemon.start
85
+ while ARGV.size > 0
86
+ deamonize = ARGV.shift
87
+ case deamonize
88
+ when 'webrick'
89
+ BivouacSampleDaemon.use='webrick'
90
+ when '-c'
91
+ ARGV.clear
92
+
93
+ include BivouacSample::Models
94
+
95
+ config = Bivouac::Environment.new( )
96
+ database_connection = config.environment.db
97
+ if database_connection[:adapter] =~ /sqlite/
98
+ database_connection[:database] = DIRNAME + "/../" + database_connection[:database]
99
+ end
100
+ BivouacSample::Models::Base.establish_connection database_connection
101
+ BivouacSample.create if BivouacSample.respond_to? :create
102
+
103
+ require 'irb'
104
+ require 'irb/completion'
105
+ if File.exists? ".irbrc"
106
+ ENV['IRBRC'] = ".irbrc"
107
+ end
108
+ IRB.start
109
+ break
110
+ when '-d'
111
+ if /Windows/.match( ENV['OS'] ) and windows_process == false
112
+ warn "You must install `win32-process' to daemonize this app."
113
+ exit 1
114
+ end
115
+
116
+ BivouacSampleDaemon.daemonize
117
+ break
118
+ when '-h'
119
+ begin
120
+ require 'mongrel/camping'
121
+ puts "=> Booting Mongrel (use 'script/server webrick [options]' to force WEBrick)"
122
+ rescue LoadError => e
123
+ puts "=> Booting WEBrick"
124
+ end
125
+ puts "script/server [-d start|stop|restart] [-h]"
126
+ exit
127
+ when '--'
128
+ BivouacSampleDaemon.start
129
+ break
130
+ else
131
+ puts "Ignore unknown option '#{deamonize}' !"
132
+ end
62
133
  end
@@ -1,6 +1,6 @@
1
- // script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
1
+ // script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
2
2
 
3
- // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
3
+ // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
4
  //
5
5
  // script.aculo.us is freely distributable under the terms of an MIT-style license.
6
6
  // For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -48,7 +48,8 @@ var Builder = {
48
48
  // attributes (or text)
49
49
  if(arguments[1])
50
50
  if(this._isStringOrNumber(arguments[1]) ||
51
- (arguments[1] instanceof Array)) {
51
+ (arguments[1] instanceof Array) ||
52
+ arguments[1].tagName) {
52
53
  this._children(element, arguments[1]);
53
54
  } else {
54
55
  var attrs = this._attributes(arguments[1]);
@@ -66,7 +67,7 @@ var Builder = {
66
67
  }
67
68
  if(element.tagName.toUpperCase() != elementName)
68
69
  element = parentElement.getElementsByTagName(elementName)[0];
69
- }
70
+ }
70
71
  }
71
72
 
72
73
  // text, or array of children
@@ -88,10 +89,14 @@ var Builder = {
88
89
  var attrs = [];
89
90
  for(attribute in attributes)
90
91
  attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
91
- '="' + attributes[attribute].toString().escapeHTML() + '"');
92
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
92
93
  return attrs.join(" ");
93
94
  },
94
95
  _children: function(element, children) {
96
+ if(children.tagName) {
97
+ element.appendChild(children);
98
+ return;
99
+ }
95
100
  if(typeof children=='object') { // array can hold nodes and text
96
101
  children.flatten().each( function(e) {
97
102
  if(typeof e=='object')
@@ -101,8 +106,8 @@ var Builder = {
101
106
  element.appendChild(Builder._text(e));
102
107
  });
103
108
  } else
104
- if(Builder._isStringOrNumber(children))
105
- element.appendChild(Builder._text(children));
109
+ if(Builder._isStringOrNumber(children))
110
+ element.appendChild(Builder._text(children));
106
111
  },
107
112
  _isStringOrNumber: function(param) {
108
113
  return(typeof param=='string' || typeof param=='number');