insights 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 +1 -0
- data/Gemfile +3 -0
- data/LICENSE.md +21 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/inputs/chart.coffee +57 -0
- data/app/assets/javascripts/inputs/chart_line.coffee +14 -0
- data/app/assets/javascripts/inputs/chart_table.coffee +14 -0
- data/app/assets/javascripts/insights.coffee +34 -0
- data/app/assets/stylesheets/insights.scss +36 -0
- data/app/helpers/insights_helper.rb +29 -0
- data/insights.gemspec +21 -0
- data/lib/insights/engine.rb +4 -0
- data/lib/insights/version.rb +3 -0
- data/lib/insights.rb +5 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 596dc0e0949da344da61b0d339001672d66a835d
|
4
|
+
data.tar.gz: 43741b49b3b56e4ac0b50eb2ba5d1116c9df68c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bffb4aa492c6e78c04c7ab8f61edeec41649fb93c883744468ea2dc199b0f7a55687ab5cb1ed94909c4eafc3ccc50166d0db05041e951c92c8965c3829211615
|
7
|
+
data.tar.gz: 41e1839edca3aee5648fe7e4e76f3761473c95b21ac6ee6b8dc2505c60564128ea4de2372eb2cf6e9806a5f8844375f0f0d23618e8625f069c7c479e4e4bc0df
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright © 2015 [Slate Studio](https://github.com/slate-studio)
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Insights
|
2
|
+
|
3
|
+
*Plug Google Analytics charts into [Character](https://github.com/slate-studio/chr) dashboard.*
|
4
|
+
|
5
|
+
|
6
|
+
### Installation
|
7
|
+
|
8
|
+
Add to ```Gemfile```:
|
9
|
+
|
10
|
+
gem 'insights'
|
11
|
+
|
12
|
+
|
13
|
+
## Insights family
|
14
|
+
|
15
|
+
- [Character](https://github.com/slate-studio/chr): Powerful javascript CMS for apps
|
16
|
+
- [Mongosteen](https://github.com/slate-studio/mongosteen): An easy way to add restful actions for mongoid models
|
17
|
+
- [Inverter](https://github.com/slate-studio/inverter): An easy way to connect Rails templates content to CMS
|
18
|
+
- [Loft](https://github.com/slate-studio/loft): Media assets manager for Character CMS
|
19
|
+
|
20
|
+
|
21
|
+
## License
|
22
|
+
|
23
|
+
Copyright © 2015 [Slate Studio](https://github.com/slate-studio). Insights is free software, and may be redistributed under the terms specified in the [license](LICENSE.md).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Authors: Maksym Melnyk <maxim@slatestudio.com>,
|
3
|
+
# Alexander Kravets <alex@slatestudio.com>,
|
4
|
+
# Slate Studio (http://www.slatestudio.com)
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# INPUT CHART
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
class @InputChart
|
9
|
+
constructor: (@name, @value, @config, @object) ->
|
10
|
+
@_create_el()
|
11
|
+
|
12
|
+
# PRIVATE ===================================================================
|
13
|
+
|
14
|
+
_create_el: ->
|
15
|
+
id = "#{ @config.fieldName }_chart_container"
|
16
|
+
@$el = $("<div id='#{ id }' class='input-chart'>")
|
17
|
+
|
18
|
+
_chart_options: ->
|
19
|
+
@config.chart
|
20
|
+
|
21
|
+
_set_default_query_options: ->
|
22
|
+
@config.query.dimensions ||= "ga:date"
|
23
|
+
@config.query["start-date"] ||= "30daysAgo"
|
24
|
+
@config.query["end-date"] ||= "today"
|
25
|
+
|
26
|
+
# PUBLIC ====================================================================
|
27
|
+
|
28
|
+
showErrorMessage: (message) -> ;
|
29
|
+
|
30
|
+
hideErrorMessage: -> ;
|
31
|
+
|
32
|
+
initialize: ->
|
33
|
+
@_set_default_query_options()
|
34
|
+
|
35
|
+
# Provides flexibility of options customization for child input classes
|
36
|
+
options = @_chart_options()
|
37
|
+
options.options = $.extend(options.options, @config.chartOptions)
|
38
|
+
|
39
|
+
@dataChart = new gapi.analytics.googleCharts.DataChart
|
40
|
+
query: @config.query
|
41
|
+
chart: options
|
42
|
+
|
43
|
+
@dataChart.set
|
44
|
+
query:
|
45
|
+
ids: "ga:#{ GA_TABLE_ID }"
|
46
|
+
chart:
|
47
|
+
container: "#{ @config.fieldName }_chart_container"
|
48
|
+
|
49
|
+
@dataChart.execute()
|
50
|
+
|
51
|
+
@config.onInitialize?(this)
|
52
|
+
|
53
|
+
hash: (hash={}) -> ;
|
54
|
+
|
55
|
+
updateValue: (@value) -> ;
|
56
|
+
|
57
|
+
chr.formInputs['chart'] = InputChart
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Authors: Maksym Melnyk <maxim@slatestudio.com>,
|
3
|
+
# Alexander Kravets <alex@slatestudio.com>,
|
4
|
+
# Slate Studio (http://www.slatestudio.com)
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# INPUT CHART
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
class @InputChartLine extends InputChart
|
9
|
+
_chart_options: ->
|
10
|
+
type: 'LINE'
|
11
|
+
options:
|
12
|
+
width: '100%'
|
13
|
+
|
14
|
+
chr.formInputs['chart-line'] = InputChartLine
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Authors: Maksym Melnyk <maxim@slatestudio.com>,
|
3
|
+
# Alexander Kravets <alex@slatestudio.com>,
|
4
|
+
# Slate Studio (http://www.slatestudio.com)
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# INPUT CHART
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
class @InputChartTable extends InputChart
|
9
|
+
_chart_options: ->
|
10
|
+
type: 'TABLE'
|
11
|
+
options:
|
12
|
+
width: '100%'
|
13
|
+
|
14
|
+
chr.formInputs['chart-table'] = InputChartTable
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Authors: Maksym Melnyk <maxim@slatestudio.com>,
|
3
|
+
# Alexander Kravets <alex@slatestudio.com>,
|
4
|
+
# Slate Studio (http://www.slatestudio.com)
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# INSIGHTS DASHBOARD
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Dependencies:
|
9
|
+
#= require_tree ./inputs
|
10
|
+
# -----------------------------------------------------------------------------
|
11
|
+
class @InsightsDashboard
|
12
|
+
constructor: (config) ->
|
13
|
+
@title = config.title
|
14
|
+
@subtitle = config.subtitle
|
15
|
+
@disableSave = true
|
16
|
+
@objectStore = new ObjectStore({ data: {} })
|
17
|
+
@formSchema = {}
|
18
|
+
|
19
|
+
for k, v of config.charts
|
20
|
+
@_add_chart(k, v)
|
21
|
+
|
22
|
+
## PRIVATE ==================================================================
|
23
|
+
|
24
|
+
_add_chart: (name, config) ->
|
25
|
+
@formSchema["#{name}_panel"] =
|
26
|
+
type: "group"
|
27
|
+
groupClass: "group-panel"
|
28
|
+
title: config.title || name.titleize()
|
29
|
+
inputs: {}
|
30
|
+
|
31
|
+
@formSchema["#{name}_panel"].inputs[name] =
|
32
|
+
type: config.type || "chart-line"
|
33
|
+
query: config.query
|
34
|
+
chartOptions: config.chartOptions
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$highlight-color: #ffffc0;
|
2
|
+
|
3
|
+
.input-chart {
|
4
|
+
margin: 0 1em;
|
5
|
+
|
6
|
+
.google-visualization-table {
|
7
|
+
margin: 0.25em 0 1em;
|
8
|
+
}
|
9
|
+
|
10
|
+
.gapi-analytics-data-chart {
|
11
|
+
.google-visualization-table-table {
|
12
|
+
font-size: 0.9em;
|
13
|
+
}
|
14
|
+
|
15
|
+
.gapi-analytics-data-chart-styles-table-th {
|
16
|
+
border-color: $border-color;
|
17
|
+
}
|
18
|
+
|
19
|
+
.gapi-analytics-data-chart-styles-table-tr-odd {
|
20
|
+
background-color: $bg-color;
|
21
|
+
}
|
22
|
+
|
23
|
+
.gapi-analytics-data-chart-styles-table-tr-over {
|
24
|
+
background-color: $border-color;
|
25
|
+
}
|
26
|
+
|
27
|
+
.gapi-analytics-data-chart-styles-table-tr-sel {
|
28
|
+
background-color: $highlight-color;
|
29
|
+
}
|
30
|
+
|
31
|
+
.gapi-analytics-data-chart-styles-table-tr-even:last-child,
|
32
|
+
.gapi-analytics-data-chart-styles-table-tr-odd:last-child {
|
33
|
+
border-color: $border-color;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module InsightsHelper
|
2
|
+
def ga_charts_include_tag
|
3
|
+
# Load Google Embed API
|
4
|
+
# To embed Google Analytics charts
|
5
|
+
# Embed API can not be loaded via Google API Loader.
|
6
|
+
script = """(function(w,d,s,g,js,fs){
|
7
|
+
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}};
|
8
|
+
js=d.createElement(s);fs=d.getElementsByTagName(s)[0];
|
9
|
+
js.src='https://apis.google.com/js/platform.js';
|
10
|
+
fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');};
|
11
|
+
}(window,document,'script'));"""
|
12
|
+
|
13
|
+
ga_access_token = GoogleService.new.access_token
|
14
|
+
ga_table_id = Rails.application.secrets.ga_table_id
|
15
|
+
|
16
|
+
callback_script = """window.GA_TABLE_ID = '#{ga_table_id}';
|
17
|
+
gapi.analytics.ready(function(){
|
18
|
+
gapi.analytics.auth.authorize({
|
19
|
+
'serverAuth': {'access_token': '#{ga_access_token}'}
|
20
|
+
});
|
21
|
+
startCharacter();
|
22
|
+
});"""
|
23
|
+
|
24
|
+
[
|
25
|
+
javascript_tag(script),
|
26
|
+
javascript_tag(callback_script)
|
27
|
+
].join("\n").html_safe
|
28
|
+
end
|
29
|
+
end
|
data/insights.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'insights/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'insights'
|
7
|
+
s.version = Insights::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Alexander Kravets', 'Maxym Melnyk']
|
10
|
+
s.email = 'alex@slatestudio.com'
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.homepage = 'https://github.com/slate-studio/insights'
|
13
|
+
s.summary = 'Plug Google Analytics into Character dashboard.'
|
14
|
+
|
15
|
+
s.rubyforge_project = 'insights'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_dependency("google-api-client")
|
21
|
+
end
|
data/lib/insights.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: insights
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Kravets
|
8
|
+
- Maxym Melnyk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: google-api-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
description:
|
29
|
+
email: alex@slatestudio.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.md
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- app/assets/javascripts/inputs/chart.coffee
|
40
|
+
- app/assets/javascripts/inputs/chart_line.coffee
|
41
|
+
- app/assets/javascripts/inputs/chart_table.coffee
|
42
|
+
- app/assets/javascripts/insights.coffee
|
43
|
+
- app/assets/stylesheets/insights.scss
|
44
|
+
- app/helpers/insights_helper.rb
|
45
|
+
- insights.gemspec
|
46
|
+
- lib/insights.rb
|
47
|
+
- lib/insights/engine.rb
|
48
|
+
- lib/insights/version.rb
|
49
|
+
homepage: https://github.com/slate-studio/insights
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project: insights
|
69
|
+
rubygems_version: 2.4.5.1
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Plug Google Analytics into Character dashboard.
|
73
|
+
test_files: []
|