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 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.3"
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
- # category_map = {}
8
- # @models =[]
9
- # models.each do |m|
10
- # if m.category
11
- # category_map[m.category] = [] unless category[m.category]
12
- # category_map[m.category] << m
13
- # else
14
- # @models << m
15
- # end
16
- # end
17
- # @models += category_map.to_a.map{|c| Hash[*c]}
18
- @models = 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
- <div class='kitsune_model_link'><%= link_to model.admin_name, admin_kitsune_model_records_path(model.object_class) %></div>
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,8 @@
1
+ class KitsuneFlatFilesGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ # lets do something brilliant
5
+ puts "Some win..."
6
+ end
7
+ end
8
+ end
@@ -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 %>
@@ -48,6 +48,11 @@ module Kitsune
48
48
  multipart
49
49
  end
50
50
 
51
+ def image(field)
52
+ add :file_field, field
53
+ multipart
54
+ end
55
+
51
56
  def multipart(value = true)
52
57
  @resource.kitsune_admin[:multipart] = value
53
58
  end
@@ -82,10 +82,10 @@ module Kitsune
82
82
  end
83
83
 
84
84
  def form_type(column)
85
- if kitsune_admin[:fields][column.name.to_sym] && kitsune_admin[:fields][column.name.to_sym][:type]
86
- case kitsune_admin[:fields][column.name.to_sym][:type]
85
+ if type = field_type(column.name)
86
+ case type
87
87
  when :sti
88
- if kitsune_admin[:fields][column.name.to_sym][:options] && kitsune_admin[:fields][column.name.to_sym][:options][:classes]
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
- if column.name =~ /_id$/
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 { |r| [ r.send(name), r.send(id) ] }, {:include_blank => true}]
156
- elsif kitsune_admin[:fields][column.name.to_sym] && kitsune_admin[:fields][column.name.to_sym][:type] == :sti && kitsune_admin[:fields][column.name.to_sym][:options] && kitsune_admin[:fields][column.name.to_sym][:options][:classes]
157
- [kitsune_admin[:fields][column.name.to_sym][:options][:classes].map {|c| [c.to_s, c.to_s]}, {:include_blank => true}]
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
@@ -4,6 +4,7 @@ module Kitsune
4
4
  model.class_eval do
5
5
  admin do
6
6
  wysiwyg :body
7
+ select :layout, Proc.new {Dir.glob(File.join(RAILS_ROOT, 'app', 'views', 'layouts', '*.html.haml')).map{|f| File.basename(f).split('.').first}}
7
8
  end
8
9
 
9
10
  before_save :update_url
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.3
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-04 00:00:00 -05:00
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.4
103
+ rubygems_version: 1.3.5
102
104
  signing_key:
103
105
  specification_version: 3
104
106
  summary: Integrated Rails Content Management System.