Skip to main content

Posts

Showing posts from February, 2012

Bulletproof EPUB zipping in a single pass (or, How to zip an EPUB from the Terminal in OS X sans .DS_Store files)

I wrote a blogpost recently on how to remove .DS_Store files that erroneously find their way into EPUBs. I have since found a proper solution to my woes and have what seems to be a bulletproof way of zipping EPUBs without the need for double-zipping or later removal of .DS_Store files. It places the mimetype where it should be (at the top of the hierarchy) and leaves the .DS_Store files outside the archive. So without any further ado here is the magical line of code to be run in Terminal from within the folder containing your book files that you want to compress into an EPUB:

    zip -Xr9D book.epub mimetype META-INF OEBPS -x *.DS_Store

Note: All the files within the folders will be incorporated. If future EPUB specs change what is incorporated in the top level folder, then additional files and folders will need to be added after OEBPS or in their specific place in the order should they have one (files after the -x are the ones to be excluded). 


Update: Thanks to elmimmo (see comments) …

EPUB and Kindle Session at Dev8d, University of London Union, Thursday 16 Feb 2012

A quick note to let you know that I'll be running a two-hour session at Dev8d in London this week - full details here.

Assigning classes to storyboard view controllers (Xcode for iOS 5 onwards)

To create new view controllers in an iPad or iPhone storyboard requires simply a drag and drop from the object menu, and as was described in the seven steps to segue post it is incredibly easy in iOS 5 to link one view controller to another.  However, there is one important step for enabling control of the content of a view controller created in this way and that is to ensure that it is assigned to the class that are you are going to use to control it. In this post I describe how to do this and provide a simple exercise for testing that it is performing correctly. Having created your new View Controller in the Storyboard, next go to the file menu and create a pair of .h and .m UIViewController subclass files

but for now deselect "With XIB for user interface" from the dialogue box.


Now use the Identity Inspector in the right-hand menu bar, and with the whole of the new view controller highlighted (not just one element of it!) you can select the Custom Class that you just crea…

Loading local and remote content into UIWebView (Xcode for iOS)

Dropping a UIWebView into an app can be a versatile way to view local (X)HTML pages, PDFs and Word Docs among other file types. To add one to your ViewController drag and drop it from the objects menu, then control click from the UIWebView to your ViewController.h file to create the IBOutlet.

Having done this, in the ViewController.m file within -(void)viewDidLoad: use the following code:
[remoteWebContentloadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://www.gylphi.co.uk/"]]];


And for local content:
[localWebContentloadRequest:[NSURLRequestrequestWithURL:[NSURLfileURLWithPath:[[NSBundlemainBundle] pathForResource:@"Text/page3"ofType:@"xhtml"inDirectory:@"Brochure/"]isDirectory:NO]]];


The second chunk of code - referencing an instance of UIWebView called localWebContent - will access a file called page3.xhtml in a folder Brochure/Text/ and as long as all the CSS and images are within the brochure folder or within a folder that is…

Accessing touch events with Javascript on an iOS device or simulator

Following on from the quick tip on how to test websites across iOS devices without an iOS device, this is a really quick post containing the code to display a very simple monitor of touch events. I hope it helps.
<!DOCTYPE html><head> <script> // Set public variables that can be accessed from all functions var touch; var startTouchX; var startTouchY; // add function on touchstart event to tell us where the touches started function movementStart(event) { event.preventDefault(); touch = event.touches[0]; startTouchX = touch.pageX; startTouchY = touch.pageY; document.getElementById("start").innerHTML="Touches Started at the Co-ordinates x:" + startTouchX + ", y:" + startTouchY; } // add function on touchmove event to tell us where the touches currently are function movement(event) { event.preventDefault(); touch = event.touches[0]; document.getElementById("position").innerHTML="Live Touch Co-ordinat…

Big Cat Beers - A list for those who like their drink the way they like their OS

This is a list inspired by a recently "overheard" conversation on Facebook.

Cheetah Beer
Black Puma Shiraz
Jaguar Wine
Panther Beers
Tiger Beer
Leopard Continental Lager (no longer seems to be available)
Snow Leopard Vodka
Lion Stout

Extras
Beers prefixed with Mac's
Kodiak Ridge Lager (public beta of OS X was called "Kodiak")
Ocelot (possible name for future version of OS X)
The White Lion (a pub not a beer but plenty of beer inside and it holds a popular annual beer festival - also a name suggested in various places online for a future version of OS X)

Testing websites across iOS devices without an iOS device

If you are using a Mac it is simple to test how webpages will look on an iOS device by running iOS Simulator. It comes packaged with Xcode, and Xcode is free to download from the Mac App Store. Once you've downloaded the 1.68GB of Xcode you can locate iOS Simulator using the Finder search box and simply typing iOS Simulator. Alternatively, it is installed in the Developer->Platforms->iPhoneSimulator.platform->Developer->Applications folder (note: the developer folder is not within your User folder but above this in the same place as the Applications folder on your hard drive).


Note: When you install Xcode you actually install a program called "Install Xcode" and to properly install the software you need to double tap on this and follow instructions.


Once you've opened iOS Simulator use the Hardware->Device menu to select from iPad, iPhone and iPhone (Retina Display), then open Safari from the dock on the simulated iOS device and either drag and drop yo…