mountain-goat 0.0.8 → 0.0.9

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.
@@ -1,9 +1,12 @@
1
1
 
2
2
  class MountainGoatController < ActionController::Base
3
3
 
4
- self.prepend_view_path File.join([File.dirname(__FILE__), '../../views/mountain_goat/'])
4
+ layout 'mountain_goat'
5
5
 
6
+ before_filter :verify_access, :except => [ :login, :login_create, :fetch ]
6
7
 
8
+ self.prepend_view_path File.join([File.dirname(__FILE__), '../../views/mountain_goat/'])
9
+
7
10
  def fetch
8
11
  ct = { :png => 'image/png', :css => 'text/css', :html => 'text/html', :js => 'text/javascript' }
9
12
 
@@ -21,5 +24,74 @@ class MountainGoatController < ActionController::Base
21
24
  render :file => "#{Rails.root}/public/404.html", :status => :not_found
22
25
  end
23
26
 
24
- layout 'mountain_goat'
27
+ def verify_access
28
+ return if session.has_key?(:mg_access) && session[:mg_access] == true
29
+ redirect_to '/mg/login' and return
30
+ end
31
+
32
+ def login
33
+ mg_yml = YAML::load(File.open("#{RAILS_ROOT}/config/mountain-goat.yml"))
34
+ if mg_yml
35
+ mg_yml_env = mg_yml.with_indifferent_access[RAILS_ENV]
36
+ if mg_yml_env
37
+ flash[:error] = "<em>config/mountain-goat.yml</em> missing password (blank / missing) for current environment. You cannot access mountain goat until you set the password for this environment." if mg_yml_env.with_indifferent_access[:password].blank?
38
+ else
39
+ flash[:error] = "<em>config/mountain-goat.yml</em> missing password for current environment '#{RAILS_ENV}'. You cannot access mountain goat until you configure this file for this environment."
40
+ end
41
+ else
42
+ flash[:error] = "<em>config/mountain-goat.yml</em> missing. You cannot access mountain goat until you configure this file."
43
+ end
44
+ end
45
+
46
+ def login_create
47
+ raise ArgumentError, "Missing password" if !params.has_key?(:password)
48
+
49
+ valid_password = nil
50
+ begin
51
+ valid_password = YAML::load(File.open("#{RAILS_ROOT}/config/mountain-goat.yml")).with_indifferent_access[RAILS_ENV].with_indifferent_access[:password]
52
+ rescue
53
+ raise ArgumentError, "config/mountain-goat.yml not properly configured"
54
+ end
55
+ raise ArgumentError, "config/mountain-goat.yml not properly configured" if valid_password.nil?
56
+
57
+ if params[:password] == valid_password
58
+ flash[:notice] = "You have successfully logged in."
59
+ session[:mg_access] = true
60
+ redirect_back_or_default '/mg'
61
+ else
62
+ flash[:notice] = "Incorrect password."
63
+ render :login
64
+ end
65
+ end
66
+
67
+ def store_location(url = nil)
68
+ if url.nil?
69
+ if request.method == :post && request.params.count > 0
70
+ session[:mg_return_to] = "#{request.request_uri}?" + encode_parameters(request.params)
71
+ else
72
+ session[:mg_return_to] = request.request_uri
73
+ end
74
+ else
75
+ session[:mg_return_to] = url
76
+ end
77
+
78
+ logger.warn "Storing location: #{session[:mg_return_to]}"
79
+ end
80
+
81
+ def redirect_back_or_default(default)
82
+ redirect_to(session[:mg_return_to] || default)
83
+ session[:mg_return_to] = nil
84
+ end
85
+
86
+ private
87
+
88
+ def self.password_digest(password, salt)
89
+ site_key = '1e9532ea39233e1e2786d80fde90d708c0918d2d'
90
+ stretches = 10
91
+ digest = site_key
92
+ stretches.times do
93
+ digest = secure_digest(digest, salt, password, site_key)
94
+ end
95
+ digest
96
+ end
25
97
  end
@@ -11,6 +11,8 @@ module MetricTracking
11
11
  #TODO: Namespace?
12
12
  ActionController::Routing::Routes.draw do |map|
13
13
  map.mg '/mg', :controller => :mountain_goat_converts, :action => :index
14
+ map.mg_login '/mg/login', :controller => :mountain_goat, :action => :login
15
+ map.mg_login_create '/mg/login/create', :controller => :mountain_goat, :action => :login_create
14
16
  map.resources :mountain_goat_metric_variants
15
17
  map.resources :mountain_goat_converts, :has_many => :mountain_goat_metrics
16
18
  map.resources :mountain_goat_metrics, :has_many => :mountain_goat_metric_variants
@@ -1,3 +1,3 @@
1
1
  class MountainGoat
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,51 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <% is_mobile = false if local_assigns[:is_mobile].nil? %>
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml">
6
+
7
+ <head>
8
+ <title>Mountain Goat <% if @title %> - <%=h @title %><% end %></title>
9
+
10
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
+
12
+ <%# These are mobile specific settings. We are disabling zooming and fixing the width. %>
13
+ <meta content='True' name='HandheldFriendly' />
14
+ <!--<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />-->
15
+ <meta name="viewport" content="width=device-width" />
16
+
17
+ <link rel="stylesheet" href="/mg/public/mg_css" type="text/css" />
18
+
19
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
20
+ <script src="/mg/public/jquery_flot_js" type="text/javascript"></script>
21
+ <script src="/mg/public/mg_js" type="text/javascript"></script>
22
+
23
+ </head>
24
+
25
+ <body>
26
+
27
+ <div class="header">
28
+ <div class="head">
29
+ <a href="/mg" class="logo">
30
+ <img src="/mg/public/mg_png" />
31
+ </a>
32
+ <ul class="nav">
33
+ <li><a href="<%= mountain_goat_converts_url %>">Goals</a></li>
34
+ <li><a href="<%= mountain_goat_metrics_url %>">Metrics</a></li>
35
+ </ul>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="content">
40
+ <div class="content-inner">
41
+ <%= yield %>
42
+ </div>
43
+ </div>
44
+
45
+ <div id="container-footer">
46
+
47
+ </div>
48
+ </div>
49
+ </body>
50
+
51
+ </html>
@@ -32,12 +32,23 @@
32
32
  <ul class="nav">
33
33
  <li><a href="<%= mountain_goat_converts_url %>">Goals</a></li>
34
34
  <li><a href="<%= mountain_goat_metrics_url %>">Metrics</a></li>
35
+ <li><a href="/">Exit</a></li>
35
36
  </ul>
36
37
  </div>
37
38
  </div>
38
39
 
39
40
  <div class="content">
40
41
  <div class="content-inner">
42
+ <% if !flash[:notice].blank? || !flash[:error].blank? %>
43
+ <div class="flash">
44
+ <% if !flash[:error].blank? %>
45
+ <div class="error"><%= flash[:error] %></div>
46
+ <% end %>
47
+ <% if !flash[:notice].blank? %>
48
+ <div class="notice"><%= flash[:notice] %></div>
49
+ <% end %>
50
+ </div>
51
+ <% end %>
41
52
  <%= yield %>
42
53
  </div>
43
54
  </div>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
+ <title>Untitled Document</title>
6
+ </head>
7
+ <body>
8
+ </body>
9
+ </html>
@@ -0,0 +1,23 @@
1
+
2
+ <div id="container-main" class="mt-login">
3
+ <div class="mountain-goat-panel">
4
+
5
+ <h1>Please login to Mountain Goat</h1>
6
+
7
+ <div class="login">
8
+ <div class="explanation">
9
+ <span class="inner">
10
+ Below are a list of conversion goals. Each goal has a set of metrics designed to achieve that goal. For each metric, there is a list of variants, each coupled with its conversation rate.</span>
11
+ </span>
12
+ </div>
13
+
14
+ <div class="login-form">
15
+
16
+ <% form_tag mg_login_create_url do %>
17
+ <%= password_field_tag :password %>
18
+ <%= submit_tag :Enter %>
19
+ <% end %>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </div>
@@ -0,0 +1,49 @@
1
+
2
+
3
+ <div id="container-main" class="mt-converts">
4
+ <div class="mountain-goat-panel centered">
5
+
6
+ <h1>Conversion Goals</h1>
7
+
8
+ <div class="conversions">
9
+ <div class="explanation">
10
+ <span class="inner">
11
+ Below are a list of conversion goals. Each goal has a set of metrics designed to achieve that goal. For each metric, there is a list of variants, each coupled with its conversation rate.</span>
12
+ </span>
13
+ </div>
14
+
15
+ <div class="converts">
16
+ <% @converts.each do |convert| %>
17
+ <h2><a href="<%= mountain_goat_convert_url :id => convert.id %>"><%=h convert.name %></a></h2>
18
+ <% convert.metrics.each do |metric| %>
19
+ <div class="metric-category">
20
+ <span class="metric"><a href="<%= mountain_goat_metric_url :id => metric.id %>"><%= metric.title %></a></span>
21
+ <% if metric.metric_variants.count == 0 %>
22
+ <span class="none">No metric variants [<a href="<%= new_mountain_goat_metric_mountain_goat_metric_variant_url :mountain_goat_metric_id => metric.id %>">Add one</a>]</span>
23
+ <% else %>
24
+ <% metric.metric_variants.each do |mv| %>
25
+ <div class="item rate">
26
+ <span class="rate-holder">
27
+ <span class="title"><a href="<%= mountain_goat_metric_variant_url mv %>"><%=h mv.name %></a></span>
28
+ <span class="rates" style="width:<%= number_to_percentage(mv.conversion_rate, :precision => 0) %>"></span>
29
+ </span>
30
+
31
+ <span class="percent-holder">
32
+ <span class="val"><%= number_to_percentage(mv.conversion_rate, :precision => 0) %></span>
33
+ (<span class="conversions"><%= mv.conversions %></span> /
34
+ <span class="served"><%= mv.served %></span>)
35
+ </span>
36
+ </div>
37
+ <% end %>
38
+ <% end %>
39
+ </div>
40
+ <% end %>
41
+ <% end %>
42
+ </div>
43
+ </div>
44
+
45
+ <div class="actions">
46
+ <a class="button" href="<%= new_mountain_goat_convert_url %>">New Goal</a>
47
+ </div>
48
+ </div>
49
+ </div>
@@ -0,0 +1,10 @@
1
+ class MountainGoatAddMgOptionsTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :mountain_goat_options do |t|
4
+ end
5
+ end
6
+
7
+ def self.down
8
+ drop_table :mountain_goat_options
9
+ end
10
+ end
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mountain-goat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoffrey Hayes
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-10 00:00:00 -05:00
19
+ date: 2011-07-11 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -96,7 +96,11 @@ files:
96
96
  - lib/mountain-goat/public/raster.png
97
97
  - lib/mountain-goat/switch_variant.rb
98
98
  - lib/mountain-goat/version.rb
99
+ - lib/mountain-goat/views/mountain_goat/layouts/.tmp_mountain_goat.html.erb.27527~
99
100
  - lib/mountain-goat/views/mountain_goat/layouts/mountain_goat.html.erb
101
+ - lib/mountain-goat/views/mountain_goat/mountain_goat/.tmp_login.html.erb.27219~
102
+ - lib/mountain-goat/views/mountain_goat/mountain_goat/login.html.erb
103
+ - lib/mountain-goat/views/mountain_goat/mountain_goat_converts/.tmp_index.html.erb.22467~
100
104
  - lib/mountain-goat/views/mountain_goat/mountain_goat_converts/_convert_form.html.erb
101
105
  - lib/mountain-goat/views/mountain_goat/mountain_goat_converts/_convert_meta_type_form.html.erb
102
106
  - lib/mountain-goat/views/mountain_goat/mountain_goat_converts/edit.html.erb
@@ -114,12 +118,14 @@ files:
114
118
  - lib/mountain-goat/views/mountain_goat/mountain_goat_metrics/new.html.erb
115
119
  - lib/mountain-goat/views/mountain_goat/mountain_goat_metrics/show.html.erb
116
120
  - migrations/20090716093747_create_metric_tracking_tables.rb
121
+ - migrations/20110710193220_mountain_goat_add_mg_options_table.rb
117
122
  - mountain-goat-0.0.1.gem
118
123
  - mountain-goat-0.0.2.gem
119
124
  - mountain-goat-0.0.3.gem
120
125
  - mountain-goat-0.0.4.gem
121
126
  - mountain-goat-0.0.5.gem
122
127
  - mountain-goat-0.0.6.gem
128
+ - mountain-goat-0.0.8.gem
123
129
  - mountain-goat.gemspec
124
130
  has_rdoc: true
125
131
  homepage: http://github.com/hayesgm/mountain_goat