<?xml version="1.0" encoding="UTF-8"?>
<app>
  <actioncardurl>http://appresource.s3.amazonaws.com/appdir/a16x47/UtahPolitics.crd</actioncardurl>
  <active type="boolean">true</active>
  <appid>a16x47</appid>
  <author>Phil Windley</author>
  <created-at type="datetime">2010-01-13T00:10:41Z</created-at>
  <description>Let's members of UtahPolitics.org to see each other's Tweets on selected sites.     </description>
  <hasactioncard type="boolean">true</hasactioncard>
  <hasbookmarklet type="boolean">true</hasbookmarklet>
  <hassource type="boolean">true</hassource>
  <id type="integer">28</id>
  <imageurl>http://appresource.s3.amazonaws.com/appdir/a16x47/appimage.jpg</imageurl>
  <name>UtahPolitics</name>
  <source>ruleset a16x47 {
    meta {
        name "UtahPolitics"
        author "Phil Windley"
        description &lt;&lt;
Let's members of UtahPolitics.org to see each other's Tweets on selected sites.             &gt;&gt;
        logging on    }
    dispatch {
        domain "www.sltrib.com"
        domain "www.deseretnews.com"
        domain "le.utah.gov"
        domain "www.heraldextra.com"
    }
    global {
        datasource searchBackTweets &lt;- "http://backtweets.com/search.json?key=23783944b830fb6986bc&amp;q=" cachable for 5 minutes
;        url = page:env("caller");        domain = url.replace(/http:\/\/([A-Za-z0-9.-]+)\/.*/, "$1");        backTweetsData = datasource:searchBackTweets(url);        results = backTweetsData.pick("$..totalresults");        datasource urly &lt;- "http://ur.ly/new.json" cachable
;        css  &lt;&lt;.kGrowl-notification a { color: #0099CC; }    .kGrowl-notification { color: #737373; }    .KOBJ_tweetItems { margin: 5px; border-top: 1px dashed #D2DADA; padding-bottom: 1px; }    #KOBJ_tweetList { list-style-position:outside; margin: 0; padding: 0; list-style-type: none; list-style-image: none; }    .KOBJ_tweetDiv { height: 300px; overflow-x: auto; overflow-y: auto; background-color: #222; opacity: 0.8; }    .KOBJ_tweetDiv p { background: none; color: #FFFFFF; font-family:arial,sans-serif; font-size: 9pt; }    .KOBJ_tweetDiv a { color: #0099CC; }    .KOBJ_tweetDiv li { list-style-position; list-style-type: none; padding-left: none }    #KOBJ_tweetLogo { background-image: url("http:\/\/frag.kobj.net/kntx/images/header_sweetter.jpg"); height: 102px; display: block; margin-bottom: 5px; }    .KOBJ_tweetedImage { float: left; margin-right: 5px; margin-top: 5px; }    .KOBJ_tweetedUser {  }    .KOBJ_tweetedTweet {  }    &gt;&gt;
;    }
    rule tweet_init is active {
        select using ".*" setting ()

        pre {
            header = &lt;&lt; 
&lt;div id="KOBJ_tweetLoading" style="text-align: center;"&gt;  &lt;a href='http:\/\/www.utahpolitics.org'&gt;&lt;img src="http:\/\/utahpolitics.org/assets/images/up_header_250x89.png" alt="UP Graphic" border="0" style="margin: 0 auto; "/&gt;&lt;/a&gt;  &lt;/div&gt;  
 &gt;&gt;;
            message = &lt;&lt; 
&lt;div class="KOBJ_tweetDiv" style="background-color: #222222;"&gt;    &lt;ul id="KOBJ_tweetList" style="background-color: #222222;"&gt;    &lt;/ul&gt;  &lt;/div&gt;   
 &gt;&gt;;
        }
        if results &gt; 0
        then
            notify(header, message)
            with
                    sticky = true and
                    width = "250px" and
                    opacity = 1;
        
        notfired {
            last;
        }
    }
    rule show_tweets is active {
        select using ".*" setting ()
            foreach backTweetsData.pick("$..tweets") setting (tweet)

        pre {
            tweetId = tweet.pick("$..tweet_id");
            i = tweet.pick("$..tweet_profile_image_url");
            tweetUser = tweet.pick("$..tweet_from_user");
            tweetText = tweet.pick("$..tweet_text");
            tweetTime = tweet.pick("$..tweet_created_at");
            tweetHTML = &lt;&lt; 
&lt;li class="KOBJ_tweetItems"&gt;  &lt;p&gt;  &lt;span class="KOBJ_tweetedImage"&gt;  &lt;a href="http://www.twitter.com/#{tweetUser}"&gt;    &lt;img width="48px" height="48px" border="none" src="#{i}" /&gt;  &lt;/a&gt;  &lt;/span&gt;  &lt;span class="KOBJ_tweetedUser"&gt;  &lt;a href="http://www.twitter.com/#{tweetUser}"&gt;#{tweetUser}&lt;/a&gt;  &lt;/span&gt;  &lt;span class="KOBJ_tweetedTweet"&gt;  #{tweetText}  &lt;span style="font-size:8pt; font-style:italic; margin-top:5px;"&gt;  (&lt;a href="http://twitter.com/#{tweetUser}/statuses/#{tweetId}"&gt;#{tweetTime}&lt;/a&gt;)  &lt;/span&gt;  &lt;/p&gt;  &lt;/span&gt;  &lt;/li&gt;   
 &gt;&gt;;
        }
        if tweetUser neq "utahpolitics"
        then
            append("#KOBJ_tweetList", tweetHTML);
        
    }
    rule finalize is active {
        select using ".*" setting ()

        pre {
            url_info = datasource:urly({"href" : page:env("caller")});
            url = "http://ur.ly/" + url_info.pick("$.code");
            tweetHTML = &lt;&lt; 
&lt;li class="KOBJ_tweetItems"&gt;  &lt;a href="javascript:(function(){f='http://twitter.com/home?status='+encodeURIComponent(document.title+'%20#{url}%20');a=function(){if(!window.open(f,'_blank'))location.href=f};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"&gt;Tweet this page&lt;/a&gt;  &lt;/li&gt;   
 &gt;&gt;;
        }
        if tweetUser neq "utahpolitics"
        then
            append("#KOBJ_tweetList", tweetHTML);
        
    }

}
</source>
  <updated-at type="datetime">2010-01-13T04:22:09Z</updated-at>
</app>
