Just drop those files into your dashing board, insert your station (choose from http://www.kvb-koeln.de/generator/index.html), done.
Created
July 25, 2013 16:58
-
-
Save bascht/6081707 to your computer and use it in GitHub Desktop.
Small KVB Monitor for dashing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dashing.NextTrains extends Dashing.Widget | |
ready: -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="logo" data-view="Image" data-image="/kvb.png"></div> | |
<table class="list-nostyle trains"> | |
<tr data-id="next_trains" data-foreach-item="next_trains"> | |
<td class="line" data-bind="item.line"></td> | |
<td class="direction" data-bind="item.direction"></td> | |
<td class="time" data-bind="item.time"></td> | |
</tr> | |
</table> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
require 'open-uri' | |
require 'nokogiri' | |
# KVB iFrame for (e.g.) Drehbrücke | |
uri = 'http://www.kvb-koeln.de/generated/?aktion=show&code=46' | |
SCHEDULER.every '15s', :first_in => 0 do |job| | |
# windows encoding. Nice one, KVB! | |
source = open(uri, 'r:windows-1252').read() | |
dom = Nokogiri::HTML.parse(source) | |
table = dom.css('body > table:nth-child(2)') | |
stations = table.css('tr') | |
next_trains = stations.collect do |station| | |
{ line: station.css("td:nth-child(1)").text().strip(), | |
direction: station.css("td:nth-child(2)").text().strip(), | |
time: station.css("td:nth-child(3)").text().strip() } | |
end | |
# Only send the next 5 trains | |
send_event('next_trains', {next_trains: next_trains[0..7]}) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.next_trains { | |
background-color: #fff; | |
.updated-at { | |
color: rgba(0, 0, 0, 0.7); | |
} | |
.logo { | |
background-color: transparent; | |
float: right; | |
padding-top: 0; | |
padding-bottom: 5px; | |
} | |
.logo img { | |
float: right; | |
} | |
table.trains { | |
background-color: #BF3030; | |
font-size: 20px; | |
border-radius: 5px; | |
-moz-border-radius: 5px; | |
} | |
table.trains td.line { | |
text-align: middle; | |
font-weight: bold; | |
background-color: #BF3030; | |
} | |
table.trains tr:nth-child(even) { | |
background-color:#A73939; | |
} | |
table.trains td.direction { | |
text-align: left; | |
padding-left: 1em; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New link to generator website:
https://www.kvb.koeln/fahrtinfo/widget-generator/