mwp_themes_proposal_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/mwp_themes_proposal_client.js.coffee +16 -0
- data/app/helpers/stats_helper.rb +49 -0
- data/lib/mwp_themes_proposal_client.rb +4 -0
- metadata +51 -0
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.libs << 'test'
|
17
|
+
t.pattern = 'test/**/*_test.rb'
|
18
|
+
t.verbose = false
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
22
|
+
|
23
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
+
rdoc.rdoc_dir = 'rdoc'
|
25
|
+
rdoc.title = 'MwpThemesProposalClient'
|
26
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
28
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class MwpEventRegister
|
2
|
+
sessionId = null
|
3
|
+
self = this
|
4
|
+
|
5
|
+
@registerEvent = (eventName, themeIds) ->
|
6
|
+
return unless eventName
|
7
|
+
$.post '/mwp-themes-proposal/1/register/'+eventName.toString()+'.json', { session_id: sessionId, theme_id: themeIds }
|
8
|
+
|
9
|
+
@hook = (selector, eventName) ->
|
10
|
+
$(selector).click ->
|
11
|
+
self.registerEvent(eventName, $(this).attr('data-theme-id'))
|
12
|
+
|
13
|
+
@setSessionId = (sid) ->
|
14
|
+
sessionId = sid
|
15
|
+
|
16
|
+
window.MwpEventRegister = MwpEventRegister
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module StatsHelper
|
2
|
+
def stats_helper(&blk)
|
3
|
+
hooks_array = Array.new
|
4
|
+
|
5
|
+
hooks = Helpers::Hooks.new(hooks_array)
|
6
|
+
hooks.instance_eval(&blk)
|
7
|
+
|
8
|
+
hooks_js = hooks_array.map do |h|
|
9
|
+
Helpers.mwp_register_hook(h[:scope], h[:event])
|
10
|
+
end.join("\n")
|
11
|
+
|
12
|
+
session[:session_id] ?
|
13
|
+
Helpers.format_hook_js(session[:session_id], hooks_js) :
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
module Helpers
|
20
|
+
class Hooks
|
21
|
+
def initialize(hooks)
|
22
|
+
@hooks = hooks
|
23
|
+
end
|
24
|
+
|
25
|
+
def hook(scope, event)
|
26
|
+
@hooks << { scope: scope, event: event }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.format_hook_js(session_id, hooks_js)
|
31
|
+
session_id = Digest::MD5.hexdigest(session_id)
|
32
|
+
%Q{
|
33
|
+
<script type="text/javascript" charset="utf-8">
|
34
|
+
(function() {
|
35
|
+
jQuery(function() {
|
36
|
+
MwpEventRegister.setSessionId('#{session_id}');
|
37
|
+
#{hooks_js}
|
38
|
+
});
|
39
|
+
}).call(this);
|
40
|
+
</script>
|
41
|
+
}.gsub("\n", "").gsub(/\s+/, ' ').html_safe
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.mwp_register_hook(scope, event)
|
45
|
+
"MwpEventRegister.hook('#{scope}', '#{event}');"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mwp_themes_proposal_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ivan Kasatenko
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Themes proposal client-side client gem
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- app/assets/javascripts/mwp_themes_proposal_client.js.coffee
|
21
|
+
- app/helpers/stats_helper.rb
|
22
|
+
- lib/mwp_themes_proposal_client.rb
|
23
|
+
- MIT-LICENSE
|
24
|
+
- Rakefile
|
25
|
+
- Gemfile
|
26
|
+
- README.rdoc
|
27
|
+
homepage:
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.24
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Themes proposal client-side client gem
|
51
|
+
test_files: []
|