Permalink
Browse files

adding configuration options

  • Loading branch information...
1 parent db6be75 commit 36a26f48ee9e18b3607bd6f4f5b5a49935ec6244 @beaucollins committed Sep 17, 2009
View
10 generators/power_reviews/power_reviews_generator.rb
@@ -6,14 +6,10 @@ def manifest
m.directory "config/initializers"
- m.file 'config/power_reviews.yml', 'config/power_reviews.yml'
- m.file 'config/initializers/power_reviews.rb', 'config/initializers/power_reviews.rb'
+ m.file 'config/power_reviews.yml', 'config/power_reviews.yml', :collision => :skip
+ m.file 'config/initializers/power_reviews.rb', 'config/initializers/power_reviews.rb', :collision => :skip
m.file 'config/schedule.rb', 'config/schedule.rb'
-
- m.directory 'app/controllers'
- m.directory 'app/views'
- m.directory 'app/helpers'
-
+
end
end
end
View
7 generators/power_reviews/templates/app/controllers/power_reviews_controller.rb
@@ -1,7 +0,0 @@
-class PowerReviewsController < ApplicationController
-
- def index
-
- end
-
-end
View
38 generators/power_reviews/templates/app/helpers/power_reviews_helper.rb
@@ -1,38 +0,0 @@
-class PowerReviewsHelper
- def power_reviews_javascript_tag
- javascript_include_tag('/system/pwr/engine/js/full')
- end
-
- def power_reviews_javascript_variables
- javascript_tag do
- <<-eos
- var pr_locale= "en_US";
- var pr_zip_location= "/system/";
- //var pr_style_sheet= "http://www.yoursite.com/css/pr_override.css";
- eos
- end
- end
-
- def power_reviews_snippet(page_id, review_anchor = '#ReviewHeader')
- javascript_tag do
- <<-eos
- POWERREVIEWS.display.snippet(document, {
- pr_page_id : '#{page_id}',
- pr_write_review : '#',
- pr_read_review : '#{review_anchor}'
- });
- eos
- end
- end
-
- def power_reviews_display(page_id)
- javascript_tag do
- <<-eos
- POWERREVIEWS.display.engine(document, {
- pr_page_id : '#{page_id}',
- pr_write_review : '#'
- });
- eos
- end
- end
-end
View
3 generators/power_reviews/templates/app/views/power_reviews/index.html.erb
@@ -1,3 +0,0 @@
-<div id="power_reviews_wrapper">
-
-</div>
View
16 generators/power_reviews/templates/config/initializers/power_reviews.rb
@@ -1,6 +1,20 @@
+# Unique for each merchant. Your merchant_group_id is located in the PowerReviews Dashboard > Merchant
+# Group Properties section.
+
+# PowerReviews::Config.merchant_group_id = 0
+
+# ID representing your website (default value is "1"). If you have multiple websites and would like to
+# integrate PowerReviews onto each site, we can set your account as a Master Merchant. This enables
+# review sharing and consolidated management among your different websites. When using the “Master
+# Merchant” configuration, you assign a different Site ID to each site that will have reviews. This ID
+# can be your own internal ID for the site or an ID assigned by PowerReviews. If you are implementing
+# a single merchant, please leave the default Site ID set to "1". The Site ID is configurable in the
+# Dashboard in the Merchant Properties section.
+
+# PowerReviews::Config.site_id = 1
+
# Supply the Power Reviews feed processor with items to produce. Feed is an
# instance of PowerReviews::Feed.
#
#
# PowerReviews::Feed.processor = lambda { |feed| }
-
View
5 lib/power_reviews.rb
@@ -1,8 +1,9 @@
-# PowerReviews
+require 'power_reviews/config'
+
require 'power_reviews/feed_item'
require 'power_reviews/feed'
require 'power_reviews/sync'
require 'power_reviews/view_helpers'
-ActionView::Base.send :include, PowerReviews::ViewHelpers if defined?(ActionView::Base)
+ActionView::Base.send :include, PowerReviews::ViewHelpers if defined? ActionView::Base
View
21 lib/power_reviews/config.rb
@@ -0,0 +1,21 @@
+module PowerReviews
+ class Config
+
+ def self.merchant_group_id
+ @@merchant_group_id
+ end
+
+ def self.merchant_group_id=id
+ @@merchant_group_id = id
+ end
+
+ def self.site_id
+ @@site_id
+ end
+
+ def self.site_id=id
+ @@site_id = id
+ end
+
+ end
+end
View
83 lib/power_reviews/view_helpers.rb
@@ -1,38 +1,61 @@
-class PowerReviewsHelper
- def power_reviews_javascript_tag
- javascript_include_tag('/system/pwr/engine/js/full')
- end
+module PowerReviews
+ module ViewHelpers
+
+ def power_reviews_javascript_tag
+ javascript_include_tag('/system/pwr/engine/js/full')
+ end
- def power_reviews_javascript_variables
- javascript_tag do
- <<-eos
- var pr_locale= "en_US";
- var pr_zip_location= "/system/";
- //var pr_style_sheet= "http://www.yoursite.com/css/pr_override.css";
- eos
+ def power_reviews_javascript_variables
+ javascript_tag do
+ <<-eos
+ var pr_locale= "en_US";
+ var pr_zip_location= "/system/";
+ //var pr_style_sheet= "http://www.yoursite.com/css/pr_override.css";
+ eos
+ end
end
- end
- def power_reviews_snippet(page_id, review_anchor = '#ReviewHeader')
- javascript_tag do
- <<-eos
- POWERREVIEWS.display.snippet(document, {
- pr_page_id : '#{page_id}',
- pr_write_review : '#',
- pr_read_review : '#{review_anchor}'
- });
- eos
+ def power_reviews_snippet(page_id, write_review_url, review_anchor = '#ReviewHeader')
+ javascript_tag do
+ <<-eos
+ POWERREVIEWS.display.snippet(document, {
+ pr_page_id : '#{page_id}',
+ pr_write_review : '#{write_review_url}',
+ pr_read_review : '#{review_anchor}'
+ });
+ eos
+ end
end
- end
- def power_reviews_display(page_id)
- javascript_tag do
- <<-eos
- POWERREVIEWS.display.engine(document, {
- pr_page_id : '#{page_id}',
- pr_write_review : '#'
- });
- eos
+ def power_reviews_display(page_id, write_review_url)
+ javascript_tag do
+ <<-eos
+ POWERREVIEWS.display.engine(document, {
+ pr_page_id : '#{page_id}',
+ pr_write_review : '#{write_review_url}'
+ });
+ eos
+ end
+ end
+
+ def power_reviews_form(page_id, options = {})
+ options = {
+ :locale => '',
+ :site_id => PowerReviews::Config.site_id,
+ :merchant_group_id => PowerReviews::Config.merchant_group_id,
+ :source => 'web',
+ :merchant_user_id => '',
+ :merchant_user_email => '',
+ :promo_code => '',
+ :style_sheet => ''
+ }.merge(options)
+
+ javascript_tag do
+ options.collect { |key, val| "var pr_#{key} = '#{val}';" unless val.blank? }.unshift("var pr_page_id = '#{page_id}';").compact!.join("\n")
+ end << javascript_include_tag('/system/pwr/engine/js/appLaunch')
+
end
+
end
+
end

0 comments on commit 36a26f4

Please sign in to comment.