diff options
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/plugins/acts_as_xapian/README.txt | 40 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/init.rb | 2 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 29 | ||||
-rw-r--r-- | vendor/plugins/has_tag_string/lib/has_tag_string.rb | 2 | ||||
m--------- | vendor/rails-locales | 0 |
5 files changed, 36 insertions, 37 deletions
diff --git a/vendor/plugins/acts_as_xapian/README.txt b/vendor/plugins/acts_as_xapian/README.txt index 62cef2f24..a1d22ef3f 100644 --- a/vendor/plugins/acts_as_xapian/README.txt +++ b/vendor/plugins/acts_as_xapian/README.txt @@ -14,7 +14,7 @@ copied from the README.txt file. Contents ======== -* a. Introduction to acts_as_xapian +* a. Introduction to acts_as_xapian * b. Installation * c. Comparison to acts_as_solr (as on 24 April 2008) * d. Documentation - indexing @@ -33,14 +33,14 @@ alternative to acts_as_solr, acts_as_ferret, Ultrasphinx, acts_as_indexed, acts_as_searchable or acts_as_tsearch. acts_as_xapian is deployed in production on these websites. -* "WhatDoTheyKnow":http://www.whatdotheyknow.com +* "WhatDoTheyKnow":http://www.whatdotheyknow.com * "MindBites":http://www.mindbites.com -The section "c. Comparison to acts_as_solr" below will give you an idea of +The section "c. Comparison to acts_as_solr" below will give you an idea of acts_as_xapian's features. acts_as_xapian was started by Francis Irving in May 2008 for search and email -alerts in WhatDoTheyKnow, and so was supported by "mySociety":http://www.mysociety.org +alerts in WhatDoTheyKnow, and so was supported by "mySociety":http://www.mysociety.org and initially paid for by the "JRSST Charitable Trust":http://www.jrrt.org.uk/jrsstct.htm @@ -52,11 +52,11 @@ this command within your Rails app. git clone git://github.com/frabcus/acts_as_xapian.git vendor/plugins/acts_as_xapian -Xapian 1.0.5 and associated Ruby bindings are also required. +Xapian 1.0.5 and associated Ruby bindings are also required. -Debian or Ubuntu - install the packages libxapian15 and libxapian-ruby1.8. +Debian or Ubuntu - install the packages libxapian15 and libxapian-ruby1.8. -Mac OSX - follow the instructions for installing from source on +Mac OSX - follow the instructions for installing from source on the "Installing Xapian":http://xapian.org/docs/install.html page - you need the Xapian library and bindings (you don't need Omega). @@ -102,7 +102,7 @@ Solr getting in the way whenever you want to use a new feature from Lucene. * No Java - an advantage if you're more used to working in the rest of the open source world. acts_as_xapian, it's pure Ruby and C++. -* Xapian's awesome email list - the kids over at +* Xapian's awesome email list - the kids over at "xapian-discuss":http://lists.xapian.org/mailman/listinfo/xapian-discuss are super helpful. Useful if you need to extend and improve acts_as_xapian. The Ruby bindings are mature and well maintained as part of Xapian. @@ -131,11 +131,11 @@ Here's how to add indexing to your Rails app: Options must include: -* :texts, an array of fields for indexing with full text search. +* :texts, an array of fields for indexing with full text search. e.g. :texts => [ :title, :body ] -* :values, things which have a range of values for sorting, or for collapsing. -Specify an array quadruple of [ field, identifier, prefix, type ] where +* :values, things which have a range of values for sorting, or for collapsing. +Specify an array quadruple of [ field, identifier, prefix, type ] where ** identifier is an arbitary numeric identifier for use in the Xapian database ** prefix is the part to use in search queries that goes before the : ** type can be any of :string, :number or :date @@ -143,8 +143,8 @@ Specify an array quadruple of [ field, identifier, prefix, type ] where e.g. :values => [ [ :created_at, 0, "created_at", :date ], [ :size, 1, "size", :string ] ] -* :terms, things which come with a prefix (before a :) in search queries. -Specify an array triple of [ field, char, prefix ] where +* :terms, things which come with a prefix (before a :) in search queries. +Specify an array triple of [ field, char, prefix ] where ** char is an arbitary single upper case char used in the Xapian database, just pick any single uppercase character, but use a different one for each prefix. ** prefix is the part to use in search queries that goes before the : @@ -152,7 +152,7 @@ For example, if you were making Google and indexing to be able to later do a query like "site:www.whatdotheyknow.com", then the prefix would be "site". e.g. :terms => [ [ :variety, 'V', "variety" ] ] - + A 'field' is a symbol referring to either an attribute or a function which returns the text, date or number to index. Both 'identifier' and 'char' must be the same for the same prefix in different models. @@ -170,7 +170,7 @@ object isn't indexed 3. Call 'rake xapian:rebuild_index models="ModelName1 ModelName2"' to build the index the first time (you must specify all your indexed models). It's put in a -development/test/production dir in acts_as_xapian/xapiandbs. See f. Configuration +development/test/production dir in acts_as_xapian/xapiandbs. See f. Configuration below if you want to change this. 4. Then from a cron job or a daemon, or by hand regularly!, call 'rake xapian:update_index' @@ -201,10 +201,10 @@ And then a hash of options: * :sort_by_ascending - Default true (documents with higher values better/earlier), set to false for descending sort * :collapse_by_prefix - Optionally, prefix of value to collapse by (i.e. only return most relevant result from group) -Google like query syntax is as described in +Google like query syntax is as described in "Xapian::QueryParser Syntax":http://www.xapian.org/docs/queryparser.html Queries can include prefix:value parts, according to what you indexed in the -acts_as_xapian part above. You can also say things like model:InfoRequestEvent +acts_as_xapian part above. You can also say things like model:InfoRequestEvent to constrain by model in more complex ways than the :model parameter, or modelid:InfoRequestEvent-100 to only find one specific object. @@ -236,12 +236,12 @@ f. Configuration ================ If you want to customise the configuration of acts_as_xapian, it will look for -a file called 'xapian.yml' under RAILS_ROOT/config. As is familiar from the +a file called 'xapian.yml' under Rails.root/config. As is familiar from the format of the database.yml file, separate :development, :test and :production sections are expected. The following options are available: -* base_db_path - specifies the directory, relative to RAILS_ROOT, in which +* base_db_path - specifies the directory, relative to Rails.root, in which acts_as_xapian stores its search index databases. Default is the directory xapiandbs within the acts_as_xapian directory. @@ -264,7 +264,7 @@ temporarily add this to the end of your config/environment.rb h. Support ========== -Please ask any questions on the +Please ask any questions on the "acts_as_xapian Google Group":http://groups.google.com/group/acts_as_xapian The official home page and repository for acts_as_xapian are the diff --git a/vendor/plugins/acts_as_xapian/init.rb b/vendor/plugins/acts_as_xapian/init.rb index 36b43ac0b..1e5b8557b 100644 --- a/vendor/plugins/acts_as_xapian/init.rb +++ b/vendor/plugins/acts_as_xapian/init.rb @@ -1,7 +1,7 @@ # acts_as_xapian/init.rb: # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. -# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ require 'acts_as_xapian' diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index 9eaedcf9e..f2cd1075c 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -1,8 +1,9 @@ +# encoding: utf-8 # acts_as_xapian/lib/acts_as_xapian.rb: # Xapian full text search in Ruby on Rails. # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. -# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ # # Documentation # ============= @@ -92,12 +93,12 @@ module ActsAsXapian raise "Set RAILS_ENV, so acts_as_xapian can find the right Xapian database" if not environment # check for a config file - config_file = Rails.root.to_s + "/config/xapian.yml" + config_file = Rails.root.join("config","xapian.yml") @@config = File.exists?(config_file) ? YAML.load_file(config_file)[environment] : {} # figure out where the DBs should go if config['base_db_path'] - db_parent_path = RAILS_ROOT + "/" + config['base_db_path'] + db_parent_path = Rails.root.join(config['base_db_path']) else db_parent_path = File.join(File.dirname(__FILE__), '../xapiandbs/') end @@ -472,7 +473,9 @@ module ActsAsXapian # date ranges or similar. Use this for cheap highlighting with # TextHelper::highlight, and excerpt. def words_to_highlight - query_nopunc = self.query_string.gsub(/[^a-z0-9:\.\/_]/i, " ") + # TODO: In Ruby 1.9 we can do matching of any unicode letter with \p{L} + # But we still need to support ruby 1.8 for the time being so... + query_nopunc = self.query_string.gsub(/[^ёЁа-яА-Яa-zA-Zà-üÀ-Ü0-9:\.\/_]/iu, " ") query_nopunc = query_nopunc.gsub(/\s+/, " ") words = query_nopunc.split(" ") # Remove anything with a :, . or / in it @@ -711,26 +714,20 @@ module ActsAsXapian # We fork here, so each batch is run in a different process. This is # because otherwise we get a memory "leak" and you can't rebuild very # large databases (however long you have!) + + ActiveRecord::Base.connection.disconnect! + pid = Process.fork # XXX this will only work on Unix, tough if pid Process.waitpid(pid) if not $?.success? raise "batch fork child failed, exiting also" end - - # FIXME: Under Rails 3.1 we get "SSL error: decryption failed or bad record mac", this works around it - retry_count = 0 - begin - # database connection doesn't survive a fork, rebuild it - ActiveRecord::Base.connection.reconnect! - rescue - retry_count += 1 - retry_count > 3 ? raise : retry - end + # database connection doesn't survive a fork, rebuild it else - # fully reopen the database each time (with a new object) # (so doc ids and so on aren't preserved across the fork) + ActiveRecord::Base.establish_connection @@db_path = ActsAsXapian.db_path + ".new" ActsAsXapian.writable_init STDOUT.puts("ActsAsXapian.rebuild_index: New batch. #{model_class.to_s} from #{i} to #{i + batch_size} of #{model_class_count} pid #{Process.pid.to_s}") if verbose @@ -746,6 +743,8 @@ module ActsAsXapian Kernel.exit! 0 end + ActiveRecord::Base.establish_connection + end end end diff --git a/vendor/plugins/has_tag_string/lib/has_tag_string.rb b/vendor/plugins/has_tag_string/lib/has_tag_string.rb index b982bc3a0..4022faaac 100644 --- a/vendor/plugins/has_tag_string/lib/has_tag_string.rb +++ b/vendor/plugins/has_tag_string/lib/has_tag_string.rb @@ -4,7 +4,7 @@ # followed by a colon - e.g. url:http://www.flourish.org # # Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. -# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ module HasTagString # Represents one tag of one model. diff --git a/vendor/rails-locales b/vendor/rails-locales deleted file mode 160000 -Subproject 7b769690775e9705f82da75aee3435e8dadebec |