neuron 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,8 @@ module Neuron
20
20
  module ClassMethods
21
21
  def resources(options = {})
22
22
  options = Neuron::Resources.default_options.merge(options)
23
+ options[:order] = {} if options[:order] == true
24
+ options[:paginate] = {} if options[:paginate] == true
23
25
 
24
26
  unless respond_to?(:resource_options)
25
27
  class_attribute :resource_options
@@ -30,15 +32,11 @@ module Neuron
30
32
  inherit_resources
31
33
  append_neuron_view_path_resolver
32
34
 
33
- if options[:order] == true
34
- order_scopes
35
- elsif options[:order]
35
+ if options[:order]
36
36
  order_scopes(options[:order])
37
37
  end
38
38
 
39
- if options[:paginate] == true
40
- paginate_scope
41
- elsif options[:paginate]
39
+ if options[:paginate]
42
40
  paginate_scope(options[:paginate])
43
41
  end
44
42
 
@@ -104,12 +102,14 @@ module Neuron
104
102
  options[:class] ||= resource_class
105
103
  options[:by] = options[:by].to_sym
106
104
  options[:as] ||= human(options[:class], options[:by])
107
- html_options[:title] ||= human(options[:class], options[:by])
108
105
  asc_orders = Array(params[:ascending]).map(&:to_sym)
109
106
  desc_orders = Array(params[:descending]).map(&:to_sym)
110
107
  ascending = asc_orders.include?(options[:by])
111
108
  selected = ascending || desc_orders.include?(options[:by])
112
109
  new_scope = ascending ? :descending : :ascending
110
+ html_options[:title] ||= human(options[:class], options[:by])
111
+ html_options['data-order-by'] = options[:by]
112
+ html_options['data-order-direction'] = new_scope
113
113
  url_options = {page: params[:page]}
114
114
  url_options[new_scope] = [options[:by]]
115
115
 
@@ -1,3 +1,3 @@
1
1
  module Neuron
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
data/lib/neuron/view.rb CHANGED
@@ -52,6 +52,19 @@ module Neuron
52
52
  canonical_url(resource, options.merge(routing_type: :path))
53
53
  end
54
54
 
55
+ def canonical_link(resource = nil, options = {})
56
+ href = case resource
57
+ when Hash
58
+ url_for(resource)
59
+ when NilClass
60
+ request.request_uri.split('?').first
61
+ else
62
+ canonical_url(resource, options)
63
+ end
64
+ href = "#{request.protocol}#{request.host_with_port}#{href}" unless href =~ /^\w+:\/\//
65
+ tag(:link, rel: 'canonical', href: href)
66
+ end
67
+
55
68
  def view_name
56
69
  {create: 'new', update: 'edit'}[action_name] || action_name
57
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neuron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
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: 2011-06-19 00:00:00.000000000Z
12
+ date: 2011-06-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &87579960 !ruby/object:Gem::Requirement
16
+ requirement: &81592100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *87579960
24
+ version_requirements: *81592100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &87579580 !ruby/object:Gem::Requirement
27
+ requirement: &81591240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *87579580
35
+ version_requirements: *81591240
36
36
  description: Code reused in many applications
37
37
  email:
38
38
  - al@semyonov.us
@@ -79,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  segments:
81
81
  - 0
82
- hash: -924094847
82
+ hash: 180076915
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  segments:
90
90
  - 0
91
- hash: -924094847
91
+ hash: 180076915
92
92
  requirements: []
93
93
  rubyforge_project: neuron
94
94
  rubygems_version: 1.8.5