freshdesk-rails 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +80 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/freshdesk.js +3 -0
- data/app/assets/javascripts/freshdesk.turbolinks.js +69 -0
- data/freshdesk-rails.gemspec +27 -0
- data/lib/freshdesk-rails/configuration.rb +15 -0
- data/lib/freshdesk-rails/controller_helper.rb +24 -0
- data/lib/freshdesk-rails/engine.rb +15 -0
- data/lib/freshdesk-rails/helper.rb +11 -0
- data/lib/freshdesk-rails/version.rb +3 -0
- data/lib/freshdesk-rails/view_helper.rb +39 -0
- data/lib/freshdesk-rails.rb +17 -0
- metadata +160 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b510bf04039ba1788b937a9d6f1d69e2f7125011
|
|
4
|
+
data.tar.gz: 94230973b4130f32296b9baeec3d6dd2c8e4fc1b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: febbf8ccfcb05e184e28a2bbe9058ef088e541885b3400439f7b874403ec3348dfd1e271abd79f574cb5c10c99ef5bb1db8110f80be7911cb5e4d6acf7285f59
|
|
7
|
+
data.tar.gz: 4d4fa981806e613bc81001139028c5458949ec9f6fbba33da96af32a6d630ce1e3879c7dd8ad81b7394400e34dab8297c82772d09690720e78a46fa31830e036
|
data/.gitignore
ADDED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Chen Yi-Cyuan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# freshdesk-rails
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/emn178/freshdesk-rails)
|
|
4
|
+
[](https://coveralls.io/r/emn178/freshdesk-rails?branch=master)
|
|
5
|
+
|
|
6
|
+
A library to integrate with [freshdesk](https://freshdesk.com/) help desk.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Add this line to your application's Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'freshdesk-rails'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Make sure you have:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'jquery-rails'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
And then execute:
|
|
23
|
+
|
|
24
|
+
bundle
|
|
25
|
+
|
|
26
|
+
Or install it yourself as:
|
|
27
|
+
|
|
28
|
+
gem install freshdesk-rails
|
|
29
|
+
|
|
30
|
+
For rails, create config `config/initializers/freshdesk-rails.rb`
|
|
31
|
+
```ruby
|
|
32
|
+
FreshdeskRails.configure do |config|
|
|
33
|
+
config.default_locale = :en
|
|
34
|
+
# list your help desks with locales.
|
|
35
|
+
config.urls = {
|
|
36
|
+
'zh-TW' => 'http://tw.example.freshdesk.com',
|
|
37
|
+
'ja-JP' => 'http://jp.example.freshdesk.com',
|
|
38
|
+
'en' => 'http://example.freshdesk.com'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# set your name of locale in cookie, this is for turbolinks
|
|
42
|
+
config.locale_cookie = :locale
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
In rails controllers, you can call `redirect_to_freshdesk` to redirect with locale.
|
|
49
|
+
```ruby
|
|
50
|
+
# using I18n.locale
|
|
51
|
+
redirect_to_freshdesk
|
|
52
|
+
```
|
|
53
|
+
Or you can assaign locale manaully
|
|
54
|
+
```ruby
|
|
55
|
+
redirect_to_freshdesk :locale => :en
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
In view, you can use `include_popup_freshdesk` to include javascript plugin.
|
|
59
|
+
```ruby
|
|
60
|
+
# in <head/>
|
|
61
|
+
include_popup_freshdesk "", {"queryString": "&widgetType=popup&formTitle=Ask+Something...&submitThanks=Thanks+for+your+feedback", "utf8": "✓", "widgetType": "popup", "buttonType": "text", "buttonText": "Help", "buttonColor": "white", "buttonBg": "#09a8be", "alignment": "2", "offset": "350px", "submitThanks": "Thanks for your feedback", "formHeight": "500px" }
|
|
62
|
+
```
|
|
63
|
+
If you use turbolinks without enabling locale_cookie, you can assaign locale manually.
|
|
64
|
+
```Ruby
|
|
65
|
+
# in <body/>
|
|
66
|
+
# using I18n.locale
|
|
67
|
+
include_freshdesk_locale
|
|
68
|
+
```
|
|
69
|
+
Or
|
|
70
|
+
```Ruby
|
|
71
|
+
include_freshdesk_locale :en
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
77
|
+
|
|
78
|
+
## Contact
|
|
79
|
+
The project's website is located at https://github.com/emn178/freshdesk-rails
|
|
80
|
+
Author: emn178@gmail.com
|
data/Rakefile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
//= require freshdesk.turbolinks
|
|
2
|
+
|
|
3
|
+
!function(){function i(a){try{return a()}catch(b){window.console&&window.console.log&&window.console.log.apply&&window.console.log("Freshdesk Error: ",b)}}function k(b){return b&&!c.test(b)?a.location.protocol+"//"+b:b}function l(b){var c=a.createElement("link");c.setAttribute("rel","stylesheet"),c.setAttribute("type","text/css"),c.setAttribute("href",b),"undefined"!=typeof c&&a.getElementsByTagName("head")[0].appendChild(c)}function m(b){var c=a.createElement("script");c.setAttribute("type","text/javascript"),c.setAttribute("src",b),"undefined"!=typeof c&&a.getElementsByTagName("head")[0].appendChild(c)}function n(a,b,c){a&&a.addEventListener?a.addEventListener(b,c,!1):a&&a.attachEvent&&a.attachEvent("on"+b,c)}function o(a){var b;for(b in a)f.hasOwnProperty(b)&&("url"===b||"assetUrl"===b?f[b]=k(a[b]):f[b]=a[b])}function p(b){var c=b.src,d=window.navigator&&window.navigator.appVersion.split("MSIE"),e=parseFloat(d[1]);return e>=5.5&&7>e&&a.body.filters&&(b.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+c+"', sizingMethod='crop')"),b}function q(){null==$widget_attr.button&&"popup"==f.widgetType&&(class_name=b[f.alignment]||"left",$widget_attr.button=a.createElement("div"),$widget_attr.button.setAttribute("id","freshwidget-button"),$widget_attr.button.style.display="none",$widget_attr.button.className="freshwidget-button fd-btn-"+class_name,j.Version()<=10&&($widget_attr.button.className+=" ie"+j.Version()),link=a.createElement("a"),link.setAttribute("href","javascript:void(0)"),text=null,proxyLink=a.createElement("a"),proxyLink.setAttribute("href","javascript:void(0)"),null==f.backgroundImage||""==f.backgroundImage||"text"==f.buttonType?(link.className="freshwidget-theme",link.style.color=f.buttonColor,link.style.backgroundColor=f.buttonBg,link.style.borderColor=f.buttonColor,proxyLink.className="proxy-link",text=a.createTextNode(f.buttonText)):(link.className="freshwidget-customimage",text=a.createElement("img"),text.src=f.backgroundImage,text.alt=f.buttonText,text=p(text)),"top"==class_name||"bottom"==class_name?$widget_attr.button.style.left=f.offset:$widget_attr.button.style.top=f.offset,a.body.insertBefore($widget_attr.button,a.body.childNodes[0]),$widget_attr.button.appendChild(link),link.appendChild(text),(null==f.backgroundImage||""==f.backgroundImage)&&j.Version()<=10&&($widget_attr.button.appendChild(proxyLink),n(proxyLink,"click",function(){window.FreshWidget.show()}),proxyLink.style.height=link.offsetHeight+"px",proxyLink.style.width=link.offsetWidth+"px"),n(link,"click",function(){window.FreshWidget.show()}))}function r(){null!=$widget_attr.button&&(a.body.removeChild($widget_attr.button),$widget_attr.button=null)}function s(){null!=$widget_attr.container&&(a.body.removeChild($widget_attr.container),$widget_attr.container=null)}function t(){null==$widget_attr.container&&($widget_attr.container=a.createElement("div"),$widget_attr.container.className="freshwidget-container",$widget_attr.container.id="FreshWidget",""==f.responsive&&($widget_attr.container.className+=" responsive"),$widget_attr.container.style.display="none",a.body.insertBefore($widget_attr.container,a.body.childNodes[0]),$widget_attr.container.innerHTML='<div class="widget-ovelay" id="freshwidget-overlay"> </div><div class="freshwidget-dialog" id="freshwidget-dialog"> <img alt="Close Feedback Form" id="freshwidget-close" class="widget-close" src="'+f.assetUrl+"/widget_close.png?ver="+d+'" /><div class="mobile-widget-close" id="mobile-widget-close"></div> <div class="frame-container"> <iframe title="Feedback Form" id="freshwidget-frame" src="about:blank" frameborder="0" scrolling="auto" allowTransparency="true" style="height: '+f.formHeight+'"/> </div>',$widget_attr.container=a.getElementById("FreshWidget"),$widget_attr.closeButton=a.getElementById("freshwidget-close"),$widget_attr.closeButton=p($widget_attr.closeButton),$widget_attr.mobileCloseButton=a.getElementById("mobile-widget-close"),$widget_attr.dialog=a.getElementById("freshwidget-dialog"),$widget_attr.iframe=a.getElementById("freshwidget-frame"),$widget_attr.overlay=a.getElementById("freshwidget-overlay"),$widget_attr.dialog.appendChild($widget_attr.iframe),u(),n($widget_attr.closeButton,"click",function(){window.FreshWidget.close()}),n($widget_attr.mobileCloseButton,"click",function(){window.FreshWidget.close()}),n($widget_attr.overlay,"click",function(){window.FreshWidget.close()}),n($widget_attr.iframe,"load",function(){$widget_attr.iframeLoaded||-1==$widget_attr.iframe.src.indexOf("/widgets/feedback_widget/new?")||($widget_attr.iframeLoaded=!0)}))}function u(){$widget_attr.iframe.src=f.url+"/loading.html?ver="+d}function v(){$widget_attr.iframe.src=f.url+"/widgets/feedback_widget/new?"+f.queryString}function w(){scroll(0,0),$widget_attr.container.style.display="block",f.responsive||(e=a.body.style.overflow,a.body.style.overflow="hidden"),j.Version()>8&&""==f.screenshot&&html2canvas([a.body],{ignoreIds:"FreshWidget|freshwidget-button",proxy:!1,onrendered:function(b){var c=b.toDataURL(),d=c;sendMessage=setInterval(function(){$widget_attr.iframeLoaded&&(a.getElementById("freshwidget-frame").contentWindow.postMessage(d,"*"),clearInterval(sendMessage))},500)}}),$widget_attr.iframeLoaded||v()}function x(){$widget_attr.container.style.display="none",f.responsive||(a.body.style.overflow=e||"auto"),v()}function y(a){o(a),j.Version()>8&&"undefined"==typeof html2canvas&&""==f.screenshot&&m(f.assetUrl+"/html2canvas.js?ver="+d),n(window,"load",function(){q(),t()}),l(f.assetUrl+"/freshwidget.css?ver="+d)}function z(a){o(a),r(),s(),$widget_attr.iframeLoaded=!1,q(),t()}function A(){r(),s(),delete window.FreshWidget}var e,a=window.document,b={1:"top",2:"right",3:"bottom",4:"left",top:"top",right:"right",bottom:"bottom",left:"left"},c=/^[a-zA-Z]+:\/\//,d=2,f={widgetId:0,buttonText:"Support",buttonBg:"#7eb600",buttonColor:"white",backgroundImage:null,alignment:"left",offset:"35%",url:"http://support.freshdesk.com",assetUrl:"https://s3.amazonaws.com/assets.freshdesk.com/widget",queryString:"",screenshot:"",formHeight:"500px",responsive:"",widgetType:"popup",buttonType:"text"};$widget_attr={button:null,dialog:null,container:null,overlay:null,iframe:null,iframeLoaded:!1,closeButton:null,mobileCloseButton:null};var j={Version:function(){var a=999;return-1!=navigator.appVersion.indexOf("MSIE")&&(a=parseFloat(navigator.appVersion.split("MSIE")[1])),a}},B={init:function(a,b){i(function(){return y(b)})},show:function(){i(function(){return w()})},close:function(){i(function(){return x()})},iframe:function(){return $widget_attr.iframe},update:function(a){i(function(){return z(a)})},destroy:function(){i(function(){return A()})}};window.FreshWidget||(window.FreshWidget=B)}();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
;(function($, undefined) {
|
|
2
|
+
var FreshdeskRails = {}, widgets = $(), iframe, button, locale, orig_locale;
|
|
3
|
+
|
|
4
|
+
window.FreshdeskRails = FreshdeskRails;
|
|
5
|
+
|
|
6
|
+
function openIframe() {
|
|
7
|
+
button.unbind('click', openIframe);
|
|
8
|
+
updateIframeLocale(orig_locale);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function updateIframeLocale (old_locale) {
|
|
12
|
+
if(locale == old_locale) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
var url = FreshdeskRails.urls[locale];
|
|
16
|
+
var old_url = FreshdeskRails.urls[old_locale];
|
|
17
|
+
if(url == old_url) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var iframe_url = iframe.attr('src');
|
|
21
|
+
iframe_url = iframe_url.replace(old_url, url);
|
|
22
|
+
iframe.attr('src', iframe_url);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function updateLocale(new_locale) {
|
|
26
|
+
if(locale == new_locale) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var old_locale = locale;
|
|
30
|
+
locale = new_locale;
|
|
31
|
+
updateIframeLocale(old_locale);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$(document).on('page:before-unload', function() {
|
|
35
|
+
if(!widgets.length) {
|
|
36
|
+
widgets = $('#FreshWidget, #freshwidget-button');
|
|
37
|
+
iframe = $('#freshwidget-frame');
|
|
38
|
+
button = $('.freshwidget-theme');
|
|
39
|
+
button.click(openIframe);
|
|
40
|
+
$('#freshwidget-close, #freshwidget-overlay').click(function () {
|
|
41
|
+
updateIframeLocale(orig_locale);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
$(document).on('page:load', function() {
|
|
46
|
+
$('body').append(widgets);
|
|
47
|
+
if(FreshdeskRails.locale) {
|
|
48
|
+
updateLocale(FreshdeskRails.locale);
|
|
49
|
+
delete FreshdeskRails.locale;
|
|
50
|
+
} else if(FreshdeskRails.locale_cookie) {
|
|
51
|
+
updateLocale(getCookie(FreshdeskRails.locale_cookie));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
$(document).ready(function () {
|
|
56
|
+
if(FreshdeskRails.locale) {
|
|
57
|
+
orig_locale = locale = FreshdeskRails.locale;
|
|
58
|
+
delete FreshdeskRails.locale;
|
|
59
|
+
} else if(FreshdeskRails.locale_cookie) {
|
|
60
|
+
orig_locale = locale = getCookie(FreshdeskRails.locale_cookie);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
function getCookie(name) {
|
|
65
|
+
var value = "; " + document.cookie;
|
|
66
|
+
var parts = value.split("; " + name + "=");
|
|
67
|
+
if (parts.length == 2) return parts.pop().split(";").shift();
|
|
68
|
+
}
|
|
69
|
+
})(jQuery);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'freshdesk-rails/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "freshdesk-rails"
|
|
8
|
+
spec.version = FreshdeskRails::VERSION
|
|
9
|
+
spec.authors = ["Chen Yi-Cyuan"]
|
|
10
|
+
spec.email = ["emn178@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A library to integrate with freshdesk help desk.}
|
|
13
|
+
spec.description = %q{A library to integrate with freshdesk help desk.}
|
|
14
|
+
spec.homepage = "https://github.com/emn178/freshdesk-rails"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
+
spec.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
22
|
+
spec.add_development_dependency "actionview"
|
|
23
|
+
spec.add_development_dependency "rspec"
|
|
24
|
+
spec.add_development_dependency "rspec-its"
|
|
25
|
+
spec.add_development_dependency "simplecov"
|
|
26
|
+
spec.add_development_dependency "coveralls"
|
|
27
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module FreshdeskRails
|
|
2
|
+
class Configuration
|
|
3
|
+
attr_accessor :urls, :default_locale, :locale_cookie
|
|
4
|
+
|
|
5
|
+
def initialize(options = {})
|
|
6
|
+
options.each { |key, value|
|
|
7
|
+
instance_variable_set("@#{key}", value)
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate!
|
|
12
|
+
raise 'default_locale is not definded in urls.' if Helper.indifferent_access(urls, default_locale).nil?
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module FreshdeskRails
|
|
2
|
+
module ControllerHelper
|
|
3
|
+
def freshdesk_url(options = {})
|
|
4
|
+
locale = freshdesk_locale(Helper.indifferent_access(options, :locale))
|
|
5
|
+
Helper.indifferent_access(FreshdeskRails.configuration.urls, locale)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def redirect_to_freshdesk(options = {})
|
|
9
|
+
redirect_to(freshdesk_url(options))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def freshdesk_locale(locale)
|
|
15
|
+
locale = locale || Helper.current_locale
|
|
16
|
+
urls = FreshdeskRails.configuration.urls
|
|
17
|
+
if Helper.indifferent_access(urls, locale).nil?
|
|
18
|
+
FreshdeskRails.configuration.default_locale
|
|
19
|
+
else
|
|
20
|
+
locale
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
if defined?(::Rails::Engine)
|
|
2
|
+
module FreshdeskRails
|
|
3
|
+
class Engine < ::Rails::Engine
|
|
4
|
+
initializer "freshdesk" do
|
|
5
|
+
ActiveSupport.on_load :action_controller do
|
|
6
|
+
include FreshdeskRails::ControllerHelper
|
|
7
|
+
end
|
|
8
|
+
ActiveSupport.on_load :action_view do
|
|
9
|
+
include FreshdeskRails::ViewHelper
|
|
10
|
+
end
|
|
11
|
+
Rails.application.config.assets.precompile += %w( freshdesk.js )
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
module FreshdeskRails
|
|
4
|
+
module ViewHelper
|
|
5
|
+
include FreshdeskRails::ControllerHelper
|
|
6
|
+
|
|
7
|
+
def freshdesk_tag
|
|
8
|
+
javascript_include_tag("freshdesk.js")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def include_popup_freshdesk(arg1, widget_options, options = {})
|
|
12
|
+
freshdesk_tag + freshdesk_script_tag(arg1, widget_options, options)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def include_freshdesk_locale(locale = nil)
|
|
16
|
+
locale = freshdesk_locale(locale)
|
|
17
|
+
javascript_tag "window.FreshdeskRails.locale=#{locale.to_json};"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def freshdesk_script_tag(arg1, widget_options, options = {})
|
|
23
|
+
javascript_tag freshdesk_init_script(arg1, widget_options, options) + freshdesk_urls_script
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def freshdesk_init_script(arg1, widget_options, options = {})
|
|
27
|
+
widget_options[:url] = freshdesk_url(options)
|
|
28
|
+
"FreshWidget.init(\"#{arg1}\", #{widget_options.to_json});"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def freshdesk_urls_script
|
|
32
|
+
script = "window.FreshdeskRails.urls=#{FreshdeskRails.configuration.urls.to_json};"
|
|
33
|
+
if FreshdeskRails.configuration.locale_cookie
|
|
34
|
+
script += "window.FreshdeskRails.locale_cookie=#{FreshdeskRails.configuration.locale_cookie.to_json};"
|
|
35
|
+
end
|
|
36
|
+
script
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "freshdesk-rails/version"
|
|
2
|
+
require "freshdesk-rails/configuration"
|
|
3
|
+
require "freshdesk-rails/helper"
|
|
4
|
+
require "freshdesk-rails/controller_helper"
|
|
5
|
+
require "freshdesk-rails/view_helper"
|
|
6
|
+
require "freshdesk-rails/engine"
|
|
7
|
+
|
|
8
|
+
module FreshdeskRails
|
|
9
|
+
def self.configure(&block)
|
|
10
|
+
yield configuration
|
|
11
|
+
configuration.validate!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.configuration
|
|
15
|
+
@configuration ||= Configuration.new
|
|
16
|
+
end
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: freshdesk-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Chen Yi-Cyuan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-11-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.10'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.10'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: actionview
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec-its
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: simplecov
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: coveralls
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
description: A library to integrate with freshdesk help desk.
|
|
112
|
+
email:
|
|
113
|
+
- emn178@gmail.com
|
|
114
|
+
executables: []
|
|
115
|
+
extensions: []
|
|
116
|
+
extra_rdoc_files: []
|
|
117
|
+
files:
|
|
118
|
+
- ".gitignore"
|
|
119
|
+
- ".rspec"
|
|
120
|
+
- ".travis.yml"
|
|
121
|
+
- CHANGELOG.md
|
|
122
|
+
- Gemfile
|
|
123
|
+
- LICENSE.txt
|
|
124
|
+
- README.md
|
|
125
|
+
- Rakefile
|
|
126
|
+
- app/assets/javascripts/freshdesk.js
|
|
127
|
+
- app/assets/javascripts/freshdesk.turbolinks.js
|
|
128
|
+
- freshdesk-rails.gemspec
|
|
129
|
+
- lib/freshdesk-rails.rb
|
|
130
|
+
- lib/freshdesk-rails/configuration.rb
|
|
131
|
+
- lib/freshdesk-rails/controller_helper.rb
|
|
132
|
+
- lib/freshdesk-rails/engine.rb
|
|
133
|
+
- lib/freshdesk-rails/helper.rb
|
|
134
|
+
- lib/freshdesk-rails/version.rb
|
|
135
|
+
- lib/freshdesk-rails/view_helper.rb
|
|
136
|
+
homepage: https://github.com/emn178/freshdesk-rails
|
|
137
|
+
licenses:
|
|
138
|
+
- MIT
|
|
139
|
+
metadata: {}
|
|
140
|
+
post_install_message:
|
|
141
|
+
rdoc_options: []
|
|
142
|
+
require_paths:
|
|
143
|
+
- lib
|
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: '0'
|
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
|
+
requirements:
|
|
151
|
+
- - ">="
|
|
152
|
+
- !ruby/object:Gem::Version
|
|
153
|
+
version: '0'
|
|
154
|
+
requirements: []
|
|
155
|
+
rubyforge_project:
|
|
156
|
+
rubygems_version: 2.4.8
|
|
157
|
+
signing_key:
|
|
158
|
+
specification_version: 4
|
|
159
|
+
summary: A library to integrate with freshdesk help desk.
|
|
160
|
+
test_files: []
|