togo 0.2.0 → 0.3.1

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/README CHANGED
@@ -4,6 +4,8 @@ With just a few lines of code in your ORM classes, you get a full-featured conte
4
4
 
5
5
  Quick example for DataMapper:
6
6
 
7
+ require 'togo'
8
+
7
9
  class BlogEntry
8
10
 
9
11
  include DataMapper::Resource
@@ -20,4 +22,8 @@ class BlogEntry
20
22
 
21
23
  end
22
24
 
25
+ Go to your app with your models in a folder called "models", then run:
26
+
27
+ togo-admin
28
+
23
29
  Current only works with DataMapper.
@@ -150,6 +150,15 @@ body {
150
150
  #main form fieldset input[type=text]:focus {
151
151
  border: 1px solid #ABABAB;
152
152
  }
153
+ #main form fieldset.belongs_to,
154
+ #main form fieldset.has_n {
155
+ padding-right: 20px;
156
+ }
157
+ #main form fieldset table th,
158
+ #main form fieldset table td {
159
+ padding: 5px;
160
+ }
161
+
153
162
  div.actions {
154
163
  position: absolute;
155
164
  bottom: 0;
@@ -3,7 +3,7 @@
3
3
  <div class="wrapper">
4
4
  <% if @errors %><div id="save_errors" class="errors"><%= @errors %></div><% end %>
5
5
  <% @model.form_properties.each do |p| %>
6
- <fieldset id="property_<%= p.name %>">
6
+ <fieldset id="property_<%= p.name %>" class="<%= @model.field_class_for(p) %>">
7
7
  <%= @model.form_for(p,@content) %>
8
8
  </fieldset>
9
9
  <% end %>
@@ -3,7 +3,7 @@
3
3
  <div class="wrapper">
4
4
  <% if @errors %><div id="save_errors" class="errors"><%= @errors %></div><% end %>
5
5
  <% @model.form_properties.each do |p| %>
6
- <fieldset id="field_<%= p.name %>">
6
+ <fieldset id="field_<%= p.name %>" class="<%= @model.field_class_for(p) %>">
7
7
  <%= @model.form_for(p,@content) %>
8
8
  </fieldset>
9
9
  <% end %>
data/lib/togo/admin.rb CHANGED
@@ -2,6 +2,6 @@ require 'dispatch'
2
2
  require 'togo/admin/admin'
3
3
 
4
4
  Togo::Admin.configure({
5
- :view_path => File.join(($:.find{|p| p =~ /lib\/togo\/admin/} || '../lib/togo/admin'),'views'),
6
- :public_path => File.join(($:.find{|p| p =~ /lib\/togo\/admin/} || '../lib/togo/admin'),'public')
5
+ :view_path => File.join($:.find{|p| p =~ /lib\/togo\/admin/},'views'),
6
+ :public_path => File.join($:.find{|p| p =~ /lib\/togo\/admin/},'public')
7
7
  })
@@ -43,13 +43,13 @@ module Togo
43
43
  @response.status = 404
44
44
  @response.write("404 Not Found")
45
45
  else
46
- begin
46
+ # begin
47
47
  __before if defined? __before
48
48
  @response.write(send(method))
49
- rescue => detail
50
- @response.status = 500
51
- @response.write("Error: #{detail}")
52
- end
49
+ # rescue => detail
50
+ # @response.status = 500
51
+ # @response.write(["Error: #{detail}",$!.backtrace.join("<br />\n")].join("<br />\n"))
52
+ # end
53
53
  end
54
54
  end
55
55
 
@@ -76,6 +76,10 @@ module Togo
76
76
  all(:conditions => [conditions.join(' OR ')] + values)
77
77
  end
78
78
 
79
+ def field_class_for(property)
80
+ type_from_property(property)
81
+ end
82
+
79
83
  private
80
84
 
81
85
  def custom_template_for(property,template)
@@ -88,6 +92,8 @@ module Togo
88
92
  Extlib::Inflection.demodulize(property.type).downcase
89
93
  when ::DataMapper::Associations::ManyToOne::Relationship
90
94
  'belongs_to'
95
+ when ::DataMapper::Associations::OneToMany::Relationship
96
+ 'has_n'
91
97
  else
92
98
  'string'
93
99
  end
@@ -1,3 +1,29 @@
1
- <label for="<%= property.name %>"><%= property.name.to_s.humanize.titleize %></label>
2
- <input type="text" name="<%= property.name %>" id="<%= property.name %>" value="<%= content.send(property.name.to_sym) %>" />
3
- <input type="hidden" name="<%= property.child_key.first.name %>" id="<%= property.child_key.first.name %>" value="<%= content.send(property.name.to_sym).id rescue '' %>" />
1
+ <% related_content = content.send(property.name.to_sym) %>
2
+ <% related_model = property.parent_key.first.model %>
3
+ <label for="<%= property.name %>"><%= property.name.to_s.humanize.titleize %> (<a href="/new/<%= related_model.name %>">New...</a>)</label>
4
+ <table id="association-table">
5
+ <thead>
6
+ <tr>
7
+ <% if related_content %>
8
+ <th></th>
9
+ <% end %>
10
+ <% related_model.list_properties.each do |p| %>
11
+ <th><%= p.name.to_s.humanize.titleize %></th>
12
+ <% end %>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% if not related_content %>
17
+ <tr>
18
+ <td colspan="<%= related_model.list_properties.size %>">No Content Associated.</td>
19
+ </tr>
20
+ <% else %>
21
+ <tr>
22
+ <td class="checkbox"><input type="checkbox" name="selection[<%= related_content.id %>]" value="1" id="selection_<%= related_content.id %>" /></td>
23
+ <% related_model.list_properties.each_with_index do |p,i| %>
24
+ <td><% if i == 0 %><a href="/edit/<%= related_model.name %>/<%= related_content.id %>"><%= related_content.send(p.name.to_sym) || '-' %></a><% else %><%= related_content.send(p.name.to_sym) %><% end %></td>
25
+ <% end %>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
@@ -0,0 +1,31 @@
1
+ <% related_content = content.send(property.name.to_sym) %>
2
+ <% related_model = property.child_key.first.model %>
3
+ <label for="<%= property.name %>"><%= related_model.display_name %></label>
4
+ <table id="association-table">
5
+ <thead>
6
+ <tr>
7
+ <% if related_content.empty? %>
8
+ <th></th>
9
+ <% end %>
10
+ <% related_model.list_properties.each do |p| %>
11
+ <th><%= p.name.to_s.humanize.titleize %></th>
12
+ <% end %>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% if not related_content.empty? %>
17
+ <tr>
18
+ <td colspan="<%= related_model.list_properties.size %>">No Content Associated.</td>
19
+ </tr>
20
+ <% else %>
21
+ <% related_content.each do |c| %>
22
+ <tr>
23
+ <td class="checkbox"><input type="checkbox" name="selection[<%= c.id %>]" value="1" id="selection_<%= c.id %>" /></td>
24
+ <% related_model.list_properties.each_with_index do |p,i| %>
25
+ <td><% if i == 0 %><a href="/edit/<%= related_model.name %>/<%= c.id %>"><%= c.send(p.name.to_sym) || '-' %></a><% else %><%= c.send(p.name.to_sym) %><% end %></td>
26
+ <% end %>
27
+ </tr>
28
+ <% end -%>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: togo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Matt King
@@ -9,19 +15,41 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-03 00:00:00 -08:00
18
+ date: 2010-06-30 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: dm-core
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - "="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 51
30
+ segments:
31
+ - 0
32
+ - 10
33
+ - 2
23
34
  version: 0.10.2
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: erubis
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">"
44
+ - !ruby/object:Gem::Version
45
+ hash: 31
46
+ segments:
47
+ - 0
48
+ - 0
49
+ - 0
50
+ version: 0.0.0
51
+ type: :runtime
52
+ version_requirements: *id002
25
53
  description: With a few lines of code in your Ruby ORMs, you get a highly configurable and extensive content administration tool.
26
54
  email: matt@mattking.org
27
55
  executables:
@@ -57,6 +85,7 @@ files:
57
85
  - lib/togo/model/types/boolean.erb
58
86
  - lib/togo/model/types/datetime.erb
59
87
  - lib/togo/model/types/float.erb
88
+ - lib/togo/model/types/has_n.erb
60
89
  - lib/togo/model/types/integer.erb
61
90
  - lib/togo/model/types/string.erb
62
91
  - lib/togo/model/types/text.erb
@@ -77,21 +106,27 @@ require_paths:
77
106
  - lib/togo/dispatch
78
107
  - lib/togo/admin
79
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
80
110
  requirements:
81
111
  - - ">="
82
112
  - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
83
116
  version: "0"
84
- version:
85
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
86
119
  requirements:
87
120
  - - ">="
88
121
  - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
89
125
  version: "0"
90
- version:
91
126
  requirements: []
92
127
 
93
128
  rubyforge_project:
94
- rubygems_version: 1.3.5
129
+ rubygems_version: 1.3.7
95
130
  signing_key:
96
131
  specification_version: 3
97
132
  summary: Automatic Content Admin Tool for Ruby ORMs