Skip to content

Instantly share code, notes, and snippets.

@burtonian
Created December 15, 2010 01:49
Show Gist options
  • Save burtonian/741513 to your computer and use it in GitHub Desktop.
Save burtonian/741513 to your computer and use it in GitHub Desktop.
ruleset a35x76 {
meta {
name "Datasource Tutorial Part 2"
description <<
Tutorial using Weather.gov Feed.
>>
author "Craig Burton"
logging on
}
dispatch {
domain "craigburton.com"
}
global {
datasource WeatherSource:XML <- "http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?format=24+hourly&numDays=1&zipCodeList="
}
rule initialize is active {
select using ".*" setting ()
pre {
InitializedDiv = <<
<div id="TempForecast">
</div>
>>;
}
notify("Temperature Forecast <br>", InitializedDiv)
with
background_color = "#7F6449" and
sticky=true and
width=350 and
opacity = 1.0 and
color = "#000000";
}
rule populate is active {
select using ".*" setting ()
pre {
WeatherSourceResult = datasource:WeatherSource("84121");
maxtemp = WeatherSourceResult.pick("$..temperature[0].value.$t");
mintemp = WeatherSourceResult.pick("$..temperature[1].value.$t");
weathermessage = <<
"<div style='
background-color:#ffc891;
margin: 3px;
font-size: 1em;
padding: 2px
color:#000000;
'>
The forecast is a high temperature of #{maxtemp} and a low of #{mintemp}
</div>";
>>;
}
{
append("#TempForecast",weathermessage);
}
}
}
@burtonian
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment