bazarvoice 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: f699bda014b26c32c479e724172697bbf7b4a8ff
4
+ metadata.gz: f4df8da0dc0bb81c3e75a5f940053b819fd149b2
5
+ SHA512:
6
+ data.tar.gz: 6b495a137d14010fdf8ae1b77a4c5e2bd5c39ce6fc0f45fc33aba444c3cf76ed61712919426c574b4424a2a19f604952a4419c503d07cb9d419a2753da63a777
7
+ metadata.gz: 46a57405d17dad5e266f4b347c80d129aea4ffdce03db1e55d082fb28a79c6f7bf50db8271f56117de5f1a9c7679cbaad9d68be4925260eb38bb1290ca436a86
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ rdoc/
3
+ coverage/
4
+ pkg/
5
+ .rvmrc
6
+ *.rbc
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ == v0.0.1 (2013-10-16)
2
+
3
+ * Enhancements
4
+
5
+ * added all conversion API
6
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 - Sapna Jadon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,82 @@
1
+ = bazarvoice implementation for Ruby on Rails
2
+
3
+ This adds {bazarvoice}[http://www.bazarvoice.com] support to your
4
+ Rails application including single sign-on.
5
+
6
+ == Installation
7
+
8
+ === As a gem
9
+ gem install bazarvoice
10
+
11
+ === As a Rails dependency
12
+ config.gem 'bazarvoice', :source => 'http://gemcutter.org'
13
+
14
+ === As a Rails plugin
15
+ ./script/plugin install http://github.com/iltempo/bazarvoice.git
16
+
17
+
18
+ == Configuration
19
+
20
+ Generate files for your app:
21
+ ./script/generate bazarvoice <key> <forum> [<api_key>]
22
+ Where <key> is the bazarvoice account name and <forum> the id of your main forum.
23
+ Find both settings in widgets section of the admin interface of bazarvoice.
24
+ Your API key <api_key> can be found in the API section of the admin documentation.
25
+
26
+ Default properties are stored in a file named bazarvoice.yml in the config
27
+ directory of your Rails application. Make it fitting to your needs. Feel free to
28
+ use erb expressions.
29
+
30
+ Add javascript function and configuration to HTML HEAD section of your template file:
31
+ <%= bazarvoice_config_javascript %>
32
+
33
+ You can override default bazarvoice settings in your view:
34
+ <%= bazarvoice_config_javascript(:alignment => 'right', :forum => 12983) %>
35
+
36
+
37
+ == Single Sign-On
38
+
39
+ Single sign-on authenticates your bazars automatically against the bazarvoice
40
+ service. A second login is not needed any more.
41
+
42
+ bazarvoice is allowing single sign-on starting from the Bronze plan.
43
+ http://bazarvoice.com/signup?ref=nav
44
+
45
+ To use single sign-on with on bazarvoice you have to set your api_key in
46
+ config/bazarvoice.yml. Find it on
47
+ https://ACCOUNT.bazarvoice.com/admin2/docs#/legacy_api
48
+
49
+ The bazar properties can be set via the :sso parameter.
50
+ <%= bazarvoice_config_javascript(:sso => {:guid => @current_bazar.id, :email => @current_bazar.email}) %>
51
+
52
+ Parameter <em>:guid</em> should be unique identifier, for example the bazar id in your
53
+ system. bazarvoice recommends setting <em>:email</em> parameter to enable bazars to get
54
+ updates and notifications via email.
55
+ See https://ACCOUNT.bazarvoice.com/admin2/docs#/sso for a list of parameters
56
+ available.
57
+
58
+
59
+ == Note on Patches/Pull Requests
60
+
61
+ * Fork the project.
62
+ * Make your feature addition or bug fix.
63
+ * Add tests for it. This is important so I don't break it in a
64
+ future version unintentionally.
65
+ * Commit, do not mess with rakefile, version, or history.
66
+ (if you want to have your own version, that is fine but bump version in a
67
+ commit by itself I can ignore when I pull)
68
+ * Send me a pull request. Bonus points for topic branches.
69
+
70
+
71
+
72
+ ==Author
73
+
74
+ {Sapna Jadon}
75
+
76
+
77
+
78
+
79
+
80
+ == Copyright
81
+
82
+ Copyright (c) 2013
@@ -0,0 +1,59 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{bazarvoice}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Sapna Jadon"]
9
+ s.date = %q{2013-10-16}
10
+ s.description = %q{This adds bazarvoice support to your Rails application
11
+ including single sign-on.}
12
+ s.extra_rdoc_files = [
13
+ "CHANGELOG.rdoc",
14
+ "LICENSE",
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "CHANGELOG.rdoc",
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "generators/bazarvoice/USAGE",
23
+ "generators/bazarvoice/templates/bazarvoice_template.yml",
24
+ "generators/bazarvoice/bazarvoice_generator.rb",
25
+ "init.rb",
26
+ "lib/bazarvoice.rb",
27
+ "lib/bazarvoice/instance_methods.rb",
28
+ "lib/bazarvoice/token.rb",
29
+ "lib/bazarvoice/view_helpers.rb",
30
+ "bazarvoice.gemspec"
31
+ ]
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.6}
35
+ s.summary = %q{bazarvoice for your Rails application}
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<ezcrypto>, [">= 0.7.2"])
43
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.1"])
44
+ s.add_runtime_dependency(%q<actionpack>, [">= 2.1"])
45
+ s.add_runtime_dependency(%q<rails>, [">= 2.1"])
46
+ else
47
+ s.add_dependency(%q<ezcrypto>, [">= 0.7.2"])
48
+ s.add_dependency(%q<activesupport>, [">= 2.1"])
49
+ s.add_dependency(%q<actionpack>, [">= 2.1"])
50
+ s.add_dependency(%q<rails>, [">= 2.1"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<ezcrypto>, [">= 0.7.2"])
54
+ s.add_dependency(%q<activesupport>, [">= 2.1"])
55
+ s.add_dependency(%q<actionpack>, [">= 2.1"])
56
+ s.add_dependency(%q<rails>, [">= 2.1"])
57
+ end
58
+ end
59
+
@@ -0,0 +1,14 @@
1
+ Name
2
+ bazarvoice - creates bazarvoice files
3
+
4
+ Description:
5
+ This generator creates all files needed for bazarvoice integration.
6
+
7
+ ./script/generate bazarvoice <bazarvoice_key> <main_forum_id> [<api_key>]
8
+
9
+ Please add to head section of your layout file:
10
+ <%= javascript_include_tag 'bazarvoice' %>
11
+ <%= uservoice_config_javascript %>
12
+
13
+ Example:
14
+ ./script/generate bazarvoice mypage 12345 myapikey
@@ -0,0 +1,15 @@
1
+ class UservoiceGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ unless [2, 3].include?(args.length)
5
+ puts usage_message
6
+ exit 1
7
+ end
8
+
9
+ record do |m|
10
+ m.directory('config')
11
+ m.template 'bazarvoice_template.yml', 'config/bazarvoice.yml'
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ uservoice_options:
2
+ # required
3
+ key: <%= args.first %>
4
+ host: <%= args.first %>.uservoice.com
5
+ forum: <%= args.second %>
6
+ # optional
7
+ showTab: true
8
+ alignment: left
9
+ background_color: "#f00"
10
+ text_color: white
11
+ hover_color: "#06C"
12
+ lang: en
13
+
14
+ uservoice_api:
15
+ api_key: <%= args.third %>
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'bazarvoice'
data/lib/bazarvoice.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Bazarvoice
2
+ end
3
+
4
+ require 'cgi'
5
+ require 'ezcrypto'
6
+ require 'bazarvoice/token'
7
+ require 'bazarvoice/instance_methods'
8
+ require 'bazarvoice/view_helpers'
9
+
10
+ ActionController::Base.send(:include, Bazarvoice::InstanceMethods)
11
+ ActionView::Base.send(:include, Bazarvoice::BazarvoiceViewHelpers)
@@ -0,0 +1,40 @@
1
+ # This module holds all instance methods to be
2
+ # included into ActionController::Base class
3
+ # for enabling bazavoice in a Rails app.
4
+ #
5
+ # Author:: Sapna J
6
+ # Copyright:: Copyright (c) 2013 il tempo
7
+ # License:: Distributes under the same terms as Ruby
8
+
9
+ require "erb"
10
+
11
+ module Bazarvoice
12
+ module InstanceMethods
13
+
14
+ # Making helper method available when module
15
+ # gets included into ActionController::Base.
16
+ #
17
+ def self.included(mod)
18
+ mod.send(:helper_method, :bazarvoice_configuration)
19
+ end
20
+
21
+ # Set bazarvoice configuration file path.
22
+ # Can be overridden.
23
+ #
24
+ def bazarvoice_configuration_file #:nodoc:
25
+ "#{::Rails.root}/config/bazarvoice.yml"
26
+ end
27
+
28
+ # Returns the bazarvoice configuration hash.
29
+ # It's been lazy loaded and cached in the controller class.
30
+ #
31
+ def bazarvoice_configuration
32
+ @@bazarvoice_configuration ||= begin
33
+ config = ERB.new(IO.read(bazarvoice_configuration_file)).result
34
+ configuration = YAML::load(config)
35
+ HashWithIndifferentAccess.new(configuration)
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ # This module represents an encrypted token
2
+ # to authenticate a bazar against the bazarvoice
3
+ # service.
4
+ #
5
+ # Author:: Sapna J
6
+ # Copyright:: Copyright (c) 2013 il tempo
7
+ # License:: Distributes under the same terms as Ruby
8
+
9
+ module Bazarvoice
10
+ class Token
11
+ attr_reader :data
12
+
13
+ # Creates a sign-in token to authenticate bazar against
14
+ # the bazarvoice service.
15
+ # See https://ACCOUNT.bazarvoice.com/admin2/docs#/sso for
16
+ # data properties available.
17
+ #
18
+ def initialize(key, api_key, data)
19
+ data.merge!({:expires => (Time.now + 5 * 60).to_s})
20
+
21
+ crypt_key = EzCrypto::Key.with_password(key, api_key)
22
+ encrypted_data = crypt_key.encrypt(data.to_json)
23
+
24
+ @data = CGI.escape(Base64.encode64(encrypted_data).gsub(/\n/, ''))
25
+ end
26
+
27
+ def to_s #:nodoc:
28
+ @data
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ # This module holds all frontend helper methods
2
+ # for bazarvoice in a Rails app.
3
+ #
4
+ # Author:: Alexander Greim (mailto:alexxx@iltempo.de)
5
+ # Copyright:: Copyright (c) 2010 il tempo
6
+ # License:: Distributes under the same terms as Ruby
7
+
8
+ module Bazarvoice
9
+ module BazarvoiceViewHelpers
10
+
11
+ # Renders javascript to configure bazarvoice feedback widget. Options
12
+ # can be used to override default settings like forum id.
13
+ # e.g. bazarvoice_config_javascript(forum_id => 12345)
14
+ # See https://ACCOUNT.bazarvoice.com/admin2/docs#/widget for options
15
+ # available.
16
+ #
17
+ def bazarvoice_config_javascript(options={})
18
+ config = bazarvoice_configuration['bazarvoice_options'].dup
19
+ config.merge!(options)
20
+
21
+ if config[:sso] && config[:sso][:guid]
22
+ config.merge!(:params => {:sso => Bazarvoice::Token.new(
23
+ bazarvoice_configuration['bazarvoice_options']['key'],
24
+ bazarvoice_configuration['bazarvoice_api']['api_key'],
25
+ config.delete(:sso)).to_s})
26
+ end
27
+
28
+ <<-EOS
29
+ <script type="text/javascript">
30
+ $(document).ready(function() {
31
+ $.ajaxSetup({ cache: true });
32
+ $.getJSON(api_server+"/reviews.json?callback=?",
33
+ "apiversion=4.9&include=products,authors&filter=DisplayLocale:en_US&passkey=" + api_key + "&limit=" + num_items,
34
+ function(json){
35
+ jQuery.each(json.Results, function(index, review) {
36
+ $("#module").append("<h1>"+review['Title']+"</h1>");
37
+ });
38
+ });
39
+ });
40
+ </script>
41
+ EOS
42
+ end
43
+
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bazarvoice
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sapna Jadon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2013-10-16 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ezcrypto
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.7.2
22
+ type: :runtime
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: activesupport
26
+ prerelease: false
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - &id003 !ruby/object:Gem::Version
31
+ version: "2.1"
32
+ type: :runtime
33
+ version_requirements: *id002
34
+ - !ruby/object:Gem::Dependency
35
+ name: actionpack
36
+ prerelease: false
37
+ requirement: &id004 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - *id003
41
+ type: :runtime
42
+ version_requirements: *id004
43
+ - !ruby/object:Gem::Dependency
44
+ name: rails
45
+ prerelease: false
46
+ requirement: &id005 !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - *id003
50
+ type: :runtime
51
+ version_requirements: *id005
52
+ description: |-
53
+ This adds bazarvoice support to your Rails application
54
+ including single sign-on.
55
+ email:
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files:
61
+ - CHANGELOG.rdoc
62
+ - LICENSE
63
+ - README.rdoc
64
+ files:
65
+ - .gitignore
66
+ - CHANGELOG.rdoc
67
+ - LICENSE
68
+ - README.rdoc
69
+ - generators/bazarvoice/USAGE
70
+ - generators/bazarvoice/templates/bazarvoice_template.yml
71
+ - generators/bazarvoice/bazarvoice_generator.rb
72
+ - init.rb
73
+ - lib/bazarvoice.rb
74
+ - lib/bazarvoice/instance_methods.rb
75
+ - lib/bazarvoice/token.rb
76
+ - lib/bazarvoice/view_helpers.rb
77
+ - bazarvoice.gemspec
78
+ homepage:
79
+ licenses: []
80
+
81
+ metadata: {}
82
+
83
+ post_install_message:
84
+ rdoc_options:
85
+ - --charset=UTF-8
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - &id006
91
+ - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - *id006
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 2.1.5
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: bazarvoice for your Rails application
104
+ test_files: []
105
+