spree_online_support 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Redistribution and use in source and binary forms, with or without modification,
2
+ are permitted provided that the following conditions are met:
3
+
4
+ * Redistributions of source code must retain the above copyright notice,
5
+ this list of conditions and the following disclaimer.
6
+ * Redistributions in binary form must reproduce the above copyright notice,
7
+ this list of conditions and the following disclaimer in the documentation
8
+ and/or other materials provided with the distribution.
9
+ * Neither the name of the Rails Dog LLC nor the names of its
10
+ contributors may be used to endorse or promote products derived from this
11
+ software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ SpreeOnlineSupport
2
+ ==================
3
+
4
+ Adds integration with online support services, like zopim.com
5
+
6
+
7
+
8
+
9
+
10
+ Copyright (c) 2011 "Сервис и Консалтинг", released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../../config/application', __FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rake/packagetask'
7
+ require 'rake/gempackagetask'
8
+
9
+ spec = eval(File.read('spree_online_support.gemspec'))
10
+
11
+ Rake::GemPackageTask.new(spec) do |p|
12
+ p.gem_spec = spec
13
+ end
14
+
15
+ desc "Release to gemcutter"
16
+ task :release => :package do
17
+ require 'rake/gemcutter'
18
+ Rake::Gemcutter::Tasks.new(spec).define
19
+ Rake::Task['gem:push'].invoke
20
+ end
21
+
22
+ desc "Default Task"
23
+ task :default => [ :spec ]
24
+
25
+ require 'rspec/core/rake_task'
26
+ RSpec::Core::RakeTask.new
27
+
28
+ # require 'cucumber/rake/task'
29
+ # Cucumber::Rake::Task.new do |t|
30
+ # t.cucumber_opts = %w{--format pretty}
31
+ # end
@@ -0,0 +1,14 @@
1
+ class Admin::OnlineSupportSettingsController < Admin::BaseController
2
+ def update
3
+ preferences = params[:preferences]
4
+ enable_online_support = preferences[:enabled].nil? ? false : true;
5
+ preferences.update(:enabled => enable_online_support)
6
+ Spree::OnlineSupport::Config.set(preferences)
7
+
8
+ respond_to do |format|
9
+ format.html {
10
+ redirect_to admin_online_support_settings_path
11
+ }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ <%= render :partial => 'admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t('online_support') %></h1>
4
+
5
+ <%= form_tag(admin_online_support_settings_path, :method => :put) do %>
6
+
7
+ <p>
8
+ <label><%= t('enable_online_support') %>:</label>
9
+ <%= check_box_tag('preferences[enabled]', '1', Spree::OnlineSupport::Config[:enabled]) %>
10
+ </p>
11
+ <p>
12
+ <label>Zopim.com <%= t('auth_key') %>:</label>
13
+ <%= text_field_tag('preferences[zopim_key]', Spree::OnlineSupport::Config[:zopim_key])%>
14
+ </p>
15
+ <p class="form-buttons">
16
+ <%= button t('update') %>
17
+ <%= t("or") %> <%= link_to t("cancel"), admin_online_support_settings_url %>
18
+ </p>
19
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <%= render :partial => 'admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t("online_support") %></h1>
4
+
5
+ <table>
6
+ <tr>
7
+ <td><%= t('enable_online_support') %>:</td>
8
+ <td><%= Spree::OnlineSupport::Config[:enabled] ? t('yes') : t('no') %></td>
9
+ </tr>
10
+ <tr>
11
+ <td>Zopim.com <%= t('auth_key') %>:</td>
12
+ <td>'<%= Spree::OnlineSupport::Config[:zopim_key] %>'</td>
13
+ </tr>
14
+ </table>
15
+
16
+ <p><%= link_to_with_icon 'edit', t("edit"), edit_admin_online_support_settings_path %></p>
17
+
18
+
@@ -0,0 +1,9 @@
1
+ <% if Spree::OnlineSupport::Config[:enabled] && Spree::OnlineSupport::Config[:zopim_key].present? %>
2
+ <!-- Start of Zopim Live Chat Script -->
3
+ <noindex>
4
+ <script type="text/javascript">
5
+ document.write(unescape("%3Cscript src='" + document.location.protocol + "//zopim.com/?<%= Spree::OnlineSupport::Config[:zopim_key] %>' charset='utf-8' type='text/javascript'%3E%3C/script%3E"));
6
+ </script>
7
+ </noindex>
8
+ <!-- End of Zopim Live Chat Script -->
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ en:
3
+ online_support: "Online Support"
4
+ online_support_description: "Configure online support Spree settings."
5
+ enable_online_support: "Enable Online Support"
6
+ auth_key: "auth key"
7
+
@@ -0,0 +1,7 @@
1
+ ---
2
+ ru:
3
+ online_support: "Онлайн-поддержка"
4
+ online_support_description: "Настройки онлайн-поддержки."
5
+ enable_online_support: "Включить онлайн-поддержку"
6
+ auth_key: "ключ"
7
+
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ namespace :admin do
3
+ resource :online_support_settings, :only => ['show', 'update', 'edit']
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ class OnlineSupportConfiguration < Configuration
2
+ preference :enabled, :boolean, :default => true
3
+ preference :zopim_key, :string, :default => ''
4
+ end
@@ -0,0 +1,23 @@
1
+ module Spree
2
+ module OnlineSupport
3
+ # Singleton class to access the advanced cart configuration object (OnlineSupportConfiguration.first by default) and it's preferences.
4
+ #
5
+ # Usage:
6
+ # Spree::OnlineSupport::Config[:foo] # Returns the foo preference
7
+ # Spree::OnlineSupport::Config[] # Returns a Hash with all the google base preferences
8
+ # Spree::OnlineSupport::Config.instance # Returns the configuration object (OnlineSupportConfiguration.first)
9
+ # Spree::OnlineSupport::Config.set(preferences_hash) # Set the advanced cart preferences as especified in +preference_hash+
10
+ class Config
11
+ include Singleton
12
+ include PreferenceAccess
13
+
14
+ class << self
15
+ def instance
16
+ return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
17
+ OnlineSupportConfiguration.find_or_create_by_name("Online Support configuration")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,17 @@
1
+ require 'spree_core'
2
+ require 'spree_online_support_hooks'
3
+
4
+ module SpreeOnlineSupport
5
+ class Engine < Rails::Engine
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ def self.activate
10
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
11
+ Rails.env.production? ? require(c) : load(c)
12
+ end
13
+ end
14
+
15
+ config.to_prepare &method(:activate).to_proc
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ class SpreeOnlineSupportHooks < Spree::ThemeSupport::HookListener
2
+ insert_after :admin_configurations_menu do
3
+ %(<tr>
4
+ <td><%= link_to t("online_support"), admin_online_support_settings_path %></td>
5
+ <td><%= t("online_support_description") %></td>
6
+ </ tr>)
7
+ end
8
+
9
+ insert_after :admin_configurations_sidebar_menu do
10
+ %(<li<%== ' class="active"' if controller.controller_name == 'online_support_settings' %>><%= link_to t("online_support"), admin_online_support_settings_path %></li>)
11
+ end
12
+
13
+ insert_after :inside_head, 'shared/online_support'
14
+ end
@@ -0,0 +1,25 @@
1
+ namespace :spree_online_support do
2
+ desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
3
+ task :install do
4
+ Rake::Task['spree_online_support:install:migrations'].invoke
5
+ Rake::Task['spree_online_support:install:assets'].invoke
6
+ end
7
+
8
+ namespace :install do
9
+ desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
10
+ task :migrations do
11
+ source = File.join(File.dirname(__FILE__), '..', '..', 'db')
12
+ destination = File.join(Rails.root, 'db')
13
+ Spree::FileUtilz.mirror_files(source, destination)
14
+ end
15
+
16
+ desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
17
+ task :assets do
18
+ source = File.join(File.dirname(__FILE__), '..', '..', 'public')
19
+ destination = File.join(Rails.root, 'public')
20
+ puts "INFO: Mirroring assets from #{source} to #{destination}"
21
+ Spree::FileUtilz.mirror_files(source, destination)
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1 @@
1
+ # add custom rake tasks here
@@ -0,0 +1,30 @@
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+ require File.expand_path("../../../config/environment", __FILE__)
5
+ require 'rspec/rails'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ # == Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+ config.mock_with :rspec
20
+
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ #config.include Devise::TestHelpers, :type => :controller
24
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
25
+ # examples within a transaction, comment the following line or assign false
26
+ # instead of true.
27
+ config.use_transactional_fixtures = true
28
+ end
29
+
30
+ @configuration ||= AppConfiguration.find_or_create_by_name("Default configuration")
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'spree_online_support'
4
+ s.version = '0.50.0'
5
+ s.summary = 'Adds integration with online support services, like zopim.com'
6
+ #s.description = 'Add (optional) gem description here'
7
+ s.required_ruby_version = '>= 1.8.7'
8
+
9
+ s.author = 'Service & Consulting'
10
+ # s.email = 'david@loudthinking.com'
11
+ s.homepage = 'https://github.com/secoint/spree_online_support'
12
+ # s.rubyforge_project = 'actionmailer'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = [ 'lib' ]
18
+ s.requirements << 'none'
19
+
20
+ s.add_dependency('spree_core', '>= 0.40.3')
21
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_online_support
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 50
8
+ - 0
9
+ version: 0.50.0
10
+ platform: ruby
11
+ authors:
12
+ - Service & Consulting
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-27 00:00:00 +04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: spree_core
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 40
30
+ - 3
31
+ version: 0.40.3
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description:
35
+ email:
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - app/controllers/admin/online_support_settings_controller.rb
47
+ - app/views/admin/online_support_settings/edit.html.erb
48
+ - app/views/admin/online_support_settings/show.html.erb
49
+ - app/views/shared/_online_support.html.erb
50
+ - config/locales/en.yml
51
+ - config/locales/ru.yml
52
+ - config/routes.rb
53
+ - lib/online_support_configuration.rb
54
+ - lib/spree/online_support/config.rb
55
+ - lib/spree_online_support.rb
56
+ - lib/spree_online_support_hooks.rb
57
+ - lib/tasks/install.rake
58
+ - lib/tasks/spree_online_support.rake
59
+ - spec/spec_helper.rb
60
+ - spree_online_support.gemspec
61
+ has_rdoc: true
62
+ homepage: https://github.com/secoint/spree_online_support
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 1
76
+ - 8
77
+ - 7
78
+ version: 1.8.7
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ requirements:
87
+ - none
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.6
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Adds integration with online support services, like zopim.com
93
+ test_files: []
94
+