bivouac 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +15 -0
- data/bin/bivouac +5 -10
- data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +46 -37
- data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +27 -20
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +45 -1
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +1 -1
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +1 -1
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +1 -1
- data/examples/bivouac_sample/Rakefile +0 -0
- data/examples/bivouac_sample/app/controllers/toggle_sortable.rb +2 -1
- data/examples/bivouac_sample/app/views/_sortable_result.rb +1 -1
- data/examples/bivouac_sample/script/console +0 -0
- data/examples/bivouac_sample/script/generate +0 -0
- data/examples/bivouac_sample/script/plugin +0 -0
- data/examples/bivouac_sample/script/server +0 -0
- data/examples/blog/Rakefile +56 -0
- data/examples/blog/app/blog.rb +107 -0
- data/examples/blog/app/controllers/comment.rb +17 -0
- data/examples/blog/app/controllers/index.rb +15 -0
- data/examples/blog/app/controllers/login.rb +33 -0
- data/examples/blog/app/controllers/logout.rb +15 -0
- data/examples/blog/app/controllers/not_found.rb +14 -0
- data/examples/blog/app/controllers/post.rb +48 -0
- data/examples/blog/app/helpers/_helpers.rb +30 -0
- data/examples/blog/app/helpers/blog.rb +14 -0
- data/examples/blog/app/models/comment.rb +18 -0
- data/examples/blog/app/models/post.rb +19 -0
- data/examples/blog/app/models/user.rb +12 -0
- data/examples/blog/app/views/_partials.rb +81 -0
- data/examples/blog/app/views/index/index.rb +23 -0
- data/examples/blog/app/views/layouts/default_layout.rb +40 -0
- data/examples/blog/app/views/login/login.rb +27 -0
- data/examples/blog/app/views/not_found.rb +13 -0
- data/examples/blog/app/views/post/add.rb +12 -0
- data/examples/blog/app/views/post/edit.rb +12 -0
- data/examples/blog/app/views/post/view.rb +14 -0
- data/examples/blog/config/console.rc +12 -0
- data/examples/blog/config/database.yml +3 -0
- data/examples/blog/config/environment.rb +58 -0
- data/examples/blog/db/blog.db +0 -0
- data/examples/blog/db/create.rb +11 -0
- data/examples/blog/db/migrate/001_users.rb +22 -0
- data/examples/blog/db/migrate/002_posts.rb +24 -0
- data/examples/blog/db/migrate/003_comments.rb +24 -0
- data/examples/blog/log/Blog.log +382 -0
- data/examples/{blog_goh → blog}/public/images/camping.png +0 -0
- data/examples/{blog_goh → blog}/public/index.html +3 -2
- data/examples/blog/public/javascripts/builder.js +136 -0
- data/examples/blog/public/javascripts/controls.js +965 -0
- data/examples/blog/public/javascripts/dragdrop.js +974 -0
- data/examples/blog/public/javascripts/effects.js +1122 -0
- data/examples/blog/public/javascripts/prototype.js +4320 -0
- data/examples/blog/public/javascripts/scriptaculous.js +58 -0
- data/examples/blog/public/javascripts/slider.js +275 -0
- data/examples/blog/public/javascripts/sound.js +55 -0
- data/examples/blog/public/javascripts/unittest.js +568 -0
- data/examples/blog/public/stylesheets/autocomplete.css +22 -0
- data/examples/blog/public/stylesheets/blog.css +107 -0
- data/examples/blog/script/console +12 -0
- data/examples/blog/script/generate +17 -0
- data/examples/blog/script/plugin +16 -0
- data/examples/blog/script/server +135 -0
- data/examples/blog/test/test_comment.rb +22 -0
- data/examples/blog/test/test_index.rb +22 -0
- data/examples/blog/test/test_login.rb +22 -0
- data/examples/blog/test/test_logout.rb +18 -0
- data/examples/blog/test/test_post.rb +30 -0
- data/examples/blog/test/test_post_new.rb +22 -0
- data/lib/bivouac.rb +2 -2
- data/lib/bivouac/commands/generate.rb +48 -8
- data/lib/bivouac/commands/plugin.rb +30 -15
- data/lib/bivouac/ext/filtering_camping.rb +46 -0
- data/lib/bivouac/helpers/view/goh/html.rb +9 -0
- data/lib/bivouac/helpers/view/goh/scriptaculous.rb +12 -8
- data/lib/bivouac/tasks/bivouac.rb +1 -0
- data/lib/bivouac/tasks/framework.rake +8 -8
- data/lib/bivouac/tasks/plugins.rake +17 -1
- data/lib/bivouac/template.rb +0 -0
- data/lib/bivouac/template/{application_goh.rb → application.rb} +36 -12
- data/lib/bivouac/template/application/{helpers_goh.rb → helpers.rb} +1 -1
- data/lib/bivouac/template/console.rb +2 -4
- data/lib/bivouac/template/environment.rb +1 -1
- data/lib/bivouac/template/generate.rb +0 -0
- data/lib/bivouac/template/generate/create.rb +0 -0
- data/lib/bivouac/template/generate/helper.rb +12 -0
- data/lib/bivouac/template/generate/migrate.rb +0 -0
- data/lib/bivouac/template/generate/migrate_end.rb +1 -0
- data/lib/bivouac/template/plugin.rb +6 -1
- data/lib/bivouac/template/server.rb +124 -3
- data/lib/bivouac/template/static/builder.js +19 -19
- data/lib/bivouac/template/static/controls.js +74 -74
- data/lib/bivouac/template/static/dragdrop.js +167 -166
- data/lib/bivouac/template/static/effects.js +171 -163
- data/lib/bivouac/template/static/not_found_controller.rb +8 -4
- data/lib/bivouac/template/static/prototype.js +218 -119
- data/lib/bivouac/template/static/scriptaculous.js +22 -20
- data/lib/bivouac/template/static/slider.js +39 -39
- data/lib/bivouac/template/static/sound.js +11 -11
- data/lib/bivouac/template/static/unittest.js +16 -16
- metadata +96 -60
- data/examples/blog_goh/app/blog.rb +0 -72
- data/examples/blog_goh/app/controllers/add.rb +0 -19
- data/examples/blog_goh/app/controllers/comment.rb +0 -9
- data/examples/blog_goh/app/controllers/edit.rb +0 -18
- data/examples/blog_goh/app/controllers/index.rb +0 -8
- data/examples/blog_goh/app/controllers/info.rb +0 -11
- data/examples/blog_goh/app/controllers/login.rb +0 -15
- data/examples/blog_goh/app/controllers/logout.rb +0 -8
- data/examples/blog_goh/app/controllers/view.rb +0 -9
- data/examples/blog_goh/app/models/comment.rb +0 -5
- data/examples/blog_goh/app/models/post.rb +0 -5
- data/examples/blog_goh/app/models/user.rb +0 -4
- data/examples/blog_goh/app/views/_form.rb +0 -16
- data/examples/blog_goh/app/views/_login.rb +0 -13
- data/examples/blog_goh/app/views/_post.rb +0 -9
- data/examples/blog_goh/app/views/add.rb +0 -9
- data/examples/blog_goh/app/views/edit.rb +0 -9
- data/examples/blog_goh/app/views/index.rb +0 -12
- data/examples/blog_goh/app/views/layout.rb +0 -18
- data/examples/blog_goh/app/views/login.rb +0 -6
- data/examples/blog_goh/app/views/logout.rb +0 -6
- data/examples/blog_goh/app/views/view.rb +0 -20
- data/examples/blog_goh/config/environment.rb +0 -27
- data/examples/blog_goh/db/Blog.db +0 -0
- data/examples/blog_goh/db/create.rb +0 -8
- data/examples/blog_goh/db/migrate/comment.rb +0 -15
- data/examples/blog_goh/db/migrate/post.rb +0 -15
- data/examples/blog_goh/db/migrate/user.rb +0 -15
- data/examples/blog_goh/log/Blog.log +0 -75
- data/examples/blog_goh/public/stylesheets/style.css +0 -10
- data/examples/blog_goh/script/generate +0 -3
- data/examples/blog_goh/script/server +0 -5
- data/lib/bivouac/template/application/postamble.rb +0 -195
- data/lib/camping/cookies_sessions.rb +0 -39
@@ -1,195 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Project <%= @conf.appname %>
|
3
|
-
#
|
4
|
-
# Created using bivouac on <%= Time.now %>.
|
5
|
-
# Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
|
6
|
-
#
|
7
|
-
# DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
|
8
|
-
# USE script/generate helper my_helper
|
9
|
-
#
|
10
|
-
|
11
|
-
## If the app run on Windows, check if win32/process is installed
|
12
|
-
windows_process = false
|
13
|
-
if /Windows/.match( ENV['OS'] )
|
14
|
-
begin
|
15
|
-
require 'win32/process'
|
16
|
-
windows_process = true
|
17
|
-
rescue LoadError => e
|
18
|
-
warn "`win32-process' is not installed!"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'simple-daemon'
|
23
|
-
|
24
|
-
DIRNAME = File.expand_path( File.dirname(__FILE__) )
|
25
|
-
SimpleDaemon::WORKING_DIRECTORY = DIRNAME + "/../log/"
|
26
|
-
|
27
|
-
class <%= @conf.appname %>Daemon < SimpleDaemon::Base
|
28
|
-
begin
|
29
|
-
begin
|
30
|
-
require 'mongrel/camping'
|
31
|
-
@@loaded_server = 'mongrel'
|
32
|
-
rescue LoadError
|
33
|
-
require 'thin'
|
34
|
-
@@loaded_server = 'thin'
|
35
|
-
end
|
36
|
-
rescue LoadError
|
37
|
-
require 'webrick/httpserver'
|
38
|
-
require 'camping/webrick'
|
39
|
-
@@loaded_server = 'webrick'
|
40
|
-
end
|
41
|
-
|
42
|
-
@@server = nil
|
43
|
-
@@force_use = nil
|
44
|
-
@@server_ip = nil
|
45
|
-
@@server_port = nil
|
46
|
-
|
47
|
-
def self.use=(x)
|
48
|
-
@@force_use=x
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.ip=(x)
|
52
|
-
@@server_ip=x
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.port=(x)
|
56
|
-
@@server_port=x
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.start
|
60
|
-
## Load configuration
|
61
|
-
config = Bivouac::Environment.new( )
|
62
|
-
|
63
|
-
if config.environment.server_force
|
64
|
-
@@force_use = config.environment.server_force
|
65
|
-
end
|
66
|
-
|
67
|
-
## Initialize database connection
|
68
|
-
database_connection = config.environment.db
|
69
|
-
if database_connection[:adapter] =~ /sqlite/
|
70
|
-
database_connection[:database] = DIRNAME + "/../" + database_connection[:database]
|
71
|
-
end
|
72
|
-
<%= @conf.appname %>::Models::Base.establish_connection database_connection
|
73
|
-
|
74
|
-
## Define log
|
75
|
-
<%= @conf.appname %>::Models::Base.logger = Logger.new(DIRNAME + "/../log/<%= @conf.appname %>.log")
|
76
|
-
|
77
|
-
## Migrate database if needed
|
78
|
-
<%= @conf.appname %>.create if <%= @conf.appname %>.respond_to? :create
|
79
|
-
|
80
|
-
## Initialize trap
|
81
|
-
trap(:INT) do
|
82
|
-
stop
|
83
|
-
end
|
84
|
-
|
85
|
-
## Set server to use
|
86
|
-
if @@force_use.nil?
|
87
|
-
@@use_server = @@loaded_server
|
88
|
-
else
|
89
|
-
@@use_server = @@force_use
|
90
|
-
end
|
91
|
-
|
92
|
-
## Set ip and port
|
93
|
-
@@server_port = config.environment.port if @@server_port.nil?
|
94
|
-
@@server_ip = config.environment.address if @@server_ip.nil?
|
95
|
-
|
96
|
-
begin
|
97
|
-
case @@use_server
|
98
|
-
when 'thin'
|
99
|
-
if @@loaded_server != @@use_server
|
100
|
-
require 'thin'
|
101
|
-
end
|
102
|
-
|
103
|
-
# Rack::Handler::Thin.run Rack::Adapter::Camping.new( <%= @conf.appname %> ), :Host => @@server_ip, :Port => @@server_port
|
104
|
-
@@server = Thin::Server.new( @@server_ip, @@server_port.to_i, Rack::Adapter::Camping.new( <%= @conf.appname %> ) )
|
105
|
-
puts "** <%= @conf.appname %> is running at http://#{@@server_ip}:#{@@server_port}"
|
106
|
-
@@server.start
|
107
|
-
when 'mongrel'
|
108
|
-
if @@loaded_server != @@use_server
|
109
|
-
require 'mongrel/camping'
|
110
|
-
end
|
111
|
-
|
112
|
-
@@server = Mongrel::Camping.start( @@server_ip, @@server_port, "/", <%= @conf.appname %>)
|
113
|
-
puts "** <%= @conf.appname %> is running at http://#{@@server_ip}:#{@@server_port}"
|
114
|
-
@@server.run.join
|
115
|
-
when 'webrick'
|
116
|
-
if @@loaded_server != @@use_server
|
117
|
-
require 'webrick/httpserver'
|
118
|
-
require 'camping/webrick'
|
119
|
-
end
|
120
|
-
|
121
|
-
@@server = WEBrick::HTTPServer.new :BindAddress => @@server_ip, :Port => @@server_port
|
122
|
-
puts "** <%= @conf.appname %> is running at http://#{@@server_ip}:#{@@server_port}"
|
123
|
-
@@server.mount "/", WEBrick::CampingHandler, <%= @conf.appname %>
|
124
|
-
@@server.start
|
125
|
-
else
|
126
|
-
puts "Don't know how to use server `#{@@use_server}'!"
|
127
|
-
exit 0
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def self.stop
|
133
|
-
begin
|
134
|
-
@@server.stop
|
135
|
-
rescue
|
136
|
-
@@server.shutdown
|
137
|
-
end
|
138
|
-
@@server = nil
|
139
|
-
end
|
140
|
-
|
141
|
-
def self.console
|
142
|
-
include <%= @conf.appname %>::Models
|
143
|
-
|
144
|
-
config = Bivouac::Environment.new( )
|
145
|
-
database_connection = config.environment.db
|
146
|
-
if database_connection[:adapter] =~ /sqlite/
|
147
|
-
database_connection[:database] = DIRNAME + "/../" + database_connection[:database]
|
148
|
-
end
|
149
|
-
<%= @conf.appname %>::Models::Base.establish_connection database_connection
|
150
|
-
<%= @conf.appname %>.create if <%= @conf.appname %>.respond_to? :create
|
151
|
-
|
152
|
-
require 'irb'
|
153
|
-
require 'irb/completion'
|
154
|
-
ENV['IRBRC'] = DIRNAME + "/console.rc"
|
155
|
-
IRB.start
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
while ARGV.size > 0
|
160
|
-
deamonize = ARGV.shift
|
161
|
-
case deamonize
|
162
|
-
when 'webrick'
|
163
|
-
<%= @conf.appname %>Daemon.use='webrick'
|
164
|
-
when 'mongrel'
|
165
|
-
<%= @conf.appname %>Daemon.use='mongrel'
|
166
|
-
when 'thin'
|
167
|
-
<%= @conf.appname %>Daemon.use='thin'
|
168
|
-
when '-c'
|
169
|
-
ARGV.clear
|
170
|
-
<%= @conf.appname %>Daemon.console
|
171
|
-
break
|
172
|
-
when '-h'
|
173
|
-
puts "Usage: server [thin|mongrel|webrick] [option]"
|
174
|
-
puts " -p port : Runs Bivouac on the specified port (default 3301)"
|
175
|
-
puts " -b ip : Binds Bivouac to the specified ip (default 0.0.0.0)"
|
176
|
-
puts " -d start|stop|restart : Make server run as a Daemon."
|
177
|
-
break
|
178
|
-
when '-p'
|
179
|
-
<%= @conf.appname %>Daemon.port=ARGV.shift
|
180
|
-
when '-b'
|
181
|
-
<%= @conf.appname %>Daemon.ip=ARGV.shift
|
182
|
-
when '-d'
|
183
|
-
if /Windows/.match( ENV['OS'] ) and windows_process == false
|
184
|
-
warn "You must install `win32-process' to daemonize this app."
|
185
|
-
exit 1
|
186
|
-
end
|
187
|
-
<%= @conf.appname %>Daemon.daemonize
|
188
|
-
break
|
189
|
-
when '--'
|
190
|
-
<%= @conf.appname %>Daemon.start
|
191
|
-
break
|
192
|
-
else
|
193
|
-
puts "Ignore unknown option '#{deamonize}' !"
|
194
|
-
end
|
195
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module Camping
|
4
|
-
module CookieSessions
|
5
|
-
# this thingy wraps around the main thingy and puts sessions in like magic, ooooOOOOOooooh! Spooky!
|
6
|
-
def service(*a)
|
7
|
-
if @cookies.identity
|
8
|
-
blob, secure_hash = @cookies.identity.to_s.split(':', 2)
|
9
|
-
blob = Base64.decode64(blob)
|
10
|
-
data = Marshal.restore(blob)
|
11
|
-
data = {} unless secure_blob_hasher(blob).strip.downcase == secure_hash.strip.downcase
|
12
|
-
else
|
13
|
-
blob = ''
|
14
|
-
data = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
app = self.class.name.gsub(/^(\w+)::.+$/, '\1')
|
18
|
-
@state = (data[app] ||= Camping::H[])
|
19
|
-
hash_before = blob.hash
|
20
|
-
return super(*a)
|
21
|
-
ensure
|
22
|
-
data[app] = @state
|
23
|
-
blob = Marshal.dump(data)
|
24
|
-
unless hash_before == blob.hash
|
25
|
-
secure_hash = secure_blob_hasher(blob)
|
26
|
-
@cookies.identity = Base64.encode64(blob).gsub("\n", '').strip + ':' + secure_hash
|
27
|
-
# hack to make cookies update
|
28
|
-
@headers['Set-Cookie'] = @cookies.map { |k,v| "#{k}=#{C.escape(v)}; path=#{self/"/"}" if v != @k[k] } - [nil]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# You can override this with whatever hashing function you think is awesome enough, don't use MD5 though! It stinks!
|
33
|
-
def secure_blob_hasher(data)
|
34
|
-
require 'digest'
|
35
|
-
require 'digest/sha2'
|
36
|
-
Digest::SHA512::hexdigest(self.class.module_eval('@@state_secret') + data)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|