searchlogic 1.6.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG.rdoc +17 -0
  3. data/{MIT-LICENSE → LICENSE} +2 -2
  4. data/README.rdoc +128 -379
  5. data/Rakefile +56 -20
  6. data/VERSION.yml +4 -0
  7. data/init.rb +1 -1
  8. data/lib/searchlogic.rb +18 -98
  9. data/lib/searchlogic/core_ext/object.rb +33 -13
  10. data/lib/searchlogic/core_ext/proc.rb +11 -0
  11. data/lib/searchlogic/named_scopes/alias_scope.rb +63 -0
  12. data/lib/searchlogic/named_scopes/associations.rb +126 -0
  13. data/lib/searchlogic/named_scopes/conditions.rb +215 -0
  14. data/lib/searchlogic/named_scopes/ordering.rb +53 -0
  15. data/lib/searchlogic/rails_helpers.rb +69 -0
  16. data/lib/searchlogic/search.rb +146 -0
  17. data/rails/init.rb +1 -0
  18. data/searchlogic.gemspec +69 -0
  19. data/spec/core_ext/object_spec.rb +7 -0
  20. data/spec/core_ext/proc_spec.rb +9 -0
  21. data/spec/named_scopes/alias_scope_spec.rb +15 -0
  22. data/spec/named_scopes/associations_spec.rb +120 -0
  23. data/spec/named_scopes/conditions_spec.rb +253 -0
  24. data/spec/named_scopes/ordering_spec.rb +23 -0
  25. data/spec/search_spec.rb +283 -0
  26. data/spec/spec_helper.rb +78 -0
  27. metadata +40 -231
  28. data/Manifest.txt +0 -158
  29. data/TODO.rdoc +0 -4
  30. data/lib/searchlogic/active_record/associations.rb +0 -52
  31. data/lib/searchlogic/active_record/base.rb +0 -224
  32. data/lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb +0 -176
  33. data/lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb +0 -172
  34. data/lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb +0 -80
  35. data/lib/searchlogic/condition/base.rb +0 -165
  36. data/lib/searchlogic/condition/begins_with.rb +0 -17
  37. data/lib/searchlogic/condition/blank.rb +0 -24
  38. data/lib/searchlogic/condition/child_of.rb +0 -11
  39. data/lib/searchlogic/condition/descendant_of.rb +0 -11
  40. data/lib/searchlogic/condition/ends_with.rb +0 -17
  41. data/lib/searchlogic/condition/equals.rb +0 -33
  42. data/lib/searchlogic/condition/greater_than.rb +0 -15
  43. data/lib/searchlogic/condition/greater_than_or_equal_to.rb +0 -15
  44. data/lib/searchlogic/condition/inclusive_descendant_of.rb +0 -10
  45. data/lib/searchlogic/condition/keywords.rb +0 -52
  46. data/lib/searchlogic/condition/less_than.rb +0 -15
  47. data/lib/searchlogic/condition/less_than_or_equal_to.rb +0 -15
  48. data/lib/searchlogic/condition/like.rb +0 -15
  49. data/lib/searchlogic/condition/nested_set.rb +0 -17
  50. data/lib/searchlogic/condition/nil.rb +0 -21
  51. data/lib/searchlogic/condition/not_begin_with.rb +0 -20
  52. data/lib/searchlogic/condition/not_blank.rb +0 -19
  53. data/lib/searchlogic/condition/not_end_with.rb +0 -20
  54. data/lib/searchlogic/condition/not_equal.rb +0 -27
  55. data/lib/searchlogic/condition/not_have_keywords.rb +0 -20
  56. data/lib/searchlogic/condition/not_like.rb +0 -20
  57. data/lib/searchlogic/condition/not_nil.rb +0 -19
  58. data/lib/searchlogic/condition/sibling_of.rb +0 -14
  59. data/lib/searchlogic/conditions/any_or_all.rb +0 -42
  60. data/lib/searchlogic/conditions/base.rb +0 -244
  61. data/lib/searchlogic/conditions/groups.rb +0 -74
  62. data/lib/searchlogic/conditions/magic_methods.rb +0 -286
  63. data/lib/searchlogic/conditions/multiparameter_attributes.rb +0 -105
  64. data/lib/searchlogic/conditions/protection.rb +0 -36
  65. data/lib/searchlogic/config.rb +0 -31
  66. data/lib/searchlogic/config/helpers.rb +0 -338
  67. data/lib/searchlogic/config/search.rb +0 -53
  68. data/lib/searchlogic/core_ext/hash.rb +0 -75
  69. data/lib/searchlogic/helpers/control_types/link.rb +0 -310
  70. data/lib/searchlogic/helpers/control_types/links.rb +0 -242
  71. data/lib/searchlogic/helpers/control_types/remote_link.rb +0 -87
  72. data/lib/searchlogic/helpers/control_types/remote_links.rb +0 -72
  73. data/lib/searchlogic/helpers/control_types/remote_select.rb +0 -36
  74. data/lib/searchlogic/helpers/control_types/select.rb +0 -82
  75. data/lib/searchlogic/helpers/form.rb +0 -208
  76. data/lib/searchlogic/helpers/utilities.rb +0 -197
  77. data/lib/searchlogic/modifiers/absolute.rb +0 -15
  78. data/lib/searchlogic/modifiers/acos.rb +0 -11
  79. data/lib/searchlogic/modifiers/asin.rb +0 -11
  80. data/lib/searchlogic/modifiers/atan.rb +0 -11
  81. data/lib/searchlogic/modifiers/avg.rb +0 -15
  82. data/lib/searchlogic/modifiers/base.rb +0 -27
  83. data/lib/searchlogic/modifiers/ceil.rb +0 -15
  84. data/lib/searchlogic/modifiers/char_length.rb +0 -15
  85. data/lib/searchlogic/modifiers/cos.rb +0 -15
  86. data/lib/searchlogic/modifiers/cot.rb +0 -15
  87. data/lib/searchlogic/modifiers/count.rb +0 -11
  88. data/lib/searchlogic/modifiers/day_of_month.rb +0 -15
  89. data/lib/searchlogic/modifiers/day_of_week.rb +0 -15
  90. data/lib/searchlogic/modifiers/day_of_year.rb +0 -15
  91. data/lib/searchlogic/modifiers/degrees.rb +0 -11
  92. data/lib/searchlogic/modifiers/exp.rb +0 -15
  93. data/lib/searchlogic/modifiers/floor.rb +0 -15
  94. data/lib/searchlogic/modifiers/hex.rb +0 -11
  95. data/lib/searchlogic/modifiers/hour.rb +0 -11
  96. data/lib/searchlogic/modifiers/log.rb +0 -15
  97. data/lib/searchlogic/modifiers/log10.rb +0 -11
  98. data/lib/searchlogic/modifiers/log2.rb +0 -11
  99. data/lib/searchlogic/modifiers/lower.rb +0 -15
  100. data/lib/searchlogic/modifiers/ltrim.rb +0 -15
  101. data/lib/searchlogic/modifiers/md5.rb +0 -11
  102. data/lib/searchlogic/modifiers/microseconds.rb +0 -11
  103. data/lib/searchlogic/modifiers/milliseconds.rb +0 -11
  104. data/lib/searchlogic/modifiers/minute.rb +0 -15
  105. data/lib/searchlogic/modifiers/month.rb +0 -15
  106. data/lib/searchlogic/modifiers/octal.rb +0 -15
  107. data/lib/searchlogic/modifiers/radians.rb +0 -11
  108. data/lib/searchlogic/modifiers/round.rb +0 -11
  109. data/lib/searchlogic/modifiers/rtrim.rb +0 -15
  110. data/lib/searchlogic/modifiers/second.rb +0 -15
  111. data/lib/searchlogic/modifiers/sign.rb +0 -11
  112. data/lib/searchlogic/modifiers/sin.rb +0 -11
  113. data/lib/searchlogic/modifiers/square_root.rb +0 -15
  114. data/lib/searchlogic/modifiers/sum.rb +0 -11
  115. data/lib/searchlogic/modifiers/tan.rb +0 -15
  116. data/lib/searchlogic/modifiers/trim.rb +0 -15
  117. data/lib/searchlogic/modifiers/upper.rb +0 -15
  118. data/lib/searchlogic/modifiers/week.rb +0 -11
  119. data/lib/searchlogic/modifiers/year.rb +0 -11
  120. data/lib/searchlogic/search/base.rb +0 -148
  121. data/lib/searchlogic/search/conditions.rb +0 -53
  122. data/lib/searchlogic/search/ordering.rb +0 -244
  123. data/lib/searchlogic/search/pagination.rb +0 -121
  124. data/lib/searchlogic/search/protection.rb +0 -89
  125. data/lib/searchlogic/search/searching.rb +0 -32
  126. data/lib/searchlogic/shared/utilities.rb +0 -57
  127. data/lib/searchlogic/shared/virtual_classes.rb +0 -39
  128. data/lib/searchlogic/version.rb +0 -79
  129. data/test/active_record_tests/associations_test.rb +0 -94
  130. data/test/active_record_tests/base_test.rb +0 -115
  131. data/test/condition_tests/base_test.rb +0 -62
  132. data/test/condition_tests/begins_with_test.rb +0 -11
  133. data/test/condition_tests/blank_test.rb +0 -31
  134. data/test/condition_tests/child_of_test.rb +0 -17
  135. data/test/condition_tests/descendant_of_test.rb +0 -12
  136. data/test/condition_tests/ends_with_test.rb +0 -11
  137. data/test/condition_tests/equals_test.rb +0 -28
  138. data/test/condition_tests/greater_than_or_equal_to_test.rb +0 -11
  139. data/test/condition_tests/greater_than_test.rb +0 -11
  140. data/test/condition_tests/inclusive_descendant_of_test.rb +0 -12
  141. data/test/condition_tests/keywords_test.rb +0 -23
  142. data/test/condition_tests/less_than_or_equal_to_test.rb +0 -11
  143. data/test/condition_tests/less_than_test.rb +0 -11
  144. data/test/condition_tests/like_test.rb +0 -11
  145. data/test/condition_tests/nil_test.rb +0 -31
  146. data/test/condition_tests/not_begin_with_test.rb +0 -8
  147. data/test/condition_tests/not_blank_test.rb +0 -8
  148. data/test/condition_tests/not_end_with_test.rb +0 -8
  149. data/test/condition_tests/not_equal_test.rb +0 -19
  150. data/test/condition_tests/not_have_keywords_test.rb +0 -8
  151. data/test/condition_tests/not_like_test.rb +0 -8
  152. data/test/condition_tests/not_nil_test.rb +0 -13
  153. data/test/condition_tests/sibling_of_test.rb +0 -15
  154. data/test/conditions_tests/any_or_all_test.rb +0 -23
  155. data/test/conditions_tests/base_test.rb +0 -185
  156. data/test/conditions_tests/groups_test.rb +0 -68
  157. data/test/conditions_tests/magic_methods_test.rb +0 -36
  158. data/test/conditions_tests/multiparameter_attributes_test.rb +0 -15
  159. data/test/conditions_tests/protection_test.rb +0 -18
  160. data/test/config_test.rb +0 -23
  161. data/test/fixtures/accounts.yml +0 -12
  162. data/test/fixtures/animals.yml +0 -7
  163. data/test/fixtures/orders.yml +0 -12
  164. data/test/fixtures/user_groups.yml +0 -5
  165. data/test/fixtures/users.yml +0 -45
  166. data/test/libs/awesome_nested_set.rb +0 -545
  167. data/test/libs/awesome_nested_set/.autotest +0 -13
  168. data/test/libs/awesome_nested_set/compatability.rb +0 -29
  169. data/test/libs/awesome_nested_set/helper.rb +0 -40
  170. data/test/libs/awesome_nested_set/named_scope.rb +0 -140
  171. data/test/libs/rexml_fix.rb +0 -14
  172. data/test/modifier_tests/day_of_month_test.rb +0 -16
  173. data/test/search_tests/base_test.rb +0 -241
  174. data/test/search_tests/conditions_test.rb +0 -21
  175. data/test/search_tests/ordering_test.rb +0 -167
  176. data/test/search_tests/pagination_test.rb +0 -74
  177. data/test/search_tests/protection_test.rb +0 -26
  178. data/test/test_helper.rb +0 -122
@@ -1,105 +0,0 @@
1
- module Searchlogic
2
- module Conditions
3
- # = Multiparameter Attributes
4
- #
5
- # This code is largely copied over from ActiveRecord, so that we can handle the date_select and datetime_select helpers.
6
- # One option would be to instantiate a new ActiveRecord object, pass the attributes to it, then get the field value. This
7
- # would not be smart for performance because there is a lot going on there that we don't need, such as instantiating an entirely
8
- # new object. ActiveRecord gives us no other way to use the code, so the only other option is to copy over the methods that handle this.
9
- # This ultimately results in better performance.
10
- module MultiparameterAttributes
11
- def self.included(klass)
12
- klass.class_eval do
13
- alias_method_chain :conditions=, :multiparameter_attributes
14
- end
15
- end
16
-
17
- def conditions_with_multiparameter_attributes=(attributes)
18
- if attributes.is_a?(Hash)
19
- multiparameter_attributes = []
20
- clean_attributes = {}
21
- attributes.each do |k,v|
22
- if k.to_s.include?("(")
23
- multiparameter_attributes << [k, v]
24
- else
25
- clean_attributes[k] = v
26
- end
27
- end
28
-
29
- attributes = clean_attributes.merge(convert_multiparameter_attributes(multiparameter_attributes))
30
- end
31
-
32
- self.conditions_without_multiparameter_attributes = attributes
33
- end
34
-
35
- private
36
- def instantiate_time_object(name, values)
37
- if klass.respond_to?(:create_time_zone_conversion_attribute, true) && klass.send(:create_time_zone_conversion_attribute?, name, column_for_attribute(name))
38
- Time.zone.local(*values)
39
- else
40
- Time.time_with_datetime_fallback(klass.default_timezone, *values)
41
- end
42
- end
43
-
44
- def convert_multiparameter_attributes(pairs)
45
- convert_callstack_for_multiparameter_attributes(
46
- extract_callstack_for_multiparameter_attributes(pairs)
47
- )
48
- end
49
-
50
- def convert_callstack_for_multiparameter_attributes(callstack)
51
- r = {}
52
- callstack.each do |name, values|
53
- date_klass = send("#{name}_object").column_for_type_cast.klass
54
- if values.empty?
55
- r[name] = nil
56
- else
57
- begin
58
- value = if Time == date_klass
59
- instantiate_time_object(name, values)
60
- elsif Date == date_klass
61
- begin
62
- Date.new(*values)
63
- rescue ArgumentError => ex # if Date.new raises an exception on an invalid date
64
- instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
65
- end
66
- else
67
- date_klass.new(*values)
68
- end
69
-
70
- r[name] = value
71
- rescue => ex
72
- raise ArgumentError.new("error on assignment #{values.inspect} to #{name}")
73
- end
74
- end
75
- end
76
- r
77
- end
78
-
79
- def extract_callstack_for_multiparameter_attributes(pairs)
80
- attributes = { }
81
-
82
- for pair in pairs
83
- multiparameter_name, value = pair
84
- attribute_name = multiparameter_name.split("(").first
85
- attributes[attribute_name] = [] unless attributes.include?(attribute_name)
86
-
87
- unless value.empty?
88
- attributes[attribute_name] <<
89
- [ find_parameter_position(multiparameter_name), type_cast_attribute_value(multiparameter_name, value) ]
90
- end
91
- end
92
-
93
- attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } }
94
- end
95
-
96
- def type_cast_attribute_value(multiparameter_name, value)
97
- multiparameter_name =~ /\([0-9]*([a-z])\)/ ? value.send("to_" + $1) : value
98
- end
99
-
100
- def find_parameter_position(multiparameter_name)
101
- multiparameter_name.scan(/\(([0-9]*).*\)/).first.first
102
- end
103
- end
104
- end
105
- end
@@ -1,36 +0,0 @@
1
- module Searchlogic
2
- module Conditions
3
- # = Conditions Protection
4
- #
5
- # Adds protection from SQL injections. Just set protect = true and it will limit what kind of conditions it will accept.
6
- module Protection
7
- def self.included(klass)
8
- klass.class_eval do
9
- attr_reader :protect
10
- alias_method_chain :conditions=, :protection
11
- end
12
- end
13
-
14
- def conditions_with_protection=(conditions)
15
- unless conditions.is_a?(Hash)
16
- if protect?
17
- return if conditions.blank?
18
- raise(ArgumentError, "You can not pass SQL as conditions while the search is being protected, you can only pass a hash")
19
- end
20
- end
21
-
22
- self.conditions_without_protection = conditions
23
- end
24
-
25
- def protect=(value)
26
- association_objects.each { |obj| obj.protect = value }
27
- @protect = value
28
- end
29
-
30
- def protect?
31
- protect == true
32
- end
33
- alias_method :protected?, :protect?
34
- end
35
- end
36
- end
@@ -1,31 +0,0 @@
1
- module Searchlogic
2
- # = Config
3
- # Adds default configuration for all of searchlogic. For rails the best place to do this is in config/initializers. Create a file in there called searchlogic.rb with the following content:
4
- #
5
- # === Example
6
- #
7
- # # config/iniitializers/searchlogic.rb
8
- # Searchlogic::Config.configure do |config|
9
- # config.search.per_page = 25
10
- # config.helpers.order_by_link_asc_indicator = "My indicator"
11
- # end
12
- #
13
- # For a list of all configuration options see Searchlogic::Config::Search and Searchlogic::Config::Helpers
14
- class Config
15
- class << self
16
- # Convenience method for setting configuration
17
- # See example at top of class.
18
- def configure
19
- yield self
20
- end
21
-
22
- def search # :nodoc:
23
- Search
24
- end
25
-
26
- def helpers # :nodoc:
27
- Helpers
28
- end
29
- end
30
- end
31
- end
@@ -1,338 +0,0 @@
1
- module Searchlogic
2
- class Config
3
- # = Helpers Configuration
4
- # Provide configuration for searchlogic's rails helpers
5
- #
6
- # === Example
7
- # Searchlogic::Config.configure do |config|
8
- # config.helpers.order_by_link_asc_indicator = "ASC"
9
- # end
10
- class Helpers
11
- class << self
12
- # Which hidden fields to automatically include when creating a form with a Searchlogic object. See Searchlogic::Helpers::Form for more info.
13
- #
14
- # * <tt>Default:</tt> [:order_by, :order_as, :priority_order_by, :priority_order_as, :per_page]
15
- # * <tt>Accepts:</tt> Array, nil, false
16
- def hidden_fields
17
- @hidden_fields ||= (Searchlogic::Search::Base::SPECIAL_FIND_OPTIONS - [:page, :priority_order])
18
- end
19
- attr_writer :hidden_fields
20
-
21
- # Searchlogic does some javascript magic when you use the form helpers with a Searchlogic object. To make configuration easier Searchlogic checks for the existence of Prototype and jQuery and uses the first
22
- # one it finds. To cut back on the javascript output you can specify your library here.
23
- #
24
- # * <tt>Default:</tt> nil
25
- # * <tt>Accepts:</tt> :prototype or :jquery
26
- def javascript_library
27
- @javascript_library
28
- end
29
- attr_writer :javascript_library
30
-
31
- # The class name for used in the order_as_link helper
32
- #
33
- # * <tt>Default:</tt> "order_as"
34
- # * <tt>Accepts:</tt> String, set to nil to disable
35
- def order_as_link_class_name
36
- return @order_as_link_class_name if defined?(@order_as_link_class_name)
37
- @order_as_link_class_name = "order_as"
38
- end
39
- attr_writer :order_as_link_class_name
40
-
41
- # The class name for used in the order_as_select helper
42
- #
43
- # * <tt>Default:</tt> "order_as"
44
- # * <tt>Accepts:</tt> String, set to nil to disable
45
- def order_as_select_class_name
46
- return @order_as_select_class_name if defined?(@order_as_select_class_name)
47
- @order_as_select_class_name = "order_as"
48
- end
49
- attr_writer :order_as_select_class_name
50
-
51
- # The indicator that is used when the sort of a column is ascending
52
- #
53
- # * <tt>Default:</tt> &nbsp;&#9650;
54
- # * <tt>Accepts:</tt> String or a Proc.
55
- #
56
- # === Examples
57
- #
58
- # config.asc_indicator = "(ASC)"
59
- # config.asc_indicator = Proc.new { |template| template.image_tag("asc.jpg") }
60
- def order_by_link_asc_indicator
61
- @order_by_link_asc_indicator ||= "&nbsp;&#9650;"
62
- end
63
- attr_writer :order_by_link_asc_indicator
64
-
65
- # The class name for used in the order_by_link helper
66
- #
67
- # * <tt>Default:</tt> "order_by"
68
- # * <tt>Accepts:</tt> String, set to nil to disable
69
- def order_by_link_class_name
70
- return @order_by_link_class_name if defined?(@order_by_link_class_name)
71
- @order_by_link_class_name = "order_by"
72
- end
73
- attr_writer :order_by_link_class_name
74
-
75
- # See order_by_link_asc_indicator=
76
- def order_by_link_desc_indicator
77
- @order_by_link_desc_indicator ||= "&nbsp;&#9660;"
78
- end
79
- attr_writer :order_by_link_desc_indicator
80
-
81
- # The class name used in order_by_links for the link that it is currently ordering by
82
- #
83
- # * <tt>Default:</tt> "# The class name for used in the page_link helper
84
- #
85
- # * <tt>Default:</tt> "page"
86
- # * <tt>Accepts:</tt> String, set to nil to disable
87
- def order_by_links_ordering_by_class_name
88
- return @order_by_links_ordering_by_class_name if defined?(@order_by_links_ordering_by_class_name)
89
- @order_by_links_ordering_by_class_name = "ordering_by"
90
- end
91
- attr_writer :order_by_links_ordering_by_class_name
92
-
93
- # The class name for used in the order_by_select helper
94
- #
95
- # * <tt>Default:</tt> "order_by"
96
- # * <tt>Accepts:</tt> String
97
- def order_by_select_class_name
98
- @order_by_select_class_name ||= "order_by"
99
- end
100
- attr_writer :order_by_select_class_name
101
-
102
- # Makes page_links look just like the output of will_paginate.
103
- #
104
- # * <tt>Default:</tt> false
105
- # * <tt>Accepts:</tt> Boolean
106
- def page_links_act_like_will_paginate
107
- @page_links_act_like_will_paginate ||= false
108
- end
109
- attr_writer :page_links_act_like_will_paginate
110
-
111
- # Convenience methods for determining if page_links_act_like_will_paginate is set to true
112
- def page_links_act_like_will_paginate?
113
- page_links_act_like_will_paginate == true
114
- end
115
-
116
- # The class name for used in the page_link helper
117
- #
118
- # * <tt>Default:</tt> "page"
119
- # * <tt>Accepts:</tt> String, set to nil to disable
120
- def page_link_class_name
121
- return @page_link_class_name if defined?(@page_link_class_name)
122
- @page_link_class_name = "page"
123
- end
124
- attr_writer :page_link_class_name
125
-
126
- # The choices used in the per_page_links helper. Works just like per_page_select_choices.
127
- def per_page_links_choices
128
- @per_page_links_choices ||= per_page_select_choices
129
- end
130
- attr_writer :per_page_links_choices
131
-
132
- # The class that the current page link gets.
133
- #
134
- # * <tt>Default:</tt> "current_page"
135
- # * <tt>Accepts:</tt> String, set to nil to disable
136
- def page_links_current_page_class_name
137
- return @page_links_current_page_class_name if defined?(@page_links_current_page_class_name)
138
- @page_links_current_page_class_name = page_links_act_like_will_paginate? ? "current" : "current_page"
139
- end
140
- attr_writer :page_links_current_page_class_name
141
-
142
- # The class that disabled page links get. Including the current page, prev page, next page, first page, and last page.
143
- #
144
- # * <tt>Default:</tt> "disabled_page"
145
- # * <tt>Accepts:</tt> String, set to nil to disable
146
- def page_links_disabled_class_name
147
- return @page_links_disabled_class_name if defined?(@page_links_disabled_class_name)
148
- @page_links_disabled_class_name = page_links_act_like_will_paginate? ? "disabled" : "disabled_page"
149
- end
150
- attr_writer :page_links_disabled_class_name
151
-
152
- # Wraps page links in a div
153
- #
154
- # * <tt>Default:</tt> false
155
- # * <tt>Accepts:</tt> Boolean
156
- def page_links_div_wrapper
157
- return @page_links_div_wrapper if defined?(@page_links_div_wrapper)
158
- @page_links_div_wrapper = page_links_act_like_will_paginate?
159
- end
160
- attr_writer :page_links_div_wrapper
161
-
162
- # If page_links_div_wrapper is true you can specify a class name here.
163
- #
164
- # * <tt>Default:</tt> "pagination"
165
- # * <tt>Accepts:</tt> String, set to nil to disable
166
- def page_links_div_wrapper_class_name
167
- return @page_links_div_wrapper_class_name if defined?(@page_links_div_wrapper_class_name)
168
- @page_links_div_wrapper_class_name = "pagination"
169
- end
170
- attr_writer :page_links_div_wrapper_class_name
171
-
172
- # The default for the :first option for the page_links helper.
173
- #
174
- # * <tt>Default:</tt> nil
175
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
176
- def page_links_first
177
- @page_links_first
178
- end
179
- attr_writer :page_links_first
180
-
181
- # The default for the :inner_spread option for the page_links helper.
182
- #
183
- # * <tt>Default:</tt> 3
184
- # * <tt>Accepts:</tt> Any integer >= 1, set to nil to show all pages
185
- def page_links_inner_spread
186
- @page_links_inner_spread ||= 3
187
- end
188
- attr_writer :page_links_inner_spread
189
-
190
- # The class for the first page link
191
- #
192
- # * <tt>Default:</tt> "first_page"
193
- # * <tt>Accepts:</tt> String, set to nil to disable
194
- def page_links_first_page_class_name
195
- return @page_links_first_page_class_name if defined?(@page_links_first_page_class_name)
196
- @page_links_first_page_class_name = "first_page"
197
- end
198
- attr_writer :page_links_first_page_class_name
199
-
200
- # The default for the :last option for the page_links helper.
201
- #
202
- # * <tt>Default:</tt> nil
203
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
204
- def page_links_last
205
- @page_links_last
206
- end
207
- attr_writer :page_links_last
208
-
209
- # The class for the last page link
210
- #
211
- # * <tt>Default:</tt> "last_page"
212
- # * <tt>Accepts:</tt> String, set to nil to disable
213
- def page_links_last_page_class_name
214
- return @page_links_last_page_class_name if defined?(@page_links_last_page_class_name)
215
- @page_links_last_page_class_name = "last_page"
216
- end
217
- attr_writer :page_links_last_page_class_name
218
-
219
- # The default for the :next option for the page_links helper.
220
- #
221
- # * <tt>Default:</tt> "Next >"
222
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
223
- def page_links_next
224
- @page_links_next ||= "Next &gt;"
225
- end
226
- attr_writer :page_links_next
227
-
228
- # The class for the next page link
229
- #
230
- # * <tt>Default:</tt> "next_page"
231
- # * <tt>Accepts:</tt> String, set to nil to disable
232
- def page_links_next_page_class_name
233
- return @page_links_next_page_class_name if defined?(@page_links_next_page_class_name)
234
- @page_links_next_page_class_name = "next_page"
235
- end
236
- attr_writer :page_links_next_page_class_name
237
-
238
- # The default for the :outer_spread option for the page_links helper.
239
- #
240
- # * <tt>Default:</tt> 2
241
- # * <tt>Accepts:</tt> Any integer >= 1, set to nil to display, 0 to only show the "..." separator
242
- def page_links_outer_spread
243
- @page_links_outer_spread ||= 1
244
- end
245
- attr_writer :page_links_outer_spread
246
-
247
- # The class for the previous page link
248
- #
249
- # * <tt>Default:</tt> "prev_page"
250
- # * <tt>Accepts:</tt> String, set to nil to disable
251
- def page_links_prev_page_class_name
252
- return @page_links_prev_page_class_name if defined?(@page_links_prev_page_class_name)
253
- @page_links_prev_page_class_name = "prev_page"
254
- end
255
- attr_writer :page_links_prev_page_class_name
256
-
257
- # The default for the :prev option for the page_links helper.
258
- #
259
- # * <tt>Default:</tt> "< Prev"
260
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
261
- def page_links_prev
262
- @page_links_prev ||= "&lt; Prev"
263
- end
264
- attr_writer :page_links_prev
265
-
266
- # The class name for used in the page_seect helper
267
- #
268
- # * <tt>Default:</tt> "page"
269
- # * <tt>Accepts:</tt> String, set to nil to disable
270
- def page_select_class_name
271
- return @page_select_class_name if defined?(@page_select_class_name)
272
- @page_select_class_name = "page"
273
- end
274
- attr_writer :page_select_class_name
275
-
276
- # The class name for used in the per_page_link helper
277
- #
278
- # * <tt>Default:</tt> "per_page"
279
- # * <tt>Accepts:</tt> String, set to nil to disable
280
- def per_page_link_class_name
281
- return @per_page_link_class_name if defined?(@per_page_link_class_name)
282
- @per_page_link_class_name = "per_page"
283
- end
284
- attr_writer :per_page_link_class_name
285
-
286
- # The choices used in the per_page_select helper
287
- #
288
- # * <tt>Default:</tt> [["10 per page", 10], ["25 per page", 25], ["50 per page", 50], ["100 per page", 100], ["150 per page", 150], ["200 per page", 200], ["Show all", nil]]
289
- # * <tt>Accepts:</tt> Array
290
- def per_page_select_choices
291
- return @per_page_select_choices if @per_page_select_choices
292
- @per_page_select_choices = []
293
- [10, 25, 50, 100, 150, 200].each { |choice| @per_page_select_choices << ["#{choice} per page", choice] }
294
- @per_page_select_choices << ["Show all", nil]
295
- end
296
- attr_writer :per_page_select_choices
297
-
298
- # The class name for used in the per_page_select helper
299
- #
300
- # * <tt>Default:</tt> "per_page"
301
- # * <tt>Accepts:</tt> String, set to nil to disable
302
- def per_page_select_class_name
303
- return @per_page_select_class_name if defined?(@per_page_select_class_name)
304
- @per_page_select_class_name = "per_page"
305
- end
306
- attr_writer :per_page_select_class_name
307
-
308
- # The default value for the :activate_text option for priority_order_by_link
309
- #
310
- # * <tt>Default:</tt> "Show %s first"
311
- # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
312
- def priority_order_by_link_activate_text
313
- @priority_order_by_link_activate_text ||= "Show %s first"
314
- end
315
- attr_writer :priority_order_by_link_activate_text
316
-
317
- # The class name for used in the priority_order_by_link helper
318
- #
319
- # * <tt>Default:</tt> "priority_order_by"
320
- # * <tt>Accepts:</tt> String, set to nil to disable
321
- def priority_order_by_link_class_name
322
- return @priority_order_by_link_class_name if defined?(@priority_order_by_link_class_name)
323
- @priority_order_by_link_class_name = "priority_order_by"
324
- end
325
- attr_writer :priority_order_by_link_class_name
326
-
327
- # The default value for the :deactivate_text option for priority_order_by_link
328
- #
329
- # * <tt>Default:</tt> "Dont' show %s first"
330
- # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
331
- def priority_order_by_link_deactivate_text
332
- @priority_order_by_link_deactivate_text ||= "Don't show %s first"
333
- end
334
- attr_writer :priority_order_by_link_deactivate_text
335
- end
336
- end
337
- end
338
- end