Created
December 15, 2010 01:49
-
-
Save burtonian/741513 to your computer and use it in GitHub Desktop.
This file contains 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
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tutorial found at: http://www.craigburton.com/?p=3122