viewer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/viewer +2 -0
  3. data/lib/viewer.rb +101 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f4dae85575e186c68ab49fa2d1f9d12bbf98a93
4
+ data.tar.gz: de0664659b0e23e185eef2d18274a8af8e1c1925
5
+ SHA512:
6
+ metadata.gz: 74989f7e531b16ed1f99e8d39742d28d4511bd29556b55d35c6fa33c97fc8a7b4c2c2e0838495ea61e523897f0ff5b029944a54dd0558238fced07141edc7896
7
+ data.tar.gz: 430c6a05236708e6eedb153ce7671b956536e70d7760741b8ce8578840ee541ee7de3535e33ff1b6d271a4fa499ea77d0b1614e76ac2aa616ad5a9bd9cc5b44b
data/bin/viewer ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'viewer'
data/lib/viewer.rb ADDED
@@ -0,0 +1,101 @@
1
+ require 'sinatra/base'
2
+ require 'yaml'
3
+
4
+ class Viewer < Sinatra::Base
5
+ get '/' do
6
+ html = "<!doctype html>
7
+ <html>
8
+ <head>
9
+ <title>Schedule</title>
10
+ <meta name='viewport' content='width=device-width, initial-scale=1'>
11
+ <link rel='stylesheet' type='text/css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
12
+ <style>
13
+ h2 a{
14
+ color:inherit;
15
+ }
16
+ h1 img{
17
+ max-width:50px;
18
+ margin-right:.5em;
19
+ }
20
+ </style>
21
+ <script>
22
+ function formatDate(date) {
23
+ var d = new Date(date),
24
+ month = '' + (d.getMonth() + 1),
25
+ day = '' + d.getDate(),
26
+ year = d.getFullYear();
27
+
28
+ if (month.length < 2) month = '0' + month;
29
+ if (day.length < 2) day = '0' + day;
30
+
31
+ return [year, month, day].join('-');
32
+ }
33
+
34
+ window.onload = function(){
35
+ var jump = document.querySelector('.js-jump')
36
+ jump.addEventListener('click', function(event){
37
+ event.preventDefault()
38
+ var d = formatDate(new Date())
39
+ var target = document.getElementById(d);
40
+ window.scrollTo(target.offsetLeft,target.offsetTop);
41
+ window.location.hash = formatDate(new Date())
42
+ })
43
+ }
44
+ </script>
45
+ </head>
46
+ <body>
47
+ <div class='page-header'>
48
+ <h1 class='container'><img src='https://avatars2.githubusercontent.com/u/11040407?v=3&s=200'>Schedule</h1>
49
+ </div>
50
+ <div class='container'>
51
+ <a href='#' class='js-jump'>Jump to Today</a>
52
+ </div>"
53
+ days = YAML.load_file('schedule.yml') # needs to come from cli
54
+ counter = 0
55
+ start = Date.parse(days[0]["start-date"])
56
+ days[1]["days"].each_with_index do |day, index|
57
+ html += "<div class='day container'>"
58
+ is_saturday = (start + counter).wday == 6
59
+ counter += 2 if is_saturday
60
+ today = (start + counter).strftime("%A, %m/%d")
61
+ yyyymmdd = Date.parse(today).strftime("%F")
62
+ html += "<h2 id='#{yyyymmdd}'><a href='##{yyyymmdd}'>#{today}</a></h2>"
63
+ day["day"].each do |events|
64
+ events.each do |time, details|
65
+ title = details["title"]
66
+ urls = details["url"].split(",")
67
+ lead = details["lead"]
68
+ support = details["support"]
69
+ html += "<div class='event'>"
70
+ html += "<h3>"
71
+ if urls[0] != ""
72
+ html += "<a href='#{urls[0]}'>#{title}</a>"
73
+ else
74
+ html += "#{title}"
75
+ end
76
+ html += "</h3><small>#{time}</small>"
77
+ if urls.length > 1
78
+ html += "<ul>"
79
+ urls.each do |url|
80
+ html += "<li><a href='#{url}'>#{url}</a></li>"
81
+ end
82
+ html += "</ul>"
83
+ end
84
+ if lead != "" && support != ""
85
+ html += "<ul>
86
+ <li>#{lead}</li>
87
+ <li>#{support}</li>
88
+ </ul>
89
+ "
90
+ end
91
+ html += "</div>"
92
+ end
93
+ end
94
+ html += "</div><hr>"
95
+ counter += 1
96
+ end
97
+ html
98
+ end
99
+ end
100
+
101
+ Viewer.run!
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: viewer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Quaranto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple hello world gem
14
+ email: nick@quaran.to
15
+ executables:
16
+ - viewer
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/viewer
21
+ - lib/viewer.rb
22
+ homepage: http://rubygems.org/gems/viewer
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.8
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Hola!
46
+ test_files: []