hobo 0.5.3
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.
- data/LICENSE.txt +22 -0
- data/README.txt +18 -0
- data/bin/hobo +81 -0
- data/hobo_files/plugin/CHANGES.txt +963 -0
- data/hobo_files/plugin/LICENSE.txt +22 -0
- data/hobo_files/plugin/README +4 -0
- data/hobo_files/plugin/Rakefile +11 -0
- data/hobo_files/plugin/generators/hobo/hobo_generator.rb +37 -0
- data/hobo_files/plugin/generators/hobo/templates/application.dryml +2 -0
- data/hobo_files/plugin/generators/hobo/templates/guest.rb +31 -0
- data/hobo_files/plugin/generators/hobo_front_controller/USAGE +11 -0
- data/hobo_files/plugin/generators/hobo_front_controller/hobo_front_controller_generator.rb +90 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/controller.rb +51 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/functional_test.rb +18 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/helper.rb +2 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +43 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/login.dryml +44 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +18 -0
- data/hobo_files/plugin/generators/hobo_front_controller/templates/signup.dryml +45 -0
- data/hobo_files/plugin/generators/hobo_model/USAGE +26 -0
- data/hobo_files/plugin/generators/hobo_model/hobo_model_generator.rb +38 -0
- data/hobo_files/plugin/generators/hobo_model/templates/fixtures.yml +11 -0
- data/hobo_files/plugin/generators/hobo_model/templates/migration.rb +13 -0
- data/hobo_files/plugin/generators/hobo_model/templates/model.rb +24 -0
- data/hobo_files/plugin/generators/hobo_model/templates/unit_test.rb +10 -0
- data/hobo_files/plugin/generators/hobo_model_controller/USAGE +30 -0
- data/hobo_files/plugin/generators/hobo_model_controller/hobo_model_controller_generator.rb +43 -0
- data/hobo_files/plugin/generators/hobo_model_controller/templates/controller.rb +5 -0
- data/hobo_files/plugin/generators/hobo_model_controller/templates/functional_test.rb +18 -0
- data/hobo_files/plugin/generators/hobo_model_controller/templates/helper.rb +2 -0
- data/hobo_files/plugin/generators/hobo_model_controller/templates/view.rhtml +2 -0
- data/hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb +51 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.js +436 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/default_mapping.rb +11 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/banner.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_bodytop.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_corner_01.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_corner_02.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_corner_03.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_corner_04.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_shadow_bottom.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_shadow_left.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_shadow_right.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg_shadow_top.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_blue.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_dblue.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_green.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_purple.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_red.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/logo.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/spinner.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt_list_img_dblue.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt_list_img_green.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt_list_img_purple.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt_list_img_red.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_corner_01.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_corner_02.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_corner_03.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_corner_04.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_shadow_bottom.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_shadow_left.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_shadow_right.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window_shadow_top.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +390 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +104 -0
- data/hobo_files/plugin/generators/hobo_user_model/USAGE +26 -0
- data/hobo_files/plugin/generators/hobo_user_model/hobo_user_model_generator.rb +38 -0
- data/hobo_files/plugin/generators/hobo_user_model/templates/fixtures.yml +11 -0
- data/hobo_files/plugin/generators/hobo_user_model/templates/migration.rb +15 -0
- data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +58 -0
- data/hobo_files/plugin/generators/hobo_user_model/templates/unit_test.rb +10 -0
- data/hobo_files/plugin/init.rb +44 -0
- data/hobo_files/plugin/lib/action_view_extensions/base.rb +14 -0
- data/hobo_files/plugin/lib/active_record/has_many_association.rb +54 -0
- data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +22 -0
- data/hobo_files/plugin/lib/active_record/table_definition.rb +34 -0
- data/hobo_files/plugin/lib/extensions.rb +245 -0
- data/hobo_files/plugin/lib/extensions/test_case.rb +130 -0
- data/hobo_files/plugin/lib/hobo.rb +353 -0
- data/hobo_files/plugin/lib/hobo/HtmlString +3 -0
- data/hobo_files/plugin/lib/hobo/authenticated_user.rb +106 -0
- data/hobo_files/plugin/lib/hobo/authentication_support.rb +108 -0
- data/hobo_files/plugin/lib/hobo/composite_model.rb +66 -0
- data/hobo_files/plugin/lib/hobo/controller.rb +134 -0
- data/hobo_files/plugin/lib/hobo/controller_helpers.rb +135 -0
- data/hobo_files/plugin/lib/hobo/core.rb +475 -0
- data/hobo_files/plugin/lib/hobo/define_tags.rb +56 -0
- data/hobo_files/plugin/lib/hobo/dryml.rb +161 -0
- data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +126 -0
- data/hobo_files/plugin/lib/hobo/dryml/tag_module.rb +9 -0
- data/hobo_files/plugin/lib/hobo/dryml/taglib.rb +57 -0
- data/hobo_files/plugin/lib/hobo/dryml/template.rb +586 -0
- data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +302 -0
- data/hobo_files/plugin/lib/hobo/dryml/template_handler.rb +19 -0
- data/hobo_files/plugin/lib/hobo/generator.rb +25 -0
- data/hobo_files/plugin/lib/hobo/html_string.rb +3 -0
- data/hobo_files/plugin/lib/hobo/lazy_hash.rb +28 -0
- data/hobo_files/plugin/lib/hobo/mapping_tags.rb +262 -0
- data/hobo_files/plugin/lib/hobo/markdown_string.rb +7 -0
- data/hobo_files/plugin/lib/hobo/model.rb +391 -0
- data/hobo_files/plugin/lib/hobo/model_controller.rb +676 -0
- data/hobo_files/plugin/lib/hobo/model_queries.rb +92 -0
- data/hobo_files/plugin/lib/hobo/model_support.rb +44 -0
- data/hobo_files/plugin/lib/hobo/password_string.rb +3 -0
- data/hobo_files/plugin/lib/hobo/predicate_dispatch.rb +78 -0
- data/hobo_files/plugin/lib/hobo/proc_binding.rb +32 -0
- data/hobo_files/plugin/lib/hobo/rapid.rb +447 -0
- data/hobo_files/plugin/lib/hobo/static_tags +92 -0
- data/hobo_files/plugin/lib/hobo/text.rb +3 -0
- data/hobo_files/plugin/lib/hobo/textile_string.rb +13 -0
- data/hobo_files/plugin/lib/hobo/undefined.rb +41 -0
- data/hobo_files/plugin/lib/hobo/undefined_access_error.rb +5 -0
- data/hobo_files/plugin/lib/hobo/where_fragment.rb +23 -0
- data/hobo_files/plugin/lib/rexml.rb +345 -0
- data/hobo_files/plugin/tags/core.dryml +6 -0
- data/hobo_files/plugin/tags/rapid.dryml +177 -0
- data/hobo_files/plugin/tags/rapid_editing.dryml +168 -0
- data/hobo_files/plugin/tags/rapid_navigation.dryml +95 -0
- data/hobo_files/plugin/tags/rapid_pages.dryml +175 -0
- data/hobo_files/plugin/tasks/environments.rake +19 -0
- data/hobo_files/plugin/tasks/hobo_tasks.rake +4 -0
- data/hobo_files/plugin/test/hobo_dryml_template_test.rb +7 -0
- data/hobo_files/plugin/test/hobo_test.rb +7 -0
- data/hobo_files/plugin/uninstall.rb +1 -0
- metadata +206 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<taglib src="plugins/hobo/tags/rapid"/>
|
|
2
|
+
|
|
3
|
+
<def tag="page" attrs="title_prefix, title">
|
|
4
|
+
<% title ||= human_type + ": " + display_name(:no_span => true) %>
|
|
5
|
+
<%= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' %>
|
|
6
|
+
<html>
|
|
7
|
+
<head content_option="head">
|
|
8
|
+
<title><%= title_prefix %><%= title %></title>
|
|
9
|
+
<theme_stylesheet/>
|
|
10
|
+
<%= javascript_include_tag :defaults %>
|
|
11
|
+
<hobo_rapid_javascripts replace_option="rapid_javascripts"/>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body onload="Hobo.applyEvents()" content_option="body">
|
|
15
|
+
|
|
16
|
+
<div id='ajax_progress'>
|
|
17
|
+
<div>
|
|
18
|
+
<span id="ajax_progress_text"></span><theme_img src="spinner.gif"/>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div id="page">
|
|
23
|
+
|
|
24
|
+
<div id="page_top">
|
|
25
|
+
<div id="page_right">
|
|
26
|
+
<div id="page_bottom">
|
|
27
|
+
<div id="page_left">
|
|
28
|
+
<div id="page_corner02">
|
|
29
|
+
<div id="page_corner04">
|
|
30
|
+
<div id="page_corner03">
|
|
31
|
+
<div id="page_corner01">
|
|
32
|
+
<div id="page_inner_top">
|
|
33
|
+
|
|
34
|
+
<div id='header' content_option="header">
|
|
35
|
+
<div class="logo" content_option="logo"><theme_img src="logo.gif"/></div>
|
|
36
|
+
|
|
37
|
+
<div class="nav_bars" content_option="navigation">
|
|
38
|
+
<div class="nav" content_option="main_nav"><application_nav/></div>
|
|
39
|
+
<if q="#login_url rescue false">
|
|
40
|
+
<div class="account_nav" content_option="account_nav"><application_account_nav/></div>
|
|
41
|
+
</if>
|
|
42
|
+
</div>
|
|
43
|
+
<clearer/>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<if q="#flash[:notice]">
|
|
47
|
+
<div class="flash"><%= flash[:notice] %></div>
|
|
48
|
+
</if>
|
|
49
|
+
|
|
50
|
+
<div content_option="intro"></div>
|
|
51
|
+
<div content_option="main">
|
|
52
|
+
<div class="maincol" content_option="maincol"/>
|
|
53
|
+
<div class="sidecol" content_option="sidecol"/>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<clearer/>
|
|
57
|
+
|
|
58
|
+
</div></div></div></div></div></div></div></div></div>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<div id="footer" content_option="footer"/>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|
|
64
|
+
</def>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
<def tag="panel">
|
|
68
|
+
<div class="panel" xattrs="">
|
|
69
|
+
<div class="panel_top"><div class="panel_right">
|
|
70
|
+
<div class="panel_bottom"><div class="panel_left">
|
|
71
|
+
<div class="panel_corner02"><div class="panel_corner04">
|
|
72
|
+
<div class="panel_corner03"><div class="panel_corner01">
|
|
73
|
+
|
|
74
|
+
<tagbody/>
|
|
75
|
+
|
|
76
|
+
</div></div></div></div></div></div></div></div>
|
|
77
|
+
</div>
|
|
78
|
+
</def>
|
|
79
|
+
|
|
80
|
+
<def tag="section">
|
|
81
|
+
<div class="section" xattrs=""><tagbody/></div>
|
|
82
|
+
</def>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
<def tag="navbar" attrs="items,current">
|
|
86
|
+
<repeat obj="#items">
|
|
87
|
+
<div class='nav_item <%= "current" if current == this[0] %>'><%= link_to this[0].upcase, this[1] %></div>
|
|
88
|
+
</repeat>
|
|
89
|
+
<clearer/>
|
|
90
|
+
</def>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
<def tag="application_nav">
|
|
94
|
+
<% items = [['Home', urlb + '/']] +
|
|
95
|
+
Hobo.models[0..2].map{|m| [m.name.pluralize.titlecase, object_url(m)]} +
|
|
96
|
+
[['Search', (search_url rescue "")]] %>
|
|
97
|
+
<navbar items="#items"/>
|
|
98
|
+
</def>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
<def tag="application_logo">
|
|
102
|
+
<theme_img src="logo.gif"/>
|
|
103
|
+
</def>
|
|
104
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
The model generator creates stubs for a new model.
|
|
3
|
+
|
|
4
|
+
The generator takes a model name as its argument. The model name may be given in CamelCase or under_score and
|
|
5
|
+
should not be suffixed with 'Model'.
|
|
6
|
+
|
|
7
|
+
As additional parameters, the generator will take attribute pairs described by name and type. These attributes will
|
|
8
|
+
be used to prepopulate the migration to create the table for the model and give you a set of predefined fixture.
|
|
9
|
+
You don't have to think up all attributes up front, but it's a good idea of adding just the baseline of what's
|
|
10
|
+
needed to start really working with the resource.
|
|
11
|
+
|
|
12
|
+
The generator creates a model class in app/models, a test suite in test/unit, test fixtures in
|
|
13
|
+
test/fixtures/singular_name.yml, and a migration in db/migrate.
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
./script/generate model account
|
|
17
|
+
|
|
18
|
+
This will create an Account model:
|
|
19
|
+
Model: app/models/account.rb
|
|
20
|
+
Test: test/unit/account_test.rb
|
|
21
|
+
Fixtures: test/fixtures/accounts.yml
|
|
22
|
+
Migration: db/migrate/XXX_add_accounts.rb
|
|
23
|
+
|
|
24
|
+
./script/generate model post title:string created_on:date body:text published:boolean
|
|
25
|
+
|
|
26
|
+
Creates post model with predefined attributes.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class HoboUserModelGenerator < Rails::Generator::NamedBase
|
|
2
|
+
default_options :skip_migration => false
|
|
3
|
+
|
|
4
|
+
def manifest
|
|
5
|
+
record do |m|
|
|
6
|
+
# Check for class naming collisions.
|
|
7
|
+
m.class_collisions class_path, class_name, "#{class_name}Test"
|
|
8
|
+
|
|
9
|
+
# Model, test, and fixture directories.
|
|
10
|
+
m.directory File.join('app/models', class_path)
|
|
11
|
+
m.directory File.join('test/unit', class_path)
|
|
12
|
+
m.directory File.join('test/fixtures', class_path)
|
|
13
|
+
|
|
14
|
+
# Model class, unit test, and fixtures.
|
|
15
|
+
m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
|
16
|
+
m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
|
|
17
|
+
m.template 'fixtures.yml', File.join('test/fixtures', class_path, "#{table_name}.yml")
|
|
18
|
+
|
|
19
|
+
unless options[:skip_migration]
|
|
20
|
+
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
|
21
|
+
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
|
|
22
|
+
}, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
protected
|
|
28
|
+
def banner
|
|
29
|
+
"Usage: #{$0} generate ModelName [field:type, field:type]"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def add_options!(opt)
|
|
33
|
+
opt.separator ''
|
|
34
|
+
opt.separator 'Options:'
|
|
35
|
+
opt.on("--skip-migration",
|
|
36
|
+
"Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
|
2
|
+
one:
|
|
3
|
+
id: 1
|
|
4
|
+
<% for attribute in attributes -%>
|
|
5
|
+
<%= attribute.name %>: <%= attribute.default %>
|
|
6
|
+
<% end -%>
|
|
7
|
+
two:
|
|
8
|
+
id: 2
|
|
9
|
+
<% for attribute in attributes -%>
|
|
10
|
+
<%= attribute.name %>: <%= attribute.default %>
|
|
11
|
+
<% end -%>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :<%= table_name %> do |t|
|
|
4
|
+
t.string :username
|
|
5
|
+
t.string :crypted_password, :salt, :limit => 40
|
|
6
|
+
t.string :remember_token
|
|
7
|
+
t.datetime :remember_token_expires_at
|
|
8
|
+
t.auto_dates
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.down
|
|
13
|
+
drop_table :<%= table_name %>
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Base
|
|
2
|
+
|
|
3
|
+
hobo_model
|
|
4
|
+
|
|
5
|
+
include Hobo::AuthenticatedUser
|
|
6
|
+
|
|
7
|
+
set_login_attr :username
|
|
8
|
+
|
|
9
|
+
alias_attribute :display_name, :username
|
|
10
|
+
|
|
11
|
+
# --- Hobo Permissions --- #
|
|
12
|
+
|
|
13
|
+
def super_user?
|
|
14
|
+
# login == 'admin'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def creatable_by?(creator)
|
|
18
|
+
false
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def updatable_by?(updater, new)
|
|
22
|
+
false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def deletable_by?(deleter)
|
|
26
|
+
false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def viewable_by?(viewer, field)
|
|
30
|
+
true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# --- Fallback permissions --- #
|
|
35
|
+
|
|
36
|
+
# (Hobo checks these for models that do not define the *_by? methods)
|
|
37
|
+
|
|
38
|
+
def can_create?(obj)
|
|
39
|
+
false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def can_update?(obj, new)
|
|
43
|
+
false
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def can_delete?(obj)
|
|
47
|
+
false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def can_view?(obj, field)
|
|
51
|
+
true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def guest?
|
|
55
|
+
false
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'extensions'
|
|
2
|
+
require 'rexml'
|
|
3
|
+
require 'active_record/has_many_association'
|
|
4
|
+
require 'active_record/has_many_through_association'
|
|
5
|
+
require 'active_record/table_definition'
|
|
6
|
+
require 'action_view_extensions/base'
|
|
7
|
+
|
|
8
|
+
require 'hobo'
|
|
9
|
+
require 'hobo/dryml'
|
|
10
|
+
|
|
11
|
+
require 'hobo/model'
|
|
12
|
+
|
|
13
|
+
require 'hobo/dryml/template'
|
|
14
|
+
require 'hobo/dryml/taglib'
|
|
15
|
+
require 'hobo/dryml/template_environment'
|
|
16
|
+
require 'hobo/dryml/template_handler'
|
|
17
|
+
|
|
18
|
+
require 'extensions/test_case' if RAILS_ENV == "test"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
ActionView::Base.register_template_handler("dryml", Hobo::Dryml::TemplateHandler)
|
|
22
|
+
|
|
23
|
+
class ActionController::Base
|
|
24
|
+
|
|
25
|
+
def self.hobo_model_controller(model=nil)
|
|
26
|
+
include Hobo::ModelController
|
|
27
|
+
self.model = model if model
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.hobo_controller(model=nil)
|
|
31
|
+
include Hobo::Controller
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def (ActiveRecord::Base).hobo_model
|
|
37
|
+
include Hobo::Model
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Default settings
|
|
41
|
+
|
|
42
|
+
Hobo.user_model ||= (User rescue (Person rescue nil))
|
|
43
|
+
|
|
44
|
+
Hobo.developer_features = ["development", "test"].include?(RAILS_ENV) if Hobo.developer_features? == nil
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module ActiveRecord::Associations
|
|
2
|
+
|
|
3
|
+
class HasManyAssociation
|
|
4
|
+
|
|
5
|
+
def new(*args)
|
|
6
|
+
res = build(*args)
|
|
7
|
+
if @owner.new_record?
|
|
8
|
+
refl = @owner.class.reverse_reflection(@reflection.name)
|
|
9
|
+
if refl
|
|
10
|
+
bta = ActiveRecord::Associations::BelongsToAssociation.new(res, refl)
|
|
11
|
+
bta.replace(@owner)
|
|
12
|
+
res.instance_variable_set("@#{refl.name}", bta)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
res
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def new_without_appending(attributes = {})
|
|
20
|
+
record = @reflection.klass.new(attributes)
|
|
21
|
+
set_belongs_to_association_for(record)
|
|
22
|
+
record
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def include?(record)
|
|
27
|
+
if loaded?
|
|
28
|
+
target.include?(record)
|
|
29
|
+
else
|
|
30
|
+
find(record.id) && true rescue false
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def member_class
|
|
36
|
+
proxy_reflection.klass
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def find_with_block(*args, &b)
|
|
41
|
+
if b
|
|
42
|
+
options = extract_options_from_args!(args)
|
|
43
|
+
args << options.merge(:conditions => member_class.conditions(&b))
|
|
44
|
+
find_without_block(*args)
|
|
45
|
+
else
|
|
46
|
+
find_without_block(*args)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
alias_method_chain :find, :block
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module ActiveRecord::Associations
|
|
2
|
+
|
|
3
|
+
class HasManyThroughAssociation
|
|
4
|
+
|
|
5
|
+
def include?(record)
|
|
6
|
+
return false unless record.is_a? ActiveRecord::Base
|
|
7
|
+
|
|
8
|
+
if loaded?
|
|
9
|
+
target.include?(record)
|
|
10
|
+
else
|
|
11
|
+
!!find_by_id(record.id)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def member_class
|
|
16
|
+
proxy_reflection.klass
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module ActiveRecord::ConnectionAdapters
|
|
2
|
+
|
|
3
|
+
class TableDefinition
|
|
4
|
+
|
|
5
|
+
def fkey(*args)
|
|
6
|
+
options = take_options!(args)
|
|
7
|
+
args.each {|col| column("#{col}_id".to_sym, :integer, options)}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def auto_dates
|
|
11
|
+
column :created_at, :datetime
|
|
12
|
+
column :updated_at, :datetime
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def method_missing(name, *args)
|
|
16
|
+
if name.in? [:integer, :float, :decimal, :datetime, :date, :timestamp,
|
|
17
|
+
:time, :text, :string, :binary, :boolean ]
|
|
18
|
+
options = take_options!(args)
|
|
19
|
+
args.each {|col| column(col, name, options)}
|
|
20
|
+
else
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def take_options!(args)
|
|
29
|
+
args.last.is_a?(Hash) ? args.pop : {}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|