Skip to content

Commit 004fe4b

Browse files
committed
adding coreylib xml parser
1 parent 1320e51 commit 004fe4b

6 files changed

Lines changed: 140 additions & 20 deletions

File tree

configure.php

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,12 @@
4242
<form>
4343
4444
<section id="source">
45+
<!-- twitter -->
4546
<div class="row">
4647
<div class="span3"><h1>Source</h1></div>
4748
<div class="span5">
4849
<h3><img src="img/logos/twitter.png" class="sourceLogo"/>Twitter</h3>
4950
<p>Enter as many usernames, hashtags and/or words as you'd like, separated by spaces. Flipstatus will search Twitter and return the most recent results.</p>
50-
<h5>Coming Soon:</h5>
51-
<img src="img/logos/rss.png" class="sourceLogo" alt="rss"/>
52-
<img src="img/logos/sms.png" class="sourceLogo" alt="sms"/>
53-
<img src="img/logos/facebook.png" class="sourceLogo" alt="facebook"/>
54-
<img src="img/logos/yelp.png" class="sourceLogo" alt="yelp"/>
55-
<img src="img/logos/foursquare.png" class="sourceLogo" alt="foursquare"/>
56-
<img src="img/logos/mail.png" class="sourceLogo" alt="mail"/>
5751
</div>
5852
<div class="span8">
5953
<fieldset>
@@ -67,6 +61,37 @@
6761
</fieldset>
6862
</div>
6963
</div>
64+
<!-- rss -->
65+
<div class="row">
66+
<div class="span3">&nbsp;</div>
67+
<div class="span5">
68+
<h3><img src="img/logos/rss.png" class="sourceLogo"/>RSS</h3>
69+
<p>Enter an RSS Feed URL:</p>
70+
</div>
71+
<div class="span8">
72+
<fieldset>
73+
<input class="span8" type="text" name="rss" />
74+
<span class="help-block">
75+
Example: ""
76+
</span>
77+
<br/>
78+
<input type="checkbox" name="rss_summary" />
79+
<span>Include Summary</span>
80+
</fieldset>
81+
</div>
82+
</div>
83+
<!-- Coming Soon -->
84+
<div class="row">
85+
<div class="span3">&nbsp;</div>
86+
<div class="span5">
87+
<h5>Coming Soon:</h5>
88+
<img src="img/logos/sms.png" class="sourceLogo" alt="sms"/>
89+
<img src="img/logos/facebook.png" class="sourceLogo" alt="facebook"/>
90+
<img src="img/logos/yelp.png" class="sourceLogo" alt="yelp"/>
91+
<img src="img/logos/foursquare.png" class="sourceLogo" alt="foursquare"/>
92+
<img src="img/logos/mail.png" class="sourceLogo" alt="mail"/>
93+
</div>
94+
</div>
7095
</section>
7196
7297
<section id="size" style="margin-top:40px;">
@@ -195,29 +220,40 @@
195220
$("#about, #contact").modal({"backdrop":true,"keyboard":true});
196221
197222
$("form").submit(function(){
198-
var queryStr = "",
199-
sep = "";
200-
// split twitter input at spaces
201-
var tWords = $("input[name=twitter]").val().split(" ");
223+
224+
// TWITTER
225+
var tStr = "",
226+
tWords = $("input[name=twitter]").val().split(" "),
227+
tSep = "";
228+
// split input at spaces
202229
for(var i=0;i<tWords.length;i++){
203230
var text = tWords[i];
204231
if(text.charAt(0) === "@"){
205232
text = text.substr(1);
206-
queryStr += sep + "from:"+text+" OR to:"+text;
233+
tStr += tSep + "from:"+text+" OR to:"+text;
207234
// pick up the "mentions" checkbox
208235
if($("input[name=noMention]:checked").length === 0){
209-
queryStr += " OR @"+text;
236+
tStr += " OR @"+text;
210237
}
211238
} else {
212-
queryStr += sep + text;
239+
tStr += tSep + text;
213240
}
214-
sep = " OR ";
241+
tSep = " OR ";
215242
}
243+
var twitter = encodeURIComponent(tStr);
244+
245+
// RSS
246+
var rssUrl = $("input[name=rss]").val(),
247+
rss = encodeURIComponent(rssUrl);
248+
216249
var size = $("input[name=size]:checked").val();
217250
// encodeURIComponent to escape hashes
218251
var title = encodeURIComponent($("input[name=title]").val());
219-
var q = encodeURIComponent(queryStr);
220-
url = "tweetboard.php?q="+q+"&size="+size+"&title="+title;
252+
url = "statusboard.php?"
253+
+ "twitter=" + twitter
254+
+ "&rss=" + rss
255+
+ "&size=" + size
256+
+ "&title=" + title;
221257
window.location = url;
222258
return false;
223259
});

plugins/rss/coreylib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8f255383b7b2f3c6b4f708f9f7444b9a42befd72

plugins/rss/custom.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
sf.plugins.rss = {
3+
4+
dataType: 'json',
5+
6+
// get tweets
7+
url: function(options){
8+
var base_url = "plugins/rss/parse.php";
9+
// pick up the query from the page URL
10+
var urlString = sf.util.getUrlParam("rss");
11+
console.log("rss:",urlString)
12+
return base_url + "?url=" + urlString;
13+
},
14+
15+
formatData: function(response){
16+
var newResponse = [];
17+
for(var i=0;i<response.results.length;i++){
18+
// console.log("Tweet Data:",response.results[i]);
19+
//
20+
21+
// Get the author
22+
var from_user = response.results[i].from_user;
23+
24+
// Set the status based on the age
25+
var status = "1";
26+
var now = new Date();
27+
var created = new Date(response.results[i].created_at);
28+
var age = Math.round((now - created)/(1000 * 60)); // minutes
29+
if(age < 60){
30+
status = "0";
31+
}
32+
console.log(age < 60)
33+
34+
// set hours and minutes
35+
var hrs = created.getHours();
36+
if(hrs < 10){
37+
hrs = "0"+hrs;
38+
}
39+
var mins = created.getMinutes();
40+
if(mins < 10){
41+
mins = "0"+mins;
42+
}
43+
timestamp = hrs.toString() + mins.toString();
44+
45+
// Split the tweet text into rows and add each row to newResponse[]
46+
// with a timestamp only on the first one
47+
var text = response.results[i].from_user+": "+response.results[i].text;
48+
var rows = sf.util.splitString(text, sf.options.numChars);
49+
for(var j=0;j<rows.length;j++){
50+
var row = {
51+
"timestamp":timestamp,
52+
"text":rows[j],
53+
"status":status
54+
};
55+
timestamp = "";
56+
from_user = "";
57+
status = "";
58+
newResponse.push(row);
59+
}
60+
// Add a blank row between tweets
61+
var blankRow = {
62+
"timestamp":"",
63+
"text":"",
64+
"status":""
65+
}
66+
newResponse.push(blankRow);
67+
}
68+
return newResponse;
69+
}
70+
71+
};

plugins/rss/parse.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
require_once('coreylib/coreylib.php');
3+
// your code goes here:
4+
// $feed = $_GET["url"];
5+
$feed = new clApi('http://feeds.feedburner.com/github');
6+
if($feed = $api -> parse()){
7+
$feed -> inspect();
8+
} else {
9+
echo "no feed found";
10+
}
11+
12+
?>

plugins/twitter/custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sf.plugins.twitter = {
77
url: function(options){
88
var base_url = "http://search.twitter.com/search.json";
99
// pick up the query from the page URL
10-
var searchString = sf.util.getUrlParam("q");
10+
var searchString = sf.util.getUrlParam("twitter");
1111
// optionally limit results
1212
var maxResults = options.maxResults ? options.maxResults : options.numRows;
1313
return base_url + "?q=" + searchString + "&rpp=" + maxResults;

tweetboard.php renamed to statusboard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
<!-- ============================================ -->
9898
<!-- CUSTOM JS FOR THIS BOARD -->
99-
<script type="text/javascript" src="plugins/twitter/custom.js"></script>
99+
<script type="text/javascript" src="plugins/rss/custom.js"></script>
100100
<script type="text/javascript">
101101

102102
$("body").click(function(){
@@ -111,7 +111,7 @@
111111
// CUSTOMIZATION OPTIONS
112112
sf.options = {
113113
// REQUIRED
114-
"plugin": "twitter", // board type
114+
"plugin": "rss", // board type
115115
"container": $("#board"), // where to put the board
116116
"template": $("#row_template"), // row template
117117
"numRows": <?php echo $numRows ?>, // number of rows

0 commit comments

Comments
 (0)