kitsune 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/app/controllers/admin/kitsune/application_controller.rb +13 -12
- data/app/views/layouts/admin/kitsune.html.erb +12 -1
- data/generators/kitsune_flat_files/kitsune_flat_files_generator.rb +8 -0
- data/generators/kitsune_flat_files/templates/index.html.erb +35 -0
- data/lib/kitsune/builder.rb +5 -0
- data/lib/kitsune/inspector.rb +29 -8
- data/lib/kitsune/page.rb +1 -0
- metadata +5 -3
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rake'
|
|
2
2
|
|
3
3
|
gem_spec = Gem::Specification.new do |gem_spec|
|
4
4
|
gem_spec.name = "kitsune"
|
5
|
-
gem_spec.version = "0.0.
|
5
|
+
gem_spec.version = "0.0.4"
|
6
6
|
gem_spec.summary = "Integrated Rails Content Management System."
|
7
7
|
gem_spec.email = "matt@toastyapps.com"
|
8
8
|
gem_spec.homepage = "http://github.com/toastyapps/kitsune"
|
@@ -18,4 +18,4 @@ task :gemspec do
|
|
18
18
|
File.open("#{gem_spec.name}.gemspec", 'w') do |f|
|
19
19
|
f.write gem_spec.to_yaml
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -4,17 +4,18 @@ class Admin::Kitsune::ApplicationController < ActionController::Base
|
|
4
4
|
private
|
5
5
|
def load_models
|
6
6
|
models = Kitsune.models_with_admin.map{ |m| Kitsune::Inspector.new(m) }
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@models
|
7
|
+
category_map = {}
|
8
|
+
|
9
|
+
@models =[]
|
10
|
+
models.each do |m|
|
11
|
+
if m.category
|
12
|
+
category_map[m.category] = [] unless category_map[m.category]
|
13
|
+
category_map[m.category] << m
|
14
|
+
else
|
15
|
+
@models << m
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@models += category_map.to_a.map{|c| Hash[*c]}
|
19
|
+
#@models = models
|
19
20
|
end
|
20
21
|
end
|
@@ -13,7 +13,18 @@
|
|
13
13
|
<div class='kitsune_container'>
|
14
14
|
<div class='kitsune_left'>
|
15
15
|
<% @models.each do |model| %>
|
16
|
-
|
16
|
+
<% if model.is_a? Hash %>
|
17
|
+
<% model.each do |key, value| %>
|
18
|
+
<div class='kitsune_category'>
|
19
|
+
<h3><%= key %></h3>
|
20
|
+
<% value.each do |inner_model| %>
|
21
|
+
<div class='kitsune_inner_model_link'><%= link_to inner_model.admin_name, admin_kitsune_model_records_path(inner_model.object_class) %></div>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
<% else %>
|
26
|
+
<div class='kitsune_model_link'><%= link_to model.admin_name, admin_kitsune_model_records_path(model.object_class) %></div>
|
27
|
+
<% end %>
|
17
28
|
<% end %>
|
18
29
|
</div>
|
19
30
|
<div class='kitsune_right'>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<div id='kitsune_record_header'>
|
2
|
+
<h2><%= @model.admin_name %></h2>
|
3
|
+
<div id='menu'>
|
4
|
+
<%= link_to "New #{params[:id]}", new_admin_kitsune_model_record_path(params[:model_id]) %>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
<% @model.tabs.each do |key, value|%>
|
8
|
+
<%= link_to key, value %>
|
9
|
+
<% end %>
|
10
|
+
<table>
|
11
|
+
<thead>
|
12
|
+
<tr>
|
13
|
+
<% @model.columns(:display).each do |column| %>
|
14
|
+
<th><%= sort_link_to(@model, column) %></th>
|
15
|
+
<% end %>
|
16
|
+
<th>Actions</th>
|
17
|
+
</tr>
|
18
|
+
</thead>
|
19
|
+
<tbody>
|
20
|
+
<% @records.each do |record| %>
|
21
|
+
<tr class="<%= cycle('odd', 'even') %>">
|
22
|
+
<% @model.columns(:display).each do |column| %>
|
23
|
+
<td><%= truncate(sanitize(record.send(column.name).to_s), :length => 20) %></td>
|
24
|
+
<% end %>
|
25
|
+
<td>
|
26
|
+
<%= link_to 'Edit', edit_admin_kitsune_model_record_path(params[:model_id], record.id) %>
|
27
|
+
-
|
28
|
+
<%= link_to 'Delete', admin_kitsune_model_record_path(params[:model_id], record.id), :method => :delete, :confirm => "Are you sure?" %>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
<% end %>
|
32
|
+
</tbody>
|
33
|
+
</table>
|
34
|
+
|
35
|
+
<%= will_paginate @records %>
|
data/lib/kitsune/builder.rb
CHANGED
data/lib/kitsune/inspector.rb
CHANGED
@@ -82,10 +82,10 @@ module Kitsune
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def form_type(column)
|
85
|
-
if
|
86
|
-
case
|
85
|
+
if type = field_type(column.name)
|
86
|
+
case type
|
87
87
|
when :sti
|
88
|
-
if
|
88
|
+
if field_options(field) && field[:classes]
|
89
89
|
:select
|
90
90
|
else
|
91
91
|
:text_field
|
@@ -148,18 +148,39 @@ module Kitsune
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def options_for(column)
|
151
|
-
|
151
|
+
|
152
|
+
field = column.name
|
153
|
+
|
154
|
+
if field_type(field) == :select
|
155
|
+
[field_options(field), {:include_blank => true}]
|
156
|
+
elsif column.name =~ /_id$/
|
152
157
|
id = :id
|
153
158
|
collection = find_association_class(column).all
|
154
159
|
name = detect_label(collection)
|
155
|
-
[collection.map { |
|
156
|
-
elsif
|
157
|
-
[
|
160
|
+
[collection.map { |element| [ element.send(name), element.send(id) ] }, {:include_blank => true}]
|
161
|
+
elsif field_type(field) == :sti && (options = field_options(field)) && options[:classes]
|
162
|
+
[options[:classes].map {|element| [element.to_s, element.to_s]}, {:include_blank => true}]
|
158
163
|
else
|
159
|
-
options = {}
|
164
|
+
options = field_options(field) || {}
|
160
165
|
options[:size] = '80x10' if [:text_area, :wysiwyg].include?(form_type(column))
|
161
166
|
[options]
|
162
167
|
end
|
163
168
|
end
|
169
|
+
|
170
|
+
private
|
171
|
+
def field_defined(field)
|
172
|
+
!!kitsune_admin[:fields][field.to_sym]
|
173
|
+
end
|
174
|
+
|
175
|
+
def field_type(field)
|
176
|
+
return kitsune_admin[:fields][field.to_sym][:type] if field_defined(field)
|
177
|
+
return nil
|
178
|
+
end
|
179
|
+
|
180
|
+
def field_options(field)
|
181
|
+
options = kitsune_admin[:fields][field.to_sym][:options] if field_defined(field)
|
182
|
+
return (options.is_a?(Proc) ? options.call : options) if options
|
183
|
+
return nil
|
184
|
+
end
|
164
185
|
end
|
165
186
|
end
|
data/lib/kitsune/page.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitsune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Mongeau <matt@toastyapps.com>
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-10 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -65,6 +65,8 @@ files:
|
|
65
65
|
- generators/kitsune/templates/README
|
66
66
|
- generators/kitsune/templates/stylesheets/global.css
|
67
67
|
- generators/kitsune/USAGE
|
68
|
+
- generators/kitsune_flat_files/kitsune_flat_files_generator.rb
|
69
|
+
- generators/kitsune_flat_files/templates/index.html.erb
|
68
70
|
- lib/kitsune/active_record.rb
|
69
71
|
- lib/kitsune/builder.rb
|
70
72
|
- lib/kitsune/extensions/routes.rb
|
@@ -98,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
100
|
requirements:
|
99
101
|
- mislav-will_paginate
|
100
102
|
rubyforge_project:
|
101
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.5
|
102
104
|
signing_key:
|
103
105
|
specification_version: 3
|
104
106
|
summary: Integrated Rails Content Management System.
|