add portal cgi

This commit is contained in:
Neale Pickett 2011-12-23 01:10:04 -07:00
parent 3d41bb490f
commit d14ada544d
2 changed files with 90 additions and 5 deletions

89
portal.cgi Executable file
View File

@ -0,0 +1,89 @@
#! /bin/sh
weather () {
curl -s 'http://rss.wunderground.com/auto/rss_full/NM/Los_Alamos.xml?units=metric' | \
awk -F ' [-:] ' '
(/Current Conditions/) {
print "<p class=\"weather\"><a href=\"http://m.wund.com/cgi-bin/findweather/getForecast?brand=mobile&query=87544\">" $2 "</a></p>";
}
(c == 2) {
print "<p class=\"weather\">" $0 "</p>";
exit;
}
(/CDATA/) {
c++;
}'
}
section () {
echo "<h2>$1</h2>"
echo "<ul>"
curl -s "$3" | \
awk -F '>' -v RS='<' -v m=${4:-5} '
(/^item[> ]/) {
a++;
}
(/^title/) {
title=$2;
}
(a && a<m+1 && /^link/) {
l=$2;
sub(/.*url=/, "", l);
print "<li><a href=\"http://news.google.com/gwt/x?u=" l "\">" title "</a></li>";
}'
echo "</ul>"
echo "<p class=\"more\"><a href=\"$2\">more...</a></p>"
}
cat <<EOF
Content-type: text/html
<!DOCTYPE html>
<html>
<head>
<title>Houyhnhnm</title>
<style type="text/css">
h1 {
font-size: large;
font-weight: bold;
text-align: center;
}
h2 {
font-size: large;
font-weight: normal;
font-style: italic;
}
.more {
text-align: right;
}
</style>
</head>
<body>
<form action="http://m.google.com/"><input name="q" size="12"><input type="submit" value="G"></form>
EOF
weather
section "Top Stories" \
'http://news.google.com/m?pz=1&cf=all&ned=us&hl=en' \
'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&gwt=on&output=rss'
section "World News" \
'http://news.google.com/m?pz=1&cf=all&ned=us&hl=en&topic=w' \
'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=w&output=rss'
section "CSM" \
'http://www.csmonitor.com/textedition' \
'http://rss.csmonitor.com/feeds/csm'
section NPR \
'http://thin.npr.org/t.php?tid=1001' \
'http://www.npr.org/rss/rss.php?id=1001'
section "Ars Technica" \
'http://m.arstechnica.com/' \
'http://feeds.arstechnica.com/arstechnica/index?format=xml'
cat <<EOF
</body>
</html>
EOF

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- Presentation Timer 2011 Neale Pickett --> <!-- Presentation Timer 2011 Neale Pickett -->
<!-- Placed in the public domain. --> <!-- Placed in the public domain. -->
<!-- Time-stamp: "2011-11-09 18:15:56 neale" --> <!-- Time-stamp: "2011-11-09 21:33:34 neale" -->
<html> <html>
<head> <head>
<title>Presentation Timer</title> <title>Presentation Timer</title>
@ -17,10 +17,6 @@
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
var duration = 12000;
var beginning;
var itimer;
function pad(i) { function pad(i) {
if (i < 10) { if (i < 10) {
return "0" + i; return "0" + i;