mountain-goat 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,147 @@
1
+ /*
2
+ * timeago: a jQuery plugin, version: 0.9.3 (2011-01-21)
3
+ * @requires jQuery v1.2.3 or later
4
+ *
5
+ * Timeago is a jQuery plugin that makes it easy to support automatically
6
+ * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
7
+ *
8
+ * For usage and examples, visit:
9
+ * http://timeago.yarp.com/
10
+ *
11
+ * Licensed under the MIT:
12
+ * http://www.opensource.org/licenses/mit-license.php
13
+ *
14
+ * Copyright (c) 2008-2011, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
15
+ */
16
+ (function($) {
17
+ $.timeago = function(timestamp) {
18
+ if (timestamp instanceof Date) {
19
+ return inWords(timestamp);
20
+ } else if (typeof timestamp === "string") {
21
+ return inWords($.timeago.parse(timestamp));
22
+ } else {
23
+ return inWords($.timeago.datetime(timestamp));
24
+ }
25
+ };
26
+ var $t = $.timeago;
27
+
28
+ $.extend($.timeago, {
29
+ settings: {
30
+ refreshMillis: 60000,
31
+ allowFuture: false,
32
+ strings: {
33
+ prefixAgo: null,
34
+ prefixFromNow: null,
35
+ suffixAgo: "ago",
36
+ suffixFromNow: "from now",
37
+ seconds: "less than a minute",
38
+ minute: "about a minute",
39
+ minutes: "%d minutes",
40
+ hour: "about an hour",
41
+ hours: "about %d hours",
42
+ day: "a day",
43
+ days: "%d days",
44
+ month: "about a month",
45
+ months: "%d months",
46
+ year: "about a year",
47
+ years: "%d years",
48
+ numbers: []
49
+ }
50
+ },
51
+ inWords: function(distanceMillis) {
52
+ var $l = this.settings.strings;
53
+ var prefix = $l.prefixAgo;
54
+ var suffix = $l.suffixAgo;
55
+ if (this.settings.allowFuture) {
56
+ if (distanceMillis < 0) {
57
+ prefix = $l.prefixFromNow;
58
+ suffix = $l.suffixFromNow;
59
+ }
60
+ distanceMillis = Math.abs(distanceMillis);
61
+ }
62
+
63
+ var seconds = distanceMillis / 1000;
64
+ var minutes = seconds / 60;
65
+ var hours = minutes / 60;
66
+ var days = hours / 24;
67
+ var years = days / 365;
68
+
69
+ function substitute(stringOrFunction, number) {
70
+ var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
71
+ var value = ($l.numbers && $l.numbers[number]) || number;
72
+ return string.replace(/%d/i, value);
73
+ }
74
+
75
+ var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
76
+ seconds < 90 && substitute($l.minute, 1) ||
77
+ minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
78
+ minutes < 90 && substitute($l.hour, 1) ||
79
+ hours < 24 && substitute($l.hours, Math.round(hours)) ||
80
+ hours < 48 && substitute($l.day, 1) ||
81
+ days < 30 && substitute($l.days, Math.floor(days)) ||
82
+ days < 60 && substitute($l.month, 1) ||
83
+ days < 365 && substitute($l.months, Math.floor(days / 30)) ||
84
+ years < 2 && substitute($l.year, 1) ||
85
+ substitute($l.years, Math.floor(years));
86
+
87
+ return $.trim([prefix, words, suffix].join(" "));
88
+ },
89
+ parse: function(iso8601) {
90
+ var s = $.trim(iso8601);
91
+ s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
92
+ s = s.replace(/-/,"/").replace(/-/,"/");
93
+ s = s.replace(/T/," ").replace(/Z/," UTC");
94
+ s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
95
+ return new Date(s);
96
+ },
97
+ datetime: function(elem) {
98
+ // jQuery's `is()` doesn't play well with HTML5 in IE
99
+ var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
100
+ var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
101
+ return $t.parse(iso8601);
102
+ }
103
+ });
104
+
105
+ $.fn.timeago = function() {
106
+ var self = this;
107
+ self.each(refresh);
108
+
109
+ var $s = $t.settings;
110
+ if ($s.refreshMillis > 0) {
111
+ setInterval(function() { self.each(refresh); }, $s.refreshMillis);
112
+ }
113
+ return self;
114
+ };
115
+
116
+ function refresh() {
117
+ var data = prepareData(this);
118
+ if (!isNaN(data.datetime)) {
119
+ $(this).text(inWords(data.datetime));
120
+ }
121
+ return this;
122
+ }
123
+
124
+ function prepareData(element) {
125
+ element = $(element);
126
+ if (!element.data("timeago")) {
127
+ element.data("timeago", { datetime: $t.datetime(element) });
128
+ var text = $.trim(element.text());
129
+ if (text.length > 0) {
130
+ element.attr("title", text);
131
+ }
132
+ }
133
+ return element.data("timeago");
134
+ }
135
+
136
+ function inWords(date) {
137
+ return $t.inWords(distance(date));
138
+ }
139
+
140
+ function distance(date) {
141
+ return (new Date().getTime() - date.getTime());
142
+ }
143
+
144
+ // fix for IE6 suckage
145
+ document.createElement("abbr");
146
+ document.createElement("time");
147
+ }(jQuery));
@@ -13,7 +13,7 @@
13
13
  }).change();
14
14
 
15
15
  if ($('.recent-rally[data-reload="true"]').size() > 0) {
16
- setTimeout(function() { reloadRallies(); }, 3000);
16
+ setTimeout(function() { reloadRallies(); }, 4000);
17
17
  }
18
18
 
19
19
  $('.reload').click(function() { reloadRallies(); });
@@ -31,18 +31,23 @@
31
31
  } else {
32
32
  $('.recent-rally').data('rally-id', json.recent_rally_id);
33
33
  $('.rally-list').prepend($(json.result));
34
-
35
34
  $('.rally-list li:gt(100)').remove(); //only show 100 elements
35
+
36
+ if ($('.rally-list abbr.time-ago').size() > 0) {
37
+ $('.rally-list abbr.time-ago').timeago();
38
+ }
36
39
  }
37
40
 
38
41
  if ($('.recent-rally[data-reload="true"]').size() > 0) {
39
- setTimeout(function() { reloadRallies(); }, 3000);
42
+ setTimeout(function() { reloadRallies(); }, 4000);
40
43
  }
41
44
  }
42
45
  });
43
46
  }
44
47
  };
45
- });
46
-
47
-
48
+
49
+ if ($('abbr.time-ago').size() > 0) {
50
+ $('abbr.time-ago').timeago();
51
+ }
52
+ });
48
53
  })();
@@ -1,3 +1,3 @@
1
1
  class MountainGoat
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
@@ -0,0 +1,63 @@
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
+ <li><a href="<%= mountain_goat_rallies_url %>">Rallies</a></li>
36
+ <li><a href="/">Exit</a></li>
37
+ </ul>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="content">
42
+ <div class="content-inner">
43
+ <% if !flash[:notice].blank? || !flash[:error].blank? %>
44
+ <div class="flash">
45
+ <% if !flash[:error].blank? %>
46
+ <div class="error"><%= flash[:error] %></div>
47
+ <% end %>
48
+ <% if !flash[:notice].blank? %>
49
+ <div class="notice"><%= flash[:notice] %></div>
50
+ <% end %>
51
+ </div>
52
+ <% end %>
53
+ <%= yield %>
54
+ </div>
55
+ </div>
56
+
57
+ <div id="container-footer">
58
+
59
+ </div>
60
+ </div>
61
+ </body>
62
+
63
+ </html>
@@ -18,8 +18,9 @@
18
18
 
19
19
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
20
20
  <script src="/mg/public/jquery_flot_js" type="text/javascript"></script>
21
+ <script src="/mg/public/jquery_timeago_js" type="text/javascript"></script>
21
22
  <script src="/mg/public/mg_js" type="text/javascript"></script>
22
-
23
+
23
24
  </head>
24
25
 
25
26
  <body>
@@ -1,9 +1,10 @@
1
1
  <%# locals => rally %>
2
2
 
3
- <li><%= rally.convert.name %> at <%= rally.created_at.to_s %>
4
- (
3
+ <li class="rally" data-rally-id="<%= rally.id %>"><span class="name"><%= rally.convert.name %></span>
4
+ <ul>
5
5
  <% rally.all_metas.each do |k,v| %>
6
- <%= k %>: <%= v %>
6
+ <li><%= k %>: <%= v %></li>
7
7
  <% end %>
8
- )
8
+ </ul>
9
+ <span class="time"><%= content_tag(:abbr, rally.created_at.to_s, :title => rally.created_at.getutc.iso8601, :class => "time-ago") %></span>
9
10
  </li>
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: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 18
10
- version: 0.0.18
9
+ - 19
10
+ version: 0.0.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoffrey Hayes
@@ -94,12 +94,14 @@ files:
94
94
  - lib/mountain-goat/public/dottedblack.png
95
95
  - lib/mountain-goat/public/dottedblue.png
96
96
  - lib/mountain-goat/public/jquery.flot.js
97
+ - lib/mountain-goat/public/jquery.timeago.js
97
98
  - lib/mountain-goat/public/mg.css
98
99
  - lib/mountain-goat/public/mg.js
99
100
  - lib/mountain-goat/public/mg.png
100
101
  - lib/mountain-goat/public/raster.png
101
102
  - lib/mountain-goat/switch_variant.rb
102
103
  - lib/mountain-goat/version.rb
104
+ - lib/mountain-goat/views/mountain_goat/layouts/.tmp_mountain_goat.html.erb.47598~
103
105
  - lib/mountain-goat/views/mountain_goat/layouts/mountain_goat.html.erb
104
106
  - lib/mountain-goat/views/mountain_goat/mountain_goat/login.html.erb
105
107
  - lib/mountain-goat/views/mountain_goat/mountain_goat_converts/_convert_form.html.erb