Browse Source

Output data to CSV and convert to HTML

html
Kevin Mok 5 years ago
parent
commit
055e1b4ebf
Signed by: Kevin-Mok GPG Key ID: AEA75288DC135CF5
  1. 2
      .gitignore
  2. 3
      .gitmodules
  3. 1
      csi.js
  4. 14
      csv-to-html.sh
  5. 3
      dark-sky.fish
  6. 3
      dark-sky.js
  7. 1171
      github-pandoc.css
  8. 10
      index.html

2
.gitignore

@ -1,3 +1,5 @@
*.csv
*.html
*.txt
api-keys-fish.sh

3
.gitmodules

@ -0,0 +1,3 @@
[submodule "csi.js"]
path = csi.js
url = https://github.com/LexmarkWeb/csi.js

1
csi.js

@ -0,0 +1 @@
Subproject commit 2d99a233a5f51a71242b55c9092644f5c867adfb

14
csv-to-html.sh

@ -0,0 +1,14 @@
#!/bin/bash
echo "<table>" ;
print_header=true
while read INPUT ; do
if $print_header;then
# echo "<tr><th>$INPUT" | sed -e 's/:[^,]*\(,\|$\)/<\/th><th>/g'
echo "<tr><th>${INPUT//,/</th><th>}</th></tr>" ;
print_header=false
else
echo "<tr><td>${INPUT//,/</td><td>}</td></tr>" ;
fi
done < dark-sky.csv ;
echo "</table>"

3
dark-sky.fish

@ -3,4 +3,5 @@ source api-keys-fish.sh
set curl_url "https://api.darksky.net/forecast/$DARK_SKY_KEY/43.8180904,-79.3350555?exclude=minutely%2Cdaily%2Calerts%2Cflags&units=auto"
curl --request GET --url $curl_url > dark-sky.json
node dark-sky.js > dark-sky.txt
node dark-sky.js > dark-sky.csv
./csv-to-html.sh > dark-sky.html

3
dark-sky.js

@ -41,5 +41,6 @@ jsonReader('./dark-sky.json', (err, weatherInfo) => {
Math.floor(hourInfo['precipProbability'])])
}
log(table(infoList, tableConfig));
// log(table(infoList, tableConfig));
log(infoList.map(row => { return row.join() }).join('\n'))
})

1171
github-pandoc.css
File diff suppressed because it is too large
View File

10
index.html

@ -0,0 +1,10 @@
<html>
<head>
<script src="csi.js/csi.min.js"></script>
<!-- <script src="http://livejs.com/live.js" charset="utf-8"></script> -->
<link rel="stylesheet" href="github-pandoc.css">
</head>
<body>
<div data-include="dark-sky.html"></div>
</body>
</html>
Loading…
Cancel
Save