Permalink
Browse files

Updated searchgasm, added in new page_links helper"

  • Loading branch information...
binarylogic committed Sep 11, 2008
1 parent 41976a8 commit a1b06e9abc1d593ec6c06431c52199aeed6c69fd
Showing with 825 additions and 4,271 deletions.
  1. +1 −0 app/views/layouts/application.html.erb
  2. +3 −3 app/views/non_ajax/users/index.html.erb
  3. +5 −3 app/views/rails_ajax/users/_users.erb
  4. +3 −1 config/environment.rb
  5. +32 −0 public/stylesheets/application.css
  6. +0 −23 vendor/plugins/searchgasm-1.0.0/CHANGELOG
  7. +0 −103 vendor/plugins/searchgasm-1.0.0/lib/searchgasm/active_record/base.rb
  8. +0 −221 vendor/plugins/searchgasm-1.0.0/lib/searchgasm/conditions/base.rb
  9. +0 −3 vendor/plugins/searchgasm-1.0.0/lib/searchgasm/helpers.rb
  10. +0 −78 vendor/plugins/searchgasm-1.0.0/lib/searchgasm/search/base.rb
  11. +0 −48 vendor/plugins/searchgasm-1.0.0/lib/searchgasm/search/conditions.rb
  12. +0 −69 vendor/plugins/searchgasm-1.0.0/lib/searchgasm/search/pagination.rb
  13. +0 −61 vendor/plugins/searchgasm-1.0.0/test/test_condition_base.rb
  14. +0 −72 vendor/plugins/searchgasm-1.0.0/test/test_search_pagination.rb
  15. +64 −0 vendor/plugins/searchgasm-1.0.1/CHANGELOG.rdoc
  16. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/MIT-LICENSE
  17. +3 −1 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/Manifest
  18. +19 −29 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/README.rdoc
  19. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/Rakefile
  20. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/examples/README.rdoc
  21. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/init.rb
  22. +3 −0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm.rb
  23. +8 −0 vendor/plugins/searchgasm-1.0.1/lib/searchgasm/active_record.rb
  24. +10 −1 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/active_record/associations.rb
  25. +153 −0 vendor/plugins/searchgasm-1.0.1/lib/searchgasm/active_record/base.rb
  26. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/base.rb
  27. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/begins_with.rb
  28. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/child_of.rb
  29. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/contains.rb
  30. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/descendant_of.rb
  31. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/does_not_equal.rb
  32. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/ends_with.rb
  33. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/equals.rb
  34. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/greater_than.rb
  35. 0 ...lugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/greater_than_or_equal_to.rb
  36. 0 ...plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/inclusive_descendant_of.rb
  37. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/keywords.rb
  38. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/less_than.rb
  39. 0 ...r/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/less_than_or_equal_to.rb
  40. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/sibling_of.rb
  41. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/condition/tree.rb
  42. +66 −19 vendor/{tmp/searchgasm-0.9.10 → plugins/searchgasm-1.0.1}/lib/searchgasm/conditions/base.rb
  43. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/conditions/protection.rb
  44. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/config.rb
  45. +22 −0 vendor/plugins/searchgasm-1.0.1/lib/searchgasm/core_ext/hash.rb
  46. +9 −0 vendor/plugins/searchgasm-1.0.1/lib/searchgasm/helpers.rb
  47. +18 −2 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types.rb
  48. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types/link.rb
  49. +65 −31 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types/links.rb
  50. 0 ...plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types/remote_link.rb
  51. 0 ...lugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types/remote_links.rb
  52. 0 ...ugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types/remote_select.rb
  53. +1 −1 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/control_types/select.rb
  54. +10 −4 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/form.rb
  55. +27 −2 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/helpers/utilities.rb
  56. +38 −9 vendor/{tmp/searchgasm-0.9.10 → plugins/searchgasm-1.0.1}/lib/searchgasm/search/base.rb
  57. +68 −0 vendor/plugins/searchgasm-1.0.1/lib/searchgasm/search/conditions.rb
  58. +14 −3 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/search/ordering.rb
  59. +114 −0 vendor/plugins/searchgasm-1.0.1/lib/searchgasm/search/pagination.rb
  60. +25 −3 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/search/protection.rb
  61. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/utilities.rb
  62. +1 −1 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/lib/searchgasm/version.rb
  63. +9 −5 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/searchgasm.gemspec
  64. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/fixtures/accounts.yml
  65. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/fixtures/orders.yml
  66. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/fixtures/users.yml
  67. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/libs/acts_as_tree.rb
  68. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/libs/rexml_fix.rb
  69. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_active_record_associations.rb
  70. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_active_record_base.rb
  71. +4 −0 vendor/{tmp/searchgasm-0.9.10 → plugins/searchgasm-1.0.1}/test/test_condition_base.rb
  72. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_condition_types.rb
  73. +10 −10 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_conditions_base.rb
  74. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_conditions_protection.rb
  75. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_helper.rb
  76. +13 −9 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_search_base.rb
  77. +2 −2 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_search_conditions.rb
  78. +2 −2 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_search_ordering.rb
  79. +3 −3 vendor/{tmp/searchgasm-0.9.10 → plugins/searchgasm-1.0.1}/test/test_search_pagination.rb
  80. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/test_search_protection.rb
  81. 0 vendor/plugins/{searchgasm-1.0.0 → searchgasm-1.0.1}/test/text_config.rb
  82. +0 −21 vendor/tmp/searchgasm-0.9.10/CHANGELOG
  83. +0 −20 vendor/tmp/searchgasm-0.9.10/MIT-LICENSE
  84. +0 −57 vendor/tmp/searchgasm-0.9.10/Manifest
  85. +0 −349 vendor/tmp/searchgasm-0.9.10/README.rdoc
  86. +0 −17 vendor/tmp/searchgasm-0.9.10/Rakefile
  87. +0 −4 vendor/tmp/searchgasm-0.9.10/examples/README.rdoc
  88. +0 −1 vendor/tmp/searchgasm-0.9.10/init.rb
  89. +0 −67 vendor/tmp/searchgasm-0.9.10/lib/searchgasm.rb
  90. +0 −64 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/active_record/associations.rb
  91. +0 −103 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/active_record/base.rb
  92. +0 −127 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/base.rb
  93. +0 −20 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/begins_with.rb
  94. +0 −11 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/child_of.rb
  95. +0 −20 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/contains.rb
  96. +0 −24 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/descendant_of.rb
  97. +0 −28 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/does_not_equal.rb
  98. +0 −20 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/ends_with.rb
  99. +0 −20 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/equals.rb
  100. +0 −25 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/greater_than.rb
  101. +0 −20 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/greater_than_or_equal_to.rb
  102. +0 −13 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/inclusive_descendant_of.rb
  103. +0 −33 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/keywords.rb
  104. +0 −25 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/less_than.rb
  105. +0 −20 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/less_than_or_equal_to.rb
  106. +0 −16 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/sibling_of.rb
  107. +0 −16 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/condition/tree.rb
  108. +0 −30 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/conditions/protection.rb
  109. +0 −163 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/config.rb
  110. +0 −162 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/helpers/form_helper.rb
  111. +0 −192 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/helpers/search_helper.rb
  112. +0 −125 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/helpers/utilities_helper.rb
  113. +0 −48 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/search/conditions.rb
  114. +0 −149 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/search/ordering.rb
  115. +0 −69 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/search/pagination.rb
  116. +0 −74 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/search/protection.rb
  117. +0 −30 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/utilities.rb
  118. +0 −79 vendor/tmp/searchgasm-0.9.10/lib/searchgasm/version.rb
  119. +0 −190 vendor/tmp/searchgasm-0.9.10/searchgasm.gemspec
  120. +0 −15 vendor/tmp/searchgasm-0.9.10/test/fixtures/accounts.yml
  121. +0 −14 vendor/tmp/searchgasm-0.9.10/test/fixtures/orders.yml
  122. +0 −27 vendor/tmp/searchgasm-0.9.10/test/fixtures/users.yml
  123. +0 −98 vendor/tmp/searchgasm-0.9.10/test/libs/acts_as_tree.rb
  124. +0 −14 vendor/tmp/searchgasm-0.9.10/test/libs/rexml_fix.rb
  125. +0 −38 vendor/tmp/searchgasm-0.9.10/test/test_active_record_associations.rb
  126. +0 −83 vendor/tmp/searchgasm-0.9.10/test/test_active_record_base.rb
  127. +0 −96 vendor/tmp/searchgasm-0.9.10/test/test_condition_types.rb
  128. +0 −168 vendor/tmp/searchgasm-0.9.10/test/test_conditions_base.rb
  129. +0 −24 vendor/tmp/searchgasm-0.9.10/test/test_conditions_protection.rb
  130. +0 −79 vendor/tmp/searchgasm-0.9.10/test/test_helper.rb
  131. +0 −187 vendor/tmp/searchgasm-0.9.10/test/test_search_base.rb
  132. +0 −27 vendor/tmp/searchgasm-0.9.10/test/test_search_conditions.rb
  133. +0 −91 vendor/tmp/searchgasm-0.9.10/test/test_search_ordering.rb
  134. +0 −35 vendor/tmp/searchgasm-0.9.10/test/test_search_protection.rb
  135. +0 −1 vendor/tmp/searchgasm-0.9.10/test/text_config.rb
@@ -6,6 +6,7 @@
<% else %>
<%= javascript_include_tag "prototype" %>
<% end %>
+ <%= stylesheet_link_tag "application" %>
</head>
<body>
<h1 style="font-size: 1.5em">Searchgasm example</h1>
@@ -64,10 +64,10 @@ Good ol' regular http requests.
<br />
Per page: <%= per_page_select %>
-
+ <br />
+ <br />
<% if @search.page_count > 1 %>
- <br />
- Page: <%= page_select %>
+ <div class="pages"><%= page_links :spread => 1 %></div>
<% end %>
<% else %>
No users were returned
@@ -28,10 +28,12 @@
<br />
Per page: <%= remote_per_page_select %>
-
+ <br />
+ <br />
<% if @search.page_count > 1 %>
- <br />
- Page: <%= remote_page_select %>
+ <div class="pages">
+ <%= remote_page_links %>
+ </div>
<% end %>
<% else %>
No users were returned
View
@@ -45,7 +45,7 @@
config.time_zone = 'UTC'
if RAILS_ENV == "development" # putting this in environments/development.rb doesn't work, not sure why
- config.plugin_paths += ["#{RAILS_ROOT}/../../Ruby Libs"]
+ config.plugin_paths = ["#{RAILS_ROOT}/../../Ruby Libs"]
config.plugins = [:searchgasm]
end
@@ -71,3 +71,5 @@
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
end
+
+require "ruby-debug"
@@ -0,0 +1,32 @@
+body {
+ font-family: Arial, Verdana, "Times New Roman", Times, serif;
+}
+
+div.pages {
+ font-weight: bold;
+}
+
+a.page, span.page {
+ padding: 4px 6px;
+}
+
+a.page {
+ margin: 0 3px;
+ border: 1px solid #ddd;
+ text-decoration: none;
+ color: #0063dc;
+}
+
+a.page:hover {
+ border: 1px solid #003366;
+ background-color: #0063dc;
+ color: #fff;
+}
+
+span.disabled_page {
+ color: #b1aab1;
+}
+
+span.current_page {
+ color: #ff0084;
+}
@@ -1,23 +0,0 @@
-v1.0.0. Major changes in the helpers, they were completely re-engineered. Much nicer and cleaner now. I established a pattern between all helpers giving you complete flexibility as to how they are used. All helpers are called differently now (see documentation).
-
-v0.9.10. Hardened more tests, fixed bug with setting the per_page configuration to only take effect on protected searches, thus staying out of the way of normal searching.
-
-v0.9.9. Fixed setting per_page to nil, false, or ''. This is done to "show all" results.
-
-v0.9.8. Fixed order_by helper bug when determing the text with arrays. Should use the first value instead of last. Added in per_page config option.
-
-v0.9.7. Complete class restructure, much more organized, added in documentation, added in helpers for using searchgasm in a rails app, updated readme with link to documentation as well as a live example, some bug fixes, more tests
-
-v0.9.6. Fixed bug when instantiating with nil options
-
-v0.9.5. Enhanced searching with conditions only. Updated read me to include example on adding your own conditions.
-
-v0.9.4. Cleaned up search methods, removed reset! method for base and conditions.
-
-v0.9.3. Changed structure of conditions to have their own class. Making it easier to add your own conditions.
-
-v0.9.2. Enhanced protection
-
-v0.9.1. Added aliases for datetime, date, time, and timestamp attrs. You could call created_at_after, mow you can also call created_after.
-
-v0.9.0. First release
@@ -1,103 +0,0 @@
-module Searchgasm
- module ActiveRecord #:nodoc: all
- module Base
- def calculate_with_searchgasm(*args)
- options = args.extract_options!
- options = sanitize_options_with_searchgasm(options)
- args << options
- calculate_without_searchgasm(*args)
- end
-
- def find_with_searchgasm(*args)
- options = args.extract_options!
- options = sanitize_options_with_searchgasm(options)
- args << options
- find_without_searchgasm(*args)
- end
-
- def scope_with_searchgasm(method, key = nil)
- scope = scope_without_searchgasm(method, key)
- return sanitize_options_with_searchgasm(scope) if key.nil? && method == :find && !scope.blank?
- scope
- end
-
- def build_conditions(values = {}, &block)
- conditions = searchgasm_conditions
- conditions.protect = true
- conditions.conditions = values
- yield conditions if block_given?
- conditions
- end
-
- def build_conditions!(values = {}, &block)
- conditions = searchgasm_conditions(values)
- yield conditions if block_given?
- conditions
- end
-
- def build_search(options = {}, &block)
- search = searchgasm_searcher
- search.protect = true
- search.options = options
- yield search if block_given?
- search
- end
-
- def build_search!(options = {}, &block)
- search = searchgasm_searcher(options)
- yield search if block_given?
- search
- end
-
- def conditions_protected(*conditions)
- write_inheritable_attribute(:conditions_protected, Set.new(conditions.map(&:to_s)) + (protected_conditions || []))
- end
-
- def protected_conditions
- read_inheritable_attribute(:conditions_protected)
- end
-
- def conditions_accessible(*conditions)
- write_inheritable_attribute(:conditions_accessible, Set.new(conditions.map(&:to_s)) + (protected_conditions || []))
- end
-
- def accessible_conditions
- read_inheritable_attribute(:conditions_accessible)
- end
-
- private
- def sanitize_options_with_searchgasm(options = {})
- return options unless Searchgasm::Search::Base.needed?(self, options)
- searchgasm_searcher(options).sanitize
- end
-
- def searchgasm_conditions(options = {})
- Searchgasm::Conditions::Base.new(self, options)
- end
-
- def searchgasm_searcher(options = {})
- Searchgasm::Search::Base.new(self, options)
- end
- end
- end
-end
-
-ActiveRecord::Base.send(:extend, Searchgasm::ActiveRecord::Base)
-
-module ActiveRecord #:nodoc: all
- class Base
- class << self
- alias_method_chain :calculate, :searchgasm
- alias_method_chain :find, :searchgasm
- alias_method_chain :scope, :searchgasm
- alias_method :new_conditions, :build_conditions
- alias_method :new_conditions!, :build_conditions!
- alias_method :new_search, :build_search
- alias_method :new_search!, :build_search!
-
- def valid_find_options
- VALID_FIND_OPTIONS
- end
- end
- end
-end
Oops, something went wrong.

0 comments on commit a1b06e9

Please sign in to comment.