rail_stat_generator 0.1.3 → 0.1.4
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/MIT-LICENSE +1 -1
- data/rail_stat_generator.rb +2 -3
- data/templates/README +2 -2
- data/templates/app/controllers/rail_stat_controller.rb +1 -1
- data/templates/app/views/layouts/rail_stat.rhtml +0 -6
- data/templates/db/railstat.rb +48 -0
- data/templates/lib/path_tracker.rb +5 -3
- metadata +101 -97
- data/templates/db/railstat.mysql.sql +0 -44
- data/templates/db/railstat.pgsql.sql +0 -48
data/MIT-LICENSE
CHANGED
data/rail_stat_generator.rb
CHANGED
@@ -32,9 +32,8 @@ class RailStatGenerator < Rails::Generator::Base
|
|
32
32
|
m.template "public/images/railstat/1pxtr.gif", "public/images/railstat/1pxtr.gif"
|
33
33
|
|
34
34
|
m.template "db/ip-to-country.mysql.sql", "db/ip-to-country.mysql.sql"
|
35
|
-
m.
|
36
|
-
|
37
|
-
|
35
|
+
m.migration_template "db/railstat.rb", "db/migrate", :migration_file_name => 'railstat'
|
36
|
+
|
38
37
|
m.template "README", "README_RAILSTAT"
|
39
38
|
end
|
40
39
|
end
|
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
|
4
|
+
2. Create the database schema using rake 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
|
@@ -18,4 +18,4 @@
|
|
18
18
|
SITE_NAME = 'www.mydomain.com'
|
19
19
|
|
20
20
|
Notes: Steps 3 - 5 are optional. If you don't want to download ip-to-country database
|
21
|
-
the system will work but the visitor country will not be tracked.
|
21
|
+
the system will work but the visitor country will not be tracked.
|
@@ -74,7 +74,7 @@ class RailStatController < ApplicationController
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def tracker_js
|
77
|
-
if @request.env['HTTP_REFERER'] and @request.env['HTTP_REFERER'].include?(
|
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;
|
@@ -11,12 +11,6 @@
|
|
11
11
|
|
12
12
|
<body onload="show_date_as_local_time()">
|
13
13
|
<%%= @content_for_layout %>
|
14
|
-
|
15
|
-
<script type="text/javascript" src="/rail_stat/tracker_js"></script>
|
16
|
-
<noscript>
|
17
|
-
<a href="/"><img src="/rail_stat/track" border="0" width="1px" height="1px" alt=""/></a>
|
18
|
-
</noscript>
|
19
|
-
|
20
14
|
</body>
|
21
15
|
</html>
|
22
16
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Railstat < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :rail_stats do |t|
|
4
|
+
t.column :remote_ip, :string
|
5
|
+
t.column :country, :string
|
6
|
+
t.column :language, :string
|
7
|
+
t.column :domain, :string
|
8
|
+
t.column :subdomain, :string
|
9
|
+
t.column :referer, :string
|
10
|
+
t.column :resource, :string
|
11
|
+
t.column :user_agent, :string
|
12
|
+
t.column :platform, :string
|
13
|
+
t.column :browser, :string
|
14
|
+
t.column :version, :string
|
15
|
+
t.column :created_at, :datetime
|
16
|
+
t.column :created_on, :date
|
17
|
+
t.column :screen_size, :string
|
18
|
+
t.column :colors, :string
|
19
|
+
t.column :java, :string
|
20
|
+
t.column :java_enabled, :string
|
21
|
+
t.column :flash, :string
|
22
|
+
end
|
23
|
+
add_index :rail_stats, :subdomain
|
24
|
+
|
25
|
+
create_table :search_terms do |t|
|
26
|
+
t.column :subdomain, :string, :default => ''
|
27
|
+
t.column :searchterms, :string, :null => false, :default => ''
|
28
|
+
t.column :count, :integer, :null => false, :default => 0
|
29
|
+
t.column :domain, :string
|
30
|
+
end
|
31
|
+
add_index :search_terms, :subdomain
|
32
|
+
|
33
|
+
create_table :iptocs do |t|
|
34
|
+
t.column :ip_from, :integer, :null => false
|
35
|
+
t.column :ip_to, :integer, :null => false
|
36
|
+
t.column :country_code2, :string, :null => false
|
37
|
+
t.column :country_code3, :string, :null => false
|
38
|
+
t.column :country_name, :string, :null => false
|
39
|
+
end
|
40
|
+
add_index :iptocs, [:ip_from, :ip_to], :unique
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.down
|
44
|
+
drop_table :rail_stats
|
45
|
+
drop_table :search_terms
|
46
|
+
drop_table :iptocs
|
47
|
+
end
|
48
|
+
end
|
@@ -27,13 +27,15 @@ module PathTracker
|
|
27
27
|
|
28
28
|
sniff_keywords(domain, subdomain, referer);
|
29
29
|
|
30
|
-
|
30
|
+
remote_ip = env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR']
|
31
|
+
|
32
|
+
if remote_ip == "127.0.0.1"
|
31
33
|
client_country = "localhost"
|
32
34
|
else
|
33
|
-
client_country = Iptoc.find_by_ip_address(
|
35
|
+
client_country = Iptoc.find_by_ip_address(remote_ip)
|
34
36
|
end
|
35
37
|
|
36
|
-
RailStat.create("remote_ip" =>
|
38
|
+
RailStat.create("remote_ip" => remote_ip,
|
37
39
|
"country" => client_country,
|
38
40
|
"language" => determine_lang(env['HTTP_ACCEPT_LANGUAGE']),
|
39
41
|
"domain" => domain,
|
metadata
CHANGED
@@ -1,122 +1,126 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: rail_stat_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date:
|
6
|
+
version: 0.1.4
|
7
|
+
date: 2006-10-31 00:00:00 +02:00
|
8
8
|
summary: RailStat is a real-time web site statistics package which uses Ruby on Rails web application framework.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: lubo_AT_manolov.org
|
12
12
|
homepage: http://www.railstat.com
|
13
13
|
rubyforge_project: railstat
|
14
|
-
description: "RailStat generator creates a real-time web site statistics system. Features: -
|
15
|
-
Page views paths on each session - Number of total hits / unique hits -
|
16
|
-
Operating system and browser - Countries and languages - Referrers and search
|
17
|
-
strings - Flash / JavaVM / Javascript / ScreenWidth / ColorDepth"
|
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"
|
18
15
|
autorequire: rail_stat_generator
|
19
16
|
default_executable:
|
20
17
|
bindir: bin
|
21
18
|
has_rdoc: false
|
22
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
23
20
|
requirements:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
28
24
|
version:
|
29
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
30
28
|
authors:
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
- Luben Manolov
|
30
|
+
- Nick Penkov
|
31
|
+
- Jeff Casimir
|
34
32
|
files:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
- LICENSE-IP2C
|
33
|
+
- templates/app
|
34
|
+
- templates/db
|
35
|
+
- templates/lib
|
36
|
+
- 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
|
+
- templates/public/stylesheets
|
63
|
+
- 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
|
+
- 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
|
+
- templates/public/images/railstat/34.gif
|
77
|
+
- templates/public/images/railstat/16.gif
|
78
|
+
- templates/public/images/railstat/35.gif
|
79
|
+
- templates/public/images/railstat/17.gif
|
80
|
+
- templates/public/images/railstat/36.gif
|
81
|
+
- templates/public/images/railstat/18.gif
|
82
|
+
- templates/public/images/railstat/37.gif
|
83
|
+
- templates/public/images/railstat/19.gif
|
84
|
+
- templates/public/images/railstat/38.gif
|
85
|
+
- templates/public/images/railstat/39.gif
|
86
|
+
- templates/public/images/railstat/20.gif
|
87
|
+
- templates/public/images/railstat/21.gif
|
88
|
+
- templates/public/images/railstat/22.gif
|
89
|
+
- templates/public/images/railstat/40.gif
|
90
|
+
- templates/public/images/railstat/23.gif
|
91
|
+
- 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
|
+
- templates/public/images/railstat/4.gif
|
101
|
+
- templates/public/images/railstat/5.gif
|
102
|
+
- templates/public/images/railstat/6.gif
|
103
|
+
- templates/public/images/railstat/7.gif
|
104
|
+
- templates/public/images/railstat/8.gif
|
105
|
+
- templates/public/images/railstat/9.gif
|
106
|
+
- templates/public/javascripts/railstat.js
|
107
|
+
- templates/public/stylesheets/tabs.css
|
108
|
+
- templates/public/stylesheets/railstat.css
|
109
|
+
- rail_stat_generator.rb
|
110
|
+
- USAGE
|
111
|
+
- MIT-LICENSE
|
112
|
+
- LICENSE-IP2C
|
116
113
|
test_files: []
|
114
|
+
|
117
115
|
rdoc_options: []
|
116
|
+
|
118
117
|
extra_rdoc_files: []
|
118
|
+
|
119
119
|
executables: []
|
120
|
+
|
120
121
|
extensions: []
|
122
|
+
|
121
123
|
requirements: []
|
122
|
-
|
124
|
+
|
125
|
+
dependencies: []
|
126
|
+
|
@@ -1,44 +0,0 @@
|
|
1
|
-
CREATE TABLE rail_stats (
|
2
|
-
id int(11) unsigned NOT NULL auto_increment,
|
3
|
-
remote_ip varchar(15) default '',
|
4
|
-
country varchar(50) default '',
|
5
|
-
language VARCHAR(5) default '',
|
6
|
-
domain varchar(250) default '',
|
7
|
-
subdomain varchar(250) default '',
|
8
|
-
referer varchar(255) default '',
|
9
|
-
resource varchar(255) default '',
|
10
|
-
user_agent varchar(255) default '',
|
11
|
-
platform varchar(50) default '',
|
12
|
-
browser varchar(50) default '',
|
13
|
-
version varchar(15) default '',
|
14
|
-
created_at datetime,
|
15
|
-
created_on date,
|
16
|
-
screen_size varchar(10) default null,
|
17
|
-
colors varchar(10) default null,
|
18
|
-
java varchar(10) default null,
|
19
|
-
java_enabled varchar(10) default null,
|
20
|
-
flash varchar(10) default null,
|
21
|
-
UNIQUE KEY id (id),
|
22
|
-
INDEX(subdomain)
|
23
|
-
) TYPE=MyISAM;
|
24
|
-
|
25
|
-
CREATE TABLE search_terms (
|
26
|
-
id int(11) unsigned NOT NULL auto_increment,
|
27
|
-
subdomain varchar(250) default '',
|
28
|
-
searchterms varchar(255) NOT NULL default '',
|
29
|
-
count int(10) unsigned NOT NULL default '0',
|
30
|
-
domain varchar(250),
|
31
|
-
PRIMARY KEY (id),
|
32
|
-
INDEX(subdomain)
|
33
|
-
) TYPE=MyISAM;
|
34
|
-
|
35
|
-
CREATE TABLE iptocs (
|
36
|
-
id int(11) unsigned NOT NULL auto_increment,
|
37
|
-
ip_from int(10) unsigned zerofill not null,
|
38
|
-
ip_to int(10) unsigned zerofill not null,
|
39
|
-
country_code2 char(2) not null,
|
40
|
-
country_code3 char(3) not null,
|
41
|
-
country_name varchar(50) not null,
|
42
|
-
PRIMARY KEY (id),
|
43
|
-
unique index(ip_from, ip_to)
|
44
|
-
);
|
@@ -1,48 +0,0 @@
|
|
1
|
-
DROP TABLE rail_stats, search_terms, iptocs CASCADE;
|
2
|
-
CREATE TABLE rail_stats (
|
3
|
-
id SERIAL,
|
4
|
-
remote_ip VARCHAR(15) default '',
|
5
|
-
country VARCHAR(50) default '',
|
6
|
-
language VARCHAR(5) default '',
|
7
|
-
domain VARCHAR(250) default '',
|
8
|
-
subdomain VARCHAR(250) default '',
|
9
|
-
referer VARCHAR(255) default '',
|
10
|
-
resource VARCHAR(255) default '',
|
11
|
-
user_agent VARCHAR(255) default '',
|
12
|
-
platform VARCHAR(50) default '',
|
13
|
-
browser VARCHAR(50) default '',
|
14
|
-
version VARCHAR(15) default '',
|
15
|
-
created_at TIMESTAMP,
|
16
|
-
created_on DATE,
|
17
|
-
screen_size VARCHAR(10) default null,
|
18
|
-
colors VARCHAR(10) default null,
|
19
|
-
java VARCHAR(10) default null,
|
20
|
-
java_enabled VARCHAR(10) default null,
|
21
|
-
flash VARCHAR(10) default null,
|
22
|
-
|
23
|
-
CONSTRAINT pk_rail_stats_id PRIMARY KEY(id)
|
24
|
-
);
|
25
|
-
CREATE UNIQUE INDEX rail_stats_subdomain_idx ON rail_stats(subdomain);
|
26
|
-
|
27
|
-
CREATE TABLE search_terms (
|
28
|
-
id SERIAL,
|
29
|
-
subdomain VARCHAR(250) default '',
|
30
|
-
searchterms VARCHAR(255) NOT NULL default '',
|
31
|
-
count INT4 NOT NULL default '0',
|
32
|
-
domain VARCHAR(250),
|
33
|
-
|
34
|
-
CONSTRAINT pk_search_terms_id PRIMARY KEY(id)
|
35
|
-
);
|
36
|
-
CREATE UNIQUE INDEX search_terms_subdomain_idx ON search_terms(subdomain);
|
37
|
-
|
38
|
-
CREATE TABLE iptocs (
|
39
|
-
id SERIAL,
|
40
|
-
ip_from INT8 NOT NULL default '0',
|
41
|
-
ip_to INT8 NOT NULL default '0',
|
42
|
-
country_code2 CHAR(2) NOT NULL,
|
43
|
-
country_code3 CHAR(3) NOT NULL,
|
44
|
-
country_name VARCHAR(50) NOT NULL,
|
45
|
-
|
46
|
-
CONSTRAINT pk_iptocs_id PRIMARY KEY(id)
|
47
|
-
);
|
48
|
-
CREATE UNIQUE INDEX iptocs_ip_from_ip_to_idx ON iptocs(ip_from, ip_to);
|