timeline_setter 0.1.2 → 0.2.0
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/Rakefile +2 -11
- data/doc/doc.markdown +22 -1
- data/doc/timeline-setter.html +88 -67
- data/doc/twitter-demo.html +5 -6
- data/documentation/TimelineSetter/CLI.html +1 -1
- data/documentation/TimelineSetter/Parser.html +1 -1
- data/documentation/TimelineSetter/Timeline.html +1 -1
- data/documentation/TimelineSetter.html +2 -2
- data/documentation/_index.html +1 -1
- data/documentation/file.README.html +1 -1
- data/documentation/index.html +1 -1
- data/documentation/top-level-namespace.html +1 -1
- data/index.html +12 -2
- data/lib/timeline_setter/cli.rb +10 -4
- data/lib/timeline_setter/timeline.rb +7 -2
- data/lib/timeline_setter/version.rb +1 -1
- data/public/javascripts/timeline-setter.js +74 -39
- data/spec/timeline_setter_spec.rb +23 -5
- data/templates/timeline-markup.erb +1 -1
- data/timeline_setter.gemspec +2 -6
- metadata +6 -7
data/doc/twitter-demo.html
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<link href="http://propublica.github.com/timeline-setter/public/stylesheets/timeline-setter.css" rel="stylesheet" />
|
5
|
-
<script src="
|
6
|
-
<script src="
|
7
|
-
<script src="
|
5
|
+
<script src="../public/javascripts/vendor/jquery-min.js"></script>
|
6
|
+
<script src="../public/javascripts/vendor/underscore-min.js"></script>
|
7
|
+
<script src="../public/javascripts/timeline-setter.js"></script>
|
8
8
|
<script src="https://github.com/bcherry/twitter-text-js/raw/master/twitter-text.js"></script>
|
9
9
|
<style>
|
10
10
|
#timeline_setter .TS-item_label a {
|
@@ -49,9 +49,8 @@
|
|
49
49
|
twitterToTS(data);
|
50
50
|
reqsDone += 1;
|
51
51
|
|
52
|
-
if (reqsDone === usernames.length)
|
52
|
+
if (reqsDone === usernames.length)
|
53
53
|
TimelineSetter.Timeline.boot(tsTimeline);
|
54
|
-
}
|
55
54
|
});
|
56
55
|
};
|
57
56
|
|
@@ -122,4 +121,4 @@
|
|
122
121
|
</div>
|
123
122
|
</script>
|
124
123
|
</body>
|
125
|
-
</html>
|
124
|
+
</html>
|
@@ -616,7 +616,7 @@ A new instance of CLI
|
|
616
616
|
</div>
|
617
617
|
|
618
618
|
<div id="footer">
|
619
|
-
Generated on Thu Apr
|
619
|
+
Generated on Thu Apr 21 10:33:41 2011 by
|
620
620
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
621
621
|
0.6.5 (ruby-1.8.7).
|
622
622
|
</div>
|
@@ -276,7 +276,7 @@ Returns the value of attribute events
|
|
276
276
|
</div>
|
277
277
|
|
278
278
|
<div id="footer">
|
279
|
-
Generated on Thu Apr
|
279
|
+
Generated on Thu Apr 21 10:33:42 2011 by
|
280
280
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
281
281
|
0.6.5 (ruby-1.8.7).
|
282
282
|
</div>
|
@@ -504,7 +504,7 @@ the events hash to JSON to stick into our HTML.
|
|
504
504
|
</div>
|
505
505
|
|
506
506
|
<div id="footer">
|
507
|
-
Generated on Thu Apr
|
507
|
+
Generated on Thu Apr 21 10:33:42 2011 by
|
508
508
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
509
509
|
0.6.5 (ruby-1.8.7).
|
510
510
|
</div>
|
@@ -90,7 +90,7 @@
|
|
90
90
|
<dt id="VERSION-constant" class="">VERSION =
|
91
91
|
|
92
92
|
</dt>
|
93
|
-
<dd><pre class="code"><span class='string val'>"0.1.
|
93
|
+
<dd><pre class="code"><span class='string val'>"0.1.2"</span>
|
94
94
|
</pre></dd>
|
95
95
|
|
96
96
|
</dl>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on Thu Apr
|
106
|
+
Generated on Thu Apr 21 10:33:42 2011 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.6.5 (ruby-1.8.7).
|
109
109
|
</div>
|
data/documentation/_index.html
CHANGED
@@ -123,7 +123,7 @@
|
|
123
123
|
</div>
|
124
124
|
|
125
125
|
<div id="footer">
|
126
|
-
Generated on Thu Apr
|
126
|
+
Generated on Thu Apr 21 10:33:40 2011 by
|
127
127
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
128
128
|
0.6.5 (ruby-1.8.7).
|
129
129
|
</div>
|
data/documentation/index.html
CHANGED
data/index.html
CHANGED
@@ -82,7 +82,7 @@
|
|
82
82
|
</head>
|
83
83
|
<body>
|
84
84
|
<a href="http://www.propublica.org" class="propublica"> </a>
|
85
|
-
<h1>TimelineSetter 0.1.
|
85
|
+
<h1>TimelineSetter 0.1.2</h1>
|
86
86
|
|
87
87
|
<p>TimelineSetter creates beautiful timelines.</p>
|
88
88
|
|
@@ -344,6 +344,7 @@ Feb. 21, 1952 and Jan. 26, 1957, as shown
|
|
344
344
|
<ul>
|
345
345
|
<li>In the Wild: <a href="http://www.propublica.org/special/tbi-psycho-platoon-timeline">ProPublica: How One Blast Affected Five Soldiers</a></li>
|
346
346
|
<li>In the Wild: <a href="http://www.talkingpointsmemo.com/interactive/2011/04/the-wisconsin-union-struggle-timeline.php">TPM: The Wisconsin Union Struggle Timeline</a></li>
|
347
|
+
<li>In the Wild: <a href="http://timelines.latimes.com/bell/">Los Angeles Times: Bell: ‘Corruption on Steroids’</a></li>
|
347
348
|
</ul>
|
348
349
|
|
349
350
|
|
@@ -351,7 +352,7 @@ Feb. 21, 1952 and Jan. 26, 1957, as shown
|
|
351
352
|
|
352
353
|
<h2>Credits</h2>
|
353
354
|
|
354
|
-
<p><a href="http://
|
355
|
+
<p><a href="http://github.com/ashaw">Al Shaw</a>, <a href="http://github.com/thejefflarson">Jeff Larson</a>, ProPublica, <a href="http://github.com/palewire">Ben Welsh</a>, Los Angeles Times</p>
|
355
356
|
|
356
357
|
<p><a id="contact"></a></p>
|
357
358
|
|
@@ -365,6 +366,15 @@ questions should go to <a href="mailto:opensource@propublica.org">opensource@pro
|
|
365
366
|
|
366
367
|
<h2>Change Log</h2>
|
367
368
|
|
369
|
+
<p><a id="release-012"></a></p>
|
370
|
+
|
371
|
+
<h3>0.1.2</h3>
|
372
|
+
|
373
|
+
<ul>
|
374
|
+
<li>Support for decade and lustrum (five year period) interval notches. <em>Thanks, <a href="http://github.com/palewire">Ben Welsh</a></em></li>
|
375
|
+
</ul>
|
376
|
+
|
377
|
+
|
368
378
|
<p><a id="release-011"></a></p>
|
369
379
|
|
370
380
|
<h3>0.1.1</h3>
|
data/lib/timeline_setter/cli.rb
CHANGED
@@ -22,8 +22,8 @@ module TimelineSetter
|
|
22
22
|
opts.on('-o', '--output OUTPUT', 'Output directory to install timeline into.') do |o|
|
23
23
|
@options[:output] = o
|
24
24
|
end
|
25
|
-
opts.on('-a', '--
|
26
|
-
@options[:
|
25
|
+
opts.on('-a', '--without-assets', 'Output timeline without supporting assets') do |a|
|
26
|
+
@options[:no_assets] = a
|
27
27
|
end
|
28
28
|
opts.on('-O', '--open', 'Open generated timeline in a browser') do |o|
|
29
29
|
@options[:open] = o
|
@@ -31,6 +31,9 @@ module TimelineSetter
|
|
31
31
|
opts.on('-m', '--min', 'Create a minified one-page version of the timeline') do |m|
|
32
32
|
@options[:min] = m
|
33
33
|
end
|
34
|
+
opts.on('-i', '--interval INTERVAL', 'Override automatic interval notches with a custom interval.') do |i|
|
35
|
+
@options[:interval] = i
|
36
|
+
end
|
34
37
|
|
35
38
|
|
36
39
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -57,7 +60,10 @@ module TimelineSetter
|
|
57
60
|
end
|
58
61
|
|
59
62
|
def html
|
60
|
-
TimelineSetter::Timeline.new(
|
63
|
+
TimelineSetter::Timeline.new({
|
64
|
+
:events => events.events,
|
65
|
+
:interval => @options[:interval] || ''
|
66
|
+
}).send(@options[:min] ? :timeline_min : :timeline)
|
61
67
|
end
|
62
68
|
|
63
69
|
def outdir
|
@@ -69,7 +75,7 @@ module TimelineSetter
|
|
69
75
|
end
|
70
76
|
|
71
77
|
def compile!
|
72
|
-
if
|
78
|
+
if !@options[:no_assets] || !@options[:min]
|
73
79
|
FileUtils.cp_r(Dir.glob("#{TimelineSetter::ROOT}/public/*"), outdir)
|
74
80
|
end
|
75
81
|
|
@@ -3,8 +3,9 @@ module TimelineSetter
|
|
3
3
|
attr_reader :timeline
|
4
4
|
# Instantiate a new timeline from an events
|
5
5
|
# array created in Parser#initialize
|
6
|
-
def initialize(
|
7
|
-
@events
|
6
|
+
def initialize(opts = {})
|
7
|
+
@events = opts[:events]
|
8
|
+
@interval = opts[:interval] || ''
|
8
9
|
end
|
9
10
|
|
10
11
|
# Convert human dates to timestamps, sort the hash by timestamp, and
|
@@ -13,6 +14,10 @@ module TimelineSetter
|
|
13
14
|
@events.each {|r| r[:timestamp] = Time.parse(r[:date]).to_i * 1000 }
|
14
15
|
@events.to_json
|
15
16
|
end
|
17
|
+
|
18
|
+
def interval_json
|
19
|
+
{"interval" => "#{@interval}"}.to_json
|
20
|
+
end
|
16
21
|
|
17
22
|
def timeline_markup
|
18
23
|
tmpl("timeline-markup.erb")
|
@@ -168,10 +168,18 @@
|
|
168
168
|
|
169
169
|
// `Intervals` is a particularly focused class to calculate even breaks based
|
170
170
|
// on the passed in `Bounds`.
|
171
|
-
var Intervals = function(bounds) {
|
171
|
+
var Intervals = function(bounds, interval) {
|
172
172
|
this.max = bounds.max;
|
173
173
|
this.min = bounds.min;
|
174
|
-
|
174
|
+
|
175
|
+
if(!interval || !this.INTERVALS[interval]) {
|
176
|
+
var i = this.computeMaxInterval();
|
177
|
+
this.maxInterval = this.INTERVAL_ORDER[i];
|
178
|
+
this.idx = i;
|
179
|
+
} else {
|
180
|
+
this.maxInterval = interval;
|
181
|
+
this.idx = _.indexOf(this.INTERVAL_ORDER, interval);
|
182
|
+
}
|
175
183
|
};
|
176
184
|
|
177
185
|
// An object containing human translations for date indexes.
|
@@ -199,6 +207,8 @@
|
|
199
207
|
return dYear;
|
200
208
|
case "Month":
|
201
209
|
return dMonth + ', ' + dYear;
|
210
|
+
case "Week":
|
211
|
+
return dDate;
|
202
212
|
case "Date":
|
203
213
|
return dDate;
|
204
214
|
case "Hours":
|
@@ -217,6 +227,7 @@
|
|
217
227
|
Lustrum : 157680000000,
|
218
228
|
FullYear : 31536000000,
|
219
229
|
Month : 2592000000,
|
230
|
+
Week : 604800000,
|
220
231
|
Date : 86400000,
|
221
232
|
Hours : 3600000,
|
222
233
|
Minutes : 60000,
|
@@ -224,7 +235,7 @@
|
|
224
235
|
},
|
225
236
|
|
226
237
|
// The order used when testing where exactly a timespan falls.
|
227
|
-
INTERVAL_ORDER : ['Seconds','Minutes','Hours','Date','Month','FullYear',
|
238
|
+
INTERVAL_ORDER : ['Seconds','Minutes','Hours','Date','Week','Month','FullYear','Lustrum','Decade'],
|
228
239
|
|
229
240
|
// A test to find the appropriate range of intervals, for example if a range of
|
230
241
|
// timestamps only spans hours this will return true when called with `"Hours"`.
|
@@ -233,12 +244,10 @@
|
|
233
244
|
},
|
234
245
|
|
235
246
|
// Find the maximum interval we should use based on the estimates in `INTERVALS`.
|
236
|
-
|
247
|
+
computeMaxInterval : function() {
|
237
248
|
for (var i = 0; i < this.INTERVAL_ORDER.length; i++)
|
238
249
|
if (!this.isAtLeastA(this.INTERVAL_ORDER[i])) break;
|
239
|
-
|
240
|
-
this.maxInterval = this.INTERVAL_ORDER[i - 1];
|
241
|
-
this.idx = i - 1;
|
250
|
+
return i - 1;
|
242
251
|
},
|
243
252
|
|
244
253
|
// Return the calculated `maxInterval`.
|
@@ -252,35 +261,59 @@
|
|
252
261
|
// with year one. For example, the current decade runs from 2010-2019.
|
253
262
|
// And if you pass in the year 2010 or 2015 you'll get 2010 back.
|
254
263
|
getDecade : function(date) {
|
255
|
-
|
264
|
+
return (date.getFullYear() / 10 | 0) * 10;
|
256
265
|
},
|
257
|
-
|
266
|
+
|
258
267
|
// Returns the first year of the five year "lustrum" a Date belongs to
|
259
268
|
// as an integer. A lustrum is a fancy Roman word for a "five-year period."
|
260
269
|
// You can read more about it [here](http://en.wikipedia.org/wiki/Lustrum).
|
261
270
|
// This all means that if you pass in the year 2011 you'll get 2010 back.
|
262
271
|
// And if you pass in the year 1997 you'll get 1995 back.
|
263
272
|
getLustrum : function(date) {
|
264
|
-
|
273
|
+
return (date.getFullYear() / 5 | 0) * 5;
|
274
|
+
},
|
275
|
+
|
276
|
+
// Return a Date object rounded down to the previous Sunday, a.k.a. the first day of the week.
|
277
|
+
getWeekFloor: function(date) {
|
278
|
+
thisDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
279
|
+
thisDate.setDate(date.getDate() - date.getDay());
|
280
|
+
return thisDate;
|
265
281
|
},
|
266
|
-
|
282
|
+
|
283
|
+
// Return a Date object rounded up to the next Sunday, a.k.a. the start of the next week.
|
284
|
+
getWeekCeil: function(date) {
|
285
|
+
thisDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
286
|
+
thisDate.setDate(thisDate.getDate() + (7 - date.getDay()));
|
287
|
+
return thisDate;
|
288
|
+
},
|
289
|
+
|
267
290
|
// Zero out a date from the current interval down to seconds.
|
268
291
|
floor : function(ts){
|
269
|
-
var
|
270
|
-
var
|
292
|
+
var date = new Date(ts);
|
293
|
+
var intvl = this.INTERVAL_ORDER[this.idx];
|
294
|
+
var idx = this.idx > _.indexOf(this.INTERVAL_ORDER,'FullYear') ?
|
295
|
+
_.indexOf(this.INTERVAL_ORDER,'FullYear') :
|
296
|
+
idx;
|
297
|
+
|
298
|
+
// Zero the special extensions, and adjust as idx necessary.
|
299
|
+
switch(intvl){
|
300
|
+
case 'Decade':
|
301
|
+
date.setFullYear(this.getDecade(date));
|
302
|
+
break;
|
303
|
+
case 'Lustrum':
|
304
|
+
date.setFullYear(this.getLustrum(date));
|
305
|
+
break;
|
306
|
+
case 'Week':
|
307
|
+
date.setDate(this.getWeekFloor(date).getDate());
|
308
|
+
idx = _.indexOf(this.INTERVAL_ORDER, 'Week');
|
309
|
+
}
|
310
|
+
|
311
|
+
// Zero out the rest
|
271
312
|
while(idx--){
|
272
313
|
var intvl = this.INTERVAL_ORDER[idx];
|
273
|
-
|
274
|
-
case 'Lustrum':
|
275
|
-
date["setFullYear"](this.getDecade(date));
|
276
|
-
break;
|
277
|
-
case 'FullYear':
|
278
|
-
date["setFullYear"](this.getLustrum(date));
|
279
|
-
break;
|
280
|
-
default:
|
281
|
-
date["set" + intvl](intvl === "Date" ? 1 : 0);
|
282
|
-
}
|
314
|
+
if(intvl !== 'Week') date["set" + intvl](intvl === "Date" ? 1 : 0);
|
283
315
|
}
|
316
|
+
|
284
317
|
return date.getTime();
|
285
318
|
},
|
286
319
|
|
@@ -290,10 +323,13 @@
|
|
290
323
|
var intvl = this.INTERVAL_ORDER[this.idx];
|
291
324
|
switch(intvl){
|
292
325
|
case 'Decade':
|
293
|
-
date
|
326
|
+
date.setFullYear(this.getDecade(date) + 10);
|
294
327
|
break;
|
295
328
|
case 'Lustrum':
|
296
|
-
date
|
329
|
+
date.setFullYear(this.getLustrum(date) + 5);
|
330
|
+
break;
|
331
|
+
case 'Week':
|
332
|
+
date.setTime(this.getWeekCeil(date).getTime());
|
297
333
|
break;
|
298
334
|
default:
|
299
335
|
date["set" + intvl](date["get" + intvl]() + 1);
|
@@ -367,7 +403,7 @@
|
|
367
403
|
|
368
404
|
// Every new `Series` gets new color. If there are too many series
|
369
405
|
// the remaining series will be a simple gray.
|
370
|
-
|
406
|
+
|
371
407
|
// These colors can be styled like such in
|
372
408
|
// timeline-setter.css, where the numbers 1-9 cycle through in that order:
|
373
409
|
//
|
@@ -404,16 +440,16 @@
|
|
404
440
|
// takes a json array of card representations and then builds series, calculates
|
405
441
|
// intervals `sync`s the `Bar` and `CardContainer` objects and triggers the
|
406
442
|
// `render` event.
|
407
|
-
var Timeline = TimelineSetter.Timeline = function(data) {
|
443
|
+
var Timeline = TimelineSetter.Timeline = function(data, config) {
|
408
444
|
data = data.sort(function(a, b){ return a.timestamp - b.timestamp; });
|
409
445
|
this.bySid = {};
|
410
446
|
this.series = [];
|
447
|
+
this.config = (config || {});
|
411
448
|
this.bounds = new Bounds();
|
412
449
|
this.bar = new Bar(this);
|
413
450
|
this.cardCont = new CardScroller(this);
|
414
451
|
this.createSeries(data);
|
415
|
-
|
416
|
-
var range = new Intervals(this.bounds);
|
452
|
+
var range = new Intervals(this.bounds, config.interval);
|
417
453
|
this.intervals = range.getRanges();
|
418
454
|
this.bounds.extend(this.bounds.min - range.getMaxInterval() / 2);
|
419
455
|
this.bounds.extend(this.bounds.max + range.getMaxInterval() / 2);
|
@@ -442,7 +478,7 @@
|
|
442
478
|
}
|
443
479
|
var series = this.bySid[card.series];
|
444
480
|
series.add(card);
|
445
|
-
|
481
|
+
|
446
482
|
this.bounds.extend(series.max());
|
447
483
|
this.bounds.extend(series.min());
|
448
484
|
}
|
@@ -610,7 +646,7 @@
|
|
610
646
|
this.timestamp = card.timestamp;
|
611
647
|
this.attributes = card;
|
612
648
|
this.attributes.topcolor = series.color;
|
613
|
-
|
649
|
+
|
614
650
|
this.template = template("#TS-card_tmpl");
|
615
651
|
this.ntemplate = template("#TS-notch_tmpl");
|
616
652
|
_.bindAll(this, "render", "activate", "flip", "setPermalink", "toggleNotch");
|
@@ -657,7 +693,7 @@
|
|
657
693
|
var margin = this.el.css("margin-left") === this.originalMargin;
|
658
694
|
var flippable = this.$(".TS-item").width() < $("#timeline_setter").width() / 2;
|
659
695
|
var offTimeline = this.el.position().left - this.$(".TS-item").width() < 0;
|
660
|
-
|
696
|
+
|
661
697
|
// If the card's right edge is more than the timeline's right edge and
|
662
698
|
// it's never been flipped before and it won't go off the timeline when
|
663
699
|
// flipped. We'll flip it.
|
@@ -692,14 +728,14 @@
|
|
692
728
|
this.el.show().addClass(("TS-card_active"));
|
693
729
|
this.notch.addClass("TS-notch_active");
|
694
730
|
this.setWidth();
|
695
|
-
|
731
|
+
|
696
732
|
// In the case that the card is outside the bounds the wrong way when
|
697
733
|
// it's flipped, we'll take care of it here before we move the actual
|
698
|
-
// card.
|
734
|
+
// card.
|
699
735
|
this.flip($.Event("move"));
|
700
736
|
this.move();
|
701
737
|
},
|
702
|
-
|
738
|
+
|
703
739
|
// For Internet Explorer each card sets the width of` .TS-item_label` to
|
704
740
|
// the maximum width of the card's children, or if that is less than the
|
705
741
|
// `.TS-item_year` element's width, `.TS-item_label` gets `.TS-item_year`s
|
@@ -833,11 +869,10 @@
|
|
833
869
|
// In the default install of TimelineSetter, Boot is called in the generated
|
834
870
|
// HTML. We'll kick everything off by creating a `Timeline`, some `Controls`
|
835
871
|
// and binding to `"keydown"`.
|
836
|
-
Timeline.boot = function(data) {
|
872
|
+
Timeline.boot = function(data, config) {
|
837
873
|
$(function(){
|
838
|
-
|
839
|
-
TimelineSetter.timeline = new Timeline(data);
|
840
|
-
|
874
|
+
|
875
|
+
TimelineSetter.timeline = new Timeline(data, config || {});
|
841
876
|
new Zoom("in");
|
842
877
|
new Zoom("out");
|
843
878
|
var chooseNext = new Chooser("next");
|
@@ -7,19 +7,34 @@ describe "TimelineSetter core" do
|
|
7
7
|
|
8
8
|
it 'should create json from an events hash' do
|
9
9
|
events = TimelineSetter::Parser.new(TEST_CSV)
|
10
|
-
j = TimelineSetter::Timeline.new(
|
10
|
+
j = TimelineSetter::Timeline.new({
|
11
|
+
:events => events.events
|
12
|
+
}).to_json
|
11
13
|
JSON.parse(j)[0]['date'].should eql "Feb. 18, 2003"
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'should create html from an events hash' do
|
15
17
|
events = TimelineSetter::Parser.new(TEST_CSV)
|
16
|
-
html = TimelineSetter::Timeline.new(
|
18
|
+
html = TimelineSetter::Timeline.new({
|
19
|
+
:events => events.events
|
20
|
+
}).timeline.to_s
|
17
21
|
html.should =~ /"timestamp":1045544400/
|
18
22
|
end
|
19
23
|
|
24
|
+
it 'should create custom intervals' do
|
25
|
+
events = TimelineSetter::Parser.new(TEST_CSV)
|
26
|
+
html = TimelineSetter::Timeline.new({
|
27
|
+
:events => events.events,
|
28
|
+
:interval => "FullYear"
|
29
|
+
}).timeline.to_s
|
30
|
+
html.should =~ /"interval":"FullYear"/
|
31
|
+
end
|
32
|
+
|
20
33
|
it 'should create minified timelines' do
|
21
34
|
events = TimelineSetter::Parser.new(TEST_CSV)
|
22
|
-
html = TimelineSetter::Timeline.new(
|
35
|
+
html = TimelineSetter::Timeline.new({
|
36
|
+
:events => events.events
|
37
|
+
}).timeline_min.to_s
|
23
38
|
|
24
39
|
# test to see we've compiled all the assets
|
25
40
|
|
@@ -39,7 +54,7 @@ end
|
|
39
54
|
describe "TimelineSetter CLI" do
|
40
55
|
it 'should drop just timeline.html into tmp' do
|
41
56
|
`mkdir /tmp/ts_test_1`
|
42
|
-
%x[ #{TS_BINARY} -c #{TEST_CSV_PATH} -o /tmp/ts_test_1/ ]
|
57
|
+
%x[ #{TS_BINARY} -c #{TEST_CSV_PATH} -o /tmp/ts_test_1/ -a ]
|
43
58
|
Dir.glob("/tmp/ts_test_1/*").should include("/tmp/ts_test_1/timeline.html")
|
44
59
|
file = File.open("/tmp/ts_test_1/timeline.html").read
|
45
60
|
file.should =~ /"timestamp":1045544400/
|
@@ -47,7 +62,7 @@ describe "TimelineSetter CLI" do
|
|
47
62
|
|
48
63
|
it 'should drop timeline.html and associated assets into tmp' do
|
49
64
|
`mkdir /tmp/ts_test_2`
|
50
|
-
%x[ #{TS_BINARY} -c #{TEST_CSV_PATH} -o /tmp/ts_test_2/
|
65
|
+
%x[ #{TS_BINARY} -c #{TEST_CSV_PATH} -o /tmp/ts_test_2/ ]
|
51
66
|
Dir.glob("/tmp/ts_test_2/*").should include("/tmp/ts_test_2/timeline.html")
|
52
67
|
Dir.glob("/tmp/ts_test_2/javascripts/*").should include("/tmp/ts_test_2/javascripts/timeline-setter.js")
|
53
68
|
Dir.glob("/tmp/ts_test_2/javascripts/vendor/*").should include("/tmp/ts_test_2/javascripts/vendor/jquery-min.js")
|
@@ -73,6 +88,9 @@ describe "TimelineSetter CLI" do
|
|
73
88
|
file.should =~ /jQuery JavaScript Library/
|
74
89
|
# test timeline-setter.js
|
75
90
|
file.should =~ /INTERVAL_ORDER/
|
91
|
+
|
92
|
+
# check to see that we DID NOT generate the assets
|
93
|
+
Dir.glob("/tmp/ts_test_3/*").should_not include("/tmp/ts_test_3/javascripts/timeline-setter.js")
|
76
94
|
end
|
77
95
|
|
78
96
|
after :all do
|
@@ -21,7 +21,7 @@
|
|
21
21
|
</div>
|
22
22
|
|
23
23
|
<script type="text/javascript">
|
24
|
-
TimelineSetter.Timeline.boot(<%= self.to_json %>);
|
24
|
+
TimelineSetter.Timeline.boot(<%= self.to_json %>, <%= self.interval_json %>);
|
25
25
|
</script>
|
26
26
|
<script id="TS-year_notch_tmpl" type="text/jst">
|
27
27
|
<div class="TS-year_notch TS-year_notch_<%%= timestamp %>">
|
data/timeline_setter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{timeline_setter}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Al Shaw", "Jeff Larson"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-07-11}
|
13
13
|
s.default_executable = %q{timeline-setter}
|
14
14
|
s.description = %q{TimelineSetter is a tool to create HTML timelines from spreadsheets of events.}
|
15
15
|
s.email = %q{almshaw@gmail.com}
|
@@ -71,10 +71,6 @@ Gem::Specification.new do |s|
|
|
71
71
|
s.require_paths = ["lib"]
|
72
72
|
s.rubygems_version = %q{1.3.7}
|
73
73
|
s.summary = %q{TimelineSetter is a tool to create HTML timelines from spreadsheets of events.}
|
74
|
-
s.test_files = [
|
75
|
-
"spec/spec_helper.rb",
|
76
|
-
"spec/timeline_setter_spec.rb"
|
77
|
-
]
|
78
74
|
|
79
75
|
if s.respond_to? :specification_version then
|
80
76
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timeline_setter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Al Shaw
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-07-11 00:00:00 -04:00
|
20
20
|
default_executable: timeline-setter
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -184,6 +184,5 @@ rubygems_version: 1.3.7
|
|
184
184
|
signing_key:
|
185
185
|
specification_version: 3
|
186
186
|
summary: TimelineSetter is a tool to create HTML timelines from spreadsheets of events.
|
187
|
-
test_files:
|
188
|
-
|
189
|
-
- spec/timeline_setter_spec.rb
|
187
|
+
test_files: []
|
188
|
+
|