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,89 @@
1
+ function launchEmailClient(subject, body) {
2
+ var uri = 'mailto:',
3
+ hasSubject = typeof subject != 'undefined',
4
+ hasBody = typeof body != 'undefined';
5
+ uri += hasSubject ? ('?subject=' + subject) : '';
6
+ uri += hasBody ? ((hasSubject ? '&' : '?') + 'body=' + body) : '';
7
+
8
+ launchUri(uri);
9
+ }
10
+
11
+ function launchUri(uri) {
12
+ var res, parent, popup, iframe, browser;
13
+
14
+ function createHiddenIframe(parent) {
15
+ var iframe;
16
+ if (!parent) parent = document.body;
17
+ iframe = document.createElement('iframe');
18
+ iframe.style.display = 'none';
19
+ parent.appendChild(iframe);
20
+ return iframe;
21
+ }
22
+
23
+ function removeHiddenIframe(parent) {
24
+ if (!iframe) return;
25
+ if (!parent) parent = document.body;
26
+ parent.removeChild(iframe);
27
+ iframe = null;
28
+ }
29
+
30
+ browser = {
31
+ isChrome: false,
32
+ isSafari: false,
33
+ isFirefox: false,
34
+ isIE: false
35
+ };
36
+
37
+ if (window.chrome && !navigator.userAgent.match(/Opera|OPR\//)) {
38
+ browser.isChrome = true;
39
+ } else if (typeof InstallTrigger !== 'undefined') {
40
+ browser.isFirefox = true;
41
+ } else if (navigator.userAgent.match(/Safari\//)) {
42
+ browser.isSafari = true;
43
+ } else if ('ActiveXObject' in window) {
44
+ browser.isIE = true;
45
+ }
46
+
47
+ if (navigator.msLaunchUri) {
48
+ // Proprietary msLaunchUri method (IE 10+ on Windows 8+)
49
+ navigator.msLaunchUri(uri, function() {}, function() {});
50
+ } else if (browser.isChrome || browser.isSafari) {
51
+ window.location.href = uri;
52
+ } else if (browser.isFirefox) {
53
+ // Catch NS_ERROR_UNKNOWN_PROTOCOL exception (Firefox)
54
+ iframe = createHiddenIframe();
55
+ try {
56
+ // if we're still allowed to change the iframe's location, the protocol is registered
57
+ iframe.contentWindow.location.href = uri;
58
+ } catch (e) {} finally {
59
+ removeHiddenIframe();
60
+ }
61
+ } else if (browser.isIE) {
62
+ // Open popup, change location, check wether we can access the location after the change (IE on Windows < 8)
63
+ popup = window.open('', 'launcher', 'width=0,height=0');
64
+ popup.location.href = uri;
65
+ try {
66
+ // Try to change the popup's location - if it fails, the protocol isn't registered
67
+ // and we'll end up in the `catch` block.
68
+ popup.location.href = 'about:blank';
69
+ // The user will be shown a modal dialog to allow the external application. While
70
+ // this dialog is open, we cannot close the popup, so we try again and again until
71
+ // we succeed.
72
+ timer = window.setInterval(function() {
73
+ popup.close();
74
+ if (popup.closed) window.clearInterval(timer);
75
+ }, 500);
76
+ } catch (e) {
77
+ // Regain access to the popup in order to close it.
78
+ popup = window.open('about:blank', 'launcher');
79
+ popup.close();
80
+ }
81
+ } else {
82
+ // No hack we can use, just open the URL in an hidden iframe
83
+ iframe = createHiddenIframe();
84
+ iframe.contentWindow.location.href = uri;
85
+ window.setTimeout(function() {
86
+ removeHiddenIframe(parent);
87
+ }, 500);
88
+ }
89
+ }