Commits

Marc Hildmann  committed a4d4fdf

Cleaned up Dragonflys Twitter search function. The css is now more generic. Updated the documentation.

  • Participants
  • Parent commits 9a936b2

Comments (0)

Files changed (4)

File example-site/dragonfly-framework/plugins-active/dragonfly_twitter.lsp

 ; !twitter functions
 ;===============================================================================
 
-;; @syntax (Dragonfly:twitter-search <keyword>)
+;; @syntax (Dragonfly:twitter-search <keyword> <max-items>)
 ;; @param <keyword> string containing the keyword for search
-;; <p>Writes the results of the search in nice speech bubbles.</p>
-;;
+;; @param <max-items> INTEGER, maximum of items you want to show
+;; <p>Writes the results of a Twitter search.</p>
 
-(define (twitter-search keyword rpp)
-	(set 'xml (get-url (string "http://search.twitter.com/search.atom?rpp="rpp"&q="keyword) ))
+(define (twitter-search keyword max-items)
+	(set 'xml (get-url (string "http://search.twitter.com/search.atom?rpp="max-items"&q="keyword) ))
 	(xml-type-tags nil nil nil nil) ; no extra tags
 	(set 'sxml (xml-parse xml 31)) ; turn on SXML options
 	(set 'entry-index (ref-all '(entry *) sxml match))
 	(when (empty? entry-index)
 		(println "No entries found")
 	)
-	(println "<div id='twitter_search_results'>")
 	(dolist (idx entry-index)
 		(set 'entry (sxml idx))
-		(println "<div class='bubble'><blockquote><p>"
-			(lookup 'title entry) 
-			"</p></blockquote><cite><strong>"
-			(lookup '(author name) entry)
-			"</strong> on " 
-			(lookup 'published entry)
-			"</cite></div>"
+		(set 'dateseconds (parse-date (lookup 'published entry) "%Y-%m-%dT%H:%M:%SZ")) ; convert string date to seconds
+		
+		(println
+			"<div class='entry'>"
+			"<div class='headline'>" (lookup 'title entry) "</div><br/>"
+			"<div class='published'>" (date dateseconds 0 "%a %d %b %Y %H:%M:%S") "</div><div class='author'>By&nbsp;" (lookup '(author name) entry) "</div><br/>"
+			"</div>"
 		)
 	)
-	(println "</div>")
 )
 
 (context MAIN)

File example-site/includes/css/screen.css

 	text-transform:uppercase;
 }
 
+
+/* Twitter  */
+
+#twitter-search {
+	margin-top:10px;
+	margin-bottom:30px;
+	font-size:10px;
+	color:#000000;
+}
+
+#twitter-search .entry {
+	margin-bottom:35px;
+}
+
+#twitter-search .headline {
+	font-size:12px;
+	font-weight:bold;
+}
+
+#twitter-search .published {
+	clear:both;
+	float:left;
+}
+
+#twitter-search .author {
+	float:left;
+	margin-left:5px;
+}
+

File example-site/includes/css/twitter.css

-
-/* twitter search definitions */
-
-#twitter_search_results {
-	width:260px;
-}
-
-#twitter_search_results p {
-	font-size:11px;
-}
-
-/* normal bubble */
-
-.bubble p { margin-top:20px; font-size: 12px; }
-.bubble cite { font-size: 12px; font-weight:bold; margin-bottom:10px;}
-
-
-div.bubble {
-	width: auto;
-	font-size: 0.75em;
-	margin-bottom: 24px;
-}
-
-div.bubble blockquote {
-	margin: 0px;
-	padding: 0px;
-	border: 1px solid #c9c2c1;
-	background-color: #fff;
-}
-
-div.bubble blockquote p {
-	margin: 10px;
-	padding: 0px;
-}
-
-div.bubble cite {
-	position: relative;
-	margin: 0px;
-	padding: 7px 0px 0px 15px;
-	top: 6px;
-	background: transparent url(/includes/images/tip.gif) no-repeat 20px 0;
-	font-style: normal;
-}

File example-site/views/dragonfly_twitter.html

 		<h1>Twitter search</h1>
 		<p class="extract">Twitter is a free social networking and micro-blogging service that enables its users to send and read messages known as tweets. Tweets are text-based posts of up to 140 characters displayed on the author's profile page and delivered to the author's subscribers who are known as followers. Senders can restrict delivery to those in their circle of friends or, by default, allow open access. (source: wikipedia.org)
 		</p>
-
-		<% (twitter-search "newlisp" "10") %>
+		
+		<h2>Example search for "newLISP"</h2>
+		<div id="twitter-search">
+			<% (twitter-search "newLISP" "10") %>
+		</div>
 		
 		<div class="line-dotted"></div>