typus 3.1.8 → 3.1.9

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.
@@ -1,7 +1,42 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
- 3.1.8 (unreleased)
4
+ 3.1.10 (unrelased)
5
+ ------------------
6
+
7
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.9...master>
8
+
9
+
10
+ 3.1.9 (2012-03-08)
11
+ ------------------
12
+
13
+ * [FIXED] _addanother save button is only shown if the user has permission
14
+ to perform the action.
15
+
16
+ * [FIXED] Custom actions on show are now showed.
17
+
18
+ * [CHANGED] Detect if application has Kaminari or WillPaginate, otherwise
19
+ we will not setup a paginate and will tell the user to install one of
20
+ those mechanisms. In the near future Typus will provide a simple
21
+ pagination mechahism.
22
+
23
+ * [NEW] Option to enable and disable counters on resources. Enabled by default.
24
+
25
+ * [FIXED] Fixed Dir compatibility for Jruby.
26
+
27
+ * [CHANGED] session#destroy now uses DELETE.
28
+
29
+ * [CHANGED] CSV/XML links should include filters.
30
+
31
+ * [CHANGED] Removed find_in_batches from "csv_export". It was useless.
32
+
33
+ * [FIXED] Fixed converting route to resource for "singular" class. Eg.
34
+ "CustomerData" was being converted to "CustomerDatum".
35
+
36
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.8...v3.1.9>
37
+
38
+
39
+ 3.1.8 (2012-02-05)
5
40
  ------------------
6
41
 
7
42
  * [CHANGED] CSV generation is now performed in memory so we play nice
@@ -19,7 +54,7 @@ CHANGELOG
19
54
  * [CHANGED] Updated Gems for the dummy application. This fixes deprecation
20
55
  warnings and keeps the plugin up to date.
21
56
 
22
- Changes: <https://github.com/fesplugas/typus/compare/v3.1.7...master>
57
+ Changes: <https://github.com/fesplugas/typus/compare/v3.1.7...v3.1.8>
23
58
 
24
59
 
25
60
  3.1.7 (2012-01-25)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source "http://rubygems.org"
2
2
 
3
3
  # Declare your gem's dependencies in typus.gemspec.
4
4
  # Bundler will treat runtime dependencies like base dependencies, and
@@ -8,33 +8,36 @@ gemspec
8
8
  # Gems used only for assets and not required
9
9
  # in production environments by default.
10
10
  group :assets do
11
- gem 'sass-rails', '~> 3.2.3'
12
- gem 'coffee-rails', '~> 3.2.1'
13
- gem 'uglifier', '>= 1.0.3'
11
+ gem "sass-rails", "~> 3.2.3"
12
+ gem "coffee-rails", "~> 3.2.1"
13
+ gem "uglifier", ">= 1.0.3"
14
14
  end
15
15
 
16
16
  # Database adapters
17
17
  platforms :jruby do
18
- gem 'activerecord-jdbcmysql-adapter'
19
- gem 'activerecord-jdbcpostgresql-adapter'
20
- gem 'activerecord-jdbcsqlite3-adapter'
18
+ gem "activerecord-jdbcmysql-adapter"
19
+ gem "activerecord-jdbcpostgresql-adapter"
20
+ gem "activerecord-jdbcsqlite3-adapter"
21
21
 
22
- gem 'jruby-openssl' # JRuby limited openssl loaded. http://jruby.org/openssl
22
+ gem "jruby-openssl" # JRuby limited openssl loaded. http://jruby.org/openssl
23
23
  end
24
24
 
25
25
  platforms :ruby do
26
- gem 'mysql2'
27
- gem 'pg'
28
- gem 'sqlite3'
26
+ gem "mysql2"
27
+ gem "pg"
28
+ gem "sqlite3"
29
29
  end
30
30
 
31
- # And this stuff needed for the demo application.
31
+ # Typus can manage lists, trees, trashes, so we want to enable this stuff
32
+ # on the demo.
32
33
  gem "acts_as_list"
33
34
  gem "acts_as_tree"
34
- gem "factory_girl_rails", "~> 1.6.0"
35
35
  gem "rails-permalink", "~> 1.0.0"
36
36
  gem "rails-trash", "~> 2.0.0"
37
37
 
38
+ # We want to be able to use Factory Girl for seeding data.
39
+ gem "factory_girl_rails", "~> 1.6.0"
40
+
38
41
  # For some reason I also need to define the `jquery-rails` gem here.
39
42
  gem "jquery-rails"
40
43
 
@@ -69,3 +72,6 @@ group :development do
69
72
  end
70
73
 
71
74
  gem "SystemTimer", :platform => :ruby_18
75
+
76
+ gem "kaminari"
77
+ # gem "will_paginate"
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Typus: Admin Panel for Ruby on Rails applications
1
+ Typus: Admin Panel for Ruby on Rails applications
2
+ =================================================
2
3
 
3
4
  [![Build Status](https://secure.travis-ci.org/fesplugas/typus.png)](http://travis-ci.org/fesplugas/typus)
4
5
 
@@ -16,16 +17,21 @@ concentrate on your application instead of the bits to manage the system.
16
17
 
17
18
  You can try a demo [here][typus_demo].
18
19
 
19
- ## Key Features
20
+
21
+ Key Features
22
+ ------------
20
23
 
21
24
  - Built-in Authentication and Access Control Lists.
22
25
  - CRUD and custom actions for your models on a clean interface.
23
26
  - Internationalized interface ([See available translations][typus_locales])
24
27
  - Customizable and extensible templates.
25
28
  - Integrated [paperclip][paperclip] and [dragonfly][dragonfly] attachments viewer.
29
+ - Support for [Kamaniri][kaminari] and [WillPaginate][will_paginate].
26
30
  - Works with `Rails 3.1.X` and `Rails 3.2.X`.
27
31
 
28
- ## Installing
32
+
33
+ Installing
34
+ ----------
29
35
 
30
36
  Add **Typus** to your `Gemfile`
31
37
 
@@ -42,7 +48,14 @@ Update your bundle, run the generator and start the application server:
42
48
 
43
49
  and go to <http://0.0.0.0:3000/admin>.
44
50
 
45
- ## Testing
51
+
52
+ Testing
53
+ -------
54
+
55
+ Create a PostgreSQL database:
56
+
57
+ $ psql -c 'CREATE USER postgres SUPERUSER' -d postgres
58
+ $ psql -c 'CREATE DATABASE typus_test;' -U postgres
46
59
 
47
60
  To test, clone the repo and run the following commands:
48
61
 
@@ -50,19 +63,31 @@ To test, clone the repo and run the following commands:
50
63
  $ bundle install --path vendor/bundle
51
64
  $ bundle exec rake
52
65
 
53
- **Note:** In `OSX Lion` it's possible you need to create a `postgres`
54
- user to be able to run tests.
55
66
 
56
- CREATE USER postgres SUPERUSER;
67
+ Submitting an Issue
68
+ -------------------
69
+
70
+ We use the [GitHub issue tracker][issues] to track bugs and features.
71
+ Before submitting a bug report or feature request, check to make sure it
72
+ hasn't already been submitted. You can indicate support for an existing
73
+ issue by voting it up. When submitting a bug report, please include a
74
+ [Gist][gist] that includes a stack trace and any details that may be
75
+ necessary to reproduce the bug, including your gem version, Ruby
76
+ version, and operating system. Ideally, a bug report should include a
77
+ pull request with failing specs.
57
78
 
58
- ## Links
79
+
80
+ Links
81
+ -----
59
82
 
60
83
  - [Documentation](http://docs.typuscmf.com/)
61
84
  - [RubyGems][typus_gem]
62
85
  - [Mailing List](http://groups.google.com/group/typus)
63
86
  - [Contributors List](http://github.com/fesplugas/typus/contributors)
64
87
 
65
- ## License
88
+
89
+ License
90
+ -------
66
91
 
67
92
  **Typus** is released under the MIT license.
68
93
 
@@ -73,3 +98,7 @@ user to be able to run tests.
73
98
  [paperclip]: http://rubygems.org/gems/paperclip
74
99
  [dragonfly]: http://rubygems.org/gems/dragonfly
75
100
  [rails]: http://rubyonrails.org/
101
+ [gist]: https://gist.github.com/
102
+ [issues]: https://github.com/fesplugas/typus/issues
103
+ [kaminari]: http://rubygems.org/gems/kaminari
104
+ [will_paginate]: http://rubygems.org/gems/will_paginate
@@ -37,7 +37,7 @@ class Admin::ResourcesController < Admin::BaseController
37
37
  @item = @resource.new(params[:resource])
38
38
 
39
39
  respond_to do |format|
40
- format.html # new.html.erb
40
+ format.html
41
41
  format.json { render :json => @item }
42
42
  end
43
43
  end
@@ -77,9 +77,13 @@ class Admin::ResourcesController < Admin::BaseController
77
77
  prepend_resources_action("Edit", {:action => 'edit', :id => @item})
78
78
  end
79
79
 
80
+ custom_actions_for(:show).each do |action|
81
+ prepend_resources_action(action.titleize, {:action => action, :id => @item})
82
+ end
83
+
80
84
  respond_to do |format|
81
- format.html # show.html.erb
82
- format.xml { can_export?(:xml) ? render(:xml => @item) : not_allowed }
85
+ format.html
86
+ format.xml { render :xml => @item }
83
87
  format.json { render :json => @item }
84
88
  end
85
89
  end
@@ -134,6 +138,8 @@ class Admin::ResourcesController < Admin::BaseController
134
138
 
135
139
  def resource
136
140
  params[:controller].extract_class
141
+ rescue
142
+ params[:controller].extract_singular_class
137
143
  end
138
144
  helper_method :resource
139
145
 
@@ -160,7 +166,6 @@ class Admin::ResourcesController < Admin::BaseController
160
166
  end
161
167
  helper_method :fields
162
168
 
163
- # Here we set the current scope!
164
169
  def set_scope
165
170
  if (scope = params[:scope])
166
171
  if @resource.respond_to?(scope)
@@ -4,7 +4,7 @@ module Admin::BaseHelper
4
4
  content_for(:title) { page_title }
5
5
  end
6
6
 
7
- def header
7
+ def admin_header
8
8
  locals = { :admin_title => admin_title }
9
9
  render "helpers/admin/base/header", locals
10
10
  end
@@ -60,11 +60,17 @@ module Admin::Resources::FormHelper
60
60
 
61
61
  def save_options
62
62
  options = {}
63
- options["_addanother"] = "Save and add another"
63
+
64
+ if admin_user.can?('create', @resource.model_name)
65
+ options["_addanother"] = "Save and add another"
66
+ end
67
+
64
68
  if admin_user.can?('edit', @resource.model_name)
65
69
  options["_continue"] = "Save and continue editing"
66
70
  end
71
+
67
72
  options["_save"] = "Save"
73
+
68
74
  options
69
75
  end
70
76
 
@@ -0,0 +1,13 @@
1
+ module Admin::Resources::PaginationHelper
2
+
3
+ def admin_paginate(items, options)
4
+ if defined?(Kaminari)
5
+ paginate(items, options)
6
+ elsif defined?(WillPaginate)
7
+ will_paginate(items, options)
8
+ else
9
+ "<p align='center'>Showing only #{@resource.typus_options_for(:per_page)} records. Please, install <strong>Kaminari</strong> or <strong>WillPaginate</strong> to paginate.</p>".html_safe
10
+ end
11
+ end
12
+
13
+ end
@@ -15,21 +15,30 @@
15
15
  <%= render 'index' %>
16
16
 
17
17
  <ul class="predefined_filters">
18
- <li><%= link_to Typus::I18n.t("All"), params.dup.cleanup.merge(:action => 'index') %> (<%= resource.count %>)</li>
18
+ <li>
19
+ <%= link_to Typus::I18n.t("All"), params.dup.cleanup.merge(:action => 'index') %>
20
+ <%= "(#{resource.count})" if @resource.typus_options_for(:counters) %>
21
+ </li>
19
22
 
20
23
  <% scopes.each do |scope| %>
21
- <li><%= link_to Typus::I18n.t(scope.humanize), :scope => scope %> <%= "(#{@resource.send(scope).count})" %></li>
24
+ <li>
25
+ <%= link_to Typus::I18n.t(scope.humanize), :scope => scope %>
26
+ <%= "(#{@resource.send(scope).count})" if @resource.typus_options_for(:counters) %>
27
+ </li>
22
28
  <% end %>
23
29
 
24
30
  <% predefined_filters.each do |filter, action, scope| %>
25
- <% url = action.is_a?(String) ? params.dup.cleanup.merge(:action => action) : action %>
26
- <li><%= link_to Typus::I18n.t(filter), url %> <%= "(#{@resource.send(scope).count})" if scope && @resource.respond_to?(scope) %></li>
31
+ <li>
32
+ <% url = action.is_a?(String) ? params.dup.cleanup.merge(:action => action) : action %>
33
+ <%= link_to Typus::I18n.t(filter), url %>
34
+ <%= "(#{@resource.send(scope).count})" if @resource.typus_options_for(:counters) && scope && @resource.respond_to?(scope) %>
35
+ </li>
27
36
  <% end %>
28
37
 
29
38
  <% if resource.any? && (formats = resource.typus_options_for(:export).extract_settings).any? %>
30
39
  <li>|</li>
31
40
  <% formats.each do |format| %>
32
- <li><%= link_to format.upcase, :format => format %></li>
41
+ <li><%= link_to format.upcase, params.merge(:format => format) %></li>
33
42
  <% end %>
34
43
  <% end %>
35
44
  </ul>
@@ -47,7 +56,7 @@
47
56
  <% else %>
48
57
  <%= build_list(@resource, fields, @items) %>
49
58
  <% end %>
50
- <%= paginate(@items, Typus.pagination) %>
59
+ <%= admin_paginate(@items, Typus.pagination) %>
51
60
  <% else %>
52
61
  <p><%= Typus::I18n.t("No %{resources} found.", :resources => @resource.model_name.human(:count => 2)) %></p>
53
62
  <% end %>
@@ -11,7 +11,7 @@
11
11
 
12
12
  <% if @items.any? -%>
13
13
  <%= table %>
14
- <%= paginate(@items, Typus.pagination.merge(:anchor => association_name, :param_name => param_name)) %>
14
+ <%= admin_paginate(@items, Typus.pagination.merge(:anchor => association_name, :param_name => param_name)) %>
15
15
  <% else %>
16
16
  <p><%= Typus::I18n.t("No %{resources} found.", :resources => association_name.humanize.downcase.pluralize) %></p>
17
17
  <% end %>
@@ -1,4 +1,4 @@
1
1
  <ul>
2
2
  <li><%= Typus::I18n.t("Logged in as") %> <%= link_to admin_user.to_label, { :controller => "/admin/#{Typus.user_class.to_resource}", :action => 'edit', :id => admin_user.id } %></li>
3
- <li><%= link_to Typus::I18n.t("Sign out"), admin_sign_out_path, :confirm => Typus::I18n.t("Are you sure you want to sign out and end your session?") %></li>
3
+ <li><%= link_to Typus::I18n.t("Sign out"), admin_sign_out_path, :method => :delete, :confirm => Typus::I18n.t("Are you sure you want to sign out and end your session?") %></li>
4
4
  </ul>
@@ -13,7 +13,7 @@
13
13
  <div id="header">
14
14
  <div class="container_12">
15
15
  <div class="grid_12 title">
16
- <%= header %>
16
+ <%= admin_header %>
17
17
  </div>
18
18
 
19
19
  <div class="grid_8 applications">
@@ -10,7 +10,7 @@ Rails.application.routes.draw do
10
10
 
11
11
  if Typus.authentication == :session
12
12
  resource :session, :only => [:new, :create], :controller => :session do
13
- get :destroy, :as => "destroy"
13
+ delete :destroy, :as => "destroy"
14
14
  end
15
15
 
16
16
  resources :account, :only => [:new, :create, :show] do
@@ -32,7 +32,8 @@ Typus.setup do |config|
32
32
  # Define subdomain to use instead of additional path
33
33
  # config.subdomain = "admin"
34
34
 
35
- # Pagination options: These options are passed to `kaminari`.
35
+ # Pagination options: These options are passed to the pagination method
36
+ # which can be Kaminari or WillPaginate.
36
37
  # config.pagination = { :previous_label => "&larr; " + Typus::I18n.t("Previous"),
37
38
  # :next_label => Typus::I18n.t("Next") + " &rarr;" }
38
39
 
@@ -1,11 +1,7 @@
1
1
  class Object
2
2
 
3
- ##
4
- # TODO: Improve this code, which works, but probably there's a better way
5
- # to make the verification.
6
- #
7
- # Probably there's a better way to verify if a model responds to an STI
8
- # pattern.
3
+ # OPTIMIZE: Probably there's a better way to verify if a model responds
4
+ # to an STI pattern.
9
5
  def self.is_sti?
10
6
  (name != base_class.name) && base_class.descends_from_active_record?
11
7
  end
@@ -12,11 +12,12 @@ class String
12
12
  remove_prefix.classify.constantize
13
13
  end
14
14
 
15
- ##
15
+ def extract_singular_class
16
+ remove_prefix.camelize.constantize
17
+ end
18
+
16
19
  # CRUD: create, read, update, delete
17
- #
18
- # You can read more at http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
19
- #
20
+ # Read more at http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
20
21
  def acl_action_mapper
21
22
  case self
22
23
  when "new", "create"
@@ -12,8 +12,6 @@ require "typus/orm/base/search"
12
12
  require "typus/orm/active_record"
13
13
  require "typus/orm/mongoid"
14
14
 
15
- require "kaminari"
16
-
17
15
  autoload :FakeUser, "support/fake_user"
18
16
 
19
17
  module Typus
@@ -53,13 +51,7 @@ module Typus
53
51
  <a href="http://core.typuscmf.com/">core.typuscmf.com</a>
54
52
  CODE
55
53
 
56
- ##
57
- # Available Authentication Mechanisms are:
58
- #
59
- # - none
60
- # - basic: Uses http authentication
61
- # - session
62
- #
54
+ # Set authentication (none, basic, session or devise)
63
55
  mattr_accessor :authentication
64
56
  @@authentication = :none
65
57
 
@@ -72,35 +64,17 @@ module Typus
72
64
  mattr_accessor :subdomain
73
65
  @@subdomain = nil
74
66
 
75
- ##
76
- # Pagination options passed to Kaminari helper.
77
- #
78
- # :previous_label => "&larr; " + Typus::I18n.t("Previous")
79
- # :next_label => Typus::I18n.t("Next") + " &rarr;"
80
- #
81
- # Note that `Kaminari` only accepts the following configuration options:
82
- #
83
- # - default_per_page (25 by default)
84
- # - window (4 by default)
85
- # - outer_window (0 by default)
86
- # - left (0 by default)
87
- # - right (0 by default)
88
- #
67
+ # Pagination options passed to pagination helper. Note that pagination
68
+ # options are different in Kaminari and WillPaginate.
89
69
  mattr_accessor :pagination
90
70
  @@pagination = { :window => 0 }
91
71
 
92
- ##
93
- # Define a password.
94
- #
95
- # Used as default password for http and advanced authentication.
96
- #
72
+ # Define a default password for http authentication.
97
73
  mattr_accessor :password
98
74
  @@password = "columbia"
99
75
 
100
- ##
101
- # Configure the e-mail address which will be shown in Admin::Mailer. If not
102
- # set `forgot_password` feature is disabled.
103
- #
76
+ # Configure the e-mail address which will be shown in Admin::Mailer.
77
+ # If not set `forgot_password` feature is disabled.
104
78
  mattr_accessor :mailer_sender
105
79
  @@mailer_sender = nil
106
80
 
@@ -127,9 +101,7 @@ module Typus
127
101
  mattr_accessor :image_table_thumb_size
128
102
  @@image_table_thumb_size = '25x25#'
129
103
 
130
- ##
131
- # Defines the default relationship table.
132
- #
104
+ # Define the default relationship table.
133
105
  mattr_accessor :relationship
134
106
  @@relationship = "typus_users"
135
107
 
@@ -147,8 +119,8 @@ module Typus
147
119
 
148
120
  class << self
149
121
 
150
- # Default way to setup typus. Run `rails generate typus` to create a fresh
151
- # initializer with all configuration values.
122
+ # Default way to setup typus. Run `rails generate typus` to create a
123
+ # fresh initializer with all configuration values.
152
124
  def setup
153
125
  yield self
154
126
  reload!
@@ -197,7 +169,7 @@ module Typus
197
169
  # Lists models under <tt>app/models</tt>.
198
170
  def detect_application_models
199
171
  model_dir = Rails.root.join("app/models")
200
- Dir.chdir(model_dir) { Dir["**/*.rb"] }
172
+ Dir.chdir(model_dir.to_s) { Dir["**/*.rb"] }
201
173
  end
202
174
 
203
175
  def application_models
@@ -230,14 +202,14 @@ module Typus
230
202
  app = Typus.root.join("**", "*.yml")
231
203
  plugins = Rails.root.join("vendor", "plugins", "*", "config", "typus", "**", "*.yml")
232
204
  lib = Rails.root.join("lib", "*", "config", "typus", "**", "*.yml")
233
- Dir[app, plugins, lib].reject { |f| f.match(/_roles.yml/) }.sort
205
+ Dir[app.to_s, plugins.to_s, lib.to_s].reject { |f| f.match(/_roles.yml/) }.sort
234
206
  end
235
207
 
236
208
  def role_configuration_files
237
209
  app = Typus.root.join("**", "*_roles.yml")
238
210
  plugins = Rails.root.join("vendor", "plugins", "*", "config", "typus", "**", "*_roles.yml")
239
211
  lib = Rails.root.join("lib", "*", "config", "typus", "**", "*_roles.yml")
240
- Dir[app, plugins, lib].sort
212
+ Dir[app.to_s, plugins.to_s, lib.to_s].sort
241
213
  end
242
214
 
243
215
  def reload!
@@ -1,6 +1,4 @@
1
- ##
2
1
  # Module designed to work with `acts_as_list`.
3
- #
4
2
  module Typus
5
3
  module Controller
6
4
  module ActsAsList
@@ -1,10 +1,10 @@
1
- ##
2
- # How predefined filters work?
1
+ # How to setup a predefined filter?
2
+ # ---------------------------------
3
3
  #
4
- # On your controllers ...
4
+ # On your controllers:
5
5
  #
6
6
  # def index
7
- # # Added predefined filter takes any argumes, but in the views we
7
+ # # Added predefined filter takes any argument, but in the views we
8
8
  # # expected the following:
9
9
  # #
10
10
  # # add_predefined_filter(filter_name, action, scope)
@@ -14,7 +14,7 @@
14
14
  # ...
15
15
  # end
16
16
  #
17
- # On your views ...
17
+ # On your views:
18
18
  #
19
19
  # <% predefined_filters.each do |filter_name, action, scope| %>
20
20
  # ...
@@ -6,38 +6,39 @@ module Typus
6
6
 
7
7
  protected
8
8
 
9
+ # This is crazy, but I want to have support for Kaminari, WillPaginate
10
+ # and whatever other pagination system which comes.
9
11
  def get_paginated_data
10
12
  items_per_page = @resource.typus_options_for(:per_page)
11
- @items = @resource.page(params[:page]).per(items_per_page)
13
+
14
+ @items = if defined?(Kaminari)
15
+ @resource.page(params[:page]).per(items_per_page)
16
+ elsif defined?(WillPaginate)
17
+ @resource.paginate(:page => params[:page], :per_page => items_per_page)
18
+ else
19
+ @resource.limit(items_per_page) # Pagination is disabled, so just in case limit to 50 records.
20
+ end
12
21
  end
13
22
 
14
23
  alias_method :generate_html, :get_paginated_data
15
24
 
16
- #--
17
- # TODO: Find in batches only works properly if it's used on models, not
18
- # controllers, so in this action does nothing. We should find a way
19
- # to be able to process large amounts of data.
20
- #++
21
25
  def generate_csv
22
26
  fields = @resource.typus_fields_for(:csv)
23
- options = { :conditions => @conditions, :batch_size => 1000 }
24
27
 
25
28
  data = ::CSV.generate do |csv|
26
29
  csv << fields.keys.map { |k| @resource.human_attribute_name(k) }
27
- @resource.find_in_batches(options) do |records|
28
- records.each do |record|
29
- csv << fields.map do |key, value|
30
- case value
31
- when :transversal
32
- a, b = key.split(".")
33
- record.send(a).send(b)
34
- when :belongs_to
35
- record.send(key).try(:to_label)
36
- else
37
- record.send(key)
38
- end
30
+ @resource.all.each do |record|
31
+ csv << fields.map do |key, value|
32
+ case value
33
+ when :transversal
34
+ a, b = key.split(".")
35
+ record.send(a).send(b)
36
+ when :belongs_to
37
+ record.send(key).try(:to_label)
38
+ else
39
+ record.send(key)
39
40
  end
40
- end
41
+ end
41
42
  end
42
43
  end
43
44
 
@@ -1,6 +1,4 @@
1
- ##
2
1
  # Module designed to work with `rails-trash`.
3
- #
4
2
  module Typus
5
3
  module Controller
6
4
  module Trash
@@ -1,5 +1,4 @@
1
1
  module Admin
2
2
  class Engine < Rails::Engine
3
-
4
3
  end
5
4
  end
@@ -5,17 +5,15 @@ module Typus
5
5
 
6
6
  class << self
7
7
 
8
- ##
9
- # Instead of having to translate strings and defining a default value:
8
+ # Instead of having to translate strings and defining a default
9
+ # value to avoid "missing translation" messages:
10
10
  #
11
- # Typus::I18n.t("Hello World!", :default => 'Hello World!')
11
+ # I18n.t("Hello World!", :default => 'Hello World!')
12
12
  #
13
- # We define this method to define the value only once:
13
+ # We define a Typus translation method which will set up a default
14
+ # value for you: (Interpolation still works)
14
15
  #
15
16
  # Typus::I18n.t("Hello World!")
16
- #
17
- # Note that interpolation still works:
18
- #
19
17
  # Typus::I18n.t("Hello %{world}!", :world => @world)
20
18
  #
21
19
  def t(key, options = {})
@@ -9,7 +9,7 @@ module Typus
9
9
  options[:password] ||= Typus.password
10
10
  options[:role] ||= Typus.master_role
11
11
  options[:status] = true
12
- user = new options, :without_protection => true
12
+ user = new(options, :without_protection => true)
13
13
  user.save ? user : false
14
14
  end
15
15
 
@@ -55,13 +55,8 @@ module Typus
55
55
  ["#{key}.id = ?", value]
56
56
  end
57
57
 
58
- ##
59
- # To build conditions we reject all those params which are not model
60
- # fields.
61
- #
62
- # Note: We still want to be able to search so the search param is not
63
- # rejected.
64
- #
58
+ # To build conditions we accept only model fields and the search
59
+ # param.
65
60
  def build_conditions(params)
66
61
  Array.new.tap do |conditions|
67
62
  query_params = params.dup
@@ -45,6 +45,9 @@ module Typus
45
45
  mattr_accessor :export
46
46
  @@export = ""
47
47
 
48
+ mattr_accessor :counters
49
+ @@counters = true
50
+
48
51
  def self.method_missing(*args)
49
52
  nil
50
53
  end
@@ -1,3 +1,3 @@
1
1
  module Typus
2
- VERSION = "3.1.8"
2
+ VERSION = "3.1.9"
3
3
  end
@@ -28,7 +28,6 @@ Gem::Specification.new do |s|
28
28
 
29
29
  s.add_dependency "bcrypt-ruby", "~> 3.0.0"
30
30
  s.add_dependency "jquery-rails"
31
- s.add_dependency "kaminari", "~> 0.13.0"
32
31
  s.add_dependency "rails", ">= 3.1.3"
33
32
 
34
33
  # Development dependencies are defined in the `Gemfile`.
@@ -2,7 +2,7 @@
2
2
  * searchField - jQuery plugin to display and remove
3
3
  * a default value in a searchvalue on blur/focus
4
4
  *
5
- * Copyright (c) 2008 J�örn Zaefferer
5
+ * Copyright (c) 2008
6
6
  *
7
7
  * $Id$
8
8
  *
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.8
4
+ version: 3.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2012-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bcrypt-ruby
16
- requirement: &70159863686960 !ruby/object:Gem::Requirement
16
+ requirement: &70175438311080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70159863686960
24
+ version_requirements: *70175438311080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &70159863684320 !ruby/object:Gem::Requirement
27
+ requirement: &70175438309000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70159863684320
36
- - !ruby/object:Gem::Dependency
37
- name: kaminari
38
- requirement: &70159863683580 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 0.13.0
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70159863683580
35
+ version_requirements: *70175438309000
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: rails
49
- requirement: &70159863682840 !ruby/object:Gem::Requirement
38
+ requirement: &70175438307180 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ! '>='
@@ -54,7 +43,7 @@ dependencies:
54
43
  version: 3.1.3
55
44
  type: :runtime
56
45
  prerelease: false
57
- version_requirements: *70159863682840
46
+ version_requirements: *70175438307180
58
47
  description: Ruby on Rails Admin Panel (Engine) to allow trusted users edit structured
59
48
  content.
60
49
  email:
@@ -114,6 +103,7 @@ files:
114
103
  - app/helpers/admin/resources/filters_helper.rb
115
104
  - app/helpers/admin/resources/form_helper.rb
116
105
  - app/helpers/admin/resources/list_helper.rb
106
+ - app/helpers/admin/resources/pagination_helper.rb
117
107
  - app/helpers/admin/resources/relationships_helper.rb
118
108
  - app/helpers/admin/resources/table_helper.rb
119
109
  - app/helpers/admin/resources_helper.rb
@@ -333,7 +323,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
323
  version: '0'
334
324
  segments:
335
325
  - 0
336
- hash: -1439892809651849873
326
+ hash: 2790734658814501466
337
327
  required_rubygems_version: !ruby/object:Gem::Requirement
338
328
  none: false
339
329
  requirements:
@@ -342,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
332
  version: '0'
343
333
  segments:
344
334
  - 0
345
- hash: -1439892809651849873
335
+ hash: 2790734658814501466
346
336
  requirements: []
347
337
  rubyforge_project: typus
348
338
  rubygems_version: 1.8.11