rail_stat_generator 0.1.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/templates/README +1 -1
- data/templates/app/controllers/rail_stat_controller.rb +11 -11
- data/templates/app/helpers/rail_stat_helper.rb +1 -1
- data/templates/app/models/rail_stat.rb +1 -1
- data/templates/app/views/rail_stat/hits.rhtml +2 -1
- data/templates/app/views/rail_stat/lang.rhtml +1 -1
- data/templates/db/railstat.rb +3 -3
- data/templates/lib/path_tracker.rb +19 -14
- metadata +103 -95
data/templates/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
== Installation
|
2
2
|
|
3
3
|
1. Create database
|
4
|
-
2. Create the database schema using rake migrate
|
4
|
+
2. Create the database schema using rake db:migrate
|
5
5
|
3. Download the IP-to-Country database from http://ip-to-country.webhosting.info/ :
|
6
6
|
|
7
7
|
wget http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip
|
@@ -12,8 +12,8 @@ class RailStatController < ApplicationController
|
|
12
12
|
def path
|
13
13
|
@ordered_resources, @orarr = RailStat.get_ordered40resources(@subdomain)
|
14
14
|
|
15
|
-
@number_hits = (
|
16
|
-
@include_search_engines = ((
|
15
|
+
@number_hits = (params['nh'] or not params['nh'].nil?) ? params['nh'].to_i : 50
|
16
|
+
@include_search_engines = ((params['ise'] == '' or params['ise'] == "1") ? 1 : 0)
|
17
17
|
|
18
18
|
@count_totals = RailStat.resource_count_totals
|
19
19
|
@paths = RailStat.find_all_by_flag(@include_search_engines == 0, @number_hits, @subdomain)
|
@@ -74,7 +74,7 @@ class RailStatController < ApplicationController
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def tracker_js
|
77
|
-
if
|
77
|
+
if request.env['HTTP_REFERER'] and request.env['HTTP_REFERER'].include?(request.host)
|
78
78
|
str = <<-JSDATA
|
79
79
|
c=0;
|
80
80
|
s=0;
|
@@ -102,24 +102,24 @@ class RailStatController < ApplicationController
|
|
102
102
|
else
|
103
103
|
str = ""
|
104
104
|
end
|
105
|
-
|
105
|
+
render :text => str
|
106
106
|
end
|
107
107
|
|
108
108
|
def track
|
109
109
|
track_path
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
110
|
+
response.headers['Pragma'] = ' '
|
111
|
+
response.headers['Cache-Control'] = ' '
|
112
|
+
response.headers['Content-Length'] = 68
|
113
|
+
response.headers['Accept-Ranges'] = 'bytes'
|
114
|
+
response.headers['Content-type'] = 'image/gif'
|
115
|
+
response.headers['Content-Disposition'] = 'inline'
|
116
116
|
File.open("#{RAILS_ROOT}/public/images/railstat/1pxtr.gif", 'rb') { |file| render :text => file.read }
|
117
117
|
end
|
118
118
|
|
119
119
|
|
120
120
|
private
|
121
121
|
def extract_subdomain
|
122
|
-
@subdomain = ((
|
122
|
+
@subdomain = ((request.subdomains and request.subdomains.first) ? request.subdomains.first : nil)
|
123
123
|
end
|
124
124
|
|
125
125
|
end
|
@@ -27,12 +27,13 @@
|
|
27
27
|
<td><%%=day['unique_hits']%></td>
|
28
28
|
</tr>
|
29
29
|
<%% end -%>
|
30
|
+
<%% unless @first_hit.blank? %>
|
30
31
|
<tr class='<%%= alternator %>'>
|
31
32
|
<td>Since <%%= @first_hit.datetime %></td>
|
32
33
|
<td><%%= @total_hits %></td>
|
33
34
|
<td><%%= @unique_hits %></td>
|
34
35
|
</tr>
|
35
|
-
|
36
|
+
<%% end %>
|
36
37
|
</table>
|
37
38
|
</div>
|
38
39
|
</div>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
<%% for country in @countries %>
|
30
30
|
<tr class="<%%= alternator %>">
|
31
31
|
<td><%%= country.country %></td>
|
32
|
-
<td><%%= sprintf("%000.2f", (
|
32
|
+
<td><%%= sprintf("%000.2f", (country.total.to_f/@total_hits)*100) %>%</td>
|
33
33
|
<td><%%= country.total %></td>
|
34
34
|
</tr>
|
35
35
|
<%% end %>
|
data/templates/db/railstat.rb
CHANGED
@@ -31,8 +31,8 @@ class Railstat < ActiveRecord::Migration
|
|
31
31
|
add_index :search_terms, :subdomain
|
32
32
|
|
33
33
|
create_table :iptocs do |t|
|
34
|
-
t.column :ip_from, :
|
35
|
-
t.column :ip_to, :
|
34
|
+
t.column :ip_from, :bigint, :null => false
|
35
|
+
t.column :ip_to, :bigint, :null => false
|
36
36
|
t.column :country_code2, :string, :null => false
|
37
37
|
t.column :country_code3, :string, :null => false
|
38
38
|
t.column :country_name, :string, :null => false
|
@@ -45,4 +45,4 @@ class Railstat < ActiveRecord::Migration
|
|
45
45
|
drop_table :search_terms
|
46
46
|
drop_table :iptocs
|
47
47
|
end
|
48
|
-
end
|
48
|
+
end
|
@@ -6,21 +6,21 @@ module PathTracker
|
|
6
6
|
|
7
7
|
def track_path
|
8
8
|
begin
|
9
|
-
referer =
|
10
|
-
req_uri =
|
9
|
+
referer = params['referer'] # env['HTTP_REFERER']
|
10
|
+
req_uri = params['doc'] # env['REQUEST_URI']
|
11
11
|
|
12
|
-
req_uri =
|
12
|
+
req_uri = request.env['HTTP_REFERER'] if req_uri.nil?
|
13
13
|
|
14
14
|
req_uri = get_doc_url(req_uri)
|
15
15
|
|
16
|
-
size =
|
17
|
-
colors =
|
18
|
-
java =
|
19
|
-
je =
|
20
|
-
flash =
|
16
|
+
size = params['size']
|
17
|
+
colors = params['colors']
|
18
|
+
java = params['java']
|
19
|
+
je = params['je']
|
20
|
+
flash = params['flash']
|
21
21
|
|
22
|
-
env =
|
23
|
-
'REMOTE_ADDR' => nil, 'HTTP_ACCEPT_LANGUAGE' => nil, 'REQUEST_URI' => nil} :
|
22
|
+
env = request.env.nil? ? {'HTTP_USER_AGENT' => nil, 'HTTP_REFERER' => nil,
|
23
|
+
'REMOTE_ADDR' => nil, 'HTTP_ACCEPT_LANGUAGE' => nil, 'REQUEST_URI' => nil} : request.env
|
24
24
|
br = parse_user_agent(env['HTTP_USER_AGENT'])
|
25
25
|
subdomain = detect_subdomain
|
26
26
|
domain = get_urls_host(referer)
|
@@ -30,13 +30,18 @@ module PathTracker
|
|
30
30
|
remote_ip = env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR']
|
31
31
|
|
32
32
|
if remote_ip == "127.0.0.1"
|
33
|
-
|
33
|
+
country_name = "LOCALHOST"
|
34
34
|
else
|
35
|
-
|
35
|
+
country = Iptoc.find_by_ip_address(remote_ip)
|
36
|
+
unless country == nil
|
37
|
+
country_name = country.country_name
|
38
|
+
else
|
39
|
+
country_name = "UNKNOWN"
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
38
43
|
RailStat.create("remote_ip" => remote_ip,
|
39
|
-
"country" =>
|
44
|
+
"country" => country_name,
|
40
45
|
"language" => determine_lang(env['HTTP_ACCEPT_LANGUAGE']),
|
41
46
|
"domain" => domain,
|
42
47
|
"subdomain" => subdomain,
|
@@ -321,7 +326,7 @@ module PathTracker
|
|
321
326
|
def detect_subdomain
|
322
327
|
subd = ''
|
323
328
|
begin
|
324
|
-
subd = ((
|
329
|
+
subd = ((request.subdomains and request.subdomains.first) ? request.subdomains.first : nil)
|
325
330
|
rescue Exception => e
|
326
331
|
logger.error("Error on subdomain parse #{e.backtrace.join('\n')}" )
|
327
332
|
end
|
metadata
CHANGED
@@ -1,126 +1,134 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: rail_stat_generator
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-10-31 00:00:00 +02:00
|
8
|
-
summary: RailStat is a real-time web site statistics package which uses Ruby on Rails web application framework.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: lubo_AT_manolov.org
|
12
|
-
homepage: http://www.railstat.com
|
13
|
-
rubyforge_project: railstat
|
14
|
-
description: "RailStat generator creates a real-time web site statistics system. Features: - Page views paths on each session - Number of total hits / unique hits - Operating system and browser - Countries and languages - Referrers and search strings - Flash / JavaVM / Javascript / ScreenWidth / ColorDepth"
|
15
|
-
autorequire: rail_stat_generator
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 2.0.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
6
|
authors:
|
29
7
|
- Luben Manolov
|
30
8
|
- Nick Penkov
|
31
9
|
- Jeff Casimir
|
10
|
+
autorequire: rail_stat_generator
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2008-10-20 00:00:00 +03:00
|
15
|
+
default_executable:
|
16
|
+
dependencies: []
|
17
|
+
|
18
|
+
description: "RailStat generator creates a real-time web site statistics system. Features: - Page views paths on each session - Number of total hits / unique hits - Operating system and browser - Countries and languages - Referrers and search strings - Flash / JavaVM / Javascript / ScreenWidth / ColorDepth"
|
19
|
+
email: lubo_AT_manolov.org
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
32
26
|
files:
|
33
|
-
- templates/app
|
34
|
-
- templates/db
|
35
|
-
- templates/lib
|
36
27
|
- templates/public
|
37
|
-
- templates/README
|
38
|
-
- templates/app/helpers
|
39
|
-
- templates/app/models
|
40
|
-
- templates/app/controllers
|
41
|
-
- templates/app/views
|
42
|
-
- templates/app/helpers/rail_stat_helper.rb
|
43
|
-
- templates/app/models/iptoc.rb
|
44
|
-
- templates/app/models/rail_stat.rb
|
45
|
-
- templates/app/models/search_term.rb
|
46
|
-
- templates/app/controllers/rail_stat_controller.rb
|
47
|
-
- templates/app/views/layouts
|
48
|
-
- templates/app/views/rail_stat
|
49
|
-
- templates/app/views/layouts/rail_stat.rhtml
|
50
|
-
- templates/app/views/rail_stat/path.rhtml
|
51
|
-
- templates/app/views/rail_stat/refs.rhtml
|
52
|
-
- templates/app/views/rail_stat/lang.rhtml
|
53
|
-
- templates/app/views/rail_stat/other.rhtml
|
54
|
-
- templates/app/views/rail_stat/_menu.rhtml
|
55
|
-
- templates/app/views/rail_stat/platform.rhtml
|
56
|
-
- templates/app/views/rail_stat/hits.rhtml
|
57
|
-
- templates/db/railstat.rb
|
58
|
-
- templates/db/ip-to-country.mysql.sql
|
59
|
-
- templates/lib/path_tracker.rb
|
60
|
-
- templates/public/images
|
61
|
-
- templates/public/javascripts
|
62
28
|
- templates/public/stylesheets
|
29
|
+
- templates/public/stylesheets/tabs.css
|
30
|
+
- templates/public/stylesheets/railstat.css
|
31
|
+
- templates/public/javascripts
|
32
|
+
- templates/public/javascripts/railstat.js
|
33
|
+
- templates/public/images
|
63
34
|
- templates/public/images/railstat
|
64
|
-
- templates/public/images/railstat/1pxtr.gif
|
65
|
-
- templates/public/images/railstat/10.gif
|
66
|
-
- templates/public/images/railstat/11.gif
|
67
|
-
- templates/public/images/railstat/other.gif
|
68
|
-
- templates/public/images/railstat/30.gif
|
69
|
-
- templates/public/images/railstat/12.gif
|
70
|
-
- templates/public/images/railstat/31.gif
|
71
|
-
- templates/public/images/railstat/13.gif
|
72
35
|
- templates/public/images/railstat/32.gif
|
73
|
-
- templates/public/images/railstat/14.gif
|
74
|
-
- templates/public/images/railstat/33.gif
|
75
|
-
- templates/public/images/railstat/15.gif
|
76
36
|
- templates/public/images/railstat/34.gif
|
77
|
-
- templates/public/images/railstat/
|
78
|
-
- templates/public/images/railstat/
|
79
|
-
- templates/public/images/railstat/17.gif
|
80
|
-
- templates/public/images/railstat/36.gif
|
81
|
-
- templates/public/images/railstat/18.gif
|
37
|
+
- templates/public/images/railstat/2.gif
|
38
|
+
- templates/public/images/railstat/12.gif
|
82
39
|
- templates/public/images/railstat/37.gif
|
83
|
-
- templates/public/images/railstat/
|
84
|
-
- templates/public/images/railstat/
|
85
|
-
- templates/public/images/railstat/
|
40
|
+
- templates/public/images/railstat/29.gif
|
41
|
+
- templates/public/images/railstat/other.gif
|
42
|
+
- templates/public/images/railstat/1.gif
|
43
|
+
- templates/public/images/railstat/27.gif
|
44
|
+
- templates/public/images/railstat/11.gif
|
86
45
|
- templates/public/images/railstat/20.gif
|
87
|
-
- templates/public/images/railstat/
|
46
|
+
- templates/public/images/railstat/17.gif
|
47
|
+
- templates/public/images/railstat/26.gif
|
48
|
+
- templates/public/images/railstat/19.gif
|
88
49
|
- templates/public/images/railstat/22.gif
|
89
|
-
- templates/public/images/railstat/
|
50
|
+
- templates/public/images/railstat/18.gif
|
51
|
+
- templates/public/images/railstat/10.gif
|
90
52
|
- templates/public/images/railstat/23.gif
|
53
|
+
- templates/public/images/railstat/38.gif
|
54
|
+
- templates/public/images/railstat/36.gif
|
55
|
+
- templates/public/images/railstat/7.gif
|
56
|
+
- templates/public/images/railstat/35.gif
|
91
57
|
- templates/public/images/railstat/24.gif
|
92
|
-
- templates/public/images/railstat/25.gif
|
93
|
-
- templates/public/images/railstat/26.gif
|
94
|
-
- templates/public/images/railstat/27.gif
|
95
|
-
- templates/public/images/railstat/28.gif
|
96
|
-
- templates/public/images/railstat/29.gif
|
97
|
-
- templates/public/images/railstat/1.gif
|
98
|
-
- templates/public/images/railstat/2.gif
|
99
|
-
- templates/public/images/railstat/3.gif
|
100
58
|
- templates/public/images/railstat/4.gif
|
101
|
-
- templates/public/images/railstat/5.gif
|
102
59
|
- templates/public/images/railstat/6.gif
|
103
|
-
- templates/public/images/railstat/
|
104
|
-
- templates/public/images/railstat/
|
60
|
+
- templates/public/images/railstat/15.gif
|
61
|
+
- templates/public/images/railstat/5.gif
|
62
|
+
- templates/public/images/railstat/28.gif
|
63
|
+
- templates/public/images/railstat/25.gif
|
64
|
+
- templates/public/images/railstat/21.gif
|
65
|
+
- templates/public/images/railstat/14.gif
|
66
|
+
- templates/public/images/railstat/40.gif
|
67
|
+
- templates/public/images/railstat/1pxtr.gif
|
105
68
|
- templates/public/images/railstat/9.gif
|
106
|
-
- templates/public/
|
107
|
-
- templates/public/
|
108
|
-
- templates/public/
|
69
|
+
- templates/public/images/railstat/33.gif
|
70
|
+
- templates/public/images/railstat/16.gif
|
71
|
+
- templates/public/images/railstat/31.gif
|
72
|
+
- templates/public/images/railstat/30.gif
|
73
|
+
- templates/public/images/railstat/8.gif
|
74
|
+
- templates/public/images/railstat/39.gif
|
75
|
+
- templates/public/images/railstat/3.gif
|
76
|
+
- templates/public/images/railstat/13.gif
|
77
|
+
- templates/lib
|
78
|
+
- templates/lib/path_tracker.rb
|
79
|
+
- templates/db
|
80
|
+
- templates/db/ip-to-country.mysql.sql
|
81
|
+
- templates/db/railstat.rb
|
82
|
+
- templates/app
|
83
|
+
- templates/app/models
|
84
|
+
- templates/app/models/search_term.rb
|
85
|
+
- templates/app/models/rail_stat.rb
|
86
|
+
- templates/app/models/iptoc.rb
|
87
|
+
- templates/app/controllers
|
88
|
+
- templates/app/controllers/rail_stat_controller.rb
|
89
|
+
- templates/app/helpers
|
90
|
+
- templates/app/helpers/rail_stat_helper.rb
|
91
|
+
- templates/app/views
|
92
|
+
- templates/app/views/rail_stat
|
93
|
+
- templates/app/views/rail_stat/platform.rhtml
|
94
|
+
- templates/app/views/rail_stat/lang.rhtml
|
95
|
+
- templates/app/views/rail_stat/other.rhtml
|
96
|
+
- templates/app/views/rail_stat/_menu.rhtml
|
97
|
+
- templates/app/views/rail_stat/hits.rhtml
|
98
|
+
- templates/app/views/rail_stat/path.rhtml
|
99
|
+
- templates/app/views/rail_stat/refs.rhtml
|
100
|
+
- templates/app/views/layouts
|
101
|
+
- templates/app/views/layouts/rail_stat.rhtml
|
102
|
+
- templates/README
|
109
103
|
- rail_stat_generator.rb
|
110
104
|
- USAGE
|
111
105
|
- MIT-LICENSE
|
112
106
|
- LICENSE-IP2C
|
113
|
-
|
114
|
-
|
107
|
+
has_rdoc: false
|
108
|
+
homepage: http://www.railstat.com
|
109
|
+
post_install_message:
|
115
110
|
rdoc_options: []
|
116
111
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: "0"
|
119
|
+
version:
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: "0"
|
125
|
+
version:
|
123
126
|
requirements: []
|
124
127
|
|
125
|
-
|
128
|
+
rubyforge_project: railstat
|
129
|
+
rubygems_version: 1.2.0
|
130
|
+
signing_key:
|
131
|
+
specification_version: 2
|
132
|
+
summary: RailStat is a real-time web site statistics package which uses Ruby on Rails web application framework.
|
133
|
+
test_files: []
|
126
134
|
|