First com, added hmtl folder
BIN
fonts/Roboto-Thin.ttf
Executable file
BIN
fonts/pixelHype.ttf
Executable file
BIN
images/cal/August.png
Normal file
|
After Width: | Height: | Size: 324 KiB |
BIN
images/cal/Elias.png
Normal file
|
After Width: | Height: | Size: 290 KiB |
BIN
images/cal/Kevin.png
Normal file
|
After Width: | Height: | Size: 278 KiB |
BIN
images/day/Clear sky.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
images/day/Cloudy.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
images/day/Fair.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
images/day/Fog.png
Normal file
|
After Width: | Height: | Size: 886 B |
BIN
images/day/Heavy rain and thunder.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
images/day/Heavy rain showers and thunder.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
images/day/Heavy rain showers.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
images/day/Heavy rain.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
images/day/Heavy sleet and thunder.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
images/day/Heavy sleet showers and thunder.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
images/day/Heavy sleet showers.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
images/day/Heavy sleet.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
images/day/Heavy snow and thunder.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
images/day/Heavy snow showers and thunder.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
images/day/Heavy snow showers.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
images/day/Heavy snow.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
images/day/Light rain and thunder.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
images/day/Light rain showers and thunder.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
images/day/Light rain showers.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
images/day/Light rain.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
images/day/Light sleet and thunder.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
images/day/Light sleet showers and thunder.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
images/day/Light sleet showers.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
images/day/Light sleet.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
images/day/Light snow and thunder.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
images/day/Light snow showers and thunder.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
images/day/Light snow showers.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
images/day/Light snow.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
images/day/Partly cloudy.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
images/day/Rain and thunder.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
images/day/Rain showers and thunder.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
images/day/Rain showers.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
images/day/Rain.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
images/day/Sleet and thunder.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
images/day/Sleet showers and thunder.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
images/day/Sleet showers.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
images/day/Sleet.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
images/day/Snow and thunder.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
images/day/Snow showers and thunder.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
images/day/Snow showers.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
images/day/Snow.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
images/night/Clear sky.png
Normal file
|
After Width: | Height: | Size: 698 B |
BIN
images/night/Cloudy.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
images/night/Fair.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
images/night/Fog.png
Normal file
|
After Width: | Height: | Size: 886 B |
BIN
images/night/Heavy rain showers and thunder.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
images/night/Heavy rain showers.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
images/night/Heavy rain.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
images/night/Heavy sleet and thunder.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
images/night/Heavy sleet showers and thunder.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
images/night/Heavy sleet showers.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
images/night/Heavy sleet.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
images/night/Heavy snow and thunder.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
images/night/Heavy snow showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
images/night/Heavy snow showers.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
images/night/Heavy snow.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
images/night/Light rain and thunder.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
images/night/Light rain showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
images/night/Light rain showers.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
images/night/Light rain.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
images/night/Light sleet and thunder.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
images/night/Light sleet showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
images/night/Light sleet showers.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
images/night/Light sleet.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
images/night/Light snow and thunder.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
images/night/Light snow showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
images/night/Light snow showers.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
images/night/Light snow.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
images/night/Partly cloudy.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
images/night/Rain and thunder.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
images/night/Rain showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
images/night/Rain showers.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
images/night/Rain.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
images/night/Sleet and thunder.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
images/night/Sleet showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
images/night/Sleet showers.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
images/night/Sleet.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
images/night/Snow and thunder.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
images/night/Snow showers and thunder.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
images/night/Snow showers.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
images/night/Snow.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
95
index.php
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name=viewport content="width=device-width, initial-scale=1">
|
||||||
|
<meta http-equiv="refresh" content="300">
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
|
||||||
|
<title>RPi Home Hub v0.1</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="col-md-2 col-sm-2 text-center">
|
||||||
|
<div id="currTime"></div>
|
||||||
|
<div id="showerthoughts">
|
||||||
|
<h3>/r/showerthoughts</h3>
|
||||||
|
<p>
|
||||||
|
<?php echo file_get_contents("topSubPost.txt"); ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4 col-sm-4" id="timetables">
|
||||||
|
<h4 id="calTitle"></h4>
|
||||||
|
<img src="images/cal/Kevin.png" width="700px">
|
||||||
|
<img src="images/cal/Elias.png" width="700px">
|
||||||
|
<img src="images/cal/August.png" width="700px">
|
||||||
|
<img src="images/cal/Nora.png" width="700px">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3 col-sm-3 text-center weatherReport" style="margin-top: -40px;">
|
||||||
|
<div>
|
||||||
|
<e id="weatherImg"></e>
|
||||||
|
</div>
|
||||||
|
<p id="weatherTempValue"></p>
|
||||||
|
<p id="weatherRainfall"></p>
|
||||||
|
<p id="weatherWind"></p>
|
||||||
|
<p id="weatherWindDirection"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
|
<div class="col-md-2 col-sm-2">
|
||||||
|
<h4 id="twitterTitle">@Politiet</h4>
|
||||||
|
<div class="twitterFeed">
|
||||||
|
<a class="twitter-timeline"
|
||||||
|
data-widget-id="685044306260918273"
|
||||||
|
href="https://twitter.com/TwitterDev"
|
||||||
|
data-chrome="nofooter noborders noheader transparent"
|
||||||
|
height="300">
|
||||||
|
Tweets by @Pooooolis
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3 col-sm-3">
|
||||||
|
<h3 id="rssTitle">Siste fra ap.no</h3>
|
||||||
|
<span id="rssFeed">
|
||||||
|
<?php include 'phpFiles/apRss.php' ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3 col-sm-3">
|
||||||
|
<h3 id="rssTitle">Siste fra db.no</h3>
|
||||||
|
<span id="rssFeed">
|
||||||
|
<?php include 'phpFiles/dbRss.php' ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>window.twttr = (function(d, s, id) {
|
||||||
|
var js, fjs = d.getElementsByTagName(s)[0],
|
||||||
|
t = window.twttr || {};
|
||||||
|
if (d.getElementById(id)) return t;
|
||||||
|
js = d.createElement(s);
|
||||||
|
js.id = id;
|
||||||
|
js.src = "https://platform.twitter.com/widgets.js";
|
||||||
|
fjs.parentNode.insertBefore(js, fjs);
|
||||||
|
|
||||||
|
t._e = [];
|
||||||
|
t.ready = function(f) {
|
||||||
|
t._e.push(f);
|
||||||
|
};
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}(document, "script", "twitter-wjs"));</script>
|
||||||
|
|
||||||
|
<script src="scripts/timeDateDisplay.js"></script>
|
||||||
|
<script src="scripts/cycleTimeplaner.js"></script>
|
||||||
|
<script src="scripts/3minReload.js"></script>
|
||||||
|
<script src="scripts/addWeatherInfo.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||||
|
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
21
phpFiles/apRss.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
$rss = new DOMDocument();
|
||||||
|
$rss->load('http://www.aftenposten.no/eksport/rss-1_0/');
|
||||||
|
$feed = array();
|
||||||
|
foreach ($rss->getElementsByTagName('item') as $node) {
|
||||||
|
$item = array (
|
||||||
|
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
|
||||||
|
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
|
||||||
|
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
|
||||||
|
);
|
||||||
|
array_push($feed, $item);
|
||||||
|
}
|
||||||
|
$limit = 4;
|
||||||
|
for($x=0;$x<$limit;$x++) {
|
||||||
|
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
|
||||||
|
$link = $feed[$x]['link'];
|
||||||
|
$description = $feed[$x]['desc'];
|
||||||
|
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
|
||||||
|
echo '<p>'.$description.'</p>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
21
phpFiles/dbRss.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
$rss = new DOMDocument();
|
||||||
|
$rss->load('http://www.dagbladet.no/rss/nyheter/');
|
||||||
|
$feed = array();
|
||||||
|
foreach ($rss->getElementsByTagName('item') as $node) {
|
||||||
|
$item = array (
|
||||||
|
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
|
||||||
|
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
|
||||||
|
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
|
||||||
|
);
|
||||||
|
array_push($feed, $item);
|
||||||
|
}
|
||||||
|
$limit = 4;
|
||||||
|
for($x=0;$x<$limit;$x++) {
|
||||||
|
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
|
||||||
|
$link = $feed[$x]['link'];
|
||||||
|
$description = $feed[$x]['desc'];
|
||||||
|
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
|
||||||
|
echo '<p>'.$description.'</p>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
3
scripts/3minReload.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
setInterval(function() {
|
||||||
|
window.location.reload();
|
||||||
|
}, 300000);
|
||||||
15
scripts/addWeatherInfo.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
var weatherData = [];
|
||||||
|
$.get('weatherData.txt', function(data) {
|
||||||
|
weatherData = data.split("\n");
|
||||||
|
var elem = document.createElement("img");
|
||||||
|
elem.setAttribute("src", 'images/' + weatherData[0] + '/' + weatherData[1]);
|
||||||
|
elem.setAttribute("height", "180");
|
||||||
|
elem.setAttribute("width", "180");
|
||||||
|
elem.setAttribute("alt", weatherData[1]);
|
||||||
|
document.getElementById("weatherImg").appendChild(elem);
|
||||||
|
|
||||||
|
document.getElementById("weatherTempValue").innerHTML = "<p class='weatherTitle' style='font-size: 30px;'>Temperatur</p><p class='weatherData' style='font-size: 35px;'>" + weatherData[2] + '°</p>';
|
||||||
|
document.getElementById("weatherRainfall").innerHTML = "<p class='weatherTitle'>Nedbør</p><p class='weatherData'>" + weatherData[3] + '</p>';
|
||||||
|
document.getElementById("weatherWind").innerHTML = "<p class='weatherTitle'>Vind</p><p class='weatherData'>" + weatherData[5] + '</p>';
|
||||||
|
document.getElementById("weatherWindDirection").innerHTML = "<p class='weatherTitle'>Vind rettning</p><p class='weatherData'>" + weatherData[6] + '</p>';
|
||||||
|
});
|
||||||
28
scripts/cycleTimeplaner.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
var imageIndex = 0;
|
||||||
|
changeBanner();
|
||||||
|
function changeBanner(){
|
||||||
|
var img = [];
|
||||||
|
|
||||||
|
var timetableImages = document.getElementById('timetables');
|
||||||
|
img[0] = timetableImages.getElementsByTagName('img')[0];
|
||||||
|
img[1] = timetableImages.getElementsByTagName('img')[1];
|
||||||
|
img[2] = timetableImages.getElementsByTagName('img')[2];
|
||||||
|
|
||||||
|
for (var i = 0; i < img.length; i++) {
|
||||||
|
img[i].style.display = 'none';
|
||||||
|
}
|
||||||
|
img[imageIndex].style.display = 'block';
|
||||||
|
var src = img[imageIndex].src;
|
||||||
|
|
||||||
|
if(src.indexOf('/') >= 0) {
|
||||||
|
src = src.substring(src.lastIndexOf('/')+1);
|
||||||
|
src = src.replace('.png', ' sin timeplan');
|
||||||
|
document.getElementById('calTitle').innerHTML = src;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageIndex == img.length - 1) {
|
||||||
|
imageIndex = 0;
|
||||||
|
} else { imageIndex++; }
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval('changeBanner()', 5000);
|
||||||
31
scripts/timeDateDisplay.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
var weekday = new Array(7);
|
||||||
|
weekday[0]= "Søndag";
|
||||||
|
weekday[1] = "Mandag";
|
||||||
|
weekday[2] = "Tirsdag";
|
||||||
|
weekday[3] = "Onsdag";
|
||||||
|
weekday[4] = "Torsdag";
|
||||||
|
weekday[5] = "Fredag";
|
||||||
|
weekday[6] = "Lørdag";
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
function checkTime(i) {
|
||||||
|
return (i < 10) ? "0" + i : i;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTime() {
|
||||||
|
var today = new Date(),
|
||||||
|
h = checkTime(today.getHours()),
|
||||||
|
m = checkTime(today.getMinutes()),
|
||||||
|
s = checkTime(today.getSeconds());
|
||||||
|
dn = weekday[today.getDay()];
|
||||||
|
d = checkTime(today.getDate());
|
||||||
|
mon = checkTime(today.getMonth() + 1);
|
||||||
|
y = checkTime(today.getFullYear());
|
||||||
|
document.getElementById('currTime').innerHTML =
|
||||||
|
"<p id='time'>" + h + ":" + m + ":" + s + "</p><p>" + dn + " " + d + "." + mon + "." + y + "</p>";
|
||||||
|
t = setTimeout(function () {
|
||||||
|
startTime()
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
startTime();
|
||||||
|
})();
|
||||||
121
style.css
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
@font-face { font-family: pixelHype; src: url('fonts/Roboto-Thin.ttf');}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
font-family: pixelHype;
|
||||||
|
font-size: 24px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#time {
|
||||||
|
border: solid;
|
||||||
|
border-width: 1.5px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
padding: 3px;
|
||||||
|
font-size: 58px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#showerthoughts h3 {
|
||||||
|
border: solid;
|
||||||
|
border-width: 1.5px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
clear:both;
|
||||||
|
float:left;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#showerthoughts p {
|
||||||
|
text-align: left;
|
||||||
|
clear: both;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weatherReport {
|
||||||
|
margin-right: -30px;
|
||||||
|
margin-left: -30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weatherTitle {
|
||||||
|
width: 50%;
|
||||||
|
float: left;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weatherData {
|
||||||
|
width: 50%;
|
||||||
|
float:right;
|
||||||
|
text-align: left;
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rssTitle {
|
||||||
|
border: solid;
|
||||||
|
border-width: 1.5px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
width: 165px;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rssFeed {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#twitterTitle {
|
||||||
|
border: solid;
|
||||||
|
border-width: 1.5px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
clear:both;
|
||||||
|
float:left;
|
||||||
|
padding: 3px;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.twitterFeed {
|
||||||
|
border: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
padding-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#calTitle {
|
||||||
|
border: solid;
|
||||||
|
border-width: 1.5px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
clear:both;
|
||||||
|
float:left;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timetables {
|
||||||
|
width: 735px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
margin-left: 20px;
|
||||||
|
margin-right: 45px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
border: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-color: black;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#timetables img {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
83
topRedditPost.py
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import praw
|
||||||
|
import ephem
|
||||||
|
import requests
|
||||||
|
|
||||||
|
user_agent = ("topRedditPost pyMachine 0.1")
|
||||||
|
submissionArray = []
|
||||||
|
|
||||||
|
weatherURL = 'http://www.yr.no/place/Norway/Oslo/Oslo/Ljabru/hour_by_hour.html'
|
||||||
|
weatherURL1 = 'http://www.yr.no/place/Norway/Sør-Trøndelag/Trondheim/Utleirvegen/hour_by_hour.html'
|
||||||
|
stringId = '<meta property="og:description" content="'
|
||||||
|
|
||||||
|
def getShowerThought():
|
||||||
|
r = praw.Reddit(user_agent = user_agent)
|
||||||
|
subreddit = r.get_subreddit("showerthoughts")
|
||||||
|
|
||||||
|
for submission in subreddit.get_hot(limit = 5):
|
||||||
|
submissionArray.append(submission.title)
|
||||||
|
|
||||||
|
with open('topSubPost.txt', 'w') as outputFile:
|
||||||
|
print(submissionArray[2])
|
||||||
|
outputFile.write(str(submissionArray[2]))
|
||||||
|
|
||||||
|
def timeOfDay():
|
||||||
|
user = ephem.Observer()
|
||||||
|
user.lat = '63.394079063'
|
||||||
|
user.lon = '10.424076010'
|
||||||
|
user.elevation = 118
|
||||||
|
|
||||||
|
next_sunrise_datetime = user.next_rising(ephem.Sun()).datetime()
|
||||||
|
next_sunset_datetime = user.next_setting(ephem.Sun()).datetime()
|
||||||
|
|
||||||
|
if (next_sunset_datetime < next_sunrise_datetime):
|
||||||
|
return "day"
|
||||||
|
else:
|
||||||
|
return "night"
|
||||||
|
|
||||||
|
def getWeatherReport():
|
||||||
|
page = str(requests.get(weatherURL).content)
|
||||||
|
idIndex = page.index(stringId) + len(stringId)
|
||||||
|
forcastDescription = page[idIndex:idIndex + page[idIndex:].index('/>') - 2]
|
||||||
|
forcastList = forcastDescription.split(', ')
|
||||||
|
|
||||||
|
# Get the worded weather state
|
||||||
|
weatherState = forcastList[0]
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
weatherState.index(':')
|
||||||
|
weatherState = weatherState[weatherState.index(':') + 2:]
|
||||||
|
pass
|
||||||
|
except ValueError:
|
||||||
|
forcastList[0] = weatherState + '.png'
|
||||||
|
break
|
||||||
|
|
||||||
|
# Get the temp value
|
||||||
|
tempValue = forcastList[1]
|
||||||
|
forcastList[1] = tempValue[12:]
|
||||||
|
|
||||||
|
# Clean up any errors in the downpour
|
||||||
|
try:
|
||||||
|
forcastList[2] = forcastList[2].replace("\\xe2\\x80\\x93", "-")
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Get the wind value and append the direction of the wind
|
||||||
|
windValue = windDir = forcastList[4]
|
||||||
|
windValue = windValue[:windValue.index('from') - 1]
|
||||||
|
windDir = windDir[windDir.index('from') + len('from') + 1:]
|
||||||
|
forcastList[4] = windValue
|
||||||
|
forcastList.append(windDir)
|
||||||
|
|
||||||
|
# Get the time of day
|
||||||
|
forcastList.insert(0,timeOfDay())
|
||||||
|
|
||||||
|
print(forcastList)
|
||||||
|
with open('weatherData.txt', 'w') as outputFile:
|
||||||
|
for element in forcastList:
|
||||||
|
outputFile.write(str(element) + '\n')
|
||||||
|
|
||||||
|
def main():
|
||||||
|
getShowerThought()
|
||||||
|
getWeatherReport()
|
||||||
|
|
||||||
|
main()
|
||||||
1
topSubPost.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"No Man's Land" is a great name for a lesbian bar
|
||||||
7
weatherData.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
day
|
||||||
|
Snow.png
|
||||||
|
-6
|
||||||
|
0.4 - 0.7 mm
|
||||||
|
Gentle breeze
|
||||||
|
6 m/s
|
||||||
|
northeast
|
||||||