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
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 14:17:05 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Controllers
|
9
|
+
class CommentAdd
|
10
|
+
def post
|
11
|
+
Comment.create(:username => input.comment_user, :body => input.comment_body,
|
12
|
+
:post_id => input.post_id)
|
13
|
+
|
14
|
+
redirect PostView, input.post_id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:28:10 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Controllers
|
9
|
+
class Index < R '/'
|
10
|
+
def get
|
11
|
+
@posts = Post.all(:order => 'updated_at DESC')
|
12
|
+
render :index_index
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:47:18 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Controllers
|
9
|
+
class Login
|
10
|
+
def get
|
11
|
+
@to = input.to
|
12
|
+
render :login_login
|
13
|
+
end
|
14
|
+
|
15
|
+
def post
|
16
|
+
@user = User.find_by_username_and_password(input.username, input.password)
|
17
|
+
@to = input.to
|
18
|
+
|
19
|
+
if @user
|
20
|
+
@state.user_id = @user.id
|
21
|
+
if @to
|
22
|
+
redirect @to
|
23
|
+
else
|
24
|
+
redirect R(Index)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
@info = 'Wrong username or password'
|
28
|
+
end
|
29
|
+
|
30
|
+
render :login_login
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:46:12 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Controllers
|
9
|
+
class Logout
|
10
|
+
def get
|
11
|
+
@state.user_id = nil
|
12
|
+
redirect Index
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:39:38 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Controllers
|
9
|
+
class PostAdd < R '/post/add'
|
10
|
+
def get
|
11
|
+
require_login!
|
12
|
+
@post = Post.new
|
13
|
+
|
14
|
+
render :post_add
|
15
|
+
end
|
16
|
+
def post
|
17
|
+
require_login!
|
18
|
+
post = Post.create(:title => input.post_title, :body => input.post_body,
|
19
|
+
:user_id => @state.user_id)
|
20
|
+
|
21
|
+
redirect PostView, post
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class PostView < R '/post/(\d+)/view'
|
26
|
+
def get(post_id)
|
27
|
+
@post = Post.find(post_id)
|
28
|
+
|
29
|
+
render :post_view
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class PostEdit < R '/post/(\d+)/edit'
|
34
|
+
def get(post_id)
|
35
|
+
require_login!
|
36
|
+
@post = Post.find(post_id)
|
37
|
+
|
38
|
+
render :post_edit
|
39
|
+
end
|
40
|
+
def post(post_id)
|
41
|
+
require_login!
|
42
|
+
@post = Post.find(post_id)
|
43
|
+
@post.update_attributes :title => input.post_title, :body => input.post_body
|
44
|
+
|
45
|
+
redirect PostView, @post
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 11:58:26 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __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
|
+
require 'bivouac/helpers/view/goh/base'
|
11
|
+
require 'bivouac/helpers/view/goh/html'
|
12
|
+
require 'bivouac/helpers/view/goh/form'
|
13
|
+
require 'bivouac/helpers/view/goh/scriptaculous'
|
14
|
+
require 'bivouac/helpers/view/goh/javascript'
|
15
|
+
require 'bivouac/helpers/view/goh/sound'
|
16
|
+
|
17
|
+
helpers = [
|
18
|
+
BivouacHelpers::BaseView,
|
19
|
+
BivouacHelpers::HtmlView,
|
20
|
+
BivouacHelpers::FormView,
|
21
|
+
BivouacHelpers::ScriptAculoUsView,
|
22
|
+
BivouacHelpers::JavaScriptView,
|
23
|
+
BivouacHelpers::SoundView,
|
24
|
+
] + viewHelperModule
|
25
|
+
|
26
|
+
Blog.module_eval "class Mab < Markaby::Builder; include #{helpers.join(', ')}; end"
|
27
|
+
|
28
|
+
if controllerHelperModule.size > 0
|
29
|
+
Blog.class_eval "include #{controllerHelperModule.join(', ')}"
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 11:52:56 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Models
|
9
|
+
class Comment < Base
|
10
|
+
belongs_to :post
|
11
|
+
|
12
|
+
before_save do |record|
|
13
|
+
cloth = RedCloth.new(record.body)
|
14
|
+
cloth.hard_breaks = false
|
15
|
+
record.html_body = cloth.to_html
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 11:51:35 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Models
|
9
|
+
class Post < Base
|
10
|
+
belongs_to :user
|
11
|
+
has_many :comments
|
12
|
+
|
13
|
+
before_save do |record|
|
14
|
+
cloth = RedCloth.new(record.body)
|
15
|
+
cloth.hard_breaks = false
|
16
|
+
record.html_body = cloth.to_html
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:20:34 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Views
|
9
|
+
def _admin_menu
|
10
|
+
text [['Log out', R(Logout)], ['New', R(PostAdd)]].map { |name, to|
|
11
|
+
capture { a name, :href => to}
|
12
|
+
}.join(' – ')
|
13
|
+
end
|
14
|
+
|
15
|
+
def _post(post)
|
16
|
+
h2 post.title
|
17
|
+
p.info do
|
18
|
+
text "Written by <strong>#{post.user.username}</strong> "
|
19
|
+
text post.updated_at.strftime('%B %M, %Y @ %H:%M ')
|
20
|
+
_post_menu(post)
|
21
|
+
end
|
22
|
+
text post.html_body
|
23
|
+
end
|
24
|
+
|
25
|
+
def _post_menu(post)
|
26
|
+
text '('
|
27
|
+
a 'comments', :href => R(PostView, post)
|
28
|
+
if logged_in?
|
29
|
+
text ', '
|
30
|
+
a 'edit', :href => R(PostEdit, post)
|
31
|
+
end
|
32
|
+
text ')'
|
33
|
+
end
|
34
|
+
|
35
|
+
def _comment(comment)
|
36
|
+
div.comment do
|
37
|
+
p.cinfo do
|
38
|
+
text "Comment by <strong>#{comment.username}</strong> "
|
39
|
+
text comment.updated_at.strftime('%B %M, %Y @ %H:%M ')
|
40
|
+
end
|
41
|
+
text comment.html_body
|
42
|
+
end
|
43
|
+
|
44
|
+
br
|
45
|
+
end
|
46
|
+
|
47
|
+
def _comments(post)
|
48
|
+
post.comments.each { |c| _comment(c) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def _add_comment(post)
|
52
|
+
form( :method => "post", :action => R(CommentAdd) ) do
|
53
|
+
label 'Author'
|
54
|
+
input :name => "comment_user", :id => "comment_user", :type => "text"
|
55
|
+
|
56
|
+
label 'Content'
|
57
|
+
textarea "", :name => "comment_body", :id => "comment_body"
|
58
|
+
|
59
|
+
br
|
60
|
+
|
61
|
+
input :type => 'hidden', :name => 'post_id', :value => post.id
|
62
|
+
input :type => 'submit', :class => 'submit', :value => 'Submit'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def _form(post, opts)
|
67
|
+
form({:method => 'post'}.merge(opts)) do
|
68
|
+
label 'Title', :for => 'post_title'
|
69
|
+
input :name => 'post_title', :id => 'post_title', :type => 'text',
|
70
|
+
:value => post.title
|
71
|
+
|
72
|
+
label 'Body', :for => 'post_body'
|
73
|
+
textarea post.body, :name => 'post_body', :id => 'post_body'
|
74
|
+
|
75
|
+
br
|
76
|
+
|
77
|
+
input :type => 'hidden', :name => 'post_id', :value => post.id
|
78
|
+
input :type => 'submit', :class => 'submit', :value => 'Submit'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:28:11 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Views
|
9
|
+
def index_index
|
10
|
+
if @posts.empty?
|
11
|
+
h2 'No posts'
|
12
|
+
p do
|
13
|
+
text 'Could not find any posts. Feel free to '
|
14
|
+
a 'add one', :href => R(PostAdd)
|
15
|
+
text ' yourself'
|
16
|
+
end
|
17
|
+
else
|
18
|
+
@posts.each do |post|
|
19
|
+
_post(post)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 11:24:50 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Views
|
9
|
+
|
10
|
+
# Default Layout
|
11
|
+
def default_layout
|
12
|
+
html do
|
13
|
+
head do
|
14
|
+
title 'My Blog'
|
15
|
+
stylesheet_link_tag "blog", :media => 'screen'
|
16
|
+
end
|
17
|
+
body do
|
18
|
+
h1 { a 'My Blog', :href => R(Index) }
|
19
|
+
|
20
|
+
div.wrapper! do
|
21
|
+
text self << yield
|
22
|
+
end
|
23
|
+
|
24
|
+
hr
|
25
|
+
|
26
|
+
p.footer! do
|
27
|
+
if logged_in?
|
28
|
+
_admin_menu
|
29
|
+
else
|
30
|
+
a 'Login', :href => R(Login, :to => @env.REQUEST_URI)
|
31
|
+
text ' to the adminpanel'
|
32
|
+
end
|
33
|
+
text ' – Powered by '
|
34
|
+
a 'Camping', :href => 'http://code.whytheluckystiff.net/camping'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 12:47:18 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Views
|
9
|
+
def login_login
|
10
|
+
h2 'Login'
|
11
|
+
p.info @info if @info
|
12
|
+
|
13
|
+
form :action => R(Login), :method => 'post' do
|
14
|
+
input :name => 'to', :type => 'hidden', :value => @to if @to
|
15
|
+
|
16
|
+
label 'Username', :for => 'username'
|
17
|
+
input :name => 'username', :id => 'username', :type => 'text'
|
18
|
+
|
19
|
+
label 'Password', :for => 'password'
|
20
|
+
input :name => 'password', :id => 'password', :type => 'password'
|
21
|
+
|
22
|
+
br
|
23
|
+
|
24
|
+
input :type => 'submit', :class => 'submit', :value => 'Login'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#
|
2
|
+
# Project Blog
|
3
|
+
#
|
4
|
+
# Created using bivouac on Thu Nov 13 11:24:50 +0100 2008.
|
5
|
+
# Copyright (c) 2008 __My__. All rights reserved.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Blog::Views
|
9
|
+
def not_found
|
10
|
+
h1.header { "Blog::Views#not_found" }
|
11
|
+
p "Sorry baby, #{@path} does nor exist !"
|
12
|
+
end
|
13
|
+
end
|