Best practices for parsing HTML from Wikipedia for iPhone viewing? - iphone

I am building an iPhone Wikipeida game app, that requires modifying the default Wiki HTML a little bit (mostly simplifying the page).
So far I am directly downloading the HTML output from en.wikipedia.org/wiki/Article_Foo to a python Google App Engine, and then modify its CSS and HTML structure, cache it, and finally output to iPhone. It works but I find this method quite tedious, there must be a better method?
Please note that I use App Engine not just for parsing the Wiki, but the game also requires it to keep the stores...etc, hence not a overkill. Also, I would prefer doing all the work with python on App Engine, to keep the iPhone client as thin and mobile as possible (XML on iPhone is a big no fun)
Thanks a lot.
=======
Nick mentions why not use the mobile Wiki which already optimizes for iPhone. However, the issue is that it goes down quite frequently (every couple weeks or so), also its HTML structure changes quite frequently too.

You can use the MediaWiki API to download the markup text and use some API tools for Python that could make the process/modify work easier.
Caching and outputting to iPhone is fine. I believe there is not much to simplify here.

Why not just fetch the mobile version of the page from http://en.m.wikipedia.org/? This is already formatted for mobile devices.

You can set up your own copy of the server used by m.wikimedia.org:
http://github.com/hcatlin/wikimedia-mobile
It's written in Ruby, but this shouldn't be an issue if your app just uses the HTML output.

Related

Parse BBCode in an iOS app

I'm writing an app for a forum. I can get the posts as HTML but I need to do lots of custom things with the posts as I'm not displaying it in UIWebView but natively as rich text (custom handling of [youtube][/youtube] tags). So I am instead getting the much cleaner BBCode output of the posts.
This tutorial seems to fit my needs well enough, however there are some obvious problems with it. On is that if the user types mis-formed BBC I get back bad HTML. Leaving out the closing [/b] as an example.
I am thinking I may just need to loop through the outputted HTML and track if there is an unclosed tag at the end, however I was hoping that there might be a better way to parse BBCode on the iPhone.
Also, lastly I know that is probably the wrong approach (outlined above) but every stack overflow question I've found on BBCode parsing has said not to reinvent the wheel and just use an existing PHP library. But, of course, this is an iOS app so I can't use any code written in PHP.
The question is, what is the best way to parse BBCode on iOS (and if there isn't a library or example available then is there a tutorial on writing a good quality one yourself)?

Objective C- Obtaining Page Screenshot/Image from URL

I'm writing an app that will take a csv file of URLs and should be able to display images of the URL pages that can be looked through. I'm wondering if anyone knows a way in Objective-C to get an image of a page from a URL? I know that it can be done with python and the qtWebKit, but I'm hoping that I don't have to write another script in python and that there is a way it can be done in Obj-C.
Thanks
At the bottom of this page you find the link to the source of Paparazzi!, a Mac app written in Objective-C and using WebKit that does pretty much what you're after.
Its current version's (v0.5) source is not available, but up to v0.3 it is and should be enough to get you started (or at least give you an idea).
Paparazzi! is a small utility for Mac OS X that makes screenshots of
webpages.
It’s written in Objective-C using the Cocoa API and the WebKit
framework.
It was inspired by webkit2png, a commandline tool written by Paul
Hammond in pyObjC.
http://derailer.org/paparazzi/

How do I build a wiki into an iPhone app?

I want to build an iPhone app that is really a wrapper around a wiki. Specifically, I have some static reference content that can be represented by a hyperlinked set of pages and want to build an app that will provide a nice interface over this content, including search, bookmarking, and annotating. I'm wondering what the best approach is for building something like this.
(I'm spent a fair bit of time googling for answers but pretty much every combination of search terms I can think of returns links to wikis, not links about putting a wiki into an app).
Are there libraries out there for handling wiki content (rendering, navigating links etc.)? I imagine I could just represent my content as a set of local HTML pages and point the web browser control at these but that doesn't seem right. Any ideas on how best to approach this in the iOS world?
Thanks in advance!
Try looking at TWedit, it is a wrapper for the excellent TiddlyWiki which is a single file WIKI built around JavaScript and HTML. TW is very powerful and well supported with many plugins available.

Web search in an iPhone app

I've got experience in C/C++ and am trying to now learn Objective-C for iPhone development. I have very little web design experience.
I'm trying to create an app for a friend's site that accesses a search feature from a website and then display the results in a UITableView. For example, (this isn't the site I'll be using, but...) using the stackoverflow search function and then being able to format the results (https://stackoverflow.com/search?q=iphone+web+search) in cells. I'd like to leave out the rest of the content on the page.
I've only been able to find info about reading xml or rss search results. Otherwise, I could use UIWebView, but that displays the entire site. Are there other classes that I should look into for doing this? Any help would be very, very much appreciated!
The iPhone SDK doesn't include Cocoa libraries for parsing HTML. Just NSXMLParser, which isn't a good tool for what you want to do. (It will choke on valid HTML that isn't valid XML.)
This page is probably a good first place to look. The author says, "For scraping/reading a webpage, XPath is the best choice. It is faster and less memory intensive then NSXMLParser, and very concise. My experience with it has been positive."

MediaWiki styling for iPhone

When you visit en.wikipedia.org with an iPhone you are forwarded to en.m.wikipedia.org which is formatted beautifully for the device. I have MediaWiki on my own server and I'd love to have this formatting available when I visit my site with my iPhone. Is there an easy way to enable this? I've gotten as far as www.mediawiki.org/wiki/Manual:$wgHandheldForIPhone and http://www.mediawiki.org/wiki/Extension:MobileSkin but nothing is jumping out at me.
I operate Wikiaudio and this is what I did:
Install and use this extension, to detect this skin (WP touch).
m.wikipedia.org is based on the wikimedia-mobile server, whose source code is available here:
http://github.com/hcatlin/wikimedia-mobile
It's a proxy of sorts that gets pages from Wikipedia, shuffles the contents and then serves them out formatted for mobiles, with caching to speed up things. It's written in Ruby and seems to be fairly customized for Wikipedia and the Monobook skin.
Wikipedia uses MobileFrontend.
You posted a link with complete instructions on how to deploy this into your installation of MediaWiki...
-t
I don't believe it's a skin that's on general release yet and was developed specifically for Wikipedia.