merb-admin 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -14,7 +14,7 @@ At the command prompt, type:
14
14
 
15
15
  In your app, add the following dependency to `config/dependencies.rb`:
16
16
 
17
- dependency "merb-admin", "0.5.1"
17
+ dependency "merb-admin", "0.5.2"
18
18
 
19
19
  Add the following route to `config/router.rb`:
20
20
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ AUTHOR = "Erik Michaels-Ober"
9
9
  EMAIL = "sferik@gmail.com"
10
10
  HOMEPAGE = "http://github.com/sferik/merb-admin"
11
11
  SUMMARY = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
12
- GEM_VERSION = "0.5.1"
12
+ GEM_VERSION = "0.5.2"
13
13
 
14
14
  spec = Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "merb"
@@ -1,4 +1,4 @@
1
- class MerbAdmin::Application < Merb::Controller
1
+ class MerbAdmin::Application < Merb::Controller
2
2
  include Merb::MerbAdmin::MainHelper
3
3
 
4
4
  controller_for_slice
@@ -80,7 +80,7 @@ class MerbAdmin::Main < MerbAdmin::Application
80
80
  end
81
81
  has_one_associations = @abstract_model.has_one_associations.map{|association| [association, (params[:associations] || {}).delete(association[:name])]}
82
82
  has_many_associations = @abstract_model.has_many_associations.map{|association| [association, (params[:associations] || {}).delete(association[:name])]}
83
- if @object.update_attributes(object) && has_one_associations.each{|association, id| update_has_one_association(association, id)} && has_many_associations.each{|association, ids| update_has_many_association(association, ids)}
83
+ if @object.update_attributes(object) && has_one_associations.each{|association, id| update_has_one_association(association, id)} && has_many_associations.each{|association, ids| update_has_many_association(association, ids)}
84
84
  if params[:_continue]
85
85
  redirect(url(:merb_admin_edit, :model_name => @abstract_model.singular_name, :id => @object.id), :message => {:notice => "#{@abstract_model.pretty_name} was successfully updated"})
86
86
  elsif params[:_add_another]
@@ -4,7 +4,7 @@ module Merb
4
4
 
5
5
  # @param *segments<Array[#to_s]> Path segments to append.
6
6
  #
7
- # @return <String>
7
+ # @return <String>
8
8
  # A path relative to the public directory, with added segments.
9
9
  def image_path(*segments)
10
10
  public_path_for(:image, *segments)
@@ -12,7 +12,7 @@ module Merb
12
12
 
13
13
  # @param *segments<Array[#to_s]> Path segments to append.
14
14
  #
15
- # @return <String>
15
+ # @return <String>
16
16
  # A path relative to the public directory, with added segments.
17
17
  def javascript_path(*segments)
18
18
  public_path_for(:javascript, *segments)
@@ -20,40 +20,40 @@ module Merb
20
20
 
21
21
  # @param *segments<Array[#to_s]> Path segments to append.
22
22
  #
23
- # @return <String>
23
+ # @return <String>
24
24
  # A path relative to the public directory, with added segments.
25
25
  def stylesheet_path(*segments)
26
26
  public_path_for(:stylesheet, *segments)
27
27
  end
28
28
 
29
29
  # Construct a path relative to the public directory
30
- #
30
+ #
31
31
  # @param <Symbol> The type of component.
32
32
  # @param *segments<Array[#to_s]> Path segments to append.
33
33
  #
34
- # @return <String>
34
+ # @return <String>
35
35
  # A path relative to the public directory, with added segments.
36
36
  def public_path_for(type, *segments)
37
37
  ::MerbAdmin.public_path_for(type, *segments)
38
38
  end
39
39
 
40
40
  # Construct an app-level path.
41
- #
41
+ #
42
42
  # @param <Symbol> The type of component.
43
43
  # @param *segments<Array[#to_s]> Path segments to append.
44
44
  #
45
- # @return <String>
45
+ # @return <String>
46
46
  # A path within the host application, with added segments.
47
47
  def app_path_for(type, *segments)
48
48
  ::MerbAdmin.app_path_for(type, *segments)
49
49
  end
50
50
 
51
51
  # Construct a slice-level path.
52
- #
52
+ #
53
53
  # @param <Symbol> The type of component.
54
54
  # @param *segments<Array[#to_s]> Path segments to append.
55
55
  #
56
- # @return <String>
56
+ # @return <String>
57
57
  # A path within the slice source (Gem), with added segments.
58
58
  def slice_path_for(type, *segments)
59
59
  ::MerbAdmin.slice_path_for(type, *segments)
@@ -21,7 +21,7 @@
21
21
  </h1>
22
22
  </div>
23
23
  </div>
24
- <%= partial('layout/message', :message => message) unless message.blank? -%>
24
+ <%= partial('layout/message', :message => message) unless message.blank? -%>
25
25
  <div id="content" class="colMS">
26
26
  <h1>
27
27
  <%= page_name %>
@@ -1,4 +1,4 @@
1
- <%
1
+ <%
2
2
  association_name = association[:name]
3
3
  collection = MerbAdmin::AbstractModel.new(association[:child_model]).all.map{|o| [o.id, object_title(o)]}.sort_by{|o| o[1]}
4
4
  selected = @object.send(association_name)
@@ -16,4 +16,4 @@
16
16
  <%= partial(property_type.to_s, :property => property) -%>
17
17
  </div>
18
18
  <% end %>
19
- </fieldset>
19
+ </fieldset>
@@ -47,7 +47,7 @@ namespace :slices do
47
47
  task :migrate do # see slicetasks.rb
48
48
  end
49
49
 
50
- desc "Freeze MerbAdmin into your app (only merb-admin/app)"
50
+ desc "Freeze MerbAdmin into your app (only merb-admin/app)"
51
51
  task :freeze => [ "freeze:app" ]
52
52
 
53
53
  namespace :freeze do
@@ -67,7 +67,7 @@ namespace :slices do
67
67
  preserved.each { |f| puts "! preserved override as #{f}" }
68
68
  end
69
69
 
70
- desc "Freeze all views into your application for easy modification"
70
+ desc "Freeze all views into your application for easy modification"
71
71
  task :views do
72
72
  puts "Copying all view templates to your application - resolves any collisions"
73
73
  copied, preserved = MerbAdmin.mirror_files_for :view
@@ -76,7 +76,7 @@ namespace :slices do
76
76
  preserved.each { |f| puts "! preserved override as #{f}" }
77
77
  end
78
78
 
79
- desc "Freeze all models into your application for easy modification"
79
+ desc "Freeze all models into your application for easy modification"
80
80
  task :models do
81
81
  puts "Copying all models to your application - resolves any collisions"
82
82
  copied, preserved = MerbAdmin.mirror_files_for :model
@@ -60,7 +60,7 @@ def load_data
60
60
  division = MerbAdmin::AbstractModel.new("Division").create(:name => mlb_team.division, :league => league)
61
61
  end
62
62
  unless team = MerbAdmin::AbstractModel.new("Team").first(:conditions => ["name = ?", mlb_team.name])
63
- team = MerbAdmin::AbstractModel.new("Team").create(:name => mlb_team.name, :division => division, :league => league)
63
+ team = MerbAdmin::AbstractModel.new("Team").create(:name => mlb_team.name, :logo_image_url => mlb_team.logo_url, :manager => mlb_team.manager, :ballpark => mlb_team.ballpark, :mascot => mlb_team.mascot, :founded => mlb_team.founded, :wins => mlb_team.wins, :losses => mlb_team.losses, :win_percentage => ("%.3f" % (mlb_team.wins.to_f / mlb_team.wins + mlb_team.losses)).to_f, :division => division, :league => league)
64
64
  end
65
65
  mlb_team.players.each do |player|
66
66
  MerbAdmin::AbstractModel.new("Player").create(:name => player.name, :number => player.number, :position => player.position, :team => team)
@@ -128,4 +128,3 @@ def split_name(name)
128
128
  mres = /^([^\/\.]+)\.(.+)$/i.match(file_name)
129
129
  mres.nil? ? [file_name, ''] : [mres[1], mres[2]]
130
130
  end
131
-
@@ -35,7 +35,7 @@ namespace :slices do
35
35
  t.spec_opts = ["--format", "specdoc", "--colour"]
36
36
  if(ENV['REQUEST'])
37
37
  t.spec_files = Dir["#{slice_root}/spec/requests/**/#{ENV['REQUEST']}_spec.rb"].sort
38
- else
38
+ else
39
39
  t.spec_files = Dir["#{slice_root}/spec/requests/**/*_spec.rb"].sort
40
40
  end
41
41
  end
data/lib/merb-admin.rb CHANGED
@@ -9,7 +9,7 @@ if defined?(Merb::Plugins)
9
9
  Merb::Slices::register(__FILE__)
10
10
 
11
11
  # Slice configuration - set this in a before_app_loads callback.
12
- # By default a Slice uses its own layout, so you can swicht to
12
+ # By default a Slice uses its own layout, so you can swicht to
13
13
  # the main application layout or no layout at all if needed.
14
14
  #
15
15
  # Configuration options:
@@ -23,7 +23,7 @@ if defined?(Merb::Plugins)
23
23
 
24
24
  # Slice metadata
25
25
  self.description = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
26
- self.version = "0.5.1"
26
+ self.version = "0.5.2"
27
27
  self.author = "Erik Michaels-Ober"
28
28
 
29
29
  # Stub classes loaded hook - runs before LoadClasses BootLoader
@@ -92,7 +92,7 @@ var DateTimeShortcuts = {
92
92
  openClock: function(num) {
93
93
  var clock_box = document.getElementById(DateTimeShortcuts.clockDivName+num)
94
94
  var clock_link = document.getElementById(DateTimeShortcuts.clockLinkName+num)
95
-
95
+
96
96
  // Recalculate the clockbox position
97
97
  // is it left-to-right or right-to-left layout ?
98
98
  if (getStyle(document.body,'direction')!='rtl') {
@@ -106,7 +106,7 @@ var DateTimeShortcuts = {
106
106
  clock_box.style.left = findPosX(clock_link) - 110 + 'px';
107
107
  }
108
108
  clock_box.style.top = findPosY(clock_link) - 30 + 'px';
109
-
109
+
110
110
  // Show the clock box
111
111
  clock_box.style.display = 'block';
112
112
  addEvent(window.document, 'click', function() { DateTimeShortcuts.dismissClock(num); return true; });
@@ -208,7 +208,7 @@ var DateTimeShortcuts = {
208
208
  }
209
209
  }
210
210
 
211
-
211
+
212
212
  // Recalculate the clockbox position
213
213
  // is it left-to-right or right-to-left layout ?
214
214
  if (getStyle(document.body,'direction')!='rtl') {
@@ -222,7 +222,7 @@ var DateTimeShortcuts = {
222
222
  cal_box.style.left = findPosX(cal_link) - 180 + 'px';
223
223
  }
224
224
  cal_box.style.top = findPosY(cal_link) - 75 + 'px';
225
-
225
+
226
226
  cal_box.style.display = 'block';
227
227
  addEvent(window.document, 'click', function() { DateTimeShortcuts.dismissCalendar(num); return true; });
228
228
  },
@@ -13,7 +13,7 @@ function html_unescape(text) {
13
13
 
14
14
  // IE doesn't accept periods or dashes in the window name, but the element IDs
15
15
  // we use to generate popup window names may contain them, therefore we map them
16
- // to allowed characters in a reversible way so that we can locate the correct
16
+ // to allowed characters in a reversible way so that we can locate the correct
17
17
  // element when the popup window is dismissed.
18
18
  function id_to_windowname(text) {
19
19
  text = text.replace(/\./g, '__dot__');
@@ -25,7 +25,7 @@ var Actions = {
25
25
  tr.className += ' selected';
26
26
  } else if (!checked) {
27
27
  tr.className = tr.className.replace(' selected', '');
28
- }
28
+ }
29
29
  },
30
30
  checker: function(checked) {
31
31
  var actionCheckboxes = document.getElementsBySelector('tr input.action-select');
@@ -78,7 +78,7 @@ function findPosX(obj) {
78
78
  curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
79
79
  obj = obj.offsetParent;
80
80
  }
81
- // IE offsetParent does not include the top-level
81
+ // IE offsetParent does not include the top-level
82
82
  if (isIE && obj.parentElement){
83
83
  curleft += obj.offsetLeft - obj.scrollLeft;
84
84
  }
@@ -95,7 +95,7 @@ function findPosY(obj) {
95
95
  curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
96
96
  obj = obj.offsetParent;
97
97
  }
98
- // IE offsetParent does not include the top-level
98
+ // IE offsetParent does not include the top-level
99
99
  if (isIE && obj.parentElement){
100
100
  curtop += obj.offsetTop - obj.scrollTop;
101
101
  }
@@ -36,7 +36,7 @@ var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Satu
36
36
  an error if 0 or more than 1 matches
37
37
  */
38
38
  function parseMonth(month) {
39
- var matches = monthNames.filter(function(item) {
39
+ var matches = monthNames.filter(function(item) {
40
40
  return new RegExp("^" + month, "i").test(item);
41
41
  });
42
42
  if (matches.length == 0) {
@@ -61,22 +61,22 @@ function parseWeekday(weekday) {
61
61
  return weekdayNames.indexOf(matches[0]);
62
62
  }
63
63
 
64
- /* Array of objects, each has 're', a regular expression and 'handler', a
65
- function for creating a date from something that matches the regular
66
- expression. Handlers may throw errors if string is unparseable.
64
+ /* Array of objects, each has 're', a regular expression and 'handler', a
65
+ function for creating a date from something that matches the regular
66
+ expression. Handlers may throw errors if string is unparseable.
67
67
  */
68
68
  var dateParsePatterns = [
69
69
  // Today
70
70
  { re: /^tod/i,
71
- handler: function() {
71
+ handler: function() {
72
72
  return new Date();
73
- }
73
+ }
74
74
  },
75
75
  // Tomorrow
76
76
  { re: /^tom/i,
77
77
  handler: function() {
78
- var d = new Date();
79
- d.setDate(d.getDate() + 1);
78
+ var d = new Date();
79
+ d.setDate(d.getDate() + 1);
80
80
  return d;
81
81
  }
82
82
  },
@@ -89,7 +89,7 @@ var dateParsePatterns = [
89
89
  }
90
90
  },
91
91
  // 4th
92
- { re: /^(\d{1,2})(st|nd|rd|th)?$/i,
92
+ { re: /^(\d{1,2})(st|nd|rd|th)?$/i,
93
93
  handler: function(bits) {
94
94
  var d = new Date();
95
95
  d.setDate(parseInt(bits[1], 10));
@@ -97,7 +97,7 @@ var dateParsePatterns = [
97
97
  }
98
98
  },
99
99
  // 4th Jan
100
- { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i,
100
+ { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i,
101
101
  handler: function(bits) {
102
102
  var d = new Date();
103
103
  d.setDate(parseInt(bits[1], 10));
@@ -116,7 +116,7 @@ var dateParsePatterns = [
116
116
  }
117
117
  },
118
118
  // Jan 4th
119
- { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i,
119
+ { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i,
120
120
  handler: function(bits) {
121
121
  var d = new Date();
122
122
  d.setDate(parseInt(bits[2], 10));
@@ -209,7 +209,7 @@ function magicDate(input) {
209
209
  var messagespan = input.id + 'Msg';
210
210
  try {
211
211
  var d = parseDateString(input.value);
212
- input.value = d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' +
212
+ input.value = d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' +
213
213
  fmt00(d.getDate());
214
214
  input.className = '';
215
215
  // Human readable date
@@ -1,12 +1,12 @@
1
1
  /* document.getElementsBySelector(selector)
2
2
  - returns an array of element objects from the current document
3
- matching the CSS selector. Selectors can contain element names,
3
+ matching the CSS selector. Selectors can contain element names,
4
4
  class names and ids and can be nested. For example:
5
-
5
+
6
6
  elements = document.getElementsBySelect('div#main p a.external')
7
-
8
- Will return an array of all 'a' elements with 'external' in their
9
- class attribute that are contained inside 'p' elements that are
7
+
8
+ Will return an array of all 'a' elements with 'external' in their
9
+ class attribute that are contained inside 'p' elements that are
10
10
  contained inside the 'div' element which has id="main"
11
11
 
12
12
  New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
@@ -14,7 +14,7 @@
14
14
 
15
15
  Version 0.4 - Simon Willison, March 25th 2003
16
16
  -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
17
- -- Opera 7 fails
17
+ -- Opera 7 fails
18
18
  */
19
19
 
20
20
  function getAllChildren(e) {
@@ -112,7 +112,7 @@ document.getElementsBySelector = function(selector) {
112
112
  case '=': // Equality
113
113
  checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
114
114
  break;
115
- case '~': // Match one of space seperated words
115
+ case '~': // Match one of space seperated words
116
116
  checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
117
117
  break;
118
118
  case '|': // Match start with value followed by optional hyphen
@@ -156,12 +156,12 @@ document.getElementsBySelector = function(selector) {
156
156
  return currentContext;
157
157
  }
158
158
 
159
- /* That revolting regular expression explained
159
+ /* That revolting regular expression explained
160
160
  /^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
161
161
  \---/ \---/\-------------/ \-------/
162
162
  | | | |
163
163
  | | | The value
164
164
  | | ~,|,^,$,* or =
165
- | Attribute
165
+ | Attribute
166
166
  Tag
167
167
  */
@@ -57,10 +57,10 @@ p img, h1 img, h2 img, h3 img, h4 img, td img { vertical-align:middle; }
57
57
  table { border-collapse:collapse; border-color:#ccc; }
58
58
  td, th { font-size:11px; line-height:13px; border-bottom:1px solid #eee; vertical-align:top; padding:5px; font-family:"Lucida Grande", Verdana, Arial, sans-serif; }
59
59
  th { text-align:left; font-size:12px; font-weight:bold; }
60
- thead th,
60
+ thead th,
61
61
  tfoot td { color:#666; padding:2px 5px; font-size:11px; background:#e1e1e1 url(../images/nav-bg.gif) top left repeat-x; border-left:1px solid #ddd; border-bottom:1px solid #ddd; }
62
62
  tfoot td { border-bottom:none; border-top:1px solid #ddd; }
63
- thead th:first-child,
63
+ thead th:first-child,
64
64
  tfoot td:first-child { border-left:none !important; }
65
65
  thead th.optional { font-weight:normal !important; }
66
66
  fieldset table { border-right:1px solid #eee; }
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe MerbAdmin::Main do
3
+ describe MerbAdmin::Main do
4
4
 
5
5
  before(:each) do
6
6
  mount_slice
@@ -1,6 +1,6 @@
1
1
  class Draft
2
2
  include DataMapper::Resource
3
-
3
+
4
4
  property :id, Serial
5
5
  property :created_at, DateTime
6
6
  property :updated_at, DateTime
@@ -1,11 +1,11 @@
1
1
  class League
2
2
  include DataMapper::Resource
3
-
3
+
4
4
  property :id, Serial
5
5
  property :created_at, DateTime
6
6
  property :updated_at, DateTime
7
7
  property :name, String, :nullable => false, :index => true
8
-
8
+
9
9
  has n, :divisions
10
10
  has n, :teams
11
11
  end
@@ -18,7 +18,7 @@ end
18
18
  given "three teams exist" do
19
19
  @teams = []
20
20
  3.times do |i|
21
- @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{i + 1}", :manager => "Manager #{i + 1}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => "%.3f" % (wins.to_f / 162))
21
+ @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{i + 1}", :manager => "Manager #{i + 1}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
22
22
  end
23
23
  end
24
24
 
@@ -31,7 +31,7 @@ given "a player exists and three teams exist" do
31
31
  @player = MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 1, :name => "Player 1")
32
32
  @teams = []
33
33
  3.times do |i|
34
- @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{i + 1}", :manager => "Manager #{i + 1}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => "%.3f" % (wins.to_f / 162))
34
+ @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{i + 1}", :manager => "Manager #{i + 1}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
35
35
  end
36
36
  end
37
37
 
@@ -39,7 +39,7 @@ given "a league exists and three teams exist" do
39
39
  @league = League.create(:name => "League 1")
40
40
  @teams = []
41
41
  3.times do |i|
42
- @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{i + 1}", :manager => "Manager #{i + 1}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => "%.3f" % (wins.to_f / 162))
42
+ @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{i + 1}", :manager => "Manager #{i + 1}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
43
43
  end
44
44
  end
45
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober