bivouac 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/README +9 -0
  2. data/bin/bivouac +15 -19
  3. data/doc/rdoc/classes/BivouacHelpers.html +117 -0
  4. data/doc/rdoc/classes/BivouacHelpers/BaseView.html +140 -0
  5. data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
  6. data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +274 -0
  7. data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
  8. data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
  9. data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
  10. data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
  11. data/doc/rdoc/created.rid +1 -1
  12. data/doc/rdoc/files/AUTHORS.html +14 -0
  13. data/doc/rdoc/files/COPYING.html +14 -0
  14. data/doc/rdoc/files/README.html +40 -1
  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/examples/bivouac_sample/app/bivouac_sample.rb +61 -0
  22. data/examples/bivouac_sample/app/controllers/autocomplete.rb +24 -0
  23. data/examples/bivouac_sample/app/controllers/drag_and_drop.rb +11 -0
  24. data/examples/bivouac_sample/app/controllers/index.rb +7 -0
  25. data/examples/bivouac_sample/app/controllers/observe.rb +14 -0
  26. data/examples/bivouac_sample/app/controllers/periodically_call.rb +12 -0
  27. data/examples/bivouac_sample/app/controllers/remote_form.rb +10 -0
  28. data/examples/bivouac_sample/app/controllers/remote_link.rb +11 -0
  29. data/examples/bivouac_sample/app/controllers/submit_remote.rb +17 -0
  30. data/examples/bivouac_sample/app/controllers/toggle.rb +10 -0
  31. data/examples/bivouac_sample/app/controllers/toggle_sortable.rb +11 -0
  32. data/examples/bivouac_sample/app/helpers/_helpers.rb +25 -0
  33. data/examples/bivouac_sample/app/helpers/source.rb +25 -0
  34. data/examples/bivouac_sample/app/views/_autocomplete_result.rb +9 -0
  35. data/examples/bivouac_sample/app/views/_drag_and_drop_result.rb +5 -0
  36. data/examples/bivouac_sample/app/views/_observe_result.rb +17 -0
  37. data/examples/bivouac_sample/app/views/_periodically_call_result.rb +5 -0
  38. data/examples/bivouac_sample/app/views/_remote_link_result.rb +5 -0
  39. data/examples/bivouac_sample/app/views/_sortable_result.rb +5 -0
  40. data/examples/bivouac_sample/app/views/_submit_remote_result.rb +5 -0
  41. data/examples/bivouac_sample/app/views/autocomplete.rb +28 -0
  42. data/examples/bivouac_sample/app/views/drag_and_drop.rb +35 -0
  43. data/examples/bivouac_sample/app/views/index.rb +19 -0
  44. data/examples/bivouac_sample/app/views/observe.rb +19 -0
  45. data/examples/bivouac_sample/app/views/periodically_call.rb +17 -0
  46. data/examples/bivouac_sample/app/views/remote_form.rb +19 -0
  47. data/examples/bivouac_sample/app/views/remote_link.rb +20 -0
  48. data/examples/bivouac_sample/app/views/submit_remote.rb +21 -0
  49. data/examples/bivouac_sample/app/views/toggle.rb +44 -0
  50. data/examples/bivouac_sample/app/views/toggle_sortable.rb +52 -0
  51. data/examples/bivouac_sample/config/environment.rb +37 -0
  52. data/examples/bivouac_sample/config/postamble.rb +62 -0
  53. data/examples/bivouac_sample/log/BivouacSample.log +77 -0
  54. data/examples/bivouac_sample/public/images/camping.png +0 -0
  55. data/examples/bivouac_sample/public/index.html +242 -0
  56. data/examples/bivouac_sample/public/javascripts/builder.js +131 -0
  57. data/examples/bivouac_sample/public/javascripts/controls.js +835 -0
  58. data/examples/bivouac_sample/public/javascripts/dragdrop.js +944 -0
  59. data/examples/bivouac_sample/public/javascripts/effects.js +1090 -0
  60. data/examples/bivouac_sample/public/javascripts/prototype.js +2515 -0
  61. data/examples/bivouac_sample/public/javascripts/scriptaculous.js +51 -0
  62. data/examples/bivouac_sample/public/javascripts/slider.js +278 -0
  63. data/examples/bivouac_sample/public/javascripts/tooltip.js +208 -0
  64. data/examples/bivouac_sample/public/javascripts/unittest.js +564 -0
  65. data/examples/bivouac_sample/public/stylesheets/autocomplete.css +22 -0
  66. data/examples/bivouac_sample/public/stylesheets/coderay.css +104 -0
  67. data/examples/bivouac_sample/script/generate +3 -0
  68. data/examples/bivouac_sample/script/server +5 -0
  69. data/lib/bivouac/helpers/view/goh/base.rb +16 -0
  70. data/lib/bivouac/helpers/view/goh/form.rb +170 -0
  71. data/lib/bivouac/helpers/view/goh/html.rb +138 -0
  72. data/lib/bivouac/helpers/view/goh/javascript.rb +532 -0
  73. data/lib/bivouac/helpers/view/goh/scriptaculous.rb +133 -0
  74. data/lib/bivouac/helpers/view/goh/tooltip.rb +33 -0
  75. data/lib/bivouac/template.rb +3 -3
  76. data/lib/bivouac/template/application/helpers_erb.rb +11 -0
  77. data/lib/bivouac/template/application/helpers_goh.rb +25 -0
  78. data/lib/bivouac/template/application/postamble.rb +62 -0
  79. data/lib/bivouac/template/application_erb.rb +4 -0
  80. data/lib/bivouac/template/application_goh.rb +4 -0
  81. data/lib/bivouac/template/environment.rb +19 -5
  82. data/lib/bivouac/template/server.rb +1 -1
  83. data/lib/bivouac/template/static/autocomplete.css +22 -0
  84. data/lib/bivouac/template/static/builder.js +131 -0
  85. data/lib/bivouac/template/static/controls.js +835 -0
  86. data/lib/bivouac/template/static/dragdrop.js +944 -0
  87. data/lib/bivouac/template/static/effects.js +1090 -0
  88. data/lib/bivouac/template/static/prototype.js +2515 -0
  89. data/lib/bivouac/template/static/scriptaculous.js +51 -0
  90. data/lib/bivouac/template/static/slider.js +278 -0
  91. data/lib/bivouac/template/static/tooltip.js +208 -0
  92. data/lib/bivouac/template/static/unittest.js +564 -0
  93. metadata +124 -7
  94. data/lib/bivouac/template/application/postamble_cgi.rb +0 -8
  95. data/lib/bivouac/template/application/postamble_fastcgi.rb +0 -8
  96. data/lib/bivouac/template/application/postamble_mongrel.rb +0 -19
  97. data/lib/bivouac/template/application/postamble_none.rb +0 -1
  98. data/lib/bivouac/template/application/postamble_webrick.rb +0 -19
@@ -0,0 +1,25 @@
1
+ require 'coderay'
2
+
3
+ def highlight_file( file, options = {} )
4
+ id = options[:id] || "source"
5
+ display = options[:display] || ""
6
+ div( :id => id, :style => "display:#{display};" ) do
7
+ CodeRay.scan_file(file, :ruby).div(:line_numbers => :table, :css => :class)
8
+ end
9
+ end
10
+
11
+ def highlight_me( options = {} )
12
+ id = options[:id] || "source"
13
+ display = options[:display] || ""
14
+ div( :id => id, :style => "display:#{display};" ) do
15
+ CodeRay.scan_file(__FILE__, :ruby).div(:line_numbers => :table, :css => :class)
16
+ end
17
+ end
18
+
19
+ def highlight_data( data, options = {} )
20
+ id = options[:id] || "source"
21
+ display = options[:display] || ""
22
+ div( :id => id, :style => "display:#{display};" ) do
23
+ CodeRay.scan(data, :ruby).div(:line_numbers => :table, :css => :class)
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ module BivouacSample::Views
2
+ def _autocomplete_result
3
+ ul do
4
+ @results.each do |n|
5
+ li n
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module BivouacSample::Views
2
+ def _drag_and_drop_result
3
+ span "You drop me "; b "#{@product}"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ module BivouacSample::Views
2
+ def _observe_result
3
+ if @results.empty?
4
+ p {
5
+ span "Pas de résultat pour "
6
+ b @search
7
+ }
8
+ else
9
+ p {
10
+ span "Résultats de la recherche de "
11
+ b @search
12
+ span " : "
13
+ i @results.join( ', ' )
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module BivouacSample::Views
2
+ def _periodically_call_result
3
+ pre @data
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module BivouacSample::Views
2
+ def _remote_link_result
3
+ span "Tu as le bonjour d'AJAX. Il est #{@date}"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module BivouacSample::Views
2
+ def _sortable_result
3
+ span "#{Time.now} ordre de la liste: #{@data}"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module BivouacSample::Views
2
+ def _submit_remote_result
3
+ span @isay
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ module BivouacSample::Views
2
+ def autocomplete
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "autocomplete"
7
+ stylesheet_link_tag "coderay"
8
+ end
9
+ body do
10
+ h1 "autocomplete text_field"
11
+
12
+ p { span "Commencez à saisir un mot. "; b "Lej"; span " par exemple ;)" }
13
+ text_field( 'test_autocomplete', "", :autocomplete => R(Autocomplete), :indicator => 'Search...' )
14
+
15
+ hr
16
+
17
+ p { span "Source du controller "; tt "app/controller/autocomplete.rb" }
18
+ highlight_file( File.dirname( __FILE__ ) + "/../controllers/autocomplete.rb", :id => "source0")
19
+
20
+ p { span "Source de la vue "; tt "app/views/autocomplete.rb" }
21
+ highlight_file( __FILE__, :id => "source1" )
22
+
23
+ p { span "Source de la vue "; tt "app/views/_autocomplete_result.rb" }
24
+ highlight_file( File.dirname( __FILE__ ) + "/_autocomplete_result.rb", :id => "source2")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,35 @@
1
+ module BivouacSample::Views
2
+ def drag_and_drop
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ style do
7
+ %(div.cart {
8
+ clear:both;
9
+ border:1px solid #E8A400;
10
+ background-color:white;
11
+ padding:8px;
12
+ width:500px;
13
+ }
14
+ div.cart-active {
15
+ background-color: #FFF4D8;
16
+ })
17
+ end
18
+ end
19
+ body do
20
+ h1 "drag_and_drop"
21
+
22
+ span "Drag one of the folowing..."
23
+ div( :id => "product-1", :style => "background-color: red; padding: 5px; width: 20px;", :class => "product" ) do; span "1"; end
24
+ draggable_element( "product-1", :revert => 'true' )
25
+ div( :id => "product-2", :style => "background-color: blue; padding: 5px; width: 20px;", :class => "product" ) do; span "2"; end
26
+ draggable_element( "product-2", :revert => 'true' )
27
+ div( :id => "product-3", :style => "background-color: green; padding: 5px; width: 20px;", :class => "product" ) do; span "3"; end
28
+ draggable_element( "product-3", :revert => 'true' )
29
+
30
+ div( :id => "cart", :class => 'cart', :style => "clear: left; height: 132px; margin-top: 10px; position: relative;") do; span "Drop me something..."; end
31
+ drop_receiving_element( "cart", :accept => 'product', :onDrop => { :url => R(DragAndDrop), :update => 'cart' }, :hoverclass => 'cart-active' )
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ module BivouacSample::Views
2
+ def index
3
+ html do
4
+ body do
5
+ h1 "test_suite"
6
+
7
+ a( "toggle", :href => R(Toggle) ); br
8
+ a( "toggle/sortable", :href => R(ToggleSortable) ); br
9
+ a( "autocomplete", :href => R(Autocomplete) ); br
10
+ a( "remote link", :href => R(RemoteLink) ); br
11
+ a( "submit to remote", :href => R(SubmitRemote) ); br
12
+ a( "observable", :href => R(Observe) ); br
13
+ a( "periodically call", :href => R(PeriodicallyCall) ); br
14
+ a( "remote form", :href => R(RemoteForm) ); br
15
+ a( "drag and drop", :href => R(DragAndDrop) ); br
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module BivouacSample::Views
2
+ def observe
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "autocomplete"
7
+ end
8
+ body do
9
+ h1 "observe_field"
10
+
11
+ span "Chercher les termes: "
12
+ input( :type => "text", :name => "search", :id => "request" )
13
+ observe_field( 'request', :update => 'response', :url => R(Observe) )
14
+
15
+ div( :id => "response") do; end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module BivouacSample::Views
2
+ def periodically_call
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "autocomplete"
7
+ end
8
+ body do
9
+ h1 "periodically_call_remote"
10
+
11
+ div( :id => "process-list", :style => "background-color: #eee;") do; end
12
+
13
+ periodically_call_remote( :update => 'process-list', :url => R(PeriodicallyCall), :frequency => 2 )
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module BivouacSample::Views
2
+ def remote_form
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ end
7
+ body do
8
+ h1 "remote_form"
9
+
10
+ form_remote_tag( :url => R(SubmitRemote), :update => 'and-i-say' ) do
11
+ span "Avant j'utilisais ROR, maintenant j'utilise... "
12
+ input( :type => 'text', :name => 'response', :value => '' )
13
+ end
14
+
15
+ div( :id => "and-i-say") do; end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module BivouacSample::Views
2
+ def remote_link
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "autocomplete"
7
+ stylesheet_link_tag "coderay"
8
+ end
9
+ body do
10
+ h1 "link_to_remote"
11
+
12
+ link_to_remote( "Déclancher Ajax", :update => "mydiv", :url => R(RemoteLink) )
13
+
14
+ div( :id => "mydiv") do
15
+ span "Ce texte va être modifié..."
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module BivouacSample::Views
2
+ def submit_remote
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "autocomplete"
7
+ end
8
+ body do
9
+ h1 "submit_to_remote"
10
+
11
+ form do
12
+ span "Avant j'utilisais ROR, maintenant j'utilise... "
13
+ input( :type => 'text', :name => 'response', :value => '' )
14
+ submit_to_remote( 'say', 'Vérifier ma réponse', :update => 'and-i-say', :url => R(SubmitRemote))
15
+ end
16
+
17
+ div( :id => "and-i-say") do; end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,44 @@
1
+ module BivouacSample::Views
2
+ def toggle
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "coderay"
7
+ end
8
+ body do
9
+ h1 "toggle element"
10
+
11
+ p {
12
+ span "Cette page montre comment utiliser les helpers "
13
+ tt "link_to_function"
14
+ span " et "
15
+ tt "toggle"
16
+ span ". En cliquant sur le lien ci-dessous, vous pouvez afficher/masquer le code source de cette page..."
17
+ }
18
+
19
+ div( :id => "show_source" ) do
20
+ link_to_function "Show source" do |page|
21
+ page.toggle "source", "show_source", "hide_source"
22
+ end
23
+ end
24
+ div( :id => "hide_source", :style => "display:none;" ) do
25
+ link_to_function "Hide source" do |page|
26
+ page.toggle "source", "show_source", "hide_source"
27
+ end
28
+ end
29
+
30
+ # Helper for syntax highlighting
31
+ highlight_file( __FILE__, :id => "source", :display => "none" )
32
+
33
+ hr
34
+
35
+ p "La coloration syntaxique se fait au moyen d'un Helper dont voici le code :"
36
+ highlight_me( :id => "helper_source" )
37
+ p {
38
+ span "Ce helper utilise le module "
39
+ a( "CodeRay", :href => "http://rubyforge.org/projects/coderay/" )
40
+ }
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,52 @@
1
+ module BivouacSample::Views
2
+ def toggle_sortable
3
+ html do
4
+ head do
5
+ javascript_include_tag :defaults
6
+ stylesheet_link_tag "coderay"
7
+ end
8
+ body do
9
+ h1 "sortable / sortable_element"
10
+ ul( :id => 'my_list' ) do
11
+ li( "Google", :id => "li_1" )
12
+ li( "Yahoo", :id => "li_2" )
13
+ li( "Accoona", :id => "li_3" )
14
+ li( "Ask.com", :id => "li_4" )
15
+ li( "Baidu", :id => "li_5" )
16
+ li( "Exalead", :id => "li_6" )
17
+ li( "Voila", :id => "li_7" )
18
+ li( "Lycos", :id => "li_8" )
19
+ end
20
+
21
+ div( :id => "sortable" ) do
22
+ button_to_function "Rendre la liste triable" do |page|
23
+ page.toggle "sortable", "unsortable", "result"
24
+ page.sortable( 'my_list', :onChange => {
25
+ :update => 'result',
26
+ :url => R(ToggleSortable)
27
+ } )
28
+ end
29
+ end
30
+
31
+ div( :id => "unsortable", :style => "display: none;" ) do
32
+ button_to_function "Rendre la liste non triable" do |page|
33
+ page.toggle "sortable", "unsortable", "result"
34
+ page.unsortable( 'my_list' )
35
+ end
36
+ end
37
+
38
+ div( :id => 'result', :style => "display: none;" )do; end
39
+
40
+ hr
41
+ p { span "Source du controller "; tt "app/controller/sortable_result.rb" }
42
+ highlight_file( File.dirname( __FILE__ ) + "/../controllers/toggle_sortable.rb", :id => "source0")
43
+
44
+ p { span "Source de la vue "; tt "app/views/toggle_sortable.rb" }
45
+ highlight_file( __FILE__, :id => "source1" )
46
+
47
+ p { span "Source de la vue "; tt "app/views/_sortable_result.rb" }
48
+ highlight_file( File.dirname( __FILE__ ) + "/_sortable_result.rb", :id => "source2")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ # Project BivouacSample
3
+ #
4
+ # Created using bivouac on Mon Sep 10 21:47:54 +0200 2007.
5
+ # Copyright (c) 2007 __My__. All rights reserved.
6
+ #
7
+
8
+ require 'ostruct'
9
+
10
+ module Bivouac
11
+ class Environment
12
+
13
+ attr_reader :environment
14
+
15
+ def initialize
16
+ @environment = OpenStruct.new(
17
+ # Address to bind to
18
+ :address => "0.0.0.0",
19
+
20
+ # Application port
21
+ :port => 3301,
22
+
23
+ # Name of the application
24
+ # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
25
+ :appname => "BivouacSample",
26
+
27
+ # Path of the application
28
+ # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
29
+ :appdir => "bivouac_sample",
30
+
31
+ # Organisation type of the application
32
+ # DO NOT CHANGE IT, OR YOU REALLY KNOW WHAT YOU ARE DOING!
33
+ :orgtype => "GOH"
34
+ )
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,62 @@
1
+ #
2
+ # Project BivouacSample
3
+ #
4
+ # Created using bivouac on Mon Sep 10 21:47:54 +0200 2007.
5
+ # Copyright (c) 2007 __My__. All rights reserved.
6
+ #
7
+
8
+ require 'simple-daemon'
9
+
10
+ DIRNAME = File.expand_path( File.dirname(__FILE__) )
11
+ SimpleDaemon::WorkingDirectory = DIRNAME + "/../log/"
12
+ class BivouacSampleDaemon < SimpleDaemon::Base
13
+ @@server = nil
14
+
15
+ def self.start
16
+ config = Bivouac::Environment.new( )
17
+
18
+ BivouacSample::Models::Base.establish_connection :adapter => 'sqlite3', :database => DIRNAME + "/../db/BivouacSample.db"
19
+ BivouacSample::Models::Base.logger = Logger.new(DIRNAME + "/../log/BivouacSample.log")
20
+ BivouacSample::Models::Base.threaded_connections = false
21
+ BivouacSample.create if BivouacSample.respond_to? :create
22
+
23
+ trap(:INT) do
24
+ stop
25
+ end
26
+
27
+ begin
28
+ require 'mongrel/camping'
29
+
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
33
+ rescue LoadError => e
34
+ require 'webrick/httpserver'
35
+ require 'camping/webrick'
36
+
37
+ @@server = WEBrick::HTTPServer.new :BindAddress => config.environment.address, :Port => config.environment.port
38
+ puts "** BivouacSample is running at http://#{config.environment.address}:#{config.environment.port}"
39
+ @@server.mount "/", WEBrick::CampingHandler, BivouacSample
40
+ end
41
+ end
42
+
43
+ def self.stop
44
+ begin
45
+ @@server.stop
46
+ rescue
47
+ @@server.shutdown
48
+ end
49
+ @@server = nil
50
+ end
51
+ end
52
+
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
62
+ end