Intermediate: RSS Feeds

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Intermediate: RSS Feeds

Post by Mag » Sat Sep 21, 2013 3:06 pm

I've spent the last two day trying to get the stack of this lesson to work without any luck...

http://lessons.runrev.com/s/lessons/m/4 ... -rss-feeds

:cry:

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Intermediate: RSS Feeds

Post by BvG » Sun Sep 22, 2013 10:21 pm

What exactly does not work?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Mon Sep 23, 2013 2:22 pm

Hi BvG,

the problem was that the RSS URL used on the tutorial, didn't work, at least here. So I changed the url and now it works.

I'm studing the stack provided with the tutorial but (in my opinion) it's a bit complicated. I would like to find a beginner guide instead of intermediate one :lol:

This is the only steps I got. Don't know how to proceed to get the rss contents

Code: Select all

on mouseUp
   put url "http://feeds.pinboard.in/rss/u:guardiantech/" into pageContent
   put "RDF" into sItemPath
   put revCreateXMLTree(pageContent, false, true, false) into tTreeID
   put revXMLChildNames(tTreeID,sItemPath, return, "item", true) into tItems -- "item[1]&return&item[2]..."
   
   repeat with x = 1 to (the number of lines in tItems) -- tItems
      
      put revXMLNodeContents(tTreeID, sItemPath & "/title")
      
      ...
   end repeat
end mouseUp

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Mon Sep 23, 2013 10:23 pm

Ok, solved, I merged some data from liveCode XML lesson and RSS lesson plus some stack examples posted in this forum. The main problem I had was to create the path of the child nodes. :lol:

Now I saw that the stack of the RSS lesson fails to display accents in the field. It uses this code:

Code: Select all

command createRssArticles pItems
   local tHtml, tItem
   
   ##  Loops through all the items contained in the RSS feed, adding their data to the html
   ##  text which will be displayed within the field on the stack.
   repeat for each line tItemName in pItems
      put itemGet(tItemName) into tItem
      put "<p><a href=" & quote & tItem["link"] & quote & ">" & tItem["title"] & "</a></p>" after tHtml
      put "<p>" & tItem["pubDate"] & "</p><p></p>" after tHtml
   end repeat
   
   if tHtml is not empty then
      set the htmlText of field "Articles" to tHtml
   end if
end createRssArticles

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Fri Sep 27, 2013 12:32 am

Anyone? :(

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Intermediate: RSS Feeds

Post by Simon » Fri Sep 27, 2013 12:49 am

Hi Mag,
What does tHtml look like?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Fri Sep 27, 2013 1:06 am

Hi Simon. Here is a part of it. It shows the same accent problems as the field where I display the text it seems to me (see the last p).

Code: Select all

<p><a href="http://gigaom.com/2013/09/26/seriously-samsung-sorry-european-roamers-but-the-new-galaxy-note-3-is-region-locked/">Seriously, Samsung? Sorry, roamers, but the new Galaxy Note 3 is region-locked >> GigaOm</a></p><p>David Meyer: <blockquote>I really thought the days of region-locking were dying with the DVD, but it seems I was wrong – Samsung has decided to revive the odious practice with its Galaxy Note 3 smartphone.<p>

Yes, if you buy an unlocked Note 3 in Europe and travel to, say, the U.S., you will not be able to use a local SIM card.<p>

UPDATE (5.50am PT): Looks like the North American version is locked to that region too. I’ve taken the word “European” out of the headline to reflect that. I also edited the piece generally to reflect that it’s not just a European thing.</blockquote>

How can a handset maker benefit from doing this?</p><p></p><p><a href="http://www.digitimes.com/news/a20130925PD203.html">Taiwan market: HTC may lose top-rank title due for lack of new flagship models >> Digitimes</a></p><p><blockquote>HTC may lose its top-rank title in Taiwan's smartphone market in the fourth quarter of 2013 as it has failed to deliver a new flagship model for the second half of the year in the local market, while rivals including Samsung Electronics, Sony Mobile Communications and LG Electronics have all released new models, according to sources in the local retail channels.<p>

The new flagship models being released recently in the local market include the Galaxy Note 3 from Samsung, the Xperia Z1 from Sony Mobile and the Optimus G2 from LG. All three models are targeting the high-end segment with a price tag of over NT$20,000 (US$676), noted the sources.<p>

The competition will become keener at the end of 2013 when Apple begins to market its iPhone 5s and iPhone 5c smartphones in the local market, the sources added.</blockquote>

Taiwan is HTC's home market. Samsung Taiwan reckons it can sell 1m Galaxy Notes there by the end of 2013. HTC is now under huge stress.</p><p></p><p><a href="http://wmpoweruser.com/nokia-windows-phones-win-pcmags-end-user-business-choice-award-2013/">Nokia Windows Phones win PCMag’s End-user Business Choice Award 2013 >> WMPoweruser</a></p><p><blockquote>Windows Phones have always scored well when it comes to customer satisfaction, and a new survey published by PCMag finds this satisfaction also carries over into the work place, with business users who use Windows Phones as their primary work phone being much more satisfied with them than Galaxy, iPhone or Blackberry users.</blockquote>

These are scores from end users. No indication of sample sizes (though the blanks for "Technical Support" and "Repairs" indicate fewer than 50 responses - so this might be a small sample). It's remarkable how badly the BlackBerry scores in what should be its stronghold: it's last in nearly everything, and doesn't lead in email. 
</p><p></p><p><a href="http://krebsonsecurity.com/2013/09/data-broker-giants-hacked-by-id-theft-service/">Data broker giants hacked by ID theft service >> Krebs on Security</a></p><p><blockquote>Until very recently, the source of the data sold by SSNDOB has remained a mystery. That mystery began to unravel in March 2013, when teenage hackers allegedly associated with the hacktivist group UGNazi showed just how deeply the service’s access went. The young hackers used SSNDOB to collect data for exposed.su, a Web site that listed the SSNs, birthdays, phone numbers, current and previous addresses for dozens of top celebrities — such as performers Beyonce, Kayne West and Jay Z — as well as prominent public figures, including First Lady Michelle Obama, CIA Director John Brennan, and then-FBI Director Robert Mueller.</blockquote>

Uh-oh.</p><p></p><p><a href="http://www.bbc.co.uk/news/uk-scotland-glasgow-west-23331456">Google Maps wipes out Scottish island of Jura >> BBC News</a></p><p>July 2013:<blockquote>The internet giant Google has said sorry after the Scottish island of Jura disappeared from its online maps.<p>

Internet users noticed on Tuesday that the island, off the west coast of the Kintyre Peninsula, was visible on the satellite view but not the maps view.</blockquote></p><p></p><p><a href="http://www.alaskadispatch.com/article/20130924/iphone-map-app-directs-fairbanks-drivers-airport-taxiway">iPhone map app directs Fairbanks drivers onto airport taxiway >> Alaska Dispatch</a></p><p>September 2013: <blockquote>At least twice in the past three weeks, drivers from out of town who followed the directions on their iPhones not only reached airport property, but also crossed the runway and drove to the airport ramp side of the passenger terminal.<p>

“These folks drove past several signs. They even drove past a gate. None of that cued them that they did something inappropriate,” said Melissa Osborn, chief of operations at the Fairbanks airport.</blockquote></p><p></p><p><a href="http://www.technologyreview.com/news/519421/the-first-carbon-nanotube-computer/">The first carbon nanotube computer >> MIT Technology Review</a></p><p><blockquote>For the first time, researchers have built a computer whose central processor is based entirely on carbon nanotubes, an incredibly tiny form carbon with remarkable material and electronic properties. The computer is slow and simple, but its creators, a group of Stanford University engineers, say it shows that carbon nanotube electronics are a viable potential replacement for silicon when it reaches its limits in ever-smaller electronic circuits.<p>

...

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Fri Sep 27, 2013 1:25 am

Here is the page content (just a part to see that the text already has problems, see the last line, near Samsung):
</channel><item rdf:about="http://gigaom.com/2013/09/26/seriously- ... on-locked/">
<title>Seriously, Samsung? Sorry, roamers, but the new Galaxy Note 3 is region-locked >> GigaOm</title>
<dc:date>2013-09-26T13:07:45+00:00</dc:date>
<link>http://gigaom.com/2013/09/26/seriously- ... ked/</link>
<dc:creator>guardiantech</dc:creator><description><![CDATA[David Meyer: <blockquote>I really thought the days of region-locking were dying with the DVD, but it seems I was wrong – Samsung has decided to revive the odious practice with its Galaxy Note 3 smartphone.<p>

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Intermediate: RSS Feeds

Post by Simon » Fri Sep 27, 2013 1:29 am

Hi Mag,
Does your RSS feed say
<?xml version="1.0" encoding="UTF-8"?>

Looking at the http://www.alaskadispatch.com link I see curly quotes (i.e “These) in the article (not straight) which I believe are not UTF-8.
yeah and in the Samsung article there are the curly's as well (Dang that news sucks... regionally locked???) also some other characters.

Not sure what to tell you. I'm not great on UTF and unicode.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Intermediate: RSS Feeds

Post by Simon » Fri Sep 27, 2013 1:30 am

That "–" is a weird hyphen.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Fri Sep 27, 2013 9:13 pm

Thanks Simon, these clues are very useful!

And now the milion dollar question: what is the best way to display this on iOS?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Intermediate: RSS Feeds

Post by Simon » Fri Sep 27, 2013 9:26 pm

I don't see that there should be a problem running this on iOS. All the revXMl... functions are cross platform.

Are you going to:
replace "“" with quote in tHtml
?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Intermediate: RSS Feeds

Post by Mag » Sat Sep 28, 2013 12:32 pm

Simon wrote:I don't see that there should be a problem running this on iOS. All the revXMl... functions are cross platform.

Are you going to:
replace "“" with quote in tHtml
?

Simon
Hi Simon,

I was searching the best way to display the text in iOS, at the end I decided to use a standard field (with non scroll bars obviously), putting this code to let user to scroll (adapted from a post I found online):

Code: Select all

local clickV

on mouseDown
   put the mouseV into clickV
end mouseDown

on mouseMove deltaH,deltaV
   if clickV is not empty then
      set the vScroll of me to the vScroll of me + (clickV - deltaV)
      put deltaV into clickV
   end if
end mouseMove

on mouseUp
  put empty into clickV
end mouseUp

on mouseRelease
  mouseUp
end mouseRelease

on linkClicked pLink
   launch url pLink 
end linkClicked
One problem is that I don't have the bounce effect...

I like the workaround of replacing "‚Äú" with quote, do you think could be a good way to proceed? The problem is that there are lot of strings to replace and maybe it needs to have a list of them... (Äôs = – etc etc)

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Intermediate: RSS Feeds

Post by Simon » Sat Sep 28, 2013 9:10 pm

Hi Mag,
Actually for bounce I'd use mobileControlCreate "scroller", that will give you a native scroller.
http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field

As for the Replace, I really don't know how many you will come across. I guess you just start making a list.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply