Skip to content

Commit 6853df9

Browse files
committed
Merge remote-tracking branch 'upstream/master' into russian_i18n
2 parents 38e8b99 + 33ad82a commit 6853df9

File tree

24 files changed

+520
-226
lines changed

24 files changed

+520
-226
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ group :development, :test do
2222
gem 'sqlite3-ruby', :require => 'sqlite3'
2323
gem 'rake', '0.8.7', :require => false
2424
gem 'haml', '~> 3.1.1', :require => false
25+
gem 'yard'
26+
gem 'rdiscount' # For yard
2527
end
2628

2729
group :test do

Rakefile

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,8 @@ end
1111

1212
require File.expand_path('../spec/support/detect_rails_version', __FILE__)
1313

14-
namespace :test do
15-
16-
desc "Run against the important versions of rails"
17-
task :major_rails_versions do
18-
current_version = detect_rails_version
19-
["3.0.7", "3.1.0.rc4"].each do |version|
20-
puts
21-
puts
22-
puts "== Using Rails #{version}"
23-
cmd "./script/use_rails #{version}"
24-
cmd "bundle exec rspec spec"
25-
cmd "bundle exec cucumber features"
26-
end
27-
cmd "./script/use_rails #{current_version}"
28-
end
29-
30-
end
31-
32-
desc "Creates a test rails app for the specs to run against"
33-
task :setup do
34-
require 'rails/version'
35-
system("mkdir spec/rails") unless File.exists?("spec/rails")
36-
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb"
37-
end
38-
39-
require "rspec/core/rake_task"
40-
RSpec::Core::RakeTask.new(:spec)
41-
42-
RSpec::Core::RakeTask.new(:rcov) do |spec|
43-
spec.rcov = true
44-
end
14+
# Import all our rake tasks
15+
FileList['tasks/**/*.rake'].each { |task| import task }
4516

4617
# Run the specs & cukes
4718
task :default do
@@ -54,39 +25,3 @@ task :default do
5425
cmd("export RAILS=3.0.5 && export RAILS_ENV=cucumber && bundle exec cucumber features"),
5526
].uniq == [true]
5627
end
57-
58-
namespace :spec do
59-
desc "Run specs for all versions of rails"
60-
task :all do
61-
(0..6).to_a.each do |v|
62-
puts "Running for Rails 3.0.#{v}"
63-
cmd "rm Gemfile.lock" if File.exists?("Gemfile.lock")
64-
cmd "/usr/bin/env RAILS=3.0.#{v} bundle install"
65-
cmd "/usr/bin/env RAILS=3.0.#{v} rake spec"
66-
end
67-
end
68-
end
69-
70-
require 'cucumber/rake/task'
71-
72-
namespace :cucumber do
73-
Cucumber::Rake::Task.new(:all) do |t|
74-
t.profile = 'default'
75-
end
76-
77-
Cucumber::Rake::Task.new(:wip) do |t|
78-
t.profile = 'wip'
79-
end
80-
end
81-
82-
task :cucumber => "cucumber:all"
83-
84-
require 'rake/rdoctask'
85-
Rake::RDocTask.new do |rdoc|
86-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
87-
88-
rdoc.rdoc_dir = 'rdoc'
89-
rdoc.title = "active_admin #{version}"
90-
rdoc.rdoc_files.include('README*')
91-
rdoc.rdoc_files.include('lib/**/*.rb')
92-
end

app/assets/stylesheets/active_admin/_forms.css.scss

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,29 @@ $sidebar-inner-content-width: $sidebar-width - ($section-padding * 2);
202202

203203
// -------------------------------------- Filter Forms
204204

205-
$date-range-filter-seperator-width: 12px;
205+
$filter-field-seperator-width: 12px;
206+
207+
$side-by-side-filter-input-width: ($sidebar-inner-content-width / 2) - ($text-input-horizontal-padding * 2) - $filter-field-seperator-width;
208+
$side-by-side-filter-select-width: ($sidebar-inner-content-width / 2) - $filter-field-seperator-width;
209+
206210
$date-range-filter-input-right-padding: 27px;
207211
$date-range-filter-input-horizontal-padding: $date-range-filter-input-right-padding + $text-input-horizontal-padding;
212+
$date-range-filter-input-width: ($sidebar-inner-content-width / 2) - $filter-field-seperator-width - $date-range-filter-input-horizontal-padding;
208213

209214
form.filter_form {
210215
.filter_form_field {
211216
margin-bottom: 10px;
212217
clear: both;
213218

214-
&.filter_numeric { input[type=text] { width: 80px; margin-left: 5px; } }
219+
&.filter_numeric {
220+
input[type=text] {
221+
margin-left: $filter-field-seperator-width + 4;
222+
width: $side-by-side-filter-input-width;
223+
}
224+
select {
225+
width: $side-by-side-filter-select-width;
226+
}
227+
}
215228

216229
&.filter_check_boxes {
217230
label { margin-bottom: 3px; }
@@ -228,13 +241,13 @@ form.filter_form {
228241
.seperator {
229242
display: inline-block;
230243
text-align: center;
231-
width: $date-range-filter-seperator-width;
244+
width: $filter-field-seperator-width;
232245
}
233246

234247
input[type=text] {
235248
background: #fff url(active_admin_image_path('datepicker/datepicker-input-icon.png')) no-repeat 100% 7px;
236249
padding-right: $date-range-filter-input-right-padding;
237-
width: ($sidebar-inner-content-width / 2) - $date-range-filter-seperator-width - $date-range-filter-input-horizontal-padding;
250+
width: $date-range-filter-input-width;
238251
}
239252
}
240253
}

app/assets/stylesheets/active_admin/components/_flash_messages.css.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
body.logged_in {
22
.flash {
33
@include primary-gradient;
4-
@include shadow;
5-
@include text-shadow(#222);
4+
@include text-shadow(#fafafa);
65
background-color: #a24a42;
76
border: none;
8-
border-bottom: 1px solid #44484B;
97
color: #fff;
108
font-weight: bold;
9+
font-size: 1.1em;
1110
line-height: 1.0em;
1211
margin-bottom: 10px;
13-
padding: 12px 30px;
12+
padding: 13px 30px 11px;
1413

15-
&.flash_notice { @include gradient(#7d9582, #667d6a); }
16-
&.flash_error { @include gradient(#a8716d, #955c59); }
14+
&.flash_notice {
15+
@include gradient(#dce9dd, #ccdfcd);
16+
border-bottom: 1px solid #adcbaf;
17+
color: #416347;
18+
}
19+
&.flash_error {
20+
@include gradient(#f5e4e4, #f1dcdc);
21+
border-bottom: 1px solid #e0c2c0;
22+
color: #b33c33;
23+
}
1724
}
1825
}
1926

docs/3-index-pages.md

Lines changed: 4 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -6,123 +6,14 @@ you to build a compelling interface into your data for the admin staff.
66

77
Built in, Active Admin has the following index renderers:
88

9-
* *Table*: A table drawn with each row being a resource
10-
* *Grid*: A set of rows and columns each cell being a resource
11-
* *Blocks*: A set of rows (not tabular) each row being a resource
12-
* *Blog*: A title and body content, similar to a blog index
9+
* *Table*: A table drawn with each row being a resource ([View Table Docs](3-index-pages/index-as-table.md))
10+
* *Grid*: A set of rows and columns each cell being a resource ([View Grid Docs](3-index-pages/index-as-grid.md))
11+
* *Blocks*: A set of rows (not tabular) each row being a resource ([View Blocks Docs](3-index-pages/index-as-blocks.md))
12+
* *Blog*: A title and body content, similar to a blog index ([View Blog Docs](3-index-pages/index-as-blog.md))
1313

1414
All index pages also support scopes, filters, pagination, action items, and
1515
sidebar sections.
1616

17-
## Index as a Table
18-
19-
By default, the index page is a table with each of the models content columns and links to
20-
show, edit and delete the object. There are many ways to customize what gets
21-
displayed.
22-
23-
### Defining Columns
24-
25-
To display an attribute or a method on a resource, simply pass a symbol into the
26-
column method:
27-
28-
index do
29-
column :title
30-
end
31-
32-
If the default title does not work for you, pass it as the first argument:
33-
34-
index do
35-
column "My Custom Title", :title
36-
end
37-
38-
Sometimes calling methods just isn't enough and you need to write some view
39-
specific code. For example, say we wanted a colum called Title which holds a
40-
link to the posts admin screen.
41-
42-
The column method accepts a block as an argument which will then be rendered
43-
within the context of the view for each of the objects in the collection.
44-
45-
index do
46-
column "Title" do |post|
47-
link_to post.title, admin_post_path(post)
48-
end
49-
end
50-
51-
The block gets called once for each resource in the collection. The resource gets passed into
52-
the block as an argument.
53-
54-
55-
### Sorting
56-
57-
When a column is generated from an Active Record attribute, the table is
58-
sortable by default. If you are creating a custom column, you may need to give
59-
Active Admin a hint for how to sort the table.
60-
61-
If a column is defined using a block, you must pass the key to turn on sorting. The key
62-
is the attribute which gets used to sort objects using Active Record.
63-
64-
index do
65-
column "Title", :sortable => :title do |post|
66-
link_to post.title, admin_post_path(post)
67-
end
68-
end
69-
70-
You can turn off sorting on any column by passing false:
71-
72-
index do
73-
column :title, :sortable => false
74-
end
75-
76-
### Showing and Hiding Columns
77-
78-
The entire index block is rendered within the context of the view, so you can
79-
easily do things that show or hide columns based on the current context.
80-
81-
For example, if you were using CanCan:
82-
83-
index do
84-
column :title, :sortable => false
85-
if can? :manage, Post
86-
column :some_secret_data
87-
end
88-
end
89-
90-
## Index as a Grid
91-
92-
Sometimes you want to display the index screen for a set of resources as a grid
93-
(possibly a grid of thumbnail images). To do so, use the :grid option for the
94-
index block.
95-
96-
index :as => :grid do |product|
97-
link_to(image_tag(product.image_path), admin_products_path(product))
98-
end
99-
100-
The block is rendered within a cell in the grid once for each resource in the
101-
collection. The resource is passed into the block for you to use in the view.
102-
103-
You can customize the number of colums that are rendered using the columns
104-
option:
105-
106-
index :as => :grid, :columns => 5 do |product|
107-
link_to(image_tag(product.image_path), admin_products_path(product))
108-
end
109-
110-
111-
## Index as a Block
112-
113-
If you want to fully customize the display of your resources on the index
114-
screen, Index as a Block allows you to render a block of content for each
115-
resource.
116-
117-
index :as => :block do |product|
118-
div :for => product do
119-
h2 auto_link(product.title)
120-
div do
121-
simple_format product.description
122-
end
123-
end
124-
end
125-
12617
## Index Filters
12718

12819
By default the index screen includes a "Filters" sidebar on the right hand side
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!-- Please don't edit this file. It will be clobbered. -->
2+
3+
# Index as a Block
4+
5+
If you want to fully customize the display of your resources on the index
6+
screen, Index as a Block allows you to render a block of content for each
7+
resource.
8+
9+
index :as => :block do |product|
10+
div :for => product do
11+
h2 auto_link(product.title)
12+
div do
13+
simple_format product.description
14+
end
15+
end
16+
end
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!-- Please don't edit this file. It will be clobbered. -->
2+
3+
# Index as Blog
4+
5+
Render your index page as a set of posts. The post has two main options:
6+
title and body.
7+
8+
index :as => :blog do
9+
title :my_title # Calls #my_title on each resource
10+
body :my_body # Calls #my_body on each resource
11+
end
12+
13+
## Post Title
14+
15+
The title is the content that will be rendered within a link to the
16+
resource. There are two main ways to set the content for the title
17+
18+
First, you can pass in a method to be called on your
19+
resource. For example:
20+
21+
index :as => :blog do
22+
title :a_method_to_call
23+
end
24+
25+
This will result in the title of the post being the return value of
26+
Resource#a_method_to_call
27+
28+
Second, you can pass a block to the tile option which will then be
29+
used as the contents fo the title. The resource being rendered
30+
is passed in to the block. For Example:
31+
32+
index :as => :blog do
33+
title do |post|
34+
span post.title, :class => 'title'
35+
span post.created_at, :class => 'created_at'
36+
end
37+
end
38+
39+
## Post Body
40+
41+
The body is rendered underneath the title of each post. The same two
42+
style of options work as the Post Title above.
43+
44+
Call a method on the resource as the body:
45+
46+
index :as => :blog do
47+
title :my_title
48+
body :my_body # Return value of #my_body will be the body
49+
end
50+
51+
Or, render a block as the body:
52+
53+
index :as => :blog do
54+
title :my_title
55+
body do |post|
56+
div truncate(post.title)
57+
div :class => 'meta' do
58+
span "Post in #{post.categories.join(', ')}"
59+
end
60+
end
61+
end

0 commit comments

Comments
 (0)