Apple’s Pastry Kit | iPhone Javascript Toolkit - by Benjamin Spiegel
Posted: December 21st, 2009 by Benjamin SpiegelANOTHER UPDATE: Thanks to a anonymous Sponsor, we got now the full Assets as well DOWNLOAD THE ENTIRE ASSETS COLLECTION
John Gruber has found a javascript library for iPhone webApps, from nobody other than Apple itself. This interesting library, called PastryKit, seems to have been pretty much undiscovered since google does not have much on it. In likes of others, Apple’s javascript library provides support for that app native-feel. (That is the main objective anyway; some look & feel emulators are pretty “good”, while others get stuck in the past).
Ok, so how do we use it, or get our hands on it?
Visit http://help.apple.com/iphone/3/mobile/ from your iPhone or iPod Touch. This is the official Apple guide using PastryKit.
Now with this page in regular Safari (on your Mac/PC), open the Develop Menu (if it’s not there, enable it in Preference|Advanced). Choose User Agent > Mobile Safari 3.x . And now you can see it in your Browser like an iPhone would. From Develop Menu, Web Inspector will let you view the script.
The HTML includes PastryKit as follows:
<!-- PastryKit --> <link rel="stylesheet" href="http://help.apple.com/iphone/3/mobile/dist/PastryKit-ug-compact.css"> <script type="text/javascript" src="http://help.apple.com/iphone/3/mobile/dist/PastryKit-ug-compact.js" charset="utf-8"></script>
PastryKit Javascript and PastryKit CSS are available via a quick Download.
- DOWNLOAD THE COMPLETE PASRTY KIT
- DOWNLOAD THE COMPLETE PASRTY KIT UNCOMPRESSED
- DOWNLOAD PASTRY KIT JAVASCRIPT
- DOWNLOAD PASTRY KIT CSS
- DOWNLOAD THE ENTIRE ASSETS COLLECTION
- PASTRY KIT UML
They are kind of hard to read because of their Compression.
Gruber looked at the source anyway:
PastryKit accomplishes all three of the aforementioned things — hiding the MobileSafari address bar, providing fixed-position toolbars, and providing scrolling with momentum — by disabling regular scrolling and setting up its own view hierarchy and implementing its own scrolling.
The question of native iPhone apps on the web was a very hot discussion topic last month after PPK whipped up a storm on the never ending question of web-apps replacing iPhone apps. The interesting point here is Apple’s stance. They launched the iPhone with web plattform intended to be the platform for 3rd party apps, then switched over to native apps and have not done very much to facilitate native-style web apps since then. Is a change coming? As Gruber puts it:
The $64,000 question, though, is whether PastryKit is something Apple intends (or that a team within Apple hopes) to ship publicly. It seems like a lot of effort to build a framework this rich just for this iPhone User Guide, so I’m hopeful the answer is yes. Perhaps something integrated with the next major release of Dashcode? And, perhaps with integrated UI layout tools, along the lines of Interface Builder?
UPDATE: Added full uncompressed Source to the Downloads
ANOTHER UPDATE: Thanks to a anonymous Sponsor, we got now the full Assets as well DOWNLOAD THE ENTIRE ASSETS COLLECTION
29 Comments »
I noticed that the links were not linking properly. Links in title position and titles in link position. Since the links in the title I got it and downloaded… So thank you much!
-roger
Thank you Roger, i fixed it! Will add some tests and samples soon!
Great, I am looking forward to that!
Do you have the assets as well? And can we see some samples?
I will take some time tonight, and get the assets together!
I am looking forward to these assets and getting going with this
I want to quote your post in my blog. It can?
And you et an account on Twitter?
you can snake the whole site including art assets from a term if you have httrack
httrack http://help.apple.com/iphone/3/mobile/ -Y -F “Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A109a Safari/419.3″ –robots=0
You will still need to go get the classes folder manually if you want the database as it is document.writed in, so the snake doesn’t catch it, just manually fetch
/iphone/3/mobile/classes/datacontroller-database.js
and
/iphone/3/mobile/classes/datacontroller-json
[...] that set off a minor feeding frenzy of digging deeper into it all over teh intertubes, like here, and here, and [...]
Great Stuff, this will help my iphone development efforts!
Nice UML, do you have some function samples for it as well? Would love to see some cool JS Samples
I think it’s till missing the content found at:
http://help.apple.com/iphone/3/Contents/en/content.json
And in addition to my previous comment…
it’s a 664KB json file. If you want to get it formatted, use Aptana: create new JS file (not new json file), paste text in, then Edit/Format.
Great work!
Thanks
Hey,
love it! it helped us to solve some major issues we had with our Javascript!
Does anyone know if Apple is allowing use of this library? Not necessarily supporting it, but allowing it. I’d like to use it in a PhoneGap app but don’t want to get blocked from the store.
[...] basic web technologies supported by the iPhone and iPad. It appears similar in some respects to the PastryKit framework described last December, although AdLib appears to be a more advanced version that incorporates [...]
I do not think I’ve seen this depicted that way before. You actually have cleared this up for me. Thanks!
Nice article. Thank you for this info
Does anyone have an example of the fixed toolbar up and working besides the scrape example? When I pull up the index page I get the loading gif and that’s about it.
I also noticed on line 690 of the javascript.js file it calls for an info.json file. Anyone have that ?
dataFolder += “http://help.apple.com/Contents/”;
var infoJsonRequest = new XMLHttpRequest();
var infoJsonURL = dataFolder + “Info.json”;
Hello,
you can find it here
http://help.apple.com/iphone/3/Contents/Info.json
or zipped from us
http://nxfx.com/demo/Info.json.zip
So i got the preloader to stop looping but the toolbar does not stay fixed as on the apple site. Are there any examples I can see what I have config’d wrong ?
Hi Guys,
doesn’t work !!! can you help me ?
Great Stuff, whats the deal with the compressions, i keep getting Firebug Errors
i got it all to work! bug Firebug still gives me errors, please advise!
Nice work, any actual samples ?
I’ve got working samples and all files that are hosted on apple’s domain.
If you want them, just send me an e-mail and you’ll receive every file.
I can guarantee, PastryKit is over the top framework for native-looks.
k0st4s@live.se