twigg-app 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/assets/javascripts/_bootstrap.js +7 -0
  3. data/assets/javascripts/_jquery.js +19 -0
  4. data/assets/javascripts/_tables.js +3 -0
  5. data/assets/javascripts/_views.js +10 -0
  6. data/assets/javascripts/application.js +9 -0
  7. data/{public/application.js → assets/javascripts/views/_commit_set_bar_chart.js} +32 -34
  8. data/assets/javascripts/views/_russia.js +61 -0
  9. data/assets/javascripts/views/_tags.js +56 -0
  10. data/assets/javascripts/views/_tags_word_cloud.js +51 -0
  11. data/assets/stylesheets/_bootstrap_overrides.scss +15 -0
  12. data/assets/stylesheets/_footer.scss +28 -0
  13. data/assets/stylesheets/_global.scss +14 -0
  14. data/assets/stylesheets/_tables.scss +20 -0
  15. data/assets/stylesheets/application.scss +10 -0
  16. data/assets/stylesheets/d3/_bar_chart.scss +25 -0
  17. data/assets/stylesheets/d3/_bubble_chart.scss +22 -0
  18. data/lib/twigg-app/app/routes.rb +4 -0
  19. data/lib/twigg-app/app/server.rb +78 -21
  20. data/lib/twigg-app/app/version.rb +1 -1
  21. data/public/vendor/bootstrap/Gruntfile.js +32 -10
  22. data/public/vendor/bootstrap/README.md +2 -0
  23. data/public/vendor/bootstrap/_config.yml +5 -10
  24. data/public/vendor/bootstrap/_includes/footer.html +2 -1
  25. data/public/vendor/bootstrap/_includes/nav-components.html +33 -31
  26. data/public/vendor/bootstrap/_includes/nav-css.html +32 -22
  27. data/public/vendor/bootstrap/_includes/nav-getting-started.html +17 -1
  28. data/public/vendor/bootstrap/_includes/nav-javascript.html +1 -1
  29. data/public/vendor/bootstrap/_includes/nav-main.html +1 -1
  30. data/public/vendor/bootstrap/_includes/social-buttons.html +1 -1
  31. data/public/vendor/bootstrap/_layouts/default.html +18 -14
  32. data/public/vendor/bootstrap/_layouts/home.html +9 -6
  33. data/public/vendor/bootstrap/assets/css/docs.css +584 -396
  34. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
  35. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
  36. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
  37. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
  38. data/public/vendor/bootstrap/assets/ico/favicon.png +0 -0
  39. data/public/vendor/bootstrap/assets/js/application.js +2 -1
  40. data/public/vendor/bootstrap/assets/js/customizer.js +160 -45
  41. data/public/vendor/bootstrap/assets/js/filesaver.js +169 -0
  42. data/public/vendor/bootstrap/assets/js/jquery.js +6 -5
  43. data/public/vendor/bootstrap/assets/js/raw-files.js +3 -0
  44. data/public/vendor/bootstrap/bower.json +1 -1
  45. data/public/vendor/bootstrap/components.html +787 -364
  46. data/public/vendor/bootstrap/composer.json +1 -1
  47. data/public/vendor/bootstrap/css.html +413 -248
  48. data/public/vendor/bootstrap/customize.html +413 -447
  49. data/public/vendor/bootstrap/dist/css/bootstrap-theme.css +384 -0
  50. data/public/vendor/bootstrap/dist/css/bootstrap-theme.min.css +1 -0
  51. data/public/vendor/bootstrap/dist/css/bootstrap.css +3033 -1807
  52. data/public/vendor/bootstrap/dist/css/bootstrap.min.css +1 -1
  53. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  54. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +228 -0
  55. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  56. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  57. data/public/vendor/bootstrap/dist/js/bootstrap.js +18 -12
  58. data/public/vendor/bootstrap/dist/js/bootstrap.min.js +1 -1
  59. data/public/vendor/bootstrap/examples/carousel/carousel.css +128 -0
  60. data/public/vendor/bootstrap/examples/carousel/index.html +201 -0
  61. data/public/vendor/bootstrap/examples/grid/grid.css +28 -0
  62. data/public/vendor/bootstrap/examples/grid/index.html +119 -0
  63. data/public/vendor/bootstrap/examples/jumbotron/index.html +111 -0
  64. data/public/vendor/bootstrap/examples/jumbotron/jumbotron.css +5 -0
  65. data/public/vendor/bootstrap/examples/jumbotron-narrow/index.html +78 -0
  66. data/public/vendor/bootstrap/examples/jumbotron-narrow/jumbotron-narrow.css +79 -0
  67. data/public/vendor/bootstrap/examples/justified-nav/index.html +79 -0
  68. data/public/vendor/bootstrap/examples/justified-nav/justified-nav.css +88 -0
  69. data/public/vendor/bootstrap/examples/navbar/index.html +83 -0
  70. data/public/vendor/bootstrap/examples/navbar/navbar.css +7 -0
  71. data/public/vendor/bootstrap/examples/navbar-fixed-top/index.html +86 -0
  72. data/public/vendor/bootstrap/examples/navbar-fixed-top/navbar-fixed-top.css +4 -0
  73. data/public/vendor/bootstrap/examples/navbar-static-top/index.html +87 -0
  74. data/public/vendor/bootstrap/examples/navbar-static-top/navbar-static-top.css +7 -0
  75. data/public/vendor/bootstrap/examples/non-responsive/index.html +96 -0
  76. data/public/vendor/bootstrap/examples/non-responsive/non-responsive.css +117 -0
  77. data/public/vendor/bootstrap/examples/offcanvas/index.html +127 -0
  78. data/public/vendor/bootstrap/examples/offcanvas/offcanvas.css +48 -0
  79. data/public/vendor/bootstrap/examples/offcanvas/offcanvas.js +5 -0
  80. data/public/vendor/bootstrap/examples/screenshots/carousel.jpg +0 -0
  81. data/public/vendor/bootstrap/examples/screenshots/grid.jpg +0 -0
  82. data/public/vendor/bootstrap/examples/screenshots/jumbotron-narrow.jpg +0 -0
  83. data/public/vendor/bootstrap/examples/screenshots/jumbotron.jpg +0 -0
  84. data/public/vendor/bootstrap/examples/screenshots/justified-nav.jpg +0 -0
  85. data/public/vendor/bootstrap/examples/screenshots/navbar-fixed.jpg +0 -0
  86. data/public/vendor/bootstrap/examples/screenshots/navbar-static.jpg +0 -0
  87. data/public/vendor/bootstrap/examples/screenshots/navbar.jpg +0 -0
  88. data/public/vendor/bootstrap/examples/screenshots/non-responsive.jpg +0 -0
  89. data/public/vendor/bootstrap/examples/screenshots/offcanvas.jpg +0 -0
  90. data/public/vendor/bootstrap/examples/screenshots/sign-in.jpg +0 -0
  91. data/public/vendor/bootstrap/examples/screenshots/starter-template.jpg +0 -0
  92. data/public/vendor/bootstrap/examples/screenshots/sticky-footer-navbar.jpg +0 -0
  93. data/public/vendor/bootstrap/examples/screenshots/sticky-footer.jpg +0 -0
  94. data/public/vendor/bootstrap/examples/screenshots/theme.jpg +0 -0
  95. data/public/vendor/bootstrap/examples/signin/index.html +46 -0
  96. data/public/vendor/bootstrap/examples/signin/signin.css +40 -0
  97. data/public/vendor/bootstrap/examples/starter-template/index.html +63 -0
  98. data/public/vendor/bootstrap/examples/starter-template/starter-template.css +7 -0
  99. data/public/vendor/bootstrap/examples/sticky-footer/index.html +51 -0
  100. data/public/vendor/bootstrap/examples/sticky-footer/sticky-footer.css +39 -0
  101. data/public/vendor/bootstrap/examples/sticky-footer-navbar/index.html +86 -0
  102. data/public/vendor/bootstrap/examples/sticky-footer-navbar/sticky-footer-navbar.css +46 -0
  103. data/public/vendor/bootstrap/examples/theme/index.html +387 -0
  104. data/public/vendor/bootstrap/examples/theme/theme.css +14 -0
  105. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  106. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg +228 -0
  107. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  108. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  109. data/public/vendor/bootstrap/getting-started.html +513 -22
  110. data/public/vendor/bootstrap/index.html +3 -4
  111. data/public/vendor/bootstrap/javascript.html +123 -115
  112. data/public/vendor/bootstrap/js/dropdown.js +3 -3
  113. data/public/vendor/bootstrap/js/modal.js +5 -3
  114. data/public/vendor/bootstrap/js/tests/unit/modal.js +19 -0
  115. data/public/vendor/bootstrap/js/tests/vendor/jquery.js +6 -5
  116. data/public/vendor/bootstrap/js/tooltip.js +9 -5
  117. data/public/vendor/bootstrap/js/transition.js +1 -1
  118. data/public/vendor/bootstrap/less/alerts.less +7 -11
  119. data/public/vendor/bootstrap/less/bootstrap.less +17 -21
  120. data/public/vendor/bootstrap/less/button-groups.less +14 -10
  121. data/public/vendor/bootstrap/less/buttons.less +3 -2
  122. data/public/vendor/bootstrap/less/carousel.less +6 -1
  123. data/public/vendor/bootstrap/less/dropdowns.less +22 -5
  124. data/public/vendor/bootstrap/less/forms.less +36 -15
  125. data/public/vendor/bootstrap/less/glyphicons.less +232 -0
  126. data/public/vendor/bootstrap/less/grid.less +9 -3
  127. data/public/vendor/bootstrap/less/input-groups.less +1 -1
  128. data/public/vendor/bootstrap/less/jumbotron.less +16 -5
  129. data/public/vendor/bootstrap/less/labels.less +9 -5
  130. data/public/vendor/bootstrap/less/mixins.less +73 -43
  131. data/public/vendor/bootstrap/less/modals.less +8 -0
  132. data/public/vendor/bootstrap/less/navbar.less +251 -189
  133. data/public/vendor/bootstrap/less/navs.less +13 -12
  134. data/public/vendor/bootstrap/less/pager.less +1 -1
  135. data/public/vendor/bootstrap/less/pagination.less +20 -9
  136. data/public/vendor/bootstrap/less/panels.less +28 -8
  137. data/public/vendor/bootstrap/less/progress-bars.less +6 -10
  138. data/public/vendor/bootstrap/less/responsive-utilities.less +120 -49
  139. data/public/vendor/bootstrap/less/scaffolding.less +37 -18
  140. data/public/vendor/bootstrap/less/tables.less +84 -59
  141. data/public/vendor/bootstrap/less/theme.less +232 -0
  142. data/public/vendor/bootstrap/less/thumbnails.less +8 -19
  143. data/public/vendor/bootstrap/less/type.less +2 -2
  144. data/public/vendor/bootstrap/less/variables.less +63 -50
  145. data/public/vendor/bootstrap/package.json +2 -1
  146. data/public/vendor/components-backbone/LICENSE +22 -0
  147. data/public/vendor/components-backbone/README.md +10 -0
  148. data/public/vendor/components-backbone/backbone-min.js +4 -0
  149. data/public/vendor/components-backbone/backbone.js +1571 -0
  150. data/public/vendor/components-backbone/bower.json +17 -0
  151. data/public/vendor/components-backbone/component.json +21 -0
  152. data/public/vendor/components-backbone/composer.json +37 -0
  153. data/public/vendor/components-backbone/package.json +24 -0
  154. data/public/vendor/d3.layout.cloud.js +401 -0
  155. data/public/vendor/replacejs/CHANGELOG.md +4 -0
  156. data/public/vendor/replacejs/replace.js +21 -2
  157. data/public/vendor/underscore/CNAME +1 -0
  158. data/public/vendor/underscore/CONTRIBUTING.md +9 -0
  159. data/public/vendor/underscore/LICENSE +22 -0
  160. data/public/vendor/underscore/README.md +19 -0
  161. data/public/vendor/underscore/Rakefile +10 -0
  162. data/public/vendor/underscore/docs/docco.css +192 -0
  163. data/public/vendor/underscore/docs/favicon.ico +0 -0
  164. data/public/vendor/underscore/docs/images/background.png +0 -0
  165. data/public/vendor/underscore/docs/images/underscore.png +0 -0
  166. data/public/vendor/underscore/docs/underscore.html +823 -0
  167. data/public/vendor/underscore/favicon.ico +0 -0
  168. data/public/vendor/underscore/index.html +2467 -0
  169. data/public/vendor/underscore/index.js +1 -0
  170. data/public/vendor/underscore/package.json +16 -0
  171. data/public/vendor/underscore/test/arrays.js +200 -0
  172. data/public/vendor/underscore/test/chaining.js +59 -0
  173. data/public/vendor/underscore/test/collections.js +453 -0
  174. data/public/vendor/underscore/test/functions.js +265 -0
  175. data/public/vendor/underscore/test/index.html +44 -0
  176. data/public/vendor/underscore/test/objects.js +570 -0
  177. data/public/vendor/underscore/test/speed.js +75 -0
  178. data/public/vendor/underscore/test/utility.js +266 -0
  179. data/public/vendor/underscore/test/vendor/jquery.js +9404 -0
  180. data/public/vendor/underscore/test/vendor/jslitmus.js +670 -0
  181. data/public/vendor/underscore/test/vendor/qunit.css +235 -0
  182. data/public/vendor/underscore/test/vendor/qunit.js +1977 -0
  183. data/public/vendor/underscore/test/vendor/runner.js +98 -0
  184. data/public/vendor/underscore/underscore-min.js +1 -0
  185. data/public/vendor/underscore/underscore.js +1226 -0
  186. data/views/dashboard.haml +1 -1
  187. data/views/layout.haml +8 -4
  188. metadata +132 -25
  189. data/public/vendor/bootstrap/_layouts/customize.html +0 -52
  190. data/public/vendor/bootstrap/assets/js/jquery.bbq.min.js +0 -1287
  191. data/public/vendor/bootstrap-glyphicons/CHANGELOG.md +0 -3
  192. data/public/vendor/bootstrap-glyphicons/CNAME +0 -1
  193. data/public/vendor/bootstrap-glyphicons/CONTRIBUTING.md +0 -54
  194. data/public/vendor/bootstrap-glyphicons/LICENSE +0 -19
  195. data/public/vendor/bootstrap-glyphicons/README.md +0 -61
  196. data/public/vendor/bootstrap-glyphicons/_config.yml +0 -12
  197. data/public/vendor/bootstrap-glyphicons/composer.json +0 -9
  198. data/public/vendor/bootstrap-glyphicons/css/bootstrap-glyphicons.css +0 -2
  199. data/public/vendor/bootstrap-glyphicons/css/bootstrap.css +0 -9
  200. data/public/vendor/bootstrap-glyphicons/css/docs.css +0 -160
  201. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.eot +0 -0
  202. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.otf +0 -0
  203. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.svg +0 -175
  204. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.ttf +0 -0
  205. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.woff +0 -0
  206. data/public/vendor/bootstrap-glyphicons/index.html +0 -255
  207. data/public/vendor/bootstrap-glyphicons/less/bootstrap-glyphicons.less +0 -201
  208. data/public/vendor/bootstrap-glyphicons/package.json +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c91cf12c7556b35c7d83003c68f8cdda885bf24
4
- data.tar.gz: b05d038bf66594e083ccf7937b5bcb05d3de767b
3
+ metadata.gz: 312409c6268f21629cf59727c1d75cf51c398e6b
4
+ data.tar.gz: d990e730d0e7c1683274619a1d83e9b58864a46f
5
5
  SHA512:
6
- metadata.gz: c2a19d6e1be2de3056b4d1884b5f2da4052447d4dc57d68a8a478d82f0f85c7c942ba2fa0d0ea38cbc3b540be344a9af331351c883cadd9165dcf939c55e02c7
7
- data.tar.gz: 0d4bf0966d6c8e6490bf97b8dbfa14418f3b4dcb967d91eefec177ec48df35bcb4512433f3cd3fc26cca6fc83f70f52d2726081da03712ece354a73abf88bbcb
6
+ metadata.gz: 21ff88bc95fa1b9041f0223c37661ff1d3b25ff384966560ccd3644629841e18343c0318650f37d13b6283619846d5d8b80705ab71916525313ea58bd17af5dc
7
+ data.tar.gz: 79e35a54350b5713c05929569905507426a9fae1da567d34f199c8ef12b3fea82a833aa4b43fb856a1c279d879fa6aac020e5fb09fa7f078557717cfdad64a17
@@ -0,0 +1,7 @@
1
+ $(document).initializeEach('[data-toggle=tooltip]', function() {
2
+ $(this).tooltip();
3
+ });
4
+
5
+ $(document).initializeEach('[data-toggle=popover]', function() {
6
+ $(this).popover({ html: true });
7
+ });
@@ -0,0 +1,19 @@
1
+ // jQuery functions
2
+
3
+ // Displays an alert inside the currently selected element, by emptying it and
4
+ // inserting a Bootstrap alert with the specified `text`.
5
+ //
6
+ // If `text` is omitted, a reasonable default it used, based on the motivatiing
7
+ // use case of providing feedback for failed Ajax requests.
8
+ //
9
+ // So-named in order to avoid a clash with Boostrap's `alert()` method.
10
+ $.fn.displayAlert = function(text) {
11
+ if (!text) {
12
+ text = 'There was a problem retrieving the data. ' +
13
+ '<a class="alert-link" href="' + window.location.href + '">Reload</a>.';
14
+ }
15
+
16
+ return this
17
+ .empty()
18
+ .append('<div class="alert alert-danger">' + text + '</div>');
19
+ };
@@ -0,0 +1,3 @@
1
+ $(document).initializeEach('table.sortable', function() {
2
+ $(this).stupidtable();
3
+ });
@@ -0,0 +1,10 @@
1
+ //= require_tree ./views
2
+ //= require_self
3
+
4
+ $(document).initializeEach('[data-view]', function() {
5
+ var $el = $(this),
6
+ viewName = $el.data('view'),
7
+ data = _.extend({ el: this }, $el.data());
8
+
9
+ new Twigg.Views[viewName](_.omit(data, 'view'));
10
+ });
@@ -0,0 +1,9 @@
1
+ //= require_self
2
+
3
+ //= require _bootstrap
4
+ //= require _jquery
5
+ //= require _tables
6
+ //= require _views
7
+
8
+ var Twigg = window.Twigg || {};
9
+ Twigg.Views = Twigg.Views || {};
@@ -1,21 +1,24 @@
1
- Twigg = {};
2
- Twigg.Profile = (function() {
3
- var loadCommitsPerDay = function(selector, data) {
1
+ Twigg.Views.CommitSetBarChart = Backbone.View.extend({
2
+ initialize: function() {
3
+ this.loadCommitsPerDay();
4
+ },
5
+
6
+ render: function() {
4
7
  var height = 200,
5
- width = $('#bar-chart').width(),
8
+ width = this.$el.width(),
6
9
  padding = 45,
7
10
  barSpacing = 1,
8
- barWidth = (width - padding) / data.length - barSpacing,
11
+ barWidth = (width - padding) / this.data.length - barSpacing,
9
12
  x = d3.scale.linear()
10
- .domain([0, data.length])
13
+ .domain([0, this.data.length])
11
14
  .range([0, width]),
12
15
  y = d3.scale.linear()
13
- .domain([0, d3.max(data, function(d) { return d.count; })])
16
+ .domain([0, d3.max(this.data, function(d) { return d.count; })])
14
17
  .range([height, 0]),
15
18
  xTimeScale = d3.time.scale()
16
19
  .domain([
17
- new Date(data[0].date),
18
- d3.time.day.offset(new Date(data[data.length - 1].date), 1)
20
+ new Date(this.data[0].date),
21
+ d3.time.day.offset(new Date(this.data[this.data.length - 1].date), 1)
19
22
  ])
20
23
  .range([0, width]),
21
24
  xAxis = d3.svg.axis()
@@ -27,29 +30,29 @@ Twigg.Profile = (function() {
27
30
  .scale(y)
28
31
  .orient('left')
29
32
  .tickFormat(d3.format(',d')),
30
- svg = d3.select(selector).append('svg')
33
+ svg = d3.select(this.el).append('svg')
31
34
  .attr('height', height + padding)
32
35
  .attr('width', width);
33
36
 
34
37
  // bars
35
- svg.selectAll('rect').data(data)
38
+ svg.selectAll('rect').data(this.data)
36
39
  .enter()
37
40
  .append('rect')
38
41
  .attr({
39
42
  'class': 'bar',
40
- 'x': function(d, i) { return x(i) + padding },
41
- 'y': function(d) { return y(d.count) },
43
+ 'x': function(d, i) { return x(i) + padding; },
44
+ 'y': function(d) { return y(d.count); },
42
45
  'width': barWidth,
43
46
  'height': function(d) { return height - y(d.count); },
44
47
  'title': function(d) { return d.count + ' (' + d.date + ')'; },
45
48
  'data-toggle': 'tooltip'
46
49
  });
47
50
 
48
- $('#bar-chart [data-toggle=tooltip]').tooltip({ container: 'body' });
51
+ $('[data-toggle=tooltip]').tooltip({ container: 'body' });
49
52
 
50
53
  // show count inside bars if wide/high enough
51
54
  if (barWidth > 20) {
52
- svg.selectAll('text').data(data)
55
+ svg.selectAll('text').data(this.data)
53
56
  .enter()
54
57
  .append('text')
55
58
  .attr('x', function(d, i) { return x(i) + barWidth + padding; })
@@ -58,7 +61,7 @@ Twigg.Profile = (function() {
58
61
  .attr('dy', '1.2em')
59
62
  .attr('text-anchor', 'middle')
60
63
  .attr('class', 'value')
61
- .text(function(d) { return height - y(d.count) > 15 ? d.count : '' });
64
+ .text(function(d) { return height - y(d.count) > 15 ? d.count : ''; });
62
65
  }
63
66
 
64
67
  // x-axis
@@ -83,24 +86,19 @@ Twigg.Profile = (function() {
83
86
  svg.selectAll('.xaxis text')
84
87
  .attr('transform', function(d) {
85
88
  var h = this.getBBox().height;
86
- return 'translate(' + h * -1 + ', ' + h + ') rotate(-30)';
87
- });
88
- };
89
-
90
- return {
91
- loadCommitsPerDay: loadCommitsPerDay
92
- };
93
- })();
89
+ return 'translate(' + h * -1 + ', ' + h + ') rotate(-30)';
90
+ });
94
91
 
95
- $(document).initializeEach('table.sortable', function() {
96
- $(this).stupidtable();
97
- });
98
-
99
- // for bootstrap:
100
- $(document).initializeEach('[data-toggle=tooltip]', function() {
101
- $(this).tooltip();
102
- });
92
+ return this;
93
+ },
103
94
 
104
- $(document).initializeEach('[data-toggle=popover]', function() {
105
- $(this).popover({ html: true });
95
+ loadCommitsPerDay: function() {
96
+ d3.json(window.location.href)
97
+ .on('error', this.$el.displayAlert)
98
+ .on('load', function(data) {
99
+ this.$el.empty();
100
+ this.data = data;
101
+ this.render();
102
+ }.bind(this)).get();
103
+ }
106
104
  });
@@ -0,0 +1,61 @@
1
+ Twigg.Views.Russia = Backbone.View.extend({
2
+ events: {
3
+ 'click svg g': 'handleAuthorClick'
4
+ },
5
+
6
+ initialize: function() {
7
+ this.showNovelStats();
8
+ },
9
+
10
+ render: function() {
11
+ var format = d3.format(',d'),
12
+ color = d3.scale.category20c(),
13
+ diameter = Math.min(this.$el.width(), window.innerHeight * 1.2),
14
+ bubble = d3.layout.pack()
15
+ .size([diameter, diameter])
16
+ .sort(function(a, b) { return a.russianness - b.russianness; } )
17
+ .value(function(d) { return d.russianness; })
18
+ .padding(1.5),
19
+ svg = d3.select(this.el).append('svg')
20
+ .attr('height', diameter)
21
+ .attr('width', diameter),
22
+ node = svg.selectAll('.node')
23
+ .data(bubble.nodes(this.data).filter(function(d) { return !d.children; }))
24
+ .enter().append('g')
25
+ .attr('class', 'node')
26
+ .attr('transform', function(d) { return "translate(" + d.x + ',' + d.y + ')'; });
27
+
28
+ node.append('title')
29
+ .text(function(d) {
30
+ return 'Author: ' + d.author + ' (' + d.team + ')\n' +
31
+ 'Russianness: ' + format(d.russianness) + '\n' +
32
+ 'Flesch Reading Ease: ' + d3.round(d.flesch_reading_ease, 2);
33
+ });
34
+
35
+ node.append('circle')
36
+ .attr('r', function(d) { return d.r; })
37
+ .style('fill', function(d) { return color(d.team); });
38
+
39
+ node.append('text')
40
+ .attr('dy', '.3em')
41
+ .style('text-anchor', 'middle')
42
+ .text(function(d) { return d.author.substring(0, d.r / 4); });
43
+
44
+ return this;
45
+ },
46
+
47
+ showNovelStats: function() {
48
+ d3.json(this.options.url)
49
+ .on('error', this.$el.displayAlert)
50
+ .on('load', function(data) {
51
+ this.$('.progress').remove();
52
+ this.data = data;
53
+ this.render();
54
+ }.bind(this)).get();
55
+ },
56
+
57
+ handleAuthorClick: function(event) {
58
+ window.location = this.options.authorsPath + '/' +
59
+ $(event.currentTarget).find('text').text().replace(/ /, '.');
60
+ }
61
+ });
@@ -0,0 +1,56 @@
1
+ // View for /gerrit/tags.
2
+ //
3
+ // Manages a set of TagsWordCloud subviews, one per word cloud.
4
+ Twigg.Views.Tags = Backbone.View.extend({
5
+ initialize: function() {
6
+ this.$globalUsed = $('#global-used');
7
+ this.width = this.$globalUsed.width();
8
+ this.fetch();
9
+ },
10
+
11
+ fetch: function() {
12
+ $.getJSON(window.location.href)
13
+ .fail(function() { this.$globalUsed.displayAlert(); }.bind(this))
14
+ .done(function(data) {
15
+ this.$globalUsed.empty();
16
+ this.data = data;
17
+ this.render();
18
+ }.bind(this));
19
+ },
20
+
21
+ render: function() {
22
+ // first render global stats
23
+ new Twigg.Views.TagsWordCloud({
24
+ el: this.$globalUsed[0],
25
+ data: this.data.global,
26
+ width: this.width
27
+ });
28
+
29
+ // then render per-author stats
30
+ var authors = JSON.parse(_.unescape(this.$el.data('authors')));
31
+ _.each(authors, function(author, idx, list) {
32
+ var id = this.nameToId(author);
33
+
34
+ // tags used
35
+ new Twigg.Views.TagsWordCloud({
36
+ el: this.$('#' + id + '-used')[0],
37
+ data: this.data.from[author],
38
+ width: this.width
39
+ });
40
+
41
+ // tags received
42
+ new Twigg.Views.TagsWordCloud({
43
+ el: this.$('#' + id + '-received')[0],
44
+ data: this.data.to[author],
45
+ width: this.width
46
+ });
47
+ }, this);
48
+
49
+ return this;
50
+ },
51
+
52
+ // Duplicative of `#name_to_id` Ruby method in Twigg::App::Server.
53
+ nameToId: function(name) {
54
+ return name.replace(/[ .@]/g, '-').toLowerCase();
55
+ }
56
+ });
@@ -0,0 +1,51 @@
1
+ // Draws a tag word cloud for the given data.
2
+ Twigg.Views.TagsWordCloud = Backbone.View.extend({
3
+ initialize: function() {
4
+ this.render();
5
+ },
6
+
7
+ render: function() {
8
+ if (!this.options.data) {
9
+ return this; // nothing to do
10
+ }
11
+
12
+ var entries = d3.map(this.options.data).entries(),
13
+ fill = d3.scale.category20(),
14
+ height = window.innerHeight * 0.8,
15
+ domain = d3.extent(entries, function(d) { return d.value; }),
16
+ scale = d3.scale.log().range([24, height * 0.33]).domain(domain),
17
+ width = this.options.width,
18
+ words = entries.map(function(d) { return { text: d.key, size: d.value }; });
19
+
20
+ d3.layout.cloud()
21
+ .size([width, height])
22
+ .words(words)
23
+ .padding(5)
24
+ .rotate(function() { return ~~(Math.random() * 2) * 90; })
25
+ .font('Impact')
26
+ .fontSize(function(d) { return scale(d.size); })
27
+ .on('end', function(words) {
28
+ d3.select(this.el)
29
+ .append('svg')
30
+ .attr('width', width)
31
+ .attr('height', height)
32
+ .append('g')
33
+ .attr('transform', 'translate(' + (width / 2) + ',' + (height / 2) + ')')
34
+ .selectAll('text')
35
+ .data(words)
36
+ .enter().append('text')
37
+ .style('font-size', function(d) { return d.size + 'px'; })
38
+ .style('font-family', 'Impact')
39
+ .style('fill', function(d, i) { return fill(i); })
40
+ .attr('text-anchor', 'middle')
41
+ .attr('transform', function(d) {
42
+ return 'translate(' + [d.x, d.y] + ') rotate(' + d.rotate + ')';
43
+ })
44
+ .text(function(d) { return d.text; });
45
+ }.bind(this))
46
+ .timeInterval(10)
47
+ .start();
48
+
49
+ return this;
50
+ }
51
+ });
@@ -0,0 +1,15 @@
1
+ body .modal-dialog {
2
+ left: 0;
3
+ margin-left: auto;
4
+ margin-right: auto;
5
+ width: 90%;
6
+ }
7
+
8
+ h1 .popover {
9
+ // popover text in headings is way too big, even inside <small><small>
10
+ font-size: 0.75em;
11
+ }
12
+
13
+ .footer .navbar-text {
14
+ float: none;
15
+ }
@@ -0,0 +1,28 @@
1
+ // "sticky" footer
2
+
3
+ body,
4
+ html {
5
+ height: 100%;
6
+ }
7
+
8
+ .wrap {
9
+ height: auto !important;
10
+ height: 100%;
11
+ margin: 0 auto -50px;
12
+ min-height: 100%;
13
+ }
14
+
15
+ .push {
16
+ height: 50px;
17
+ }
18
+
19
+ .footer {
20
+ height: 50px;
21
+ margin-top: -50px;
22
+
23
+ p {
24
+ overflow: hidden;
25
+ text-overflow: ellipsis;
26
+ white-space: nowrap;
27
+ }
28
+ }
@@ -0,0 +1,14 @@
1
+ .day-links {
2
+ cursor: pointer;
3
+ }
4
+
5
+ .replace-active:after {
6
+ color: #aaa;
7
+ content: 'loading...';
8
+ font-style: italic;
9
+ }
10
+
11
+ .pairs a {
12
+ color: inherit;
13
+ text-decoration: none;
14
+ }
@@ -0,0 +1,20 @@
1
+ th[data-sort] {
2
+ cursor: pointer;
3
+
4
+ &:after {
5
+ color: #ccc;
6
+ content: '\25b2'; // upward facing triangle
7
+ font-size: 10px;
8
+ margin-left: 2px;
9
+ visibility: hidden;
10
+ }
11
+
12
+ &.sorting-asc:after {
13
+ visibility: visible;
14
+ }
15
+
16
+ &.sorting-desc:after {
17
+ content: '\25bc'; // downward facing triangle
18
+ visibility: visible;
19
+ }
20
+ }
@@ -0,0 +1,10 @@
1
+ // third-party
2
+ @import 'compass/css3/user-interface';
3
+
4
+ // internal
5
+ @import 'bootstrap_overrides';
6
+ @import 'd3/bar_chart';
7
+ @import 'd3/bubble_chart';
8
+ @import 'footer';
9
+ @import 'global';
10
+ @import 'tables';
@@ -0,0 +1,25 @@
1
+ .bar-chart svg {
2
+ .axis {
3
+ fill: none;
4
+ stroke: #000;
5
+ shape-rendering: crispEdges;
6
+
7
+ text {
8
+ fill: #000;
9
+ font-family: sans-serif;
10
+ font-size: 11px;
11
+ }
12
+ }
13
+
14
+ .bar {
15
+ fill: steelblue;
16
+
17
+ &:hover {
18
+ fill: lightsteelblue;
19
+ }
20
+ }
21
+
22
+ .value {
23
+ fill: #fff;
24
+ }
25
+ }
@@ -0,0 +1,22 @@
1
+ .bubble-chart svg {
2
+ display: block;
3
+ margin: 0 auto;
4
+
5
+ .node {
6
+ cursor: pointer;
7
+
8
+ &:hover {
9
+ circle {
10
+ -webkit-svg-shadow: 0 0 7px #666;
11
+ }
12
+
13
+ text {
14
+ fill: #fff;
15
+ }
16
+ }
17
+
18
+ text {
19
+ @include user-select(none);
20
+ }
21
+ }
22
+ }
@@ -17,6 +17,10 @@ module Twigg
17
17
  '/gerrit'
18
18
  end
19
19
 
20
+ def gerrit_tags_path
21
+ '/gerrit/tags'
22
+ end
23
+
20
24
  def pairs_path(options = {})
21
25
  '/pairs' + query_string_from_options(options)
22
26
  end
@@ -5,6 +5,7 @@ require 'sass'
5
5
  require 'sinatra'
6
6
  require 'sinatra/content_for'
7
7
  require 'sinatra/respond_with'
8
+ require 'sprockets'
8
9
  require 'yaml'
9
10
 
10
11
  module Twigg
@@ -14,12 +15,15 @@ module Twigg
14
15
 
15
16
  set :bind, Config.app.bind
16
17
  set :public_dir, App.root + 'public'
17
- set :views, App.root + 'views'
18
+ set :views, [App.root + 'views', App.root + 'assets']
19
+ set :assets, (Sprockets::Environment.new(App.root) do |env|
20
+ env.append_path 'assets/javascripts'
21
+ end)
18
22
 
19
23
  configure do
20
24
  Compass.configuration do |config|
21
25
  config.project_path = __dir__
22
- config.sass_dir = 'views/stylesheets'
26
+ config.sass_dir = 'assets/stylesheets'
23
27
  end
24
28
 
25
29
  set :sass, Compass.sass_engine_options
@@ -41,10 +45,28 @@ module Twigg
41
45
  helpers Twigg::Util
42
46
 
43
47
  helpers do
44
- # Returns true if the current request corresponds to any path in
45
- # `paths`.
46
- def active?(*paths)
47
- 'active' if Array(paths).include?(request.path_info)
48
+ # Support multiple view directories.
49
+ #
50
+ # See: https://github.com/sinatra/sinatra/commit/441b17ead90d3e3a90a3a4
51
+ def find_template(views, name, engine, &block)
52
+ Array(views).each { |v| super(v, name, engine, &block) }
53
+ end
54
+
55
+ def h(str)
56
+ Rack::Utils.escape_html(str)
57
+ end
58
+
59
+ # Returns a truthy value (the "active" class) if the current request
60
+ # corresponds to any path in `paths_or_regex`; otherwise, returns `nil`.
61
+ #
62
+ # @param paths_or_regex May be a String, Array of Strings, or a Regexp.
63
+ def active?(*paths_or_regex)
64
+ case paths_or_regex
65
+ when Array, String
66
+ Array(paths_or_regex).include?(request.path_info)
67
+ when Regexp
68
+ paths_or_regex.match(request.path_info)
69
+ end && 'active'
48
70
  end
49
71
 
50
72
  def day_links
@@ -83,16 +105,24 @@ module Twigg
83
105
  end
84
106
 
85
107
  get '/authors' do
86
- @commit_set = Gatherer.gather(Config.repositories_directory, @days)
108
+ @commit_set = Cacher.get('authors', @days) do
109
+ Gatherer.gather(Config.repositories_directory, @days)
110
+ end
111
+
87
112
  haml :'authors/index', layout: !request.xhr?
88
113
  end
89
114
 
90
- get '/authors/:slug' do
115
+ get '/authors/:slug', provides: %i[html json] do
91
116
  @author = slug_to_name(params[:slug])
92
- @commit_set = Gatherer.gather(Config.repositories_directory, @days).
93
- select_author(@author)
94
- @nvd3_data = @commit_set.count_by_day(@days)
95
- haml :'authors/show'
117
+ @commit_set = Cacher.get('authors', @author, @days) do
118
+ Gatherer.gather(Config.repositories_directory, @days).
119
+ select_author(@author)
120
+ end
121
+
122
+ respond_to do |f|
123
+ f.html { haml :'authors/show' }
124
+ f.json { @commit_set.count_by_day(@days).to_json }
125
+ end
96
126
  end
97
127
 
98
128
  if Config.app.gerrit.enabled
@@ -106,11 +136,28 @@ module Twigg
106
136
  @authors = Gerrit::Author.stats(days: @days)
107
137
  haml :'gerrit/authors'
108
138
  end
139
+
140
+ get '/gerrit/tags', provides: %i[html json] do
141
+ @stats = Gerrit::Tag.stats(days: @days)
142
+ @authors = (@stats[:from].keys + @stats[:to].keys).uniq.sort
143
+ respond_to do |f|
144
+ f.html { haml :'gerrit/tags' }
145
+ f.json { @stats.to_json }
146
+ end
147
+ end
109
148
  end
110
149
  end
111
150
 
151
+ get '/javascripts/:name.js' do
152
+ content_type 'application/javascript'
153
+ settings.assets["#{params[:name]}.js"]
154
+ end
155
+
112
156
  get '/pairs' do
113
- @pairs = Gatherer.gather(Config.repositories_directory, @days).pairs
157
+ @pairs = Cacher.get('pairs', @days) do
158
+ Gatherer.gather(Config.repositories_directory, @days).pairs
159
+ end
160
+
114
161
  haml :'pairs/index', layout: !request.xhr?
115
162
  end
116
163
 
@@ -118,8 +165,10 @@ module Twigg
118
165
  respond_to do |f|
119
166
  f.html { haml :'russian-novels/index' }
120
167
  f.json {
121
- commit_set = Gatherer.gather(Config.repositories_directory, @days)
122
- RussianNovel.new(commit_set).data.to_json
168
+ Cacher.get('russian-novels', @days) do
169
+ commit_set = Gatherer.gather(Config.repositories_directory, @days)
170
+ RussianNovel.new(commit_set).data.to_json
171
+ end
123
172
  }
124
173
  end
125
174
  end
@@ -130,16 +179,24 @@ module Twigg
130
179
  end
131
180
 
132
181
  get '/teams' do
133
- @commit_set = Gatherer.gather(Config.repositories_directory, @days)
182
+ @commit_set = Cacher.get('teams', @days) do
183
+ Gatherer.gather(Config.repositories_directory, @days)
184
+ end
185
+
134
186
  haml :'teams/index', layout: !request.xhr?
135
187
  end
136
188
 
137
- get '/teams/:slug' do
189
+ get '/teams/:slug', provides: %i[html json] do
138
190
  @team = slug_to_name(params[:slug])
139
- @commit_set = Gatherer.gather(Config.repositories_directory, @days).
140
- select_team(@team)
141
- @nvd3_data = @commit_set.count_by_day(@days)
142
- haml :'teams/show'
191
+ @commit_set = Cacher.get('teams', @team, @days) do
192
+ Gatherer.gather(Config.repositories_directory, @days).
193
+ select_team(@team)
194
+ end
195
+
196
+ respond_to do |f|
197
+ f.html { haml :'teams/show' }
198
+ f.json { @commit_set.count_by_day(@days).to_json }
199
+ end
143
200
  end
144
201
  end
145
202
  end
@@ -1,5 +1,5 @@
1
1
  module Twigg
2
2
  module App
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end