yamlandar 1.0.3 → 1.0.4
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.
- checksums.yaml +4 -4
- data/lib/views/index.erb +50 -0
- data/lib/yamlandar.rb +25 -68
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b55bc034a91ead4c564ea7380e4ab4ea56c9cb29
|
4
|
+
data.tar.gz: b971700ff34ed18f253936988ab5237a013f165f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 643ce12a1bfcd298635f290958fca0956a87d7692e54dca793a6cb114b32be6b6cce7d68345b5134712435de40632a4fdba36d903aa2817aab434f82ed480f40
|
7
|
+
data.tar.gz: eec55316de2808a2c66d494c0929126d3c09cba38f1801c5c39b327a511875454628bba3458979ef462506d33a35126bbda7ecccc33fc30d81e4e1e172761389
|
data/lib/views/index.erb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Schedule</title>
|
5
|
+
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
6
|
+
<link rel='stylesheet' type='text/css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
|
7
|
+
<style>
|
8
|
+
h2 a{
|
9
|
+
color:inherit;
|
10
|
+
}
|
11
|
+
h1 img{
|
12
|
+
max-width:50px;
|
13
|
+
margin-right:.5em;
|
14
|
+
}
|
15
|
+
</style>
|
16
|
+
<script>
|
17
|
+
function formatDate(date) {
|
18
|
+
var d = new Date(date),
|
19
|
+
month = '' + (d.getMonth() + 1),
|
20
|
+
day = '' + d.getDate(),
|
21
|
+
year = d.getFullYear();
|
22
|
+
|
23
|
+
if (month.length < 2) month = '0' + month;
|
24
|
+
if (day.length < 2) day = '0' + day;
|
25
|
+
|
26
|
+
return [year, month, day].join('-');
|
27
|
+
}
|
28
|
+
|
29
|
+
window.onload = function(){
|
30
|
+
var jump = document.querySelector('.js-jump')
|
31
|
+
jump.addEventListener('click', function(event){
|
32
|
+
event.preventDefault()
|
33
|
+
var d = formatDate(new Date())
|
34
|
+
var target = document.getElementById(d);
|
35
|
+
window.scrollTo(target.offsetLeft,target.offsetTop);
|
36
|
+
window.location.hash = formatDate(new Date())
|
37
|
+
})
|
38
|
+
}
|
39
|
+
</script>
|
40
|
+
</head>
|
41
|
+
<body>
|
42
|
+
<div class='page-header'>
|
43
|
+
<h1 class='container'><img src='https://avatars2.githubusercontent.com/u/11040407?v=3&s=200'>Schedule</h1>
|
44
|
+
</div>
|
45
|
+
<div class='container'>
|
46
|
+
<a href='#' class='js-jump'>Jump to Today</a>
|
47
|
+
</div>
|
48
|
+
<%= @html %>
|
49
|
+
</body>
|
50
|
+
</html>
|
data/lib/yamlandar.rb
CHANGED
@@ -2,100 +2,57 @@ require 'sinatra/base'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
class Yamlandar < Sinatra::Base
|
5
|
-
|
6
|
-
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>"
|
5
|
+
def self.generate
|
6
|
+
@html = ""
|
53
7
|
days = YAML.load_file('schedule.yml')
|
54
8
|
counter = 0
|
55
9
|
start = Date.parse(days[0]["start-date"])
|
56
10
|
days[1]["days"].each_with_index do |day, index|
|
57
|
-
html += "<div class='day container'>"
|
11
|
+
@html += "<div class='day container'>"
|
58
12
|
is_saturday = (start + counter).wday == 6
|
59
13
|
counter += 2 if is_saturday
|
60
14
|
today = (start + counter).strftime("%A, %m/%d")
|
61
15
|
yyyymmdd = Date.parse(today).strftime("%F")
|
62
|
-
html += "<h2 id='#{yyyymmdd}'><a href='##{yyyymmdd}'>#{today}</a></h2>"
|
16
|
+
@html += "<h2 id='#{yyyymmdd}'><a href='##{yyyymmdd}'>#{today}</a></h2>"
|
63
17
|
day["day"].each do |events|
|
64
18
|
events.each do |time, details|
|
65
19
|
title = details["title"]
|
66
20
|
urls = details["url"].split(",")
|
67
21
|
lead = details["lead"]
|
68
22
|
support = details["support"]
|
69
|
-
html += "<div class='event'>"
|
70
|
-
html += "<h3>"
|
23
|
+
@html += "<div class='event'>"
|
24
|
+
@html += "<h3>"
|
71
25
|
if urls[0] != ""
|
72
|
-
html += "<a href='#{urls[0]}'>#{title}</a>"
|
26
|
+
@html += "<a href='#{urls[0]}'>#{title}</a>"
|
73
27
|
else
|
74
|
-
html += "#{title}"
|
28
|
+
@html += "#{title}"
|
75
29
|
end
|
76
|
-
html += "</h3><small>#{time}</small>"
|
30
|
+
@html += "</h3><small>#{time}</small>"
|
77
31
|
if urls.length > 1
|
78
|
-
html += "<ul>"
|
32
|
+
@html += "<ul>"
|
79
33
|
urls.each do |url|
|
80
|
-
html += "<li><a href='#{url}'>#{url}</a></li>"
|
34
|
+
@html += "<li><a href='#{url}'>#{url}</a></li>"
|
81
35
|
end
|
82
|
-
html += "</ul>"
|
36
|
+
@html += "</ul>"
|
83
37
|
end
|
84
|
-
if lead != ""
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
"
|
38
|
+
if lead != "" || support != ""
|
39
|
+
@html += "<ul>"
|
40
|
+
@html += "<li>#{lead}</li>" unless lead == ""
|
41
|
+
@html += "<li>#{support}</li>" unless support == ""
|
42
|
+
@html += "</ul>"
|
90
43
|
end
|
91
|
-
html += "</div>"
|
44
|
+
@html += "</div>"
|
92
45
|
end
|
93
46
|
end
|
94
|
-
html += "</div><hr>"
|
47
|
+
@html += "</div><hr>"
|
95
48
|
counter += 1
|
96
49
|
end
|
97
|
-
|
50
|
+
@html
|
51
|
+
end
|
52
|
+
get '/' do
|
53
|
+
@html = Yamlandar.generate
|
54
|
+
erb :index
|
98
55
|
end
|
99
56
|
end
|
100
57
|
|
101
|
-
|
58
|
+
Yamlandar.run!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamlandar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Olds
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- bin/yamlandar
|
22
|
+
- lib/views/index.erb
|
22
23
|
- lib/yamlandar.rb
|
23
24
|
homepage: http://rubygems.org/gems/yamlandar
|
24
25
|
licenses:
|
@@ -40,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
41
|
version: '0'
|
41
42
|
requirements: []
|
42
43
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
44
|
+
rubygems_version: 2.5.1
|
44
45
|
signing_key:
|
45
46
|
specification_version: 4
|
46
47
|
summary: Hola!
|