 
 import Foundation
 
+
+///
+/// Because bridging is not complete in Linux, we must use Any objects for dictionaries
+/// instead of AnyObject. The main branch SwiftyJSON takes as input AnyObject, however
+/// our patched version for Linux accepts Any.
+///
+#if os(OSX)
+    typealias JSONDictionary = [String: AnyObject]
+#else
+    typealias JSONDictionary = [String: Any]
+#endif
+
+
 func parsePhotosList (list: JSON) -> JSON {
     var photos = [JSON]()
     let listLength = Int(list["total_rows"].number!)

    return JSON(photos)
}

func createPhotoDocument (request: RouterRequest) -> ([String:AnyObject]?, String?) {
    let ownerId = request.params["ownerId"]
    var ownerName = request.params["ownerName"]
    var title = request.params["title"]

    let ext = photoName!.componentsSeparatedByString(".")[1].lowercaseString
    let contentType = ContentType.contentTypeForExtension(ext)

    let tempDateString = NSDate().descriptionWithLocale(nil).bridge()
    let dateString = tempDateString.substringToIndex(10) + "T" + tempDateString.substringWithRange(NSMakeRange(11, 8))
    
    let doc : JSONDictionary = ["ownerId": ownerId!, "ownerName": ownerName!, "title": title!, "date": dateString, "inFeed": true, "type": "photo"]
    
    return (doc, contentType)
}

func createUploadReply (fromDocument document: JSONDictionary, id: String, photoName: String) -> JSON {
    var result = [String:String]()
    result["picturePath"] = "\(id)/\(photoName)"
    result["ownerId"] = document["ownerId"] as? String
