bowtie 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/bowtie.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{bowtie}
3
- s.version = "0.5.7"
3
+ s.version = "0.5.8"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Tomás Pollak"]
@@ -135,22 +135,12 @@ module DataMapper::Resource
135
135
  send(self.class.primary_key)
136
136
  end
137
137
 
138
- def to_json
139
- attributes.to_json
140
- end
141
-
142
- end
143
-
144
- if Bowtie.models.empty? # models not loaded yet
138
+ unless defined?(:to_json)
145
139
 
146
- class Class # need to figure out how to extend *only* DM models
147
- include Bowtie::ClassMethods
148
- end
149
-
150
- else
140
+ def to_json
141
+ attributes.to_json
142
+ end
151
143
 
152
- Bowtie.models.each do |mod|
153
- mod.extend Bowtie::ClassMethods
154
144
  end
155
145
 
156
146
  end
@@ -128,21 +128,3 @@ module MongoMapper::Document
128
128
  end
129
129
 
130
130
  end
131
-
132
- if Bowtie.models.empty? # models not loaded yet
133
-
134
- module MongoMapper::Document
135
-
136
- included do
137
- extend Bowtie::ClassMethods
138
- end
139
-
140
- end
141
-
142
- else
143
-
144
- Bowtie.models.each do |mod|
145
- mod.extend Bowtie::ClassMethods
146
- end
147
-
148
- end
data/lib/bowtie/admin.rb CHANGED
@@ -74,10 +74,12 @@ module Bowtie
74
74
 
75
75
  if res.is_a?(Array)
76
76
  @model = res.first.class
77
+ @model.extend(ClassMethods) unless @model.respond_to?(:model_associations)
77
78
  @resources = Bowtie.add_paging(res, params[:page])
78
79
  erb :index
79
80
  else
80
81
  @model = res.class
82
+ @model.extend(ClassMethods) unless @model.respond_to?(:model_associations)
81
83
  @resource = res
82
84
  erb :show
83
85
  end
@@ -11,7 +11,7 @@ module Bowtie
11
11
  end
12
12
 
13
13
  def action_name
14
- current_model.pluralize
14
+ model.pluralize
15
15
  end
16
16
 
17
17
  def base_path
@@ -30,7 +30,7 @@ module Bowtie
30
30
  def redirect(uri, *args)
31
31
  super base_path + uri.downcase, *args
32
32
  end
33
-
33
+
34
34
  def referer
35
35
  URI.parse(@env['HTTP_REFERER']).path.sub("#{base_path}", '')
36
36
  end
@@ -52,17 +52,15 @@ module Bowtie
52
52
  end
53
53
 
54
54
  def get_model_class(mod = params[:model])
55
- mappings[mod] or halt(404, "Model not found.")
55
+ m = mappings[mod] or halt(404, "Model not found.")
56
+ m.extend(ClassMethods) unless m.respond_to?(:model_associations)
57
+ m
56
58
  end
57
59
 
58
60
  def model
59
61
  @model ||= get_model_class
60
62
  end
61
63
 
62
- def current_model
63
- model
64
- end
65
-
66
64
  def resource
67
65
  Bowtie.get_one(model, params[:id]) or halt(404, 'Resource not found!')
68
66
  end
@@ -73,7 +71,7 @@ module Bowtie
73
71
  erb(name, {:layout => false}, *args)
74
72
  end
75
73
 
76
- def model_path(m = current_model)
74
+ def model_path(m = model)
77
75
  string = m.name ||= m
78
76
  linkable_path(string.to_s.pluralize.downcase)
79
77
  end
@@ -11,6 +11,11 @@ var Bowtie = {
11
11
  $('table td.editable').data('disabled.editable', true);
12
12
  html = 'Edit Mode OFF';
13
13
 
14
+ $('table td.editable').each(function(i, e){
15
+ if($(e).html() == '<em>(edit)</em>')
16
+ $(e).html('');
17
+ })
18
+
14
19
  } else {
15
20
 
16
21
  if ($('table td.editable').data('disabled.editable'))
@@ -4,7 +4,7 @@
4
4
 
5
5
  <ul>
6
6
  <% @resource.errors.each do |key, message| %>
7
- <li><strong><%= key %></strong> <%= ":#{message}" if message %></li>
7
+ <li><strong><%= key %></strong><%= ": #{message}" if message %></li>
8
8
  <% end %>
9
9
  </ul>
10
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowtie
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 7
10
- version: 0.5.7
9
+ - 8
10
+ version: 0.5.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Tom\xC3\xA1s Pollak"
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-18 00:00:00 -04:00
19
- default_executable:
18
+ date: 2012-04-18 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: sinatra
@@ -70,7 +69,6 @@ files:
70
69
  - lib/bowtie/public/js/bowtie.js
71
70
  - lib/bowtie/public/js/jquery.tablesorter.pack.js
72
71
  - lib/bowtie/public/js/jquery.jeditable.pack.js
73
- has_rdoc: true
74
72
  homepage: http://github.com/tomas/bowtie
75
73
  licenses: []
76
74
 
@@ -106,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
104
  requirements: []
107
105
 
108
106
  rubyforge_project: bowtie
109
- rubygems_version: 1.5.2
107
+ rubygems_version: 1.8.21
110
108
  signing_key:
111
109
  specification_version: 3
112
110
  summary: MongoMapper & DataMapper admin interface