Permalink
Browse files

Backport from revision 2, http://logeek-labs.googlecode.com/svn/trunk…

  • Loading branch information...
0 parents commit 42ecbe4903e24b716579af8ac9565ce8cafd6729 Thibaut Barrère committed May 13, 2008
@@ -0,0 +1,33 @@
+MephistoAmazon
+==============
+
+This plugin is a partial rewrite of Nicholas Faiz's MephistoAmazon.
+Instead of using Ruby/Amazon, it uses the new amazon/ecs (http://www.pluitsolutions.com/projects/amazon-ecs).
+There is one liquid filter and one tag so far: asin_search.
+You can modify how it renders by editing the liquid files in the views directory.
+Use the filter to render content in an article. Use the tag for the layout.
+
+ASIN Search
+-----------
+
+<filter:asin_search>0553214322</filter:asin_search>
+
+or
+
+{% asin_search books 0553214322 %} {% endkeyword_search %}
+
+What is a ASIN? See http://en.wikipedia.org/wiki/Amazon_Standard_Identification_Number
+
+Authors
+=======
+
+Original work by Nicholas Faiz (https://tfw.devguard.com/svn/os/plugins/mephisto_amazon/).
+
+Adaptation to Amazon/ECS by Thibaut Barrère (http://blog.logeek.fr).
+
+The file ecs.rb and everything under the amazon directory is the work of Herryanto Siatono (released under the MIT License).
+
+Dependencies
+------------
+
+This plugin depends on Hpricot.
@@ -0,0 +1,10 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Test the mephisto_amazon plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
@@ -0,0 +1,11 @@
+require 'mephisto_amazon'
+require 'asin_search_macro'
+require 'mephistoamazon/asin_search'
+require 'mephistoamazon/search_delegate'
+require 'mephistoamazon/product_drop'
+
+require File.join(lib_path, 'plugin')
+
+Liquid::Template.register_tag('asin_search', MephistoAmazon::AsinSearch)
+
+FilteredColumn.macros[:asin_search_macro] = AsinSearchMacro
@@ -0,0 +1 @@
+# Install hook code here
@@ -0,0 +1,21 @@
+0.5.3 2007-09-12
+----------------
+* send_request to use default options.
+
+0.5.2 2007-09-08
+----------------
+* Fixed Amazon::Element.get_unescaped error when result returned for given element path is nil
+
+0.5.1 2007-02-08
+----------------
+* Fixed Amazon Japan and France URL error
+* Removed opts.delete(:search_index) from item_lookup, SearchIndex param is allowed
+ when looking for a book with IdType other than the ASIN.
+* Check for defined? RAILS_DEFAULT_LOGGER to avoid exception for non-rails ruby app
+* Added check for LOGGER constant if RAILS_DEFAULT_LOGGER is not defined
+* Added Ecs.configure(&proc) method for easier configuration of default options
+* Added Element#search_and_convert method
+
+0.5.0 2006-09-12
+----------------
+Initial Release
@@ -0,0 +1,93 @@
+== amazon-ecs
+
+Generic Amazon E-commerce REST API using Hpricot with configurable
+default options and method call options. Uses Response and
+Element wrapper classes for easy access to REST XML output. It supports ECS 4.0.
+
+It is generic, so you can easily extend <tt>Amazon::Ecs</tt> to support
+other not implemented REST operations; and it is also generic because it just wraps around
+Hpricot element object, instead of providing one-to-one object/attributes to XML elements map.
+
+If in the future, there is a change in REST XML output structure,
+no changes will be required on <tt>amazon-ecs</tt> library,
+instead you just need to change the element path.
+
+Version: 0.5.1
+
+== INSTALLATION
+
+ $ gem install amazon-ecs
+
+== EXAMPLE
+
+ require 'amazon/ecs'
+
+ # set the default options; options will be camelized and converted to REST request parameters.
+ Amazon::Ecs.options = {:aWS_access_key_id => [your developer token]}
+
+ # options provided on method call will merge with the default options
+ res = Amazon::Ecs.item_search('ruby', {:response_group => 'Medium', :sort => 'salesrank'})
+
+ # some common response object methods
+ res.is_valid_request? # return true if request is valid
+ res.has_error? # return true if there is an error
+ res.error # return error message if there is any
+ res.total_pages # return total pages
+ res.total_results # return total results
+ res.item_page # return current page no if :item_page option is provided
+
+ # traverse through each item (Amazon::Element)
+ res.items.each do |item|
+ # retrieve string value using XML path
+ item.get('asin')
+ item.get('itemattributes/title')
+
+ # or return Amazon::Element instance
+ atts = item.search_and_convert('itemattributes')
+ atts.get('title')
+
+ # return first author or a string array of authors
+ atts.get('author') # 'Author 1'
+ atts.get_array('author') # ['Author 1', 'Author 2', ...]
+
+ # return an hash of children text values with the element names as the keys
+ item.get_hash('smallimage') # {:url => ..., :width => ..., :height => ...}
+
+ # note that '/' returns Hpricot::Elements array object, nil if not found
+ reviews = item/'editorialreview'
+
+ # traverse through Hpricot elements
+ reviews.each do |review|
+ # Getting hash value out of Hpricot element
+ Amazon::Element.get_hash(review) # [:source => ..., :content ==> ...]
+
+ # Or to get unescaped HTML values
+ Amazon::Element.get_unescaped(review, 'source')
+ Amazon::Element.get_unescaped(review, 'content')
+
+ # Or this way
+ el = Amazon::Element.new(review)
+ el.get_unescaped('source')
+ el.get_unescaped('content')
+ end
+
+ # returns Amazon::Element instead of string
+ item.search_and_convert('itemattributes').
+ end
+
+Refer to Amazon ECS documentation for more information on Amazon REST request parameters and XML output:
+http://docs.amazonwebservices.com/AWSEcommerceService/2006-09-13/
+
+To get a sample of Amazon REST response XML output, use AWSZone.com scratch pad:
+http://www.awszone.com/scratchpads/aws/ecs.us/index.aws
+
+== LINKS
+
+* http://amazon-ecs.rubyforge.org
+* http://www.pluitsolutions.com/amazon-ecs
+
+== LICENSE
+
+(The MIT License)
+
+Copyright (c) 2006 Herryanto Siatono, Pluit Solutions
Oops, something went wrong.

0 comments on commit 42ecbe4

Please sign in to comment.