news_reader 0.1.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.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/.vscode/settings.json +3 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +97 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +41 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +14 -0
  13. data/bin/news-reader +6 -0
  14. data/bin/setup +8 -0
  15. data/fixtures/.DS_Store +0 -0
  16. data/fixtures/blog/index.html +200 -0
  17. data/fixtures/blog/index_files/Box.css +29 -0
  18. data/fixtures/blog/index_files/Java_Box.js +89 -0
  19. data/fixtures/blog/index_files/ModuleStyleSheets.css +1655 -0
  20. data/fixtures/blog/index_files/black.css +11 -0
  21. data/fixtures/blog/index_files/blog-jive.jpg +0 -0
  22. data/fixtures/blog/index_files/blog-musolfs.jpg +0 -0
  23. data/fixtures/blog/index_files/blog-poolpak.jpg +0 -0
  24. data/fixtures/blog/index_files/blog-portalaudit.png +0 -0
  25. data/fixtures/blog/index_files/blog-semicolon1.jpg +0 -0
  26. data/fixtures/blog/index_files/blog-semicolon2.jpg +0 -0
  27. data/fixtures/blog/index_files/blog-spa1.jpg +0 -0
  28. data/fixtures/blog/index_files/blog-spa2.jpg +0 -0
  29. data/fixtures/blog/index_files/blog-statera.jpg +0 -0
  30. data/fixtures/blog/index_files/blue.css +11 -0
  31. data/fixtures/blog/index_files/common.js +149 -0
  32. data/fixtures/blog/index_files/dark.css +31 -0
  33. data/fixtures/blog/index_files/featherlight.min.css +8 -0
  34. data/fixtures/blog/index_files/featherlight.min.js +8 -0
  35. data/fixtures/blog/index_files/font-awesome.min.css +4 -0
  36. data/fixtures/blog/index_files/green.css +11 -0
  37. data/fixtures/blog/index_files/isotope.css +64 -0
  38. data/fixtures/blog/index_files/jquery-ui.min.js +5 -0
  39. data/fixtures/blog/index_files/jquery.carouFredSel-6.2.1-packed.js +16 -0
  40. data/fixtures/blog/index_files/jquery.contentcarousel.js +137 -0
  41. data/fixtures/blog/index_files/jquery.easing.1.3.js +205 -0
  42. data/fixtures/blog/index_files/jquery.form.js +1121 -0
  43. data/fixtures/blog/index_files/jquery.hoverdir.js +220 -0
  44. data/fixtures/blog/index_files/jquery.inview.js +60 -0
  45. data/fixtures/blog/index_files/jquery.isotope.min.js +11 -0
  46. data/fixtures/blog/index_files/jquery.magnific-popup.js +2046 -0
  47. data/fixtures/blog/index_files/jquery.mb.YTPlayer.js +1041 -0
  48. data/fixtures/blog/index_files/jquery.min.js +5 -0
  49. data/fixtures/blog/index_files/jquery.nav.js +223 -0
  50. data/fixtures/blog/index_files/jquery.smoothwheel.js +153 -0
  51. data/fixtures/blog/index_files/jquery.sticky.js +129 -0
  52. data/fixtures/blog/index_files/jquery.superslides.js +656 -0
  53. data/fixtures/blog/index_files/jquery.validate.js +1231 -0
  54. data/fixtures/blog/index_files/jquery.vegas.css +34 -0
  55. data/fixtures/blog/index_files/js +201 -0
  56. data/fixtures/blog/index_files/loading.gif +0 -0
  57. data/fixtures/blog/index_files/magnific-popup.css +365 -0
  58. data/fixtures/blog/index_files/main.css +301 -0
  59. data/fixtures/blog/index_files/main.js +26 -0
  60. data/fixtures/blog/index_files/modernizr-2.6.2.min.js +4 -0
  61. data/fixtures/blog/index_files/normalize.css +533 -0
  62. data/fixtures/blog/index_files/ohp3fra.js +44 -0
  63. data/fixtures/blog/index_files/orange.css +11 -0
  64. data/fixtures/blog/index_files/paralax.js +525 -0
  65. data/fixtures/blog/index_files/paralaxNEW4.css +2730 -0
  66. data/fixtures/blog/index_files/plugins.js +221 -0
  67. data/fixtures/blog/index_files/portfolio.js +142 -0
  68. data/fixtures/blog/index_files/purple.css +11 -0
  69. data/fixtures/blog/index_files/red.css +11 -0
  70. data/fixtures/blog/index_files/responsive3.css +329 -0
  71. data/fixtures/blog/index_files/superslides.css +65 -0
  72. data/fixtures/blog/index_files/turquoise.css +11 -0
  73. data/fixtures/blog/index_files/util.js +287 -0
  74. data/fixtures/blog/index_files/yellow.css +11 -0
  75. data/lib/news_reader/article.rb +60 -0
  76. data/lib/news_reader/cli.rb +41 -0
  77. data/lib/news_reader/scraper.rb +17 -0
  78. data/lib/news_reader/version.rb +3 -0
  79. data/lib/news_reader.rb +4 -0
  80. data/news_reader.gemspec +40 -0
  81. metadata +209 -0
@@ -0,0 +1,656 @@
1
+ /*! Superslides - v0.6.2 - 2013-07-10
2
+ * https://github.com/nicinabox/superslides
3
+ * Copyright (c) 2013 Nic Aitch; Licensed MIT */
4
+ (function(window, $) {
5
+
6
+ var Superslides, plugin = 'superslides';
7
+
8
+ Superslides = function(el, options) {
9
+ this.options = $.extend({
10
+ play: false,
11
+ animation_speed: 600,
12
+ animation_easing: 'swing',
13
+ animation: 'slide',
14
+ inherit_width_from: window,
15
+ inherit_height_from: window,
16
+ pagination: true,
17
+ hashchange: false,
18
+ scrollable: true,
19
+ elements: {
20
+ preserve: '.preserve',
21
+ nav: '.slides-navigation',
22
+ container: '.slides-container',
23
+ pagination: '.slides-pagination'
24
+ }
25
+ }, options);
26
+
27
+ var that = this,
28
+ $control = $('<div>', { "class": 'slides-control' }),
29
+ multiplier = 1;
30
+
31
+ this.$el = $(el);
32
+ this.$container = this.$el.find(this.options.elements.container);
33
+
34
+ // Private Methods
35
+ var initialize = function() {
36
+ multiplier = that._findMultiplier();
37
+
38
+ that.$el.on('click', that.options.elements.nav + " a", function(e) {
39
+ e.preventDefault();
40
+
41
+ that.stop();
42
+ if ($(this).hasClass('next')) {
43
+ that.animate('next', function() {
44
+ that.start();
45
+ });
46
+ } else {
47
+ that.animate('prev', function() {
48
+ that.start();
49
+ });
50
+ }
51
+ });
52
+
53
+ $(document).on('keyup', function(e) {
54
+ if (e.keyCode === 37) {
55
+ that.animate('prev');
56
+ }
57
+ if (e.keyCode === 39) {
58
+ that.animate('next');
59
+ }
60
+ });
61
+
62
+ $(window).on('resize', function() {
63
+ setTimeout(function() {
64
+ var $children = that.$container.children();
65
+
66
+ that.width = that._findWidth();
67
+ that.height = that._findHeight();
68
+
69
+ $children.css({
70
+ width: that.width,
71
+ left: that.width
72
+ });
73
+
74
+ that.css.containers();
75
+ that.css.images();
76
+ }, 10);
77
+ });
78
+
79
+ $(window).on('hashchange', function() {
80
+ var hash = that._parseHash(), index;
81
+
82
+ if (hash && !isNaN(hash)) {
83
+ // Minus 1 here because we don't want the url
84
+ // to be zero-indexed
85
+ index = that._upcomingSlide(hash - 1);
86
+
87
+ } else {
88
+ index = that._upcomingSlide(hash);
89
+ }
90
+
91
+ if (index >= 0 && index !== that.current) {
92
+ that.animate(index);
93
+ }
94
+ });
95
+
96
+ that.pagination._events();
97
+
98
+ that.start();
99
+ return that;
100
+ };
101
+
102
+ var css = {
103
+ containers: function() {
104
+ if (that.init) {
105
+ that.$el.css({
106
+ height: that.height
107
+ });
108
+
109
+ that.$control.css({
110
+ width: that.width * multiplier,
111
+ left: -that.width
112
+ });
113
+
114
+ that.$container.css({
115
+
116
+ });
117
+ } else {
118
+ $('body').css({
119
+ margin: 0
120
+ });
121
+
122
+ that.$el.css({
123
+ position: 'relative',
124
+ overflow: 'hidden',
125
+ width: '100%',
126
+ height: that.height
127
+ });
128
+
129
+ that.$control.css({
130
+ position: 'relative',
131
+ transform: 'translate3d(0)',
132
+ height: '100%',
133
+ width: that.width * multiplier,
134
+ left: -that.width
135
+ });
136
+
137
+ that.$container.css({
138
+ display: 'none',
139
+ margin: '0',
140
+ padding: '0',
141
+ listStyle: 'none',
142
+ position: 'relative',
143
+ height: '100%'
144
+ });
145
+ }
146
+
147
+ if (that.size() === 1) {
148
+ that.$el.find(that.options.elements.nav).hide();
149
+ }
150
+ },
151
+ images: function() {
152
+ var $images = that.$container.find('img')
153
+ .not(that.options.elements.preserve)
154
+
155
+ $images.removeAttr('width').removeAttr('height')
156
+ .css({
157
+ "-webkit-backface-visibility": 'hidden',
158
+ "-ms-interpolation-mode": 'bicubic',
159
+ "position": 'absolute',
160
+ "left": '0',
161
+ "top": '0',
162
+ "z-index": '-1',
163
+ "max-width": 'none'
164
+ });
165
+
166
+ $images.each(function() {
167
+ var image_aspect_ratio = that.image._aspectRatio(this),
168
+ image = this;
169
+
170
+ if (!$.data(this, 'processed')) {
171
+ var img = new Image();
172
+ img.onload = function() {
173
+ that.image._scale(image, image_aspect_ratio);
174
+ that.image._center(image, image_aspect_ratio);
175
+ $.data(image, 'processed', true);
176
+ };
177
+ img.src = this.src;
178
+
179
+ } else {
180
+ that.image._scale(image, image_aspect_ratio);
181
+ that.image._center(image, image_aspect_ratio);
182
+ }
183
+ });
184
+ },
185
+ children: function() {
186
+ var $children = that.$container.children();
187
+
188
+ if ($children.is('img')) {
189
+ $children.each(function() {
190
+ if ($(this).is('img')) {
191
+ $(this).wrap('<div>');
192
+
193
+ // move id attribute
194
+ var id = $(this).attr('id');
195
+ $(this).removeAttr('id');
196
+ $(this).parent().attr('id', id);
197
+ }
198
+ });
199
+
200
+ $children = that.$container.children();
201
+ }
202
+
203
+ if (!that.init) {
204
+ $children.css({
205
+ display: 'none',
206
+ left: that.width * 2
207
+ });
208
+ }
209
+
210
+ $children.css({
211
+ position: 'absolute',
212
+ overflow: 'hidden',
213
+ height: '100%',
214
+ width: that.width,
215
+ top: 0,
216
+ zIndex: 0
217
+ });
218
+
219
+ }
220
+ }
221
+
222
+ var fx = {
223
+ slide: function(orientation, complete) {
224
+ var $children = that.$container.children(),
225
+ $target = $children.eq(orientation.upcoming_slide);
226
+
227
+ $target.css({
228
+ left: orientation.upcoming_position,
229
+ display: 'block'
230
+ });
231
+
232
+ that.$control.animate({
233
+ left: orientation.offset
234
+ },
235
+ that.options.animation_speed,
236
+ that.options.animation_easing,
237
+ function() {
238
+ if (that.size() > 1) {
239
+ that.$control.css({
240
+ left: -that.width
241
+ });
242
+
243
+ $children.eq(orientation.upcoming_slide).css({
244
+ left: that.width,
245
+ zIndex: 2
246
+ });
247
+
248
+ if (orientation.outgoing_slide >= 0) {
249
+ $children.eq(orientation.outgoing_slide).css({
250
+ left: that.width,
251
+ display: 'none',
252
+ zIndex: 0
253
+ });
254
+ }
255
+ }
256
+
257
+ complete();
258
+ });
259
+ },
260
+ fade: function(orientation, complete) {
261
+ var that = this,
262
+ $children = that.$container.children(),
263
+ $outgoing = $children.eq(orientation.outgoing_slide),
264
+ $target = $children.eq(orientation.upcoming_slide);
265
+
266
+ $target.css({
267
+ left: this.width,
268
+ opacity: 1,
269
+ display: 'block'
270
+ });
271
+
272
+ if (orientation.outgoing_slide >= 0) {
273
+ $outgoing.animate({
274
+ opacity: 0
275
+ },
276
+ that.options.animation_speed,
277
+ that.options.animation_easing,
278
+ function() {
279
+ if (that.size() > 1) {
280
+ $children.eq(orientation.upcoming_slide).css({
281
+ zIndex: 2
282
+ });
283
+
284
+ if (orientation.outgoing_slide >= 0) {
285
+ $children.eq(orientation.outgoing_slide).css({
286
+ opacity: 1,
287
+ display: 'none',
288
+ zIndex: 0
289
+ });
290
+ }
291
+ }
292
+
293
+ complete();
294
+ });
295
+ } else {
296
+ $target.css({
297
+ zIndex: 2
298
+ });
299
+ complete();
300
+ }
301
+ }
302
+ };
303
+
304
+ fx = $.extend(fx, $.fn.superslides.fx);
305
+
306
+ var image = {
307
+ _centerY: function(image) {
308
+ var $img = $(image);
309
+
310
+ $img.css({
311
+ top: (that.height - $img.height()) / 2
312
+ });
313
+ },
314
+ _centerX: function(image) {
315
+ var $img = $(image);
316
+
317
+ $img.css({
318
+ left: (that.width - $img.width()) / 2
319
+ });
320
+ },
321
+ _center: function(image) {
322
+ that.image._centerX(image);
323
+ that.image._centerY(image);
324
+ },
325
+ _aspectRatio: function(image) {
326
+ if (!image.naturalHeight && !image.naturalWidth) {
327
+ var img = new Image();
328
+ img.src = image.src;
329
+ image.naturalHeight = img.height;
330
+ image.naturalWidth = img.width;
331
+ }
332
+
333
+ return image.naturalHeight / image.naturalWidth;
334
+ },
335
+ _scale: function(image, image_aspect_ratio) {
336
+ image_aspect_ratio = image_aspect_ratio || that.image._aspectRatio(image);
337
+
338
+ var container_aspect_ratio = that.height / that.width,
339
+ $img = $(image);
340
+
341
+ if (container_aspect_ratio > image_aspect_ratio) {
342
+ $img.css({
343
+ height: that.height,
344
+ width: that.height / image_aspect_ratio
345
+ });
346
+
347
+ } else {
348
+ $img.css({
349
+ height: that.width * image_aspect_ratio,
350
+ width: that.width
351
+ });
352
+ }
353
+ }
354
+ };
355
+
356
+ var pagination = {
357
+ _setCurrent: function(i) {
358
+ if (!that.$pagination) { return; }
359
+
360
+ var $pagination_children = that.$pagination.children();
361
+
362
+ $pagination_children.removeClass('current');
363
+ $pagination_children.eq(i)
364
+ .addClass('current');
365
+ },
366
+ _addItem: function(i) {
367
+ var slide_number = i + 1,
368
+ href = slide_number,
369
+ $slide = that.$container.children().eq(i),
370
+ slide_id = $slide.attr('id');
371
+
372
+ if (slide_id) {
373
+ href = slide_id;
374
+ }
375
+
376
+ var $item = $("<a>", {
377
+ 'href': "#" + href,
378
+ 'text': href
379
+ });
380
+
381
+ $item.appendTo(that.$pagination);
382
+ },
383
+ _setup: function() {
384
+ if (!that.options.pagination || that.size() === 1) { return; }
385
+
386
+ var $pagination = $("<nav>", {
387
+ 'class': that.options.elements.pagination.replace(/^\./, '')
388
+ });
389
+
390
+ that.$pagination = $pagination.appendTo(that.$el);
391
+
392
+ for (var i = 0; i < that.size(); i++) {
393
+ that.pagination._addItem(i);
394
+ }
395
+ },
396
+ _events: function() {
397
+ that.$el.on('click', that.options.elements.pagination + ' a', function(e) {
398
+ e.preventDefault();
399
+
400
+ var hash = that._parseHash(this.hash),
401
+ index = that._upcomingSlide(hash - 1);
402
+
403
+ if (index !== that.current) {
404
+ that.animate(index, function() {
405
+ that.start();
406
+ });
407
+ }
408
+ });
409
+ }
410
+ };
411
+
412
+ this.css = css;
413
+ this.image = image;
414
+ this.pagination = pagination;
415
+ this.fx = fx;
416
+ this.animation = this.fx[this.options.animation];
417
+
418
+ this.$control = this.$container.wrap($control).parent('.slides-control');
419
+
420
+ that._findPositions();
421
+ that.width = that._findWidth();
422
+ that.height = that._findHeight();
423
+
424
+ this.css.children();
425
+ this.css.containers();
426
+ this.css.images();
427
+ this.pagination._setup();
428
+
429
+ return initialize();
430
+ };
431
+
432
+ Superslides.prototype = {
433
+ _findWidth: function() {
434
+ return $(this.options.inherit_width_from).width();
435
+ },
436
+ _findHeight: function() {
437
+ return $(this.options.inherit_height_from).height();
438
+ },
439
+
440
+ _findMultiplier: function() {
441
+ return this.size() === 1 ? 1 : 3;
442
+ },
443
+
444
+ _upcomingSlide: function(direction) {
445
+ if ((/next/).test(direction)) {
446
+ return this._nextInDom();
447
+
448
+ } else if ((/prev/).test(direction)) {
449
+ return this._prevInDom();
450
+
451
+ } else if ((/\d/).test(direction)) {
452
+ return +direction;
453
+
454
+ } else if (direction && (/\w/).test(direction)) {
455
+ var index = this._findSlideById(direction);
456
+ if (index >= 0) {
457
+ return index;
458
+ } else {
459
+ return 0;
460
+ }
461
+
462
+ } else {
463
+ return 0;
464
+ }
465
+ },
466
+
467
+ _findSlideById: function(id) {
468
+ return this.$container.find('#' + id).index();
469
+ },
470
+
471
+ _findPositions: function(current, thisRef) {
472
+ thisRef = thisRef || this;
473
+
474
+ if (current === undefined) {
475
+ current = -1;
476
+ }
477
+
478
+ thisRef.current = current;
479
+ thisRef.next = thisRef._nextInDom();
480
+ thisRef.prev = thisRef._prevInDom();
481
+ },
482
+
483
+ _nextInDom: function() {
484
+ var index = this.current + 1;
485
+
486
+ if (index === this.size()) {
487
+ index = 0;
488
+ }
489
+
490
+ return index;
491
+ },
492
+
493
+ _prevInDom: function() {
494
+ var index = this.current - 1;
495
+
496
+ if (index < 0) {
497
+ index = this.size() - 1;
498
+ }
499
+
500
+ return index;
501
+ },
502
+
503
+ _parseHash: function(hash) {
504
+ hash = hash || window.location.hash;
505
+ hash = hash.replace(/^#/, '');
506
+
507
+ if (hash && !isNaN(+hash)) {
508
+ hash = +hash;
509
+ }
510
+
511
+ return hash;
512
+ },
513
+
514
+ size: function() {
515
+ return this.$container.children().length;
516
+ },
517
+
518
+ destroy: function() {
519
+ return this.$el.removeData();
520
+ },
521
+
522
+ update: function() {
523
+ this.css.children();
524
+ this.css.containers();
525
+ this.css.images();
526
+
527
+ this.pagination._addItem(this.size())
528
+
529
+ this._findPositions(this.current);
530
+ this.$el.trigger('updated.slides');
531
+ },
532
+
533
+ stop: function() {
534
+ clearInterval(this.play_id);
535
+ delete this.play_id;
536
+
537
+ this.$el.trigger('stopped.slides');
538
+ },
539
+
540
+ start: function() {
541
+ var that = this;
542
+
543
+ if (that.options.hashchange) {
544
+ $(window).trigger('hashchange');
545
+ } else {
546
+ this.animate();
547
+ }
548
+
549
+ if (this.options.play) {
550
+ if (this.play_id) {
551
+ this.stop();
552
+ }
553
+
554
+ this.play_id = setInterval(function() {
555
+ that.animate();
556
+ }, this.options.play);
557
+ }
558
+
559
+ this.$el.trigger('started.slides');
560
+ },
561
+
562
+ animate: function(direction, userCallback) {
563
+ var that = this,
564
+ orientation = {};
565
+
566
+ if (this.animating) {
567
+ return;
568
+ }
569
+
570
+ this.animating = true;
571
+
572
+ if (direction === undefined) {
573
+ direction = 'next';
574
+ }
575
+
576
+ orientation.upcoming_slide = this._upcomingSlide(direction);
577
+
578
+ if (orientation.upcoming_slide >= this.size()) {
579
+ return;
580
+ }
581
+
582
+ orientation.outgoing_slide = this.current;
583
+ orientation.upcoming_position = this.width * 2;
584
+ orientation.offset = -orientation.upcoming_position;
585
+
586
+ if (direction === 'prev' || direction < orientation.outgoing_slide) {
587
+ orientation.upcoming_position = 0;
588
+ orientation.offset = 0;
589
+ }
590
+
591
+ if (that.size() > 1) {
592
+ that.pagination._setCurrent(orientation.upcoming_slide);
593
+ }
594
+
595
+ if (that.options.hashchange) {
596
+ var hash = orientation.upcoming_slide + 1,
597
+ id = that.$container.children(':eq(' + orientation.upcoming_slide + ')').attr('id');
598
+
599
+ if (id) {
600
+ window.location.hash = id;
601
+ } else {
602
+ window.location.hash = hash;
603
+ }
604
+ }
605
+
606
+ that.$el.trigger('animating.slides', [orientation]);
607
+
608
+ that.animation(orientation, function() {
609
+ that._findPositions(orientation.upcoming_slide, that);
610
+
611
+ if (typeof userCallback === 'function') {
612
+ userCallback();
613
+ }
614
+
615
+ that.animating = false;
616
+ that.$el.trigger('animated.slides');
617
+
618
+ if (!that.init) {
619
+ that.$el.trigger('init.slides');
620
+ that.init = true;
621
+ that.$container.fadeIn('fast');
622
+ }
623
+ });
624
+ }
625
+ };
626
+
627
+ // jQuery plugin definition
628
+
629
+ $.fn[plugin] = function(option, args) {
630
+ var result = [];
631
+
632
+ this.each(function() {
633
+ var $this, data, options;
634
+
635
+ $this = $(this);
636
+ data = $this.data(plugin);
637
+ options = typeof option === 'object' && option;
638
+
639
+ if (!data) {
640
+ result = $this.data(plugin, (data = new Superslides(this, options)));
641
+ }
642
+
643
+ if (typeof option === "string") {
644
+ result = data[option];
645
+ if (typeof result === 'function') {
646
+ return result = result.call(data, args);
647
+ }
648
+ }
649
+ });
650
+
651
+ return result;
652
+ };
653
+
654
+ $.fn[plugin].fx = {};
655
+
656
+ })(this, jQuery);