├── .gitignore ├── Default.tribo ├── .gitignore ├── Posts │ └── 2012-03-08-example-post.md ├── Source │ ├── favicon.ico │ ├── scripts │ │ └── main.js │ ├── stylesheets │ │ ├── archives.css │ │ └── post.css │ ├── index.mustache │ └── archives │ │ └── index.mustache ├── Templates │ ├── Post.mustache │ ├── Feed.mustache │ └── Default.mustache └── Info.plist ├── Dependencies ├── CZAFileWatcher │ ├── .gitignore │ ├── CZAFileWatcher.xcodeproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── License.md │ ├── watch-file.m │ ├── Readme.md │ └── CZAFileWatcher.h ├── Rsync │ └── rsync ├── CocoaHTTPServer │ ├── .gitignore │ ├── .hgignore │ ├── Samples │ │ ├── WebDAVServer │ │ │ ├── WebDAVServer_Prefix.pch │ │ │ ├── README.markdown │ │ │ ├── main.m │ │ │ ├── AppDelegate.h │ │ │ ├── English.lproj │ │ │ │ └── MainMenu.nib │ │ │ │ │ └── keyedobjects.nib │ │ │ ├── WebDAVServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── Info.plist │ │ │ └── AppDelegate.m │ │ ├── DynamicServer │ │ │ ├── English.lproj │ │ │ │ └── InfoPlist.strings │ │ │ ├── MyHTTPConnection.h │ │ │ ├── DynamicServer_Prefix.pch │ │ │ ├── DynamicServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── main.m │ │ │ ├── DynamicServerAppDelegate.h │ │ │ ├── HTTPResponseTest.h │ │ │ ├── README.markdown │ │ │ ├── Web │ │ │ │ └── index.html │ │ │ ├── DynamicServer-Info.plist │ │ │ └── DynamicServerAppDelegate.m │ │ ├── SimpleWebSocketServer │ │ │ ├── English.lproj │ │ │ │ └── InfoPlist.strings │ │ │ ├── MyWebSocket.h │ │ │ ├── MyHTTPConnection.h │ │ │ ├── SimpleWebSocketServer_Prefix.pch │ │ │ ├── SimpleWebSocketServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── main.m │ │ │ ├── SimpleWebSocketServerAppDelegate.h │ │ │ ├── Web │ │ │ │ ├── index.html │ │ │ │ ├── WebSocketTest.js │ │ │ │ └── WebSocketTest2.js │ │ │ ├── MyWebSocket.m │ │ │ ├── README.markdown │ │ │ ├── SimpleWebSocketServer-Info.plist │ │ │ ├── SimpleWebSocketServerAppDelegate.m │ │ │ └── MyHTTPConnection.m │ │ ├── SecureWebSocketServer │ │ │ ├── SecureWebSocketServer │ │ │ │ ├── en.lproj │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ └── Credits.rtf │ │ │ │ ├── DDKeychain.m │ │ │ │ ├── MyWebSocket.h │ │ │ │ ├── MyHTTPConnection.h │ │ │ │ ├── SecureWebSocketServer-Prefix.pch │ │ │ │ ├── main.m │ │ │ │ ├── SecureWebSocketServerAppDelegate.h │ │ │ │ ├── Web │ │ │ │ │ ├── WebSocketTest.js │ │ │ │ │ ├── index.html │ │ │ │ │ └── WebSocketTest2.js │ │ │ │ ├── DDKeychain.h │ │ │ │ ├── MyWebSocket.m │ │ │ │ ├── SecureWebSocketServer-Info.plist │ │ │ │ └── SecureWebSocketServerAppDelegate.m │ │ │ ├── SecureWebSocketServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ └── README.markdown │ │ ├── SimpleFileUploadServer │ │ │ ├── SimpleFileUploadServer │ │ │ │ ├── en.lproj │ │ │ │ │ ├── InfoPlist.strings │ │ │ │ │ └── Credits.rtf │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── SimpleFileUploadServer-Prefix.pch │ │ │ │ ├── web │ │ │ │ │ ├── upload.html │ │ │ │ │ └── index.html │ │ │ │ ├── MyHTTPConnection.h │ │ │ │ ├── main.m │ │ │ │ ├── SimpleFileUploadServer-Info.plist │ │ │ │ └── AppDelegate.m │ │ │ ├── SimpleFileUploadServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ └── README.markdown │ │ ├── Xcode-Configurations │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── ReadMe.txt │ │ │ └── Base.xcconfig │ │ ├── SecureHTTPServer │ │ │ ├── DDKeychain.m │ │ │ ├── English.lproj │ │ │ │ └── InfoPlist.strings │ │ │ ├── MyHTTPConnection.h │ │ │ ├── AppDelegate.h │ │ │ ├── SecureHTTPServer.xcodeproj │ │ │ │ ├── TemplateIcon.icns │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── SecureHTTPServer_Prefix.pch │ │ │ ├── main.m │ │ │ ├── DDKeychain.h │ │ │ ├── Info.plist │ │ │ ├── MyHTTPConnection.m │ │ │ ├── README.markdown │ │ │ └── AppDelegate.m │ │ ├── PostHTTPServer │ │ │ ├── MyHTTPConnection.h │ │ │ ├── English.lproj │ │ │ │ └── InfoPlist.strings │ │ │ ├── AppDelegate.h │ │ │ ├── PostHTTPServer.xcodeproj │ │ │ │ ├── TemplateIcon.icns │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── PostHTTPServer_Prefix.pch │ │ │ ├── Web │ │ │ │ └── index.html │ │ │ ├── main.m │ │ │ ├── README.markdown │ │ │ ├── Info.plist │ │ │ └── AppDelegate.m │ │ ├── iPhoneHTTPServer │ │ │ ├── Default-568h@2x.png │ │ │ ├── Classes │ │ │ │ ├── iPhoneHTTPServerViewController.m │ │ │ │ ├── iPhoneHTTPServerViewController.h │ │ │ │ └── iPhoneHTTPServerAppDelegate.h │ │ │ ├── iPhoneHTTPServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── iPhoneHTTPServer_Prefix.pch │ │ │ ├── Web │ │ │ │ └── index.html │ │ │ ├── main.m │ │ │ ├── iPhoneHTTPServer-Info.plist │ │ │ └── README.markdown │ │ ├── SimpleHTTPServer │ │ │ ├── AppDelegate.h │ │ │ ├── English.lproj │ │ │ │ ├── InfoPlist.strings │ │ │ │ └── MainMenu.nib │ │ │ │ │ └── keyedobjects.nib │ │ │ ├── SimpleHTTPServer_Prefix.pch │ │ │ ├── SimpleHTTPServer.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── main.m │ │ │ ├── README.markdown │ │ │ ├── Info.plist │ │ │ └── AppDelegate.m │ │ ├── PasswdHTTPServer │ │ │ ├── English.lproj │ │ │ │ └── InfoPlist.strings │ │ │ ├── MyHTTPConnection.h │ │ │ ├── AppDelegate.h │ │ │ ├── PasswdHTTPServer.xcodeproj │ │ │ │ ├── TemplateIcon.icns │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── PasswdHTTPServer_Prefix.pch │ │ │ ├── main.m │ │ │ ├── Info.plist │ │ │ ├── README.markdown │ │ │ ├── MyHTTPConnection.m │ │ │ └── AppDelegate.m │ │ └── README.markdown │ ├── Extensions │ │ └── WebDAV │ │ │ ├── DAVConnection.h │ │ │ ├── DELETEResponse.h │ │ │ ├── PUTResponse.h │ │ │ ├── DAVResponse.h │ │ │ ├── DELETEResponse.m │ │ │ └── PUTResponse.m │ ├── Core │ │ ├── Responses │ │ │ ├── HTTPErrorResponse.h │ │ │ ├── HTTPDataResponse.h │ │ │ ├── HTTPRedirectResponse.h │ │ │ ├── HTTPFileResponse.h │ │ │ ├── HTTPErrorResponse.m │ │ │ ├── HTTPRedirectResponse.m │ │ │ ├── HTTPDynamicFileResponse.h │ │ │ └── HTTPDataResponse.m │ │ ├── Categories │ │ │ ├── DDData.h │ │ │ ├── DDNumber.h │ │ │ ├── DDNumber.m │ │ │ ├── DDData.m │ │ │ └── DDRange.h │ │ ├── Mime │ │ │ ├── MultipartMessageHeaderField.h │ │ │ ├── MultipartMessageHeader.h │ │ │ ├── MultipartFormDataParser.h │ │ │ └── MultipartMessageHeader.m │ │ ├── HTTPAuthenticationRequest.h │ │ ├── HTTPMessage.h │ │ └── HTTPMessage.m │ ├── Vendor │ │ ├── CocoaAsyncSocket │ │ │ └── About.txt │ │ └── CocoaLumberjack │ │ │ ├── Extensions │ │ │ ├── README.txt │ │ │ └── ContextFilterLogFormatter.h │ │ │ ├── DDASLLogger.h │ │ │ └── About.txt │ ├── README.markdown │ └── LICENSE.txt └── BLAKE3 │ └── blake3.h ├── Mac App ├── Resources │ ├── Arrow.png │ ├── Arrow.psd │ ├── Stop.png │ ├── Stop.psd │ ├── Stop@2x.png │ ├── Stop@2x.psd │ ├── Arrow@2x.png │ ├── Arrow@2x.psd │ ├── Credits.rtf │ └── Tribo.entitlements ├── Tribo Open Source Developer.p12 ├── Prefix.pch ├── HTTP Server │ ├── TBWebSocket.h │ ├── TBHTTPServer.h │ ├── TBSocketConnection.h │ ├── TBPage+LiveReload.h │ ├── TBPage+LiveReload.m │ ├── TBHTTPServer.m │ ├── TBWebSocket.m │ └── TBSocketConnection.m ├── TBAppDelegate.h ├── TBAppDelegate.m ├── Controllers │ ├── TBStatusView.h │ ├── TBViewController.h │ ├── TBShadowedButtonCell.h │ ├── TBShadowedTextFieldCell.h │ ├── TBPublishSheetController.h │ ├── TBSettingsSheetController.h │ ├── TBStatusViewController.h │ ├── TBSourceViewControllerViewController.h │ ├── TBAddPostSheetController.h │ ├── TBNewSiteSheetController.h │ ├── TBTemplatesViewController.h │ ├── TBPostsViewController.h │ ├── TBViewController.m │ ├── TBStatusViewController.m │ ├── TBSiteWindowController.h │ ├── TBShadowedTextFieldCell.m │ ├── TBShadowedButtonCell.m │ ├── TBSourceViewControllerViewController.m │ ├── TBTemplatesViewController.m │ ├── TBPublishSheetController.m │ └── TBNewSiteSheetController.m ├── Publishing │ ├── TBFTPPublisher.h │ ├── TBSFTPPublisher.h │ ├── TBCloudflarePublisher.h │ ├── TBPublisher.h │ └── TBPublisher.m ├── Core.m ├── Scripting │ ├── TBSite+Scripting.h │ ├── TBPost+Scripting.h │ ├── TBSiteDocument+Scripting.h │ ├── Example Script.applescript │ ├── TBPost+Scripting.m │ ├── TBSite+Scripting.m │ └── TBSiteDocument+Scripting.m ├── Views │ ├── TBTableView.h │ ├── TBTabView.h │ └── TBTableView.m └── TBSiteDocument.h ├── Command Line Interface ├── CLI-Prefix.pch └── tribo.m ├── Tribo.xcodeproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── .gitmodules ├── Shared ├── System Additions │ ├── NSResponder+TBAdditions.h │ ├── NSDateFormatter+TBAdditions.h │ ├── NSResponder+TBAdditions.m │ └── NSDateFormatter+TBAdditions.m ├── TBError.h ├── Template Additions │ ├── TBPost+TemplateAdditions.h │ ├── TBSite+TemplateAdditions.h │ ├── TBSite+TemplateAdditions.m │ └── TBPost+TemplateAdditions.m ├── TBConstants.h ├── en.lproj │ └── TBError.strings ├── TBConstants.m ├── TBAsset.m ├── TBAsset.h ├── TBError.m └── TBPost.h └── License.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | xcuserdata -------------------------------------------------------------------------------- /Default.tribo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Output 3 | -------------------------------------------------------------------------------- /Dependencies/CZAFileWatcher/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | xcuserdata -------------------------------------------------------------------------------- /Default.tribo/Posts/2012-03-08-example-post.md: -------------------------------------------------------------------------------- 1 | # Example Post # 2 | 3 | -------------------------------------------------------------------------------- /Dependencies/Rsync/rsync: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/Rsync/rsync -------------------------------------------------------------------------------- /Mac App/Resources/Arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Arrow.png -------------------------------------------------------------------------------- /Mac App/Resources/Arrow.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Arrow.psd -------------------------------------------------------------------------------- /Mac App/Resources/Stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Stop.png -------------------------------------------------------------------------------- /Mac App/Resources/Stop.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Stop.psd -------------------------------------------------------------------------------- /Mac App/Resources/Stop@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Stop@2x.png -------------------------------------------------------------------------------- /Mac App/Resources/Stop@2x.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Stop@2x.psd -------------------------------------------------------------------------------- /Default.tribo/Source/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Default.tribo/Source/favicon.ico -------------------------------------------------------------------------------- /Mac App/Resources/Arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Arrow@2x.png -------------------------------------------------------------------------------- /Mac App/Resources/Arrow@2x.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Resources/Arrow@2x.psd -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pbxuser 3 | *.mode1v3 4 | *.mode2v3 5 | xcuserdata 6 | *~ 7 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | 3 | Samples/*/build 4 | *.pbxuser 5 | *.mode1v3 6 | *.xcuserdatad 7 | -------------------------------------------------------------------------------- /Mac App/Tribo Open Source Developer.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Mac App/Tribo Open Source Developer.p12 -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/WebDAVServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/Xcode-Configurations/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Base" 2 | 3 | // Common 4 | ONLY_ACTIVE_ARCH = YES 5 | GCC_OPTIMIZATION_LEVEL = 0 6 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/DDKeychain.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/DDKeychain.m -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/README.markdown: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/WebDAVServer/README.markdown -------------------------------------------------------------------------------- /Mac App/Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Tribo' target in the 'Tribo' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char* argv[]) { 4 | return NSApplicationMain(argc, (const char**)argv); 5 | } 6 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPConnection.h" 3 | 4 | 5 | @interface MyHTTPConnection : HTTPConnection 6 | 7 | @end -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/Default-568h@2x.png -------------------------------------------------------------------------------- /Command Line Interface/CLI-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Tribo' target in the 'Tribo' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | @class HTTPServer; 3 | 4 | @interface AppDelegate : NSObject 5 | { 6 | HTTPServer *httpServer; 7 | } 8 | @end 9 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPConnection.h" 3 | 4 | 5 | @interface MyHTTPConnection : HTTPConnection 6 | 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerViewController.m: -------------------------------------------------------------------------------- 1 | #import "iPhoneHTTPServerViewController.h" 2 | 3 | 4 | @implementation iPhoneHTTPServerViewController 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/MyWebSocket.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "WebSocket.h" 3 | 4 | 5 | @interface MyWebSocket : WebSocket 6 | { 7 | 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h: -------------------------------------------------------------------------------- 1 | #import "HTTPConnection.h" 2 | 3 | @interface DAVConnection : HTTPConnection { 4 | id requestContentBody; 5 | NSOutputStream* requestContentStream; 6 | } 7 | @end 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPConnection.h" 3 | 4 | 5 | @interface MyHTTPConnection : HTTPConnection 6 | { 7 | 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPConnection.h" 3 | 4 | 5 | @interface MyHTTPConnection : HTTPConnection 6 | { 7 | 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | @interface AppDelegate : NSObject { 6 | @private 7 | HTTPServer* _httpServer; 8 | } 9 | @end 10 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | 6 | @interface AppDelegate : NSObject 7 | { 8 | HTTPServer *httpServer; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | 6 | @interface AppDelegate : NSObject 7 | { 8 | HTTPServer *httpServer; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/PostHTTPServer.xcodeproj/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/PostHTTPServer.xcodeproj/TemplateIcon.icns -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | 6 | @interface AppDelegate : NSObject 7 | { 8 | HTTPServer *httpServer; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/DDKeychain.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/DDKeychain.m -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/WebDAVServer/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Tribo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h: -------------------------------------------------------------------------------- 1 | #import "HTTPResponse.h" 2 | 3 | @interface DELETEResponse : NSObject { 4 | NSInteger _status; 5 | } 6 | - (id) initWithFilePath:(NSString*)path; 7 | @end 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/Xcode-Configurations/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Base" 2 | 3 | // Common 4 | GCC_TREAT_WARNINGS_AS_ERRORS = YES 5 | GCC_PREPROCESSOR_DEFINITIONS = NDEBUG NS_BLOCK_ASSERTIONS 6 | VALIDATE_PRODUCT = YES 7 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface iPhoneHTTPServerViewController : UIViewController { 5 | 6 | } 7 | 8 | @end 9 | 10 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/PasswdHTTPServer.xcodeproj/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/PasswdHTTPServer.xcodeproj/TemplateIcon.icns -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/SecureHTTPServer.xcodeproj/TemplateIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarterA/Tribo/HEAD/Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/SecureHTTPServer.xcodeproj/TemplateIcon.icns -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/MyWebSocket.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "WebSocket.h" 3 | 4 | 5 | @interface MyWebSocket : WebSocket 6 | { 7 | 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/DynamicServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'DynamicServer' target in the 'DynamicServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h: -------------------------------------------------------------------------------- 1 | #import "HTTPResponse.h" 2 | 3 | @interface HTTPErrorResponse : NSObject { 4 | NSInteger _status; 5 | } 6 | 7 | - (id)initWithErrorCode:(int)httpErrorCode; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/PostHTTPServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PostHTTPServer' target in the 'PostHTTPServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/PasswdHTTPServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PasswdHTTPServer' target in the 'PasswdHTTPServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/SecureHTTPServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SecureHTTPServer' target in the 'SecureHTTPServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/SimpleHTTPServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimpleHTTPServer' target in the 'SimpleHTTPServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Vendor/CocoaAsyncSocket/About.txt: -------------------------------------------------------------------------------- 1 | The CocoaAsyncSocket project is under Public Domain license. 2 | http://code.google.com/p/cocoaasyncsocket/ 3 | 4 | The AsyncSocket project has been around since 2001 and is used in many applications and frameworks. -------------------------------------------------------------------------------- /Dependencies/CZAFileWatcher/CZAFileWatcher.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/Web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | What is 5 + 5 ? :
5 | 6 |
7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPConnection.h" 3 | 4 | @class MyWebSocket; 5 | 6 | @interface MyHTTPConnection : HTTPConnection 7 | { 8 | MyWebSocket *ws; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/SimpleWebSocketServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimpleWebSocketServer' target in the 'SimpleWebSocketServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @class HTTPServer; 5 | 6 | @interface AppDelegate : NSObject { 7 | HTTPServer *httpServer; 8 | } 9 | 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/WebDAVServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Default.tribo/Templates/Post.mustache: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

{{title}}

5 | {{dateString}} 6 |
7 |
8 | {{{content}}} 9 |
10 |
-------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/DynamicServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/PostHTTPServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBWebSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBWebSocket.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/24/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "WebSocket.h" 10 | 11 | @interface TBWebSocket : WebSocket 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Mac App/TBAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBAppDelegate.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/1/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | @interface TBAppDelegate : NSObject 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPConnection.h" 3 | 4 | @class MyWebSocket; 5 | 6 | @interface MyHTTPConnection : HTTPConnection 7 | { 8 | MyWebSocket *ws; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/SecureWebSocketServer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SecureWebSocketServer' target in the 'SecureWebSocketServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Mac App/TBAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBAppDelegate.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/1/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBAppDelegate.h" 11 | 12 | @implementation TBAppDelegate 13 | @end 14 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/PasswdHTTPServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/SecureHTTPServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/SimpleHTTPServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/iPhoneHTTPServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/iPhoneHTTPServer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'iPhoneHTTPServer' target in the 'iPhoneHTTPServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/SimpleFileUploadServer-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SimpleFileUploadServer' target in the 'SimpleFileUploadServer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBStatusView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBStatusView.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/15/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @interface TBStatusView : NSView 13 | @end 14 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPResponse.h" 3 | 4 | 5 | @interface HTTPDataResponse : NSObject 6 | { 7 | NSUInteger offset; 8 | NSData *data; 9 | } 10 | 11 | - (id)initWithData:(NSData *)data; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPResponse.h" 3 | 4 | 5 | @interface HTTPRedirectResponse : NSObject 6 | { 7 | NSString *redirectPath; 8 | } 9 | 10 | - (id)initWithPath:(NSString *)redirectPath; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/SimpleWebSocketServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBHTTPServer.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBHTTPServer.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/24/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "HTTPServer.h" 10 | 11 | @interface TBHTTPServer : HTTPServer 12 | - (void)refreshPages; 13 | @end 14 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBSocketConnection.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSocketConnection.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/24/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "HTTPConnection.h" 10 | 11 | @interface TBSocketConnection : HTTPConnection 12 | @end 13 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Categories/DDData.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSData (DDData) 4 | 5 | - (NSData *)md5Digest; 6 | 7 | - (NSData *)sha1Digest; 8 | 9 | - (NSString *)hexStringValue; 10 | 11 | - (NSString *)base64Encoded; 12 | 13 | - (NSData *)base64Decoded; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBPage+LiveReload.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPage+LiveReload.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/25/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBPage.h" 10 | 11 | @interface TBPage (LiveReload) 12 | - (NSString *)livereload; 13 | @end 14 | -------------------------------------------------------------------------------- /Mac App/Publishing/TBFTPPublisher.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBFTPPublisher.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/5/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBPublisher.h" 11 | 12 | @interface TBFTPPublisher : TBPublisher 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Mac App/Publishing/TBSFTPPublisher.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSFTPPublisher.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/5/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBPublisher.h" 11 | 12 | @interface TBSFTPPublisher : TBPublisher 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Mac App/Core.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/1/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | int main(int argc, char *argv[]) { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/web/upload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %MyFiles% 8 | 9 | -------------------------------------------------------------------------------- /Default.tribo/Source/scripts/main.js: -------------------------------------------------------------------------------- 1 | /* Simple shim for HTML5 elements in older browsers */ 2 | (function(){if(!/*@cc_on!@*/0)return;var e="abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(',');for(var i=0;i 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h: -------------------------------------------------------------------------------- 1 | #import "HTTPResponse.h" 2 | 3 | @interface PUTResponse : NSObject { 4 | NSInteger _status; 5 | } 6 | - (id) initWithFilePath:(NSString*)path headers:(NSDictionary*)headers bodyData:(NSData*)body; 7 | - (id) initWithFilePath:(NSString*)path headers:(NSDictionary*)headers bodyFile:(NSString*)body; 8 | @end 9 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PasswdHTTPServer 4 | // 5 | // Created by Robbie Hanson on 5/19/09. 6 | // Copyright Deusty Designs, LLC. 2009. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PostHTTPServer 4 | // 5 | // Created by Robbie Hanson on 11/20/08. 6 | // Copyright Deusty Designs, LLC. 2008. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SecureHTTPServer 4 | // 5 | // Created by Robbie Hanson on 5/19/09. 6 | // Copyright Deusty Designs, LLC. 2009. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/MyHTTPConnection.h: -------------------------------------------------------------------------------- 1 | 2 | #import "HTTPConnection.h" 3 | 4 | @class MultipartFormDataParser; 5 | 6 | @interface MyHTTPConnection : HTTPConnection { 7 | MultipartFormDataParser* parser; 8 | NSFileHandle* storeFile; 9 | 10 | NSMutableArray* uploadedFiles; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleHTTPServer 4 | // 5 | // Created by Robert Hanson on 6/6/07. 6 | // Copyright Deusty Designs, LLC 2007. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Mac App/Scripting/TBSite+Scripting.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSite+Scripting.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/7/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBSite.h" 10 | 11 | @class TBPost; 12 | 13 | @interface TBSite (Scripting) 14 | - (NSScriptObjectSpecifier *)objectSpecifierForPost:(TBPost *)post; 15 | @end 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Dependencies/GRMustache"] 2 | path = Dependencies/GRMustache 3 | url = https://github.com/groue/GRMustache.git 4 | [submodule "Dependencies/Sundown"] 5 | path = Dependencies/Sundown 6 | url = https://github.com/CarterA/sundown.git 7 | [submodule "Dependencies/CurlHandle"] 8 | path = Dependencies/CurlHandle 9 | url = git@github.com:CarterA/CurlHandle.git 10 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/DynamicServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | 6 | @interface DynamicServerAppDelegate : NSObject 7 | { 8 | HTTPServer *httpServer; 9 | 10 | NSWindow *__unsafe_unretained window; 11 | } 12 | 13 | @property (unsafe_unretained) IBOutlet NSWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleWebSocketServer 4 | // 5 | // Created by Robbie Hanson on 4/20/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SecureWebSocketServer 4 | // 5 | // Created by Robbie Hanson on 6/3/11. 6 | // Copyright 2011 Voalte. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /Mac App/Resources/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf230 2 | {\fonttbl\f0\fnil\fcharset0 LucidaGrande;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \margl1440\margr1440\vieww9000\viewh8400\viewkind0 5 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural 6 | 7 | \f0\fs22 \cf0 Developed by Carter Allen and George Woodliff-Stanley} -------------------------------------------------------------------------------- /Shared/System Additions/NSResponder+TBAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSResponder+TBAdditions.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 8/11/13. 6 | // Copyright (c) 2013 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @interface NSResponder (TBAdditions) 13 | - (void)tb_presentErrorOnMainQueue:(NSError *)error; 14 | @end 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/SimpleWebSocketServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | 6 | @interface SimpleWebSocketServerAppDelegate : NSObject 7 | { 8 | HTTPServer *httpServer; 9 | NSWindow *__unsafe_unretained window; 10 | } 11 | 12 | @property (unsafe_unretained) IBOutlet NSWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains some sample formatters that may be helpful. 2 | 3 | Feel free to change them, extend them, or use them as the basis for your own custom formatter(s). 4 | 5 | More information about creating your own custom formatters can be found on the wiki: 6 | https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters 7 | 8 | -------------------------------------------------------------------------------- /Mac App/Publishing/TBCloudflarePublisher.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBCloudflarePublisher.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/27/22. 6 | // Copyright (c) 2022 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBPublisher.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface TBCloudflarePublisher : TBPublisher 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /Shared/System Additions/NSDateFormatter+TBAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateFormatter+TBAdditions.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 6/15/13. 6 | // Copyright (c) 2013 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDateFormatter (TBAdditions) 12 | + (instancetype)tb_cachedDateFormatterFromString:(NSString *)format; 13 | @end 14 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleFileUploadServer 4 | // 5 | // Created by Валерий Гаврилов on 16.04.12. 6 | // Copyright (c) 2012 muhtau1@gmail.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/SecureWebSocketServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class HTTPServer; 4 | 5 | 6 | @interface SecureWebSocketServerAppDelegate : NSObject { 7 | @private 8 | HTTPServer *httpServer; 9 | NSWindow *__unsafe_unretained window; 10 | } 11 | 12 | @property (unsafe_unretained) IBOutlet NSWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Mac App/Scripting/TBPost+Scripting.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPost+Scripting.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/7/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBPost.h" 10 | 11 | @interface TBPost (Scripting) 12 | - (NSScriptObjectSpecifier *)objectSpecifier; 13 | - (NSTextStorage *)markdownContentForScripting; 14 | - (NSTextStorage *)HTMLContentForScripting; 15 | @end 16 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBViewController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/21/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | @class TBSiteDocument; 11 | @interface TBViewController : NSViewController 12 | @property (nonatomic, weak) TBSiteDocument *document; 13 | - (NSString *)defaultNibName; 14 | - (void)viewDidLoad; 15 | @end 16 | -------------------------------------------------------------------------------- /Mac App/Scripting/TBSiteDocument+Scripting.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSiteDocument+Scripting.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/7/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBSiteDocument.h" 10 | 11 | @interface TBSiteDocument (Scripting) 12 | - (void)startPreviewFromScript:(NSScriptCommand *)command; 13 | - (void)stopPreviewFromScript:(NSScriptCommand *)command; 14 | @end 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h: -------------------------------------------------------------------------------- 1 | #import "HTTPResponse.h" 2 | 3 | @interface DAVResponse : NSObject { 4 | @private 5 | UInt64 _offset; 6 | NSMutableDictionary* _headers; 7 | NSData* _data; 8 | NSInteger _status; 9 | } 10 | - (id) initWithMethod:(NSString*)method headers:(NSDictionary*)headers bodyData:(NSData*)body resourcePath:(NSString*)resourcePath rootPath:(NSString*)rootPath; 11 | @end 12 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBPage+LiveReload.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBPage+LiveReload.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/25/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBPage+LiveReload.h" 10 | 11 | @implementation TBPage (LiveReload) 12 | 13 | - (NSString *)livereload { 14 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"TBLiveReloadSnippet"]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/Web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | iPhone HTTP Server Example 4 | 5 | 6 |

Welcome to CocoaHTTPServer!

7 | 8 | You can customize this page for your app, make other pages, or even serve up dynamic content.
9 | 10 | CocoaHTTPServer Project Page
11 | 12 | 13 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // iPhoneHTTPServer 4 | // 5 | // Created by Robbie Hanson on 11/25/10. 6 | // Copyright 2010 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Categories/DDNumber.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSNumber (DDNumber) 4 | 5 | + (BOOL)parseString:(NSString *)string intoSInt64:(SInt64 *)integer; 6 | + (BOOL)parseString:(NSString *)string intoUInt64:(UInt64 *)integer; 7 | 8 | + (BOOL)parseString:(NSString *)string intoNSInteger:(NSInteger *)integer; 9 | + (BOOL)parseString:(NSString *)string intoNSUInteger:(NSUInteger *)integer; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBShadowedButtonCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBShadowedButtonCell.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/17/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @interface TBShadowedButtonCell : NSButtonCell 13 | @property (nonatomic, strong) NSColor *aquaShadowColor; 14 | @property (nonatomic, strong) NSColor *graphiteShadowColor; 15 | @end 16 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBShadowedTextFieldCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBShadowedTextFieldCell.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/17/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @interface TBShadowedTextFieldCell : NSTextFieldCell 13 | @property (nonatomic, strong) NSColor *aquaShadowColor; 14 | @property (nonatomic, strong) NSColor *graphiteShadowColor; 15 | @end 16 | -------------------------------------------------------------------------------- /Default.tribo/Source/stylesheets/archives.css: -------------------------------------------------------------------------------- 1 | #archives { 2 | margin: 0px auto; 3 | padding: 0px; 4 | width: 500px; 5 | } 6 | #archives li { 7 | display: inline; 8 | padding-right: 2em; 9 | } 10 | #archives p { 11 | margin: 0px; 12 | line-height: 0pt; 13 | } 14 | .archiveDate { 15 | font-style: italic; 16 | float: right; 17 | } 18 | @media (max-width: 520px) { 19 | #archives { 20 | width: 300px; 21 | } 22 | section#content { 23 | width: 320px; 24 | } 25 | } -------------------------------------------------------------------------------- /Mac App/Controllers/TBPublishSheetController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPublishSheetController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/29/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @class TBSite; 13 | 14 | @interface TBPublishSheetController : NSWindowController 15 | @property (nonatomic, strong) TBSite *site; 16 | - (void)runModalForWindow:(NSWindow *)window site:(TBSite *)site; 17 | @end 18 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBSettingsSheetController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSettingsSheetController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/27/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @class TBSite; 13 | 14 | @interface TBSettingsSheetController : NSWindowController 15 | @property (nonatomic, strong) TBSite *site; 16 | - (void)runModalForWindow:(NSWindow *)window site:(TBSite *)site; 17 | @end 18 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This example project demonstrates the ability of accepting a file upload. 4 | 5 | INSTRUCTIONS: 6 | 7 | Open the Xcode project, and build and go. 8 | 9 | On the Xcode console you'll see a message saying: 10 | "Started HTTP server on port 59123" 11 | 12 | Now open your browser and type in the URL: 13 | http://localhost:59123 14 | 15 | (Replace 59123 with whatever port the server is actually running on.) 16 | 17 | Enjoy. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/Xcode-Configurations/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Since there are so many different sample Xcode projects, we use these Xcode config files to help simplify a lot configuring of the projects and targets, and ensuring they are all in sync. 2 | 3 | Please note: These settings are not required if you want to include the CocoaHTTPServer in your project. They mostly help the developers of the project by ensuring that many compiler warnings are turned on so we don't introduce compiler issues into the project. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/Web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SimpleWebSocketServer 4 | 5 | 6 | 7 | 8 | Does my browser support WebSockets?
9 |
10 | Open WebSocket and tell me what time it is. 11 | 12 | -------------------------------------------------------------------------------- /Mac App/Views/TBTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBTableView.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/8/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | @protocol TBTableViewDelegate; 11 | 12 | @interface TBTableView : NSTableView 13 | - (IBAction)deleteSelectedRows:(id)sender; 14 | @end 15 | 16 | @protocol TBTableViewDelegate 17 | - (void)tableView:(NSTableView *)tableView shouldDeleteRows:(NSIndexSet *)rowIndexes; 18 | @end 19 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/Web/WebSocketTest.js: -------------------------------------------------------------------------------- 1 | function WebSocketTest() 2 | { 3 | if ("WebSocket" in window) 4 | { 5 | alert("WebSocket supported here! :)\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\n(based on Google sample code)"); 6 | } 7 | else 8 | { 9 | // Browser doesn't support WebSocket 10 | alert("WebSocket NOT supported here! :(\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\n(based on Google sample code)"); 11 | } 12 | } -------------------------------------------------------------------------------- /Mac App/Controllers/TBStatusViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBStatusViewController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/13/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBViewController.h" 11 | 12 | typedef void(^TBStatusViewControllerStopHandler)(); 13 | 14 | @interface TBStatusViewController : TBViewController 15 | @property (nonatomic, strong) NSURL *link; 16 | @property (nonatomic, copy) TBStatusViewControllerStopHandler stopHandler; 17 | @end 18 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBSourceViewControllerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSourceViewControllerViewController.h 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 2/22/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "TBViewController.h" 11 | 12 | @interface TBSourceViewControllerViewController : TBViewController 13 | @property (nonatomic, weak) IBOutlet NSOutlineView *outlineView; 14 | @property (nonatomic, weak) IBOutlet NSTreeController *assetTree; 15 | @end 16 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBAddPostSheetController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBAddPostSheetController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/7/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | typedef void(^TBAddPostSheetControllerCompletionHandler)(NSString *title, NSString *slug); 11 | 12 | @interface TBAddPostSheetController : NSWindowController 13 | - (void)runModalForWindow:(NSWindow *)window completionBlock:(TBAddPostSheetControllerCompletionHandler)completionHandler; 14 | @end 15 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/Web/WebSocketTest.js: -------------------------------------------------------------------------------- 1 | function WebSocketTest() 2 | { 3 | if ("WebSocket" in window) 4 | { 5 | alert("WebSocket supported here! :)\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\n(based on Google sample code)"); 6 | } 7 | else 8 | { 9 | // Browser doesn't support WebSocket 10 | alert("WebSocket NOT supported here! :(\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\n(based on Google sample code)"); 11 | } 12 | } -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class iPhoneHTTPServerViewController; 4 | @class HTTPServer; 5 | 6 | @interface iPhoneHTTPServerAppDelegate : NSObject 7 | { 8 | HTTPServer *httpServer; 9 | 10 | UIWindow *window; 11 | iPhoneHTTPServerViewController *viewController; 12 | } 13 | 14 | @property (nonatomic) IBOutlet UIWindow *window; 15 | @property (nonatomic) IBOutlet iPhoneHTTPServerViewController *viewController; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBNewSiteSheetController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBNewSiteSheetController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/19/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | typedef void(^TBNewSiteSheetCompletionHandler)(NSString *name, NSString *author, NSURL *URL); 13 | 14 | @interface TBNewSiteSheetController : NSWindowController 15 | - (void)runModalForWindow:(NSWindow *)window completionHandler:(TBNewSiteSheetCompletionHandler)handler; 16 | @end 17 | -------------------------------------------------------------------------------- /Shared/TBError.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBError.h 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 1/31/12. 6 | // Copyright (c) 2013 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | extern const struct TBError { 11 | NSError *(*missingPostsDirectory)(NSURL *postsDirectory); 12 | NSError *(*missingPostPartial)(NSURL *postPartial); 13 | NSError *(*badPostFileName)(NSURL *postURL); 14 | NSError *(*missingSourceDirectory)(NSURL *sourceDirectory); 15 | NSError *(*filterStandardError)(NSURL *filterURL, NSString *standardError); 16 | } TBError; 17 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This is a bare bones example of how to embed the CocoaHTTPServer in a desktop application. The document root of the server is set to the ~/Sites folder. 4 | 5 | INSTRUCTIONS: 6 | 7 | Open the Xcode project, and build and go. 8 | 9 | On the Xcode console you'll see a message saying: 10 | "Started HTTP server on port 59123" 11 | 12 | Now open your browser and type in the URL: 13 | http://localhost:59123 14 | 15 | (Replace 59123 with whatever port the server is actually running on.) 16 | 17 | Enjoy. -------------------------------------------------------------------------------- /Mac App/Controllers/TBTemplatesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBTemplatesViewController.h 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 2/20/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | #import "TBViewController.h" 12 | 13 | @interface TBTemplatesViewController : TBViewController 14 | @property (nonatomic, weak) IBOutlet NSArrayController *assets; 15 | @property (nonatomic, weak) IBOutlet NSTableView *tableView; 16 | 17 | - (void)doubleClickRow:(NSTableView *)outlineView; 18 | @end 19 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPResponse.h" 3 | 4 | @class HTTPConnection; 5 | 6 | 7 | @interface HTTPFileResponse : NSObject 8 | { 9 | HTTPConnection *connection; 10 | 11 | NSString *filePath; 12 | UInt64 fileLength; 13 | UInt64 fileOffset; 14 | 15 | BOOL aborted; 16 | 17 | int fileFD; 18 | void *buffer; 19 | NSUInteger bufferSize; 20 | } 21 | 22 | - (id)initWithFilePath:(NSString *)filePath forConnection:(HTTPConnection *)connection; 23 | - (NSString *)filePath; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/Xcode-Configurations/Base.xcconfig: -------------------------------------------------------------------------------- 1 | // Common Settings 2 | ALWAYS_SEARCH_USER_PATHS = NO 3 | GCC_PRECOMPILE_PREFIX_HEADER = YES 4 | GCC_C_LANGUAGE_STANDARD = c99 5 | GCC_ENABLE_CPP_EXCEPTIONS = NO 6 | GCC_ENABLE_CPP_RTTI = NO 7 | 8 | // Common Warnings 9 | GCC_WARN_SHADOW = YES 10 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES 11 | GCC_WARN_ABOUT_RETURN_TYPE = YES 12 | GCC_WARN_MISSING_PARENTHESES = YES 13 | GCC_WARN_UNUSED_VARIABLE = YES 14 | WARNING_CFLAGS = -Wall -Winline 15 | 16 | // iOS SDK 17 | CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer 18 | 19 | 20 | -------------------------------------------------------------------------------- /Shared/System Additions/NSResponder+TBAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSResponder+TBAdditions.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 8/11/13. 6 | // Copyright (c) 2013 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "NSResponder+TBAdditions.h" 11 | #import "TBMacros.h" 12 | 13 | @implementation NSResponder (TBAdditions) 14 | 15 | - (void)tb_presentErrorOnMainQueue:(NSError *)error { 16 | MAWeakSelfDeclare(); 17 | dispatch_async(dispatch_get_main_queue(), ^{ 18 | MAWeakSelfImport(); 19 | [self presentError:error]; 20 | }); 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Mac App/Scripting/Example Script.applescript: -------------------------------------------------------------------------------- 1 | tell application "Tribo" 2 | 3 | -- The basic Tribo object structure -- 4 | 5 | set theDocument to the document named "Blog.tribo" 6 | set theSite to the site of theDocument 7 | set thePost to the first post of theSite 8 | 9 | -- Tribo text can be accessed and parsed using the Text Suit commands -- 10 | 11 | get first paragraph of the markdown content of thePost 12 | 13 | -- Document previewing can be started and stopped using commands in either format -- 14 | 15 | start preview of theDocument 16 | tell theDocument to stop preview 17 | 18 | end tell -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 |
10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBPostsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPostsViewController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/24/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBViewController.h" 11 | #import 12 | 13 | @interface TBPostsViewController : TBViewController 14 | @property (nonatomic, assign) IBOutlet NSTableView *postTableView; 15 | - (IBAction)editPost:(id)sender; 16 | - (IBAction)previewPost:(id)sender; 17 | - (IBAction)revealPost:(id)sender; 18 | @end 19 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/Web/WebSocketTest2.js: -------------------------------------------------------------------------------- 1 | function WebSocketTest2() 2 | { 3 | if ("WebSocket" in window) 4 | { 5 | var ws = new WebSocket("%%WEBSOCKET_URL%%"); 6 | ws.onopen = function() 7 | { 8 | // Web Socket is connected 9 | alert("websocket is open"); 10 | 11 | // You can send data now 12 | ws.send("Hey man, you got the time?"); 13 | }; 14 | ws.onmessage = function(evt) { alert("received: " + evt.data); }; 15 | ws.onclose = function() { alert("websocket is closed"); }; 16 | } 17 | else 18 | { 19 | alert("Browser doesn't support WebSocket!"); 20 | } 21 | } -------------------------------------------------------------------------------- /Mac App/Views/TBTabView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBTabView.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/29/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | @protocol TBTabViewDelegate; 11 | 12 | @interface TBTabView : NSView 13 | @property (nonatomic, strong) NSArray *titles; 14 | @property (nonatomic, assign) NSUInteger selectedIndex; 15 | @property (nonatomic, unsafe_unretained) IBOutlet id delegate; 16 | @end 17 | 18 | @protocol TBTabViewDelegate 19 | - (void)tabView:(TBTabView *)tabView didSelectIndex:(NSUInteger)index; 20 | @end 21 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/Web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SimpleWebSocketServer 4 | 5 | 6 | 7 | 8 | 9 | 10 | Does my browser support WebSockets?
11 |
12 |
13 | Server Time 14 | not updated yet 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Default.tribo/Templates/Feed.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{name}} 4 | 5 | 6 | {{XMLDate}} 7 | {{baseURL}} 8 | 9 | {{author}} 10 | 11 | {{#posts}} 12 | 13 | {{title}} 14 | 15 | {{XMLDate}} 16 | {{site.baseURL}}{{relativeURL}} 17 | {{content}} 18 | 19 | {{/posts}} 20 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/HTTPResponseTest.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPResponse.h" 3 | 4 | @class HTTPConnection; 5 | 6 | // 7 | // This class is a UnitTest for the delayResponseHeaders capability of HTTPConnection 8 | // 9 | 10 | @interface HTTPResponseTest : NSObject 11 | { 12 | // Parents retain children, children do NOT retain parents 13 | 14 | __unsafe_unretained HTTPConnection *connection; 15 | dispatch_queue_t responseQueue; 16 | 17 | BOOL readyToSendResponseHeaders; 18 | } 19 | 20 | - (id)initWithConnection:(HTTPConnection *)connection; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Mac App/TBSiteDocument.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSiteDocument.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/3/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | typedef void(^TBSiteDocumentPreviewCallback)(NSURL *localURL, NSError *error); 11 | 12 | @class TBSite, TBHTTPServer; 13 | 14 | @interface TBSiteDocument : NSDocument 15 | @property (nonatomic, strong) TBSite *site; 16 | @property (nonatomic, strong) TBHTTPServer *server; 17 | @property (readonly) BOOL previewIsRunning; 18 | - (void)startPreview:(TBSiteDocumentPreviewCallback)callback; 19 | - (void)stopPreview; 20 | @end 21 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/DDKeychain.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface DDKeychain : NSObject 5 | { 6 | 7 | } 8 | 9 | + (NSString *)passwordForHTTPServer; 10 | + (BOOL)setPasswordForHTTPServer:(NSString *)password; 11 | 12 | + (void)createNewIdentity; 13 | + (NSArray *)SSLIdentityAndCertificates; 14 | 15 | + (NSString *)applicationTemporaryDirectory; 16 | + (NSString *)stringForSecExternalFormat:(SecExternalFormat)extFormat; 17 | + (NSString *)stringForSecExternalItemType:(SecExternalItemType)itemType; 18 | + (NSString *)stringForSecKeychainAttrType:(SecKeychainAttrType)attrType; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBHTTPServer.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBHTTPServer.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/24/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBHTTPServer.h" 10 | #import "TBSocketConnection.h" 11 | #import "TBWebSocket.h" 12 | 13 | @implementation TBHTTPServer 14 | - (id)init { 15 | self = [super init]; 16 | if (self) { 17 | self.connectionClass = [TBSocketConnection class]; 18 | } 19 | return self; 20 | } 21 | - (void)refreshPages { 22 | for (TBWebSocket *webSocket in webSockets) { 23 | [webSocket sendMessage:@"{ \"command\": \"reload\", \"path\": \"/\", \"liveCSS\": true }"]; 24 | } 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBViewController.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/21/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBViewController.h" 11 | 12 | @implementation TBViewController 13 | 14 | - (id)init { 15 | NSString *nibName = [self defaultNibName]; 16 | self = [super initWithNibName:nibName bundle:[NSBundle mainBundle]]; 17 | return self; 18 | } 19 | 20 | - (NSString *)defaultNibName { 21 | return [self className]; 22 | } 23 | 24 | - (void)viewDidLoad {} 25 | 26 | - (void)loadView { 27 | [super loadView]; 28 | [self viewDidLoad]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/DDKeychain.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface DDKeychain : NSObject 5 | { 6 | 7 | } 8 | 9 | + (NSString *)passwordForHTTPServer; 10 | + (BOOL)setPasswordForHTTPServer:(NSString *)password; 11 | 12 | + (void)createNewIdentity; 13 | + (NSArray *)SSLIdentityAndCertificates; 14 | 15 | + (NSString *)applicationTemporaryDirectory; 16 | + (NSString *)stringForSecExternalFormat:(SecExternalFormat)extFormat; 17 | + (NSString *)stringForSecExternalItemType:(SecExternalItemType)itemType; 18 | + (NSString *)stringForSecKeychainAttrType:(SecKeychainAttrType)attrType; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Mac App/Scripting/TBPost+Scripting.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBPost+Scripting.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/7/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBPost+Scripting.h" 10 | #import "TBSite+Scripting.h" 11 | 12 | @implementation TBPost (Scripting) 13 | - (NSScriptObjectSpecifier *)objectSpecifier { 14 | return [self.site objectSpecifierForPost:self]; 15 | } 16 | - (NSTextStorage *)markdownContentForScripting { 17 | return [[NSTextStorage alloc] initWithString:self.markdownContent]; 18 | } 19 | - (NSTextStorage *)HTMLContentForScripting { 20 | return [[NSTextStorage alloc] initWithString:self.content]; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m: -------------------------------------------------------------------------------- 1 | #import "HTTPErrorResponse.h" 2 | 3 | @implementation HTTPErrorResponse 4 | 5 | -(id)initWithErrorCode:(int)httpErrorCode 6 | { 7 | if ((self = [super init])) 8 | { 9 | _status = httpErrorCode; 10 | } 11 | 12 | return self; 13 | } 14 | 15 | - (UInt64) contentLength { 16 | return 0; 17 | } 18 | 19 | - (UInt64) offset { 20 | return 0; 21 | } 22 | 23 | - (void)setOffset:(UInt64)offset { 24 | ; 25 | } 26 | 27 | - (NSData*) readDataOfLength:(NSUInteger)length { 28 | return nil; 29 | } 30 | 31 | - (BOOL) isDone { 32 | return YES; 33 | } 34 | 35 | - (NSInteger) status { 36 | return _status; 37 | } 38 | @end 39 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBWebSocket.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBWebSocket.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/24/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBWebSocket.h" 10 | 11 | @implementation TBWebSocket 12 | 13 | - (void)didOpen { 14 | NSString *helloMessage = @"{ \"command\": \"hello\", \"protocols\": [\"http://livereload.com/protocols/official-7\", \"http://livereload.com/protocols/official-8\", \"http://livereload.com/protocols/2.x-origin-version-negotiation\"], \"serverName\": \"Tribo\" }"; 15 | [self sendMessage:helloMessage]; 16 | } 17 | 18 | - (void)didReceiveMessage:(NSString *)message { 19 | 20 | } 21 | 22 | - (void)didClose { 23 | 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBStatusViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBStatusViewController.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/13/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBStatusViewController.h" 11 | 12 | @interface TBStatusViewController () 13 | - (IBAction)openLink:(id)sender; 14 | - (IBAction)stop:(id)sender; 15 | @end 16 | 17 | @implementation TBStatusViewController 18 | 19 | - (NSString *)defaultNibName { 20 | return @"TBStatusView"; 21 | } 22 | 23 | - (IBAction)openLink:(id)sender { 24 | [[NSWorkspace sharedWorkspace] openURL:self.link]; 25 | } 26 | 27 | - (IBAction)stop:(id)sender { 28 | if (self.stopHandler) self.stopHandler(); 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Default.tribo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TBSiteAuthor 6 | Author 7 | TBSiteBaseURL 8 | 9 | TBSiteName 10 | Site Name 11 | TBSiteNumberOfRecentPosts 12 | 5 13 | TBSitePort 14 | 15 | TBSiteProtocol 16 | TBSiteProtocolSFTP 17 | TBSiteRemotePathKey 18 | 19 | TBSiteServer 20 | 21 | TBSiteUserName 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/MyWebSocket.m: -------------------------------------------------------------------------------- 1 | #import "MyWebSocket.h" 2 | #import "HTTPLogging.h" 3 | 4 | // Log levels: off, error, warn, info, verbose 5 | // Other flags : trace 6 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN | HTTP_LOG_FLAG_TRACE; 7 | 8 | 9 | @implementation MyWebSocket 10 | 11 | - (void)didOpen 12 | { 13 | HTTPLogTrace(); 14 | 15 | [super didOpen]; 16 | } 17 | 18 | - (void)didReceiveMessage:(NSString *)msg 19 | { 20 | HTTPLogTrace2(@"%@[%p]: didReceiveMessage: %@", THIS_FILE, self, msg); 21 | 22 | [self sendMessage:[NSString stringWithFormat:@"%@", [NSDate date]]]; 23 | } 24 | 25 | - (void)didClose 26 | { 27 | HTTPLogTrace(); 28 | 29 | [super didClose]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Shared/Template Additions/TBPost+TemplateAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPost+TemplateAdditions.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 5/13/13. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | // 11 | // Template additions contain properties designed to be accessed by templates. 12 | // No configuration "hooks" are provided, so all properties should be generated 13 | // lazily, caching anything expensive like date formatters. 14 | // 15 | 16 | #import "TBPost.h" 17 | 18 | @interface TBPost (TemplateAdditions) 19 | @property (readonly) NSString *dateString; 20 | @property (readonly) NSString *XMLDate; 21 | @property (readonly) NSString *summary; 22 | @property (readonly) NSString *relativeURL; 23 | @end 24 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/MyWebSocket.m: -------------------------------------------------------------------------------- 1 | #import "MyWebSocket.h" 2 | #import "HTTPLogging.h" 3 | 4 | // Log levels: off, error, warn, info, verbose 5 | // Other flags : trace 6 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN | HTTP_LOG_FLAG_TRACE; 7 | 8 | 9 | @implementation MyWebSocket 10 | 11 | - (void)didOpen 12 | { 13 | HTTPLogTrace(); 14 | 15 | [super didOpen]; 16 | 17 | [self sendMessage:@"Welcome to my WebSocket"]; 18 | } 19 | 20 | - (void)didReceiveMessage:(NSString *)msg 21 | { 22 | HTTPLogTrace2(@"%@[%p]: didReceiveMessage: %@", THIS_FILE, self, msg); 23 | 24 | [self sendMessage:[NSString stringWithFormat:@"%@", [NSDate date]]]; 25 | } 26 | 27 | - (void)didClose 28 | { 29 | HTTPLogTrace(); 30 | 31 | [super didClose]; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This example project demonstrates the ability of the HTTPDynamicFileResponse to easily create dynamic content. 4 | 5 | Take a look at the Web/index.html file. You'll notice a bunch of "%%PLACEHOLDERS%%" meant to be replaced dynamically. With only a few lines of code, the HTTPDynamicFileResponse will replace these automatically, and asynchronously, as the file gets uploaded to the client! 6 | 7 | INSTRUCTIONS: 8 | 9 | Open the Xcode project, and build and go. 10 | 11 | On the Xcode console you'll see a message saying: 12 | "Started HTTP server on port 59123" 13 | 14 | Now open your browser and type in the URL: 15 | http://localhost:59123 16 | 17 | (Replace 59123 with whatever port the server is actually running on.) 18 | 19 | Enjoy. -------------------------------------------------------------------------------- /Default.tribo/Source/stylesheets/post.css: -------------------------------------------------------------------------------- 1 | .post { 2 | display: block; 3 | } 4 | .post-header { margin-bottom: -15px; } 5 | .date { 6 | float:right; 7 | font-size: 14px; 8 | } 9 | .date a { 10 | color: black; 11 | } 12 | .post-content { 13 | font-size: 12pt; 14 | font-family: 'Georgia', Georgia, Times, serif; 15 | } 16 | .post-content img { 17 | border: 5px solid #e5e5e5; 18 | padding: 5px; 19 | margin: 5px; 20 | } 21 | .right { 22 | display: block; 23 | float: right; 24 | } 25 | .center { 26 | text-align: center; 27 | } 28 | .continue-reading { 29 | float: right; 30 | margin: 15px 0px 0px 0px; 31 | font-size: 14px; 32 | font-style: italic; 33 | text-align: right; 34 | } 35 | .continue-reading a { text-decoration: none; } 36 | .continue-reading a:hover { text-decoration: underline } -------------------------------------------------------------------------------- /Default.tribo/Source/index.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{#site.recentPosts}} 5 | 17 |

~

18 | {{/site.recentPosts}} 19 | 20 | {{^site.recentPosts}} 21 |

0 posts

22 | {{/site.recentPosts}} 23 | 24 |
25 | Archives » 26 |
-------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | //----------------------------------------------------------------- 5 | // interface MultipartMessageHeaderField 6 | //----------------------------------------------------------------- 7 | 8 | @interface MultipartMessageHeaderField : NSObject { 9 | NSString* name; 10 | NSString* value; 11 | NSMutableDictionary* params; 12 | } 13 | 14 | @property (strong, readonly) NSString* value; 15 | @property (strong, readonly) NSDictionary* params; 16 | @property (strong, readonly) NSString* name; 17 | 18 | //- (id) initWithLine:(NSString*) line; 19 | //- (id) initWithName:(NSString*) paramName value:(NSString*) paramValue; 20 | 21 | - (id) initWithData:(NSData*) data contentEncoding:(NSStringEncoding) encoding; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This is an extremely simplified example of accepting a POST. 4 | 5 | The included Web folder is added to the project, copied into the applications resource bundle, and set as the document root of the http server. It only has a single index.html file which prompts you to answer a simple math question. Your answer is submitted as a post. 6 | 7 | The MyHTTPConnection class reads your response, and dynamically generates the response. 8 | 9 | INSTRUCTIONS: 10 | 11 | Open the Xcode project, and build and go. 12 | 13 | On the Xcode console you'll see a message saying: 14 | "Started HTTP server on port 59123" 15 | 16 | Now open your browser and type in the URL: 17 | http://localhost:59123 18 | 19 | (Replace 59123 with whatever port the server is actually running on.) 20 | 21 | Enjoy. -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | Tribo is a collaborative effort of the following people (the "Tribo Authors"): 2 | 3 | - J. Carter Allen 4 | - Samuel Goodwin 5 | 6 | Copyright of all project assets is held collectively by the Tribo Authors. 7 | 8 | ----- 9 | 10 | Copyright 2012 The Tribo Authors 11 | 12 | Licensed under the Apache License, Version 2.0 (the "License"); 13 | you may not use the files in this project except in compliance with the License. 14 | You may obtain a copy of the License at 15 | 16 | http://www.apache.org/licenses/LICENSE-2.0 17 | 18 | Unless required by applicable law or agreed to in writing, software 19 | distributed under the License is distributed on an "AS IS" BASIS, 20 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | See the License for the specific language governing permissions and 22 | limitations under the License. -------------------------------------------------------------------------------- /Mac App/Resources/Tribo.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.bookmarks.app-scope 8 | 9 | com.apple.security.files.user-selected.read-write 10 | 11 | com.apple.security.network.client 12 | 13 | com.apple.security.network.server 14 | 15 | com.apple.security.temporary-exception.apple-events 16 | 17 | com.apple.safari 18 | 19 | com.apple.security.temporary-exception.mach-lookup.global-name 20 | 21 | com.apple.UNCUserNotification 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #if TARGET_OS_IPHONE 4 | #import 5 | #endif 6 | 7 | @class HTTPMessage; 8 | 9 | @interface HTTPAuthenticationRequest : NSObject 10 | 11 | - (id)initWithRequest:(HTTPMessage *)request; 12 | 13 | @property (readonly, getter = isBasic) BOOL basic; 14 | @property (readonly, getter = isDigest) BOOL digest; 15 | 16 | // Basic 17 | @property (readonly) NSString *base64Credentials; 18 | 19 | // Digest 20 | @property (readonly) NSString *username; 21 | @property (readonly) NSString *realm; 22 | @property (readonly) NSString *nonce; 23 | @property (readonly) NSString *URI; 24 | @property (readonly) NSString *qualityOfProtection; 25 | @property (readonly) NSString *nonceCount; 26 | @property (readonly) NSString *cnonce; 27 | @property (readonly) NSString *response; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This example project demonstrates support for WebSockets. 4 | 5 | The sample includes a Web folder which is added to the project, copied into the application's resources folder, and is set as the document root of the http server. It contains a simple index.html file and the client-side code (run in the web browser) for the websocket stuff. 6 | 7 | Take a look at the MyWebSocket class to see the related server code. 8 | 9 | INSTRUCTIONS: 10 | 11 | Open the Xcode project, and build and go. 12 | 13 | On the Xcode console you'll see a message saying: 14 | "Started HTTP server on port 59123" 15 | 16 | Now open a browser that supports WebSockets (e.g. Google Chrome or Safari) 17 | and type in the URL: 18 | http://localhost:59123 19 | 20 | (Replace 59123 with whatever port the server is actually running on.) 21 | 22 | Enjoy. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleVersion 18 | 1.0 19 | NSMainNibFile 20 | MainMenu 21 | NSPrincipalClass 22 | NSApplication 23 | 24 | 25 | -------------------------------------------------------------------------------- /Shared/Template Additions/TBSite+TemplateAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSite+TemplateAdditions.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 5/11/13. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | // 11 | // Template additions contain properties designed to be accessed by templates. 12 | // No configuration "hooks" are provided, so all properties should be generated 13 | // lazily, caching anything expensive like date formatters. 14 | // 15 | 16 | #import "TBSite.h" 17 | 18 | @class TBPost; 19 | 20 | @interface TBSite (TemplateAdditions) 21 | @property (nonatomic, readonly) TBPost *latestPost; 22 | @property (nonatomic, readonly) NSArray *recentPosts; 23 | @property (nonatomic, readonly) NSString *XMLDate; 24 | @property (nonatomic, readonly) NSString *name; 25 | @property (nonatomic, readonly) NSString *author; 26 | @property (nonatomic, readonly) NSString *baseURL; 27 | @end 28 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBSiteWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBSiteWindowController.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/21/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | @class TBViewController, TBAddPostSheetController; 11 | 12 | @interface TBSiteWindowController : NSWindowController 13 | @property (nonatomic, strong) NSArray *viewControllers; 14 | @property (readonly) TBViewController *selectedViewController; 15 | @property (nonatomic, assign) NSUInteger selectedViewControllerIndex; 16 | 17 | - (IBAction)switchToPosts:(id)sender; 18 | - (IBAction)switchToTemplates:(id)sender; 19 | - (IBAction)switchToSources:(id)sender; 20 | 21 | - (IBAction)showAddPostSheet:(id)sender; 22 | 23 | - (IBAction)showActionMenu:(id)sender; 24 | - (IBAction)preview:(id)sender; 25 | - (IBAction)publish:(id)sender; 26 | - (IBAction)showSettingsSheet:(id)sender; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Mac App/Publishing/TBPublisher.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPublisher.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/28/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | @class TBSite; 13 | 14 | typedef void(^TBPublisherProgressHandler)(NSInteger progress, NSInteger total); 15 | typedef void(^TBPublisherCompletionHandler)(); 16 | typedef void(^TBPublisherErrorHandler)(NSError *error); 17 | 18 | @interface TBPublisher : NSObject 19 | 20 | @property (nonatomic, strong) TBSite *site; 21 | 22 | @property (nonatomic, copy) TBPublisherProgressHandler progressHandler; 23 | @property (nonatomic, copy) TBPublisherCompletionHandler completionHandler; 24 | @property (nonatomic, copy) TBPublisherErrorHandler errorHandler; 25 | 26 | + (instancetype)publisherWithSite:(TBSite *)site; 27 | - (instancetype)initWithSite:(TBSite *)site; 28 | - (void)publish; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Default.tribo/Templates/Default.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{site/name}} - {{title}} 7 | 8 | 9 | 10 | 11 | 12 | {{#stylesheets}} 13 | 14 | {{/stylesheets}} 15 | 16 | 17 | 18 | {{{livereload}}} 19 | 20 | 21 | 22 |
23 |
24 | 25 |

{{site.name}}

26 |
27 |

By {{site.author}}

28 |
29 |
{{{content}}}
30 |
31 |

Copyright 2012 {{site.author}}

32 |
33 |
34 | 35 | 36 | 37 | 40 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.SimpleHTTPServer 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/iPhoneHTTPServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /Shared/TBConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBConstants.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/7/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import 11 | 12 | extern NSString * const TBSiteNameMetadataKey; 13 | extern NSString * const TBSiteAuthorMetadataKey; 14 | extern NSString * const TBSiteBaseURLMetadataKey; 15 | extern NSString * const TBSiteNumberOfRecentPostsMetadataKey; 16 | 17 | extern NSString * const TBSiteProtocolKey; 18 | extern NSString * const TBSiteProtocolFTP; 19 | extern NSString * const TBSiteProtocolSFTP; 20 | extern NSString * const TBSiteProtocolCloudflare; 21 | extern NSString * const TBSiteServerKey; 22 | extern NSString * const TBSitePortKey; // Not a teleportation device 23 | extern NSString * const TBSiteUserNameKey; 24 | extern NSString * const TBSiteRemotePathKey; 25 | 26 | extern NSString * const TBSiteFilters; 27 | 28 | extern NSString * const TBSiteIdentityFileEnvironmentKey; 29 | extern NSString * const TBSiteEnvironmentKey; 30 | extern NSString * const TBSiteCurrentFileEnvironmentKey; 31 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBShadowedTextFieldCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBShadowedTextFieldCell.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/17/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBShadowedTextFieldCell.h" 11 | 12 | @implementation TBShadowedTextFieldCell 13 | 14 | - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { 15 | NSColor *shadowColor = self.aquaShadowColor; 16 | if ([NSColor currentControlTint] == NSGraphiteControlTint) 17 | shadowColor = self.graphiteShadowColor; 18 | if (!controlView.window.isKeyWindow) 19 | shadowColor = [shadowColor highlightWithLevel:0.3]; 20 | NSShadow *shadow = [NSShadow new]; 21 | shadow.shadowOffset = NSMakeSize(0.0, -1.0); 22 | shadow.shadowBlurRadius = 0.0; 23 | shadow.shadowColor = shadowColor; 24 | [shadow set]; 25 | [super drawInteriorWithFrame:cellFrame inView:controlView]; 26 | } 27 | 28 | - (NSSize)cellSizeForBounds:(NSRect)aRect { 29 | NSSize cellSize = [super cellSizeForBounds:aRect]; 30 | cellSize.height += 1.0; 31 | return cellSize; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Shared/System Additions/NSDateFormatter+TBAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateFormatter+TBAdditions.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 6/15/13. 6 | // Copyright (c) 2013 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSDateFormatter+TBAdditions.h" 10 | 11 | NSString * const TBDateFormatterCachePrefix = @"TBDateFormatter:"; 12 | 13 | @implementation NSDateFormatter (TBAdditions) 14 | 15 | + (instancetype)tb_cachedDateFormatterFromString:(NSString *)format { 16 | NSString *cacheKey = [TBDateFormatterCachePrefix stringByAppendingString:format]; 17 | NSDateFormatter *dateFormatter = [[self tb_dateFormatterCache] objectForKey:cacheKey]; 18 | if (!dateFormatter) { 19 | dateFormatter = [NSDateFormatter new]; 20 | dateFormatter.dateFormat = format; 21 | [[self tb_dateFormatterCache] setObject:dateFormatter forKey:cacheKey]; 22 | } 23 | return dateFormatter; 24 | } 25 | 26 | + (NSCache *)tb_dateFormatterCache { 27 | static NSCache *TBDateFormatterCache; 28 | if (!TBDateFormatterCache) 29 | TBDateFormatterCache = [NSCache new]; 30 | return TBDateFormatterCache; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/Web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dynamic Server Example 4 | 5 | 6 |

7 | Welcome to CocoaHTTPServer! 8 |

9 | 10 |

11 | Parts of this file are generated dynamically.
12 | This is done via the HTTPDynamicFileResponse class.
13 | It uses a replacement dictionary to automatically replace
14 | tagged strings in the included Web/index.html file.
15 |

16 | 17 |

18 | Computer name: %%COMPUTER_NAME%%
19 |
20 | 21 | 22 | The current time is: %%TIME%%
23 |
24 | Tell me a story: %%STORY%%
25 |
26 | 27 | 28 | The first letter of the english alphabet: %%ALPHABET%%
29 |
30 | 31 | 32 | The sound a duck makes: %%QUACK%%
33 |
34 |
35 | Thank you. Come again. 36 |

37 | 38 | 39 | -------------------------------------------------------------------------------- /Shared/en.lproj/TBError.strings: -------------------------------------------------------------------------------- 1 | /* 2 | TBError.strings (English) 3 | Tribo 4 | 5 | Created by Carter Allen on 7/27/13. 6 | Copyright (c) 2013 The Tribo Authors. 7 | See the included License.md file. 8 | */ 9 | 10 | "MISSING_POSTS_DIRECTORY" = "Tribo requires a posts directory for every site. It couldn't be either found or read at the following path: %@"; 11 | 12 | "MISSING_POSTS_PARTIAL" = "Tribo requires a post template file for every site. It couldn't be either found or read at the following path: %@"; 13 | 14 | "BAD_POST_FILE_NAME" = "Tribo uses the file name of a post to derive its publishing date and slug. The post at path %@ does not have a file name beginning with a date in the format \"YYYY-MM-DD\", followed by a dash ('-'), then a slug."; 15 | 16 | "MISSING_SOURCE_DIRECTORY" = "Tribo requires a source directory for every site. It couldn't be either found or read at the following path: %@"; 17 | 18 | "FILTER_STANDARD_ERROR" = "The custom filter at path %@ logged the following information into its stderr pipe: %@"; 19 | 20 | "EMPTY_PAGE_FILE" = "Tribo does not support empty page files. The following page file is empty: %@"; 21 | -------------------------------------------------------------------------------- /Dependencies/CZAFileWatcher/License.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Carter Allen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/WebDAVServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "DDLog.h" 3 | #import "DDTTYLogger.h" 4 | #import "HTTPServer.h" 5 | #import "DAVConnection.h" 6 | 7 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 8 | 9 | @implementation AppDelegate 10 | 11 | - (void) applicationDidFinishLaunching:(NSNotification*)notification { 12 | // Configure logging system 13 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 14 | 15 | // Create DAV server 16 | _httpServer = [[HTTPServer alloc] init]; 17 | [_httpServer setConnectionClass:[DAVConnection class]]; 18 | [_httpServer setPort:8080]; 19 | 20 | // Enable Bonjour 21 | [_httpServer setType:@"_http._tcp."]; 22 | 23 | // Set document root 24 | [_httpServer setDocumentRoot:[@"~/Sites" stringByExpandingTildeInPath]]; 25 | 26 | // Start DAV server 27 | NSError* error = nil; 28 | if (![_httpServer start:&error]) { 29 | DDLogError(@"Error starting HTTP Server: %@", error); 30 | } 31 | } 32 | 33 | - (void) applicationWillTerminate:(NSNotification*)notification { 34 | // Stop DAV server 35 | [_httpServer stop]; 36 | _httpServer = nil; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/DynamicServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MultipartMessagePart.h 3 | // HttpServer 4 | // 5 | // Created by Валерий Гаврилов on 29.03.12. 6 | // Copyright (c) 2012 LLC "Online Publishing Partners" (onlinepp.ru). All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | //----------------------------------------------------------------- 13 | // interface MultipartMessageHeader 14 | //----------------------------------------------------------------- 15 | enum { 16 | contentTransferEncoding_unknown, 17 | contentTransferEncoding_7bit, 18 | contentTransferEncoding_8bit, 19 | contentTransferEncoding_binary, 20 | contentTransferEncoding_base64, 21 | contentTransferEncoding_quotedPrintable, 22 | }; 23 | 24 | @interface MultipartMessageHeader : NSObject { 25 | NSMutableDictionary* fields; 26 | int encoding; 27 | NSString* contentDispositionName; 28 | } 29 | @property (strong,readonly) NSDictionary* fields; 30 | @property (readonly) int encoding; 31 | 32 | - (id) initWithData:(NSData*) data formEncoding:(NSStringEncoding) encoding; 33 | @end 34 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/MyHTTPConnection.m: -------------------------------------------------------------------------------- 1 | #import "MyHTTPConnection.h" 2 | #import "HTTPLogging.h" 3 | #import "DDKeychain.h" 4 | 5 | // Log levels: off, error, warn, info, verbose 6 | // Other flags: trace 7 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE; 8 | 9 | 10 | @implementation MyHTTPConnection 11 | 12 | /** 13 | * Overrides HTTPConnection's method 14 | **/ 15 | - (BOOL)isSecureServer 16 | { 17 | HTTPLogTrace(); 18 | 19 | // Create an HTTPS server (all connections will be secured via SSL/TLS) 20 | return YES; 21 | } 22 | 23 | /** 24 | * Overrides HTTPConnection's method 25 | * 26 | * This method is expected to returns an array appropriate for use in kCFStreamSSLCertificates SSL Settings. 27 | * It should be an array of SecCertificateRefs except for the first element in the array, which is a SecIdentityRef. 28 | **/ 29 | - (NSArray *)sslIdentityAndCertificates 30 | { 31 | HTTPLogTrace(); 32 | 33 | NSArray *result = [DDKeychain SSLIdentityAndCertificates]; 34 | if([result count] == 0) 35 | { 36 | [DDKeychain createNewIdentity]; 37 | return [DDKeychain SSLIdentityAndCertificates]; 38 | } 39 | return result; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/SimpleWebSocketServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleShortVersionString 22 | 1.0 23 | LSMinimumSystemVersion 24 | ${MACOSX_DEPLOYMENT_TARGET} 25 | CFBundleVersion 26 | 1 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Mac App/HTTP Server/TBSocketConnection.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBSocketConnection.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/24/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBSocketConnection.h" 10 | #import "TBWebSocket.h" 11 | #import "HTTPDataResponse.h" 12 | 13 | @interface TBSocketConnection () 14 | @property (nonatomic, strong) WebSocket *socket; 15 | @end 16 | 17 | @implementation TBSocketConnection 18 | 19 | - (WebSocket *)webSocketForURI:(NSString *)path { 20 | if ([path isEqualToString:@"/livereload"]) { 21 | self.socket = [[TBWebSocket alloc] initWithRequest:request socket:asyncSocket]; 22 | return self.socket; 23 | } 24 | return [super webSocketForURI:path]; 25 | } 26 | 27 | - (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path { 28 | 29 | if ([path hasPrefix:@"/livereload.js"]) { 30 | NSString *liveReloadJS = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"TBLiveReloadJS"]; 31 | return [[HTTPDataResponse alloc] initWithData:[liveReloadJS dataUsingEncoding:NSUTF8StringEncoding]]; 32 | } 33 | 34 | return [super httpResponseForMethod:method URI:path]; 35 | 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Mac App/Scripting/TBSite+Scripting.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBSite+Scripting.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/7/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBSite+Scripting.h" 10 | 11 | @implementation TBSite (Scripting) 12 | - (NSScriptObjectSpecifier *)objectSpecifierForPost:(TBPost *)post { 13 | NSScriptObjectSpecifier *postSpecifier = nil; 14 | NSUInteger postIndex = [self.posts indexOfObject:post]; 15 | if (postIndex != NSNotFound) { 16 | NSScriptObjectSpecifier *siteSpecifier = self.objectSpecifier; 17 | postSpecifier = [[NSIndexSpecifier alloc] initWithContainerClassDescription:[siteSpecifier keyClassDescription] containerSpecifier:siteSpecifier key:@"posts" index:postIndex]; 18 | } 19 | return postSpecifier; 20 | } 21 | - (NSScriptObjectSpecifier *)objectSpecifier { 22 | NSScriptObjectSpecifier *documentSpecifier = [[[NSDocumentController sharedDocumentController] documentForURL:self.root] objectSpecifier]; 23 | NSPropertySpecifier *siteSpecifier = [[NSPropertySpecifier alloc] initWithContainerClassDescription:documentSpecifier.keyClassDescription containerSpecifier:documentSpecifier key:@"site"]; 24 | return siteSpecifier; 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/SecureWebSocketServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.deusty.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Shared/TBConstants.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBConstants.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/7/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBConstants.h" 11 | 12 | NSString * const TBSiteNameMetadataKey = @"TBSiteName"; 13 | NSString * const TBSiteAuthorMetadataKey = @"TBSiteAuthor"; 14 | NSString * const TBSiteBaseURLMetadataKey = @"TBSiteBaseURL"; 15 | NSString * const TBSiteNumberOfRecentPostsMetadataKey = @"TBSiteNumberOfRecentPosts"; 16 | 17 | NSString * const TBSiteProtocolKey = @"TBSiteProtocol"; 18 | NSString * const TBSiteProtocolFTP = @"TBSiteProtocolFTP"; 19 | NSString * const TBSiteProtocolSFTP = @"TBSiteProtocolSFTP"; 20 | NSString * const TBSiteProtocolCloudflare = @"TBSiteProtocolCloudflare"; 21 | NSString * const TBSiteServerKey = @"TBSiteServer"; 22 | NSString * const TBSitePortKey = @"TBSitePort"; 23 | NSString * const TBSiteUserNameKey = @"TBSiteUserName"; 24 | NSString * const TBSiteRemotePathKey = @"TBSiteRemotePathKey"; 25 | 26 | NSString * const TBSiteFilters = @"TBSiteFilters"; 27 | 28 | NSString * const TBSiteIdentityFileEnvironmentKey = @"TB_IDENTITY_FILE"; 29 | NSString * const TBSiteCurrentFileEnvironmentKey = @"TBSiteCurrentFileEnvironmentKey"; 30 | -------------------------------------------------------------------------------- /Dependencies/CZAFileWatcher/watch-file.m: -------------------------------------------------------------------------------- 1 | // 2 | // watch-file.m 3 | // CZAFileWatcher 4 | // 5 | // Created by Carter Allen on 8/7/13. 6 | // Copyright (c) 2013 Carter Allen. 7 | // 8 | // Released under the MIT License. 9 | // See the included License.md file for details. 10 | // 11 | 12 | #import 13 | #import "CZAFileWatcher.h" 14 | 15 | int main(int argc, const char * argv[]) { 16 | 17 | @autoreleasepool { 18 | 19 | if (argc < 2) { 20 | printf("watch-file requires one or more file paths as arguments.\n"); 21 | return EXIT_FAILURE; 22 | } 23 | 24 | NSMutableArray *URLs = [NSMutableArray arrayWithCapacity:argc - 1]; 25 | for (NSUInteger index = 1; index < argc; index++) { 26 | NSString *path = [NSString stringWithUTF8String:argv[index]]; 27 | [URLs addObject:[NSURL fileURLWithPath:[path stringByStandardizingPath]]]; 28 | } 29 | 30 | CZAFileWatcher *watcher = [CZAFileWatcher fileWatcherForURLs:URLs changesHandler:^(NSArray *changedURLs) { 31 | for (NSURL *URL in changedURLs) { 32 | printf("Change detected at path: %s\n", [URL.path UTF8String]); 33 | } 34 | }]; 35 | [watcher startWatching]; 36 | 37 | dispatch_main(); 38 | 39 | } 40 | 41 | return EXIT_SUCCESS; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m: -------------------------------------------------------------------------------- 1 | #import "DELETEResponse.h" 2 | #import "HTTPLogging.h" 3 | 4 | // HTTP methods: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html 5 | // HTTP headers: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 6 | // HTTP status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 7 | 8 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; 9 | 10 | @implementation DELETEResponse 11 | 12 | - (id) initWithFilePath:(NSString*)path { 13 | if ((self = [super init])) { 14 | BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path]; 15 | if ([[NSFileManager defaultManager] removeItemAtPath:path error:NULL]) { 16 | _status = exists ? 200 : 204; 17 | } else { 18 | HTTPLogError(@"Failed deleting \"%@\"", path); 19 | _status = 404; 20 | } 21 | } 22 | return self; 23 | } 24 | 25 | - (UInt64) contentLength { 26 | return 0; 27 | } 28 | 29 | - (UInt64) offset { 30 | return 0; 31 | } 32 | 33 | - (void)setOffset:(UInt64)offset { 34 | ; 35 | } 36 | 37 | - (NSData*) readDataOfLength:(NSUInteger)length { 38 | return nil; 39 | } 40 | 41 | - (BOOL) isDone { 42 | return YES; 43 | } 44 | 45 | - (NSInteger) status { 46 | return _status; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/HTTPMessage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * The HTTPMessage class is a simple Objective-C wrapper around Apple's CFHTTPMessage class. 3 | **/ 4 | 5 | #import 6 | 7 | #if TARGET_OS_IPHONE 8 | #import 9 | #endif 10 | 11 | #define HTTPVersion1_0 ((NSString *)kCFHTTPVersion1_0) 12 | #define HTTPVersion1_1 ((NSString *)kCFHTTPVersion1_1) 13 | 14 | 15 | @interface HTTPMessage : NSObject 16 | 17 | - (id)initEmptyRequest; 18 | - (id)initRequestWithMethod:(NSString *)method URL:(NSURL *)URL version:(NSString *)version; 19 | - (id)initResponseWithStatusCode:(NSInteger)code description:(NSString *)description version:(NSString *)version; 20 | 21 | - (BOOL)appendData:(NSData *)data; 22 | 23 | @property (readonly, getter = isHeaderComplete) BOOL headerComplete; 24 | @property (readonly) NSString *version; 25 | @property (readonly) NSString *method; 26 | @property (readonly) NSURL *URL; 27 | @property (readonly) NSInteger statusCode; 28 | @property (readonly) NSDictionary *allHeaderFields; 29 | @property (readonly) NSData *messageData; 30 | @property (nonatomic, strong) NSData *body; 31 | 32 | - (NSString *)valueForHeaderField:(NSString *)headerField; 33 | - (void)setValue:(NSString *)value forHeaderField:(NSString *)headerField; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/iPhoneHTTPServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This is a bare bones project demonstrating how to embed the CocoaHTTPServer in an iOS project. 4 | 5 | Notice the Web folder. This folder is added to the project as a resource, and the folder itself is copied into the iPhone app. The contents of the folder are set as the document root of the http server. 6 | 7 | Critical note: The server is running only while application is in foreground. As soon as you exit from the application (by switching to another app or locking a device) the server will be stopped. The server will be restarted when you enter the application again. 8 | Read this Apple technical note for the details: http://developer.apple.com/library/ios/#technotes/tn2277/_index.html 9 | 10 | INSTRUCTIONS: 11 | 12 | Open the Xcode project, and build and go. 13 | 14 | On the Xcode console you'll see a message saying: 15 | "Started HTTP server on port 59123" 16 | 17 | Now open your browser and type in the URL to access the server. 18 | If you're running it via the simulator, then you can use: 19 | http://localhost:59123 20 | 21 | If you're running it on your device, then you'll need to use: 22 | http://<local IP of device>:59123 23 | 24 | (Replace 59123 with whatever port the server is actually running on.) 25 | 26 | Enjoy. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/Web/WebSocketTest2.js: -------------------------------------------------------------------------------- 1 | 2 | var ws; 3 | var t; 4 | 5 | function init() 6 | { 7 | document.getElementById('updateme').innerHTML = "connecting to websocket"; 8 | OpenWebSocket(); 9 | } 10 | 11 | function OpenWebSocket() 12 | { 13 | if ("WebSocket" in window) 14 | { 15 | ws = new WebSocket("%%WEBSOCKET_URL%%"); 16 | ws.onopen = function() 17 | { 18 | // Web Socket is connected 19 | 20 | document.getElementById('updateme').innerHTML = "websocket is open"; 21 | 22 | t=setTimeout("SendMessage()",1000); 23 | }; 24 | ws.onmessage = function(evt) 25 | { 26 | document.getElementById('updateme').innerHTML = evt.data; 27 | }; 28 | ws.onclose = function() 29 | { 30 | document.getElementById('updateme').innerHTML = "websocket is closed"; 31 | OpenWebSocket(); 32 | }; 33 | ws.onerror = function(evt) 34 | { 35 | alert("onerror: " + evt); 36 | }; 37 | } 38 | else 39 | { 40 | alert("Browser doesn't support WebSocket!"); 41 | } 42 | } 43 | 44 | function SendMessage() 45 | { 46 | if ("WebSocket" in window) 47 | { 48 | ws.send("time"); 49 | 50 | t=setTimeout("SendMessage()",1000); 51 | } 52 | else 53 | { 54 | alert("Browser doesn't support WebSocket!"); 55 | } 56 | } -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/README.markdown: -------------------------------------------------------------------------------- 1 | CocoaHTTPServer is a small, lightweight, embeddable HTTP server for Mac OS X or iOS applications. 2 | 3 | Sometimes developers need an embedded HTTP server in their app. Perhaps it's a server application with remote monitoring. Or perhaps it's a desktop application using HTTP for the communication backend. Or perhaps it's an iOS app providing over-the-air access to documents. Whatever your reason, CocoaHTTPServer can get the job done. It provides: 4 | 5 | - Built in support for bonjour broadcasting 6 | - IPv4 and IPv6 support 7 | - Asynchronous networking using GCD and standard sockets 8 | - Password protection support 9 | - SSL/TLS encryption support 10 | - Extremely FAST and memory efficient 11 | - Extremely scalable (built entirely upon GCD) 12 | - Heavily commented code 13 | - Very easily extensible 14 | - WebDAV is supported too! 15 | 16 |
17 | Can't find the answer to your question in any of the [wiki](https://github.com/robbiehanson/CocoaHTTPServer/wiki) articles? Try the **[mailing list](http://groups.google.com/group/cocoahttpserver)**. 18 |
19 |
20 | Love the project? Wanna buy me a coffee? (or a beer :D) [![donation](http://www.paypal.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BHF2DJRETGV5S) 21 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | This project demonstrates password protecting a specific resource. More specifically, the project allows unrestricted access to the ~/Sites folder, but requires a password for anything in the ~/Sites/secret/ subfolder. 4 | 5 | INSTRUCTIONS: 6 | 7 | Create the following folder: 8 | ~/Sites/secret 9 | 10 | And then add a file to it. For example: 11 | ~/Sites/secret/doc.txt 12 | 13 | Open the Xcode project, and build and go. 14 | 15 | On the Xcode console you'll see a message saying something like: 16 | "Started HTTP server on port 59123" 17 | 18 | _The actual port the server uses is not hard-coded. You can hard-code it if you want, but by default it will just allow the operating system to provide an available port._ 19 | 20 | Now open your browser and type the URL (replacing with the proper port):
21 | http://localhost:59123 22 | 23 | Notice that it displays your file without password prompt:
24 | ~/Sites/index.html 25 | 26 | Now type the URL (replacing with password prompt):
27 | http://localhost:59123/secret/doc.txt 28 | 29 | Notice that it prompts you for a username/password. 30 | The sample code accepts any username, and the password is "secret". 31 | 32 | (Replace 59123 with whatever port the server is actually running on.) 33 | 34 | Enjoy. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/SimpleFileUploadServer-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | mycompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012 muhtau1@gmail.com. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m: -------------------------------------------------------------------------------- 1 | #import "HTTPRedirectResponse.h" 2 | #import "HTTPLogging.h" 3 | 4 | #if ! __has_feature(objc_arc) 5 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 6 | #endif 7 | 8 | // Log levels : off, error, warn, info, verbose 9 | // Other flags: trace 10 | static const int httpLogLevel = HTTP_LOG_LEVEL_OFF; // | HTTP_LOG_FLAG_TRACE; 11 | 12 | 13 | @implementation HTTPRedirectResponse 14 | 15 | - (id)initWithPath:(NSString *)path 16 | { 17 | if ((self = [super init])) 18 | { 19 | HTTPLogTrace(); 20 | 21 | redirectPath = [path copy]; 22 | } 23 | return self; 24 | } 25 | 26 | - (UInt64)contentLength 27 | { 28 | return 0; 29 | } 30 | 31 | - (UInt64)offset 32 | { 33 | return 0; 34 | } 35 | 36 | - (void)setOffset:(UInt64)offset 37 | { 38 | // Nothing to do 39 | } 40 | 41 | - (NSData *)readDataOfLength:(NSUInteger)length 42 | { 43 | HTTPLogTrace(); 44 | 45 | return nil; 46 | } 47 | 48 | - (BOOL)isDone 49 | { 50 | return YES; 51 | } 52 | 53 | - (NSDictionary *)httpHeaders 54 | { 55 | HTTPLogTrace(); 56 | 57 | return [NSDictionary dictionaryWithObject:redirectPath forKey:@"Location"]; 58 | } 59 | 60 | - (NSInteger)status 61 | { 62 | HTTPLogTrace(); 63 | 64 | return 302; 65 | } 66 | 67 | - (void)dealloc 68 | { 69 | HTTPLogTrace(); 70 | 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Mac App/Publishing/TBPublisher.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBPublisher.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/28/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBPublisher.h" 11 | #import "TBSite.h" 12 | 13 | #import "TBFTPPublisher.h" 14 | #import "TBSFTPPublisher.h" 15 | #import "TBCloudflarePublisher.h" 16 | 17 | @interface TBPlaceholderPublisher : TBPublisher 18 | @end 19 | 20 | @implementation TBPublisher 21 | 22 | + (instancetype)publisherWithSite:(TBSite *)site { 23 | NSString *protocol = (site.metadata)[TBSiteProtocolKey]; 24 | if ([protocol isEqualToString:TBSiteProtocolFTP]) 25 | return [[TBFTPPublisher alloc] initWithSite:site]; 26 | else if ([protocol isEqualToString:TBSiteProtocolSFTP]) 27 | return [[TBSFTPPublisher alloc] initWithSite:site]; 28 | else if ([protocol isEqualToString:TBSiteProtocolCloudflare]) 29 | return [[TBCloudflarePublisher alloc] initWithSite:site]; 30 | [[NSException exceptionWithName:@"TBPublisherUnrecognizedProtocolException" reason:@"The protocol key of the site's metadata dictionary did not contain a valid protocol." userInfo:nil] raise]; 31 | return nil; 32 | } 33 | 34 | - (instancetype)initWithSite:(TBSite *)site { 35 | self = [super init]; 36 | if (self) { 37 | self.site = site; 38 | } 39 | return self; 40 | } 41 | 42 | - (void)publish {} 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import "DDLog.h" 5 | 6 | /** 7 | * Welcome to Cocoa Lumberjack! 8 | * 9 | * The project page has a wealth of documentation if you have any questions. 10 | * https://github.com/robbiehanson/CocoaLumberjack 11 | * 12 | * If you're new to the project you may wish to read the "Getting Started" wiki. 13 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted 14 | * 15 | * 16 | * This class provides a logger for the Apple System Log facility. 17 | * 18 | * As described in the "Getting Started" page, 19 | * the traditional NSLog() function directs it's output to two places: 20 | * 21 | * - Apple System Log 22 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console 23 | * 24 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger. 25 | * However, if you instead choose to use file logging (for faster performance), 26 | * you may choose to use a file logger and a tty logger. 27 | **/ 28 | 29 | @interface DDASLLogger : DDAbstractLogger 30 | { 31 | aslclient client; 32 | } 33 | 34 | + (DDASLLogger *)sharedInstance; 35 | 36 | // Inherited from DDAbstractLogger 37 | 38 | // - (id )logFormatter; 39 | // - (void)setLogFormatter:(id )formatter; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2011, Deusty, LLC 4 | All rights reserved. 5 | 6 | Redistribution and use of this software in source and binary forms, 7 | with or without modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above 10 | copyright notice, this list of conditions and the 11 | following disclaimer. 12 | 13 | * Neither the name of Deusty nor the names of its 14 | contributors may be used to endorse or promote products 15 | derived from this software without specific prior 16 | written permission of Deusty, LLC. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Mac App/Controllers/TBShadowedButtonCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBShadowedButtonCell.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/17/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBShadowedButtonCell.h" 11 | 12 | @implementation TBShadowedButtonCell 13 | 14 | - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { 15 | NSColor *shadowColor = self.aquaShadowColor; 16 | if ([NSColor currentControlTint] == NSGraphiteControlTint) 17 | shadowColor = self.graphiteShadowColor; 18 | if (!controlView.window.isKeyWindow) 19 | shadowColor = [shadowColor highlightWithLevel:0.3]; 20 | NSShadow *shadow = [NSShadow new]; 21 | shadow.shadowOffset = NSMakeSize(0.0, -1.0); 22 | shadow.shadowBlurRadius = 0.0; 23 | shadow.shadowColor = shadowColor; 24 | [shadow set]; 25 | [super drawInteriorWithFrame:cellFrame inView:controlView]; 26 | } 27 | 28 | - (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView *)controlView { 29 | if (!flag) { 30 | [self drawInteriorWithFrame:cellFrame inView:controlView]; 31 | return; 32 | } 33 | NSShadow *inset = [NSShadow new]; 34 | inset.shadowOffset = NSMakeSize(0.0, -1.0); 35 | inset.shadowBlurRadius = 0.0; 36 | inset.shadowColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.25]; 37 | [inset set]; 38 | [super drawImage:self.image withFrame:[self imageRectForBounds:cellFrame] inView:controlView]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBSourceViewControllerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBSourceViewControllerViewController.m 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 2/22/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBSourceViewControllerViewController.h" 10 | #import "TBAsset.h" 11 | 12 | @implementation TBSourceViewControllerViewController 13 | 14 | - (NSString *)defaultNibName { 15 | return @"TBSourceViewControllerView"; 16 | } 17 | 18 | - (NSString *)title { 19 | return @"Sources"; 20 | } 21 | 22 | - (void)awakeFromNib { 23 | [self.outlineView setTarget:self]; 24 | [self.outlineView setDoubleAction:@selector(doubleClickRow:)]; 25 | } 26 | 27 | - (void)doubleClickRow:(NSOutlineView *)outlineView { 28 | NSArray *assets = [self.assetTree selectedObjects]; 29 | NSArray *assetURLS = [assets valueForKey:@"URL"]; 30 | [assetURLS enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 31 | NSArray *singleFileArray = @[obj]; 32 | BOOL fileOpened = [[NSWorkspace sharedWorkspace] openURLs:singleFileArray withAppBundleIdentifier:nil options:NSWorkspaceLaunchAsync additionalEventParamDescriptor:nil launchIdentifiers:NULL]; 33 | if(!fileOpened){ 34 | [[NSWorkspace sharedWorkspace] openURLs:singleFileArray withAppBundleIdentifier:@"com.apple.TextEdit" options:NSWorkspaceLaunchAsync additionalEventParamDescriptor:nil launchIdentifiers:NULL]; 35 | } 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/MyHTTPConnection.m: -------------------------------------------------------------------------------- 1 | #import "MyHTTPConnection.h" 2 | #import "HTTPLogging.h" 3 | 4 | // Log levels : off, error, warn, info, verbose 5 | // Other flags: trace 6 | static const int httpLogLevel = HTTP_LOG_LEVEL_VERBOSE | HTTP_LOG_FLAG_TRACE; 7 | 8 | 9 | @implementation MyHTTPConnection 10 | 11 | - (BOOL)isPasswordProtected:(NSString *)path 12 | { 13 | // We're only going to password protect the "secret" directory. 14 | 15 | BOOL result = [path hasPrefix:@"/secret"]; 16 | 17 | HTTPLogTrace2(@"%@[%p]: isPasswordProtected(%@) - %@", THIS_FILE, self, path, (result ? @"YES" : @"NO")); 18 | 19 | return result; 20 | } 21 | 22 | - (BOOL)useDigestAccessAuthentication 23 | { 24 | HTTPLogTrace(); 25 | 26 | // Digest access authentication is the default setting. 27 | // Notice in Safari that when you're prompted for your password, 28 | // Safari tells you "Your login information will be sent securely." 29 | // 30 | // If you return NO in this method, the HTTP server will use 31 | // basic authentication. Try it and you'll see that Safari 32 | // will tell you "Your password will be sent unencrypted", 33 | // which is strongly discouraged. 34 | 35 | return YES; 36 | } 37 | 38 | - (NSString *)passwordForUser:(NSString *)username 39 | { 40 | HTTPLogTrace(); 41 | 42 | // You can do all kinds of cool stuff here. 43 | // For simplicity, we're not going to check the username, only the password. 44 | 45 | return @"secret"; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Shared/Template Additions/TBSite+TemplateAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBSite+TemplateAdditions.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 5/11/13. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | 11 | #import "TBSite+TemplateAdditions.h" 12 | #import "NSDateFormatter+TBAdditions.h" 13 | 14 | @implementation TBSite (TemplateAdditions) 15 | - (TBPost *)latestPost { 16 | return self.posts[0]; 17 | } 18 | - (NSArray *)recentPosts { 19 | if ([self.posts count] == 0) return @[]; 20 | NSUInteger recentPostCount = [self.metadata[TBSiteNumberOfRecentPostsMetadataKey] unsignedIntegerValue]; 21 | if (!recentPostCount) recentPostCount = 5; 22 | if ([self.posts count] < recentPostCount) recentPostCount = [self.posts count]; 23 | return [self.posts subarrayWithRange:NSMakeRange(0, recentPostCount)]; 24 | } 25 | - (NSString *)XMLDate { 26 | NSDate *date = [NSDate date]; 27 | NSDateFormatter *XMLDateFormatter = [NSDateFormatter tb_cachedDateFormatterFromString:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"]; 28 | NSMutableString *mutableDateString = [[XMLDateFormatter stringFromDate:date] mutableCopy]; 29 | [mutableDateString insertString:@":" atIndex:mutableDateString.length - 2]; 30 | return mutableDateString; 31 | } 32 | - (NSString *)name { 33 | return self.metadata[TBSiteNameMetadataKey]; 34 | } 35 | - (NSString *)author { 36 | return self.metadata[TBSiteAuthorMetadataKey]; 37 | } 38 | - (NSString *)baseURL { 39 | return self.metadata[TBSiteBaseURLMetadataKey]; 40 | } 41 | @end 42 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleHTTPServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "DDLog.h" 4 | #import "DDTTYLogger.h" 5 | 6 | // Log levels: off, error, warn, info, verbose 7 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 8 | 9 | 10 | @implementation AppDelegate 11 | 12 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 13 | { 14 | // Configure our logging framework. 15 | // To keep things simple and fast, we're just going to log to the Xcode console. 16 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 17 | 18 | // Initalize our http server 19 | httpServer = [[HTTPServer alloc] init]; 20 | 21 | // Tell the server to broadcast its presence via Bonjour. 22 | // This allows browsers such as Safari to automatically discover our service. 23 | [httpServer setType:@"_http._tcp."]; 24 | 25 | // Normally there's no need to run our server on any specific port. 26 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 27 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 28 | // [httpServer setPort:12345]; 29 | 30 | // Serve files from the standard Sites folder 31 | NSString *docRoot = [@"~/Sites" stringByExpandingTildeInPath]; 32 | DDLogInfo(@"Setting document root: %@", docRoot); 33 | 34 | [httpServer setDocumentRoot:docRoot]; 35 | 36 | NSError *error = nil; 37 | if(![httpServer start:&error]) 38 | { 39 | DDLogError(@"Error starting HTTP Server: %@", error); 40 | } 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Shared/Template Additions/TBPost+TemplateAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBPost+TemplateAdditions.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 5/13/13. 6 | // Copyright (c) 2013 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBPost+TemplateAdditions.h" 10 | #import "NSDateFormatter+TBAdditions.h" 11 | 12 | @implementation TBPost (TemplateAdditions) 13 | - (NSString *)dateString { 14 | NSDateFormatter *dateStringFormatter = [NSDateFormatter tb_cachedDateFormatterFromString:@"d MMM yyyy"]; 15 | return [dateStringFormatter stringFromDate:self.date]; 16 | } 17 | - (NSString *)XMLDate { 18 | NSDateFormatter *XMLDateFormatter = [NSDateFormatter tb_cachedDateFormatterFromString:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"]; 19 | NSMutableString *mutableDateString = [[XMLDateFormatter stringFromDate:self.date] mutableCopy]; 20 | [mutableDateString insertString:@":" atIndex:mutableDateString.length - 2]; 21 | return mutableDateString; 22 | } 23 | - (NSString *)summary { 24 | NSUInteger paraStart = 0, paraEnd = 0, contentsEnd = 0; 25 | [self.content getParagraphStart:¶Start end:¶End contentsEnd:&contentsEnd forRange:NSMakeRange(0, 0)]; 26 | NSRange paragraphRange = NSMakeRange(paraStart, contentsEnd - paraStart); 27 | return [self.content substringWithRange:paragraphRange]; 28 | } 29 | - (NSString *)relativeURL { 30 | NSDateFormatter *relativeURLFormatter = [NSDateFormatter tb_cachedDateFormatterFromString:@"/yyyy/MM/dd"]; 31 | NSString *directoryStructure = [relativeURLFormatter stringFromDate:self.date]; 32 | return [directoryStructure stringByAppendingPathComponent:self.slug]; 33 | } 34 | @end 35 | -------------------------------------------------------------------------------- /Default.tribo/Source/archives/index.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | 41 |
    42 | {{#site.posts}} 43 |
  • 44 |

    45 | {{title}} 46 | {{dateString}} 47 |

    48 |
  • 49 | {{/site.posts}} 50 |
-------------------------------------------------------------------------------- /Shared/TBAsset.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBAsset.m 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 2/20/12. 6 | // Copyright (c) 2013 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBAsset.h" 11 | 12 | @implementation TBAsset 13 | 14 | + (NSArray *)assetsFromDirectory:(NSURL*)URL error:(NSError **)error { 15 | 16 | NSMutableArray *assets = [NSMutableArray array]; 17 | NSArray *properties = @[NSURLTypeIdentifierKey, NSURLLocalizedNameKey, NSURLIsDirectoryKey]; 18 | NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:URL includingPropertiesForKeys:properties options:NSDirectoryEnumerationSkipsHiddenFiles|NSDirectoryEnumerationSkipsSubdirectoryDescendants errorHandler:nil]; 19 | for (NSURL *assetURL in enumerator) { 20 | 21 | NSDictionary *resourceValues = [assetURL resourceValuesForKeys:properties error:error]; 22 | if (!resourceValues) return nil; 23 | 24 | TBAsset *asset = [[self class] new]; 25 | asset.URL = assetURL; 26 | asset.displayName = resourceValues[NSURLLocalizedNameKey]; 27 | asset.type = resourceValues[NSURLTypeIdentifierKey]; 28 | 29 | if ([resourceValues[NSURLIsDirectoryKey] boolValue]) { 30 | asset.children = [[self class] assetsFromDirectory:assetURL error:error]; 31 | if (!asset.children) return nil; 32 | } 33 | 34 | [assets addObject:asset]; 35 | 36 | } 37 | 38 | [assets sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"displayName" ascending:YES]]]; 39 | 40 | return assets; 41 | 42 | } 43 | 44 | - (BOOL)isLeaf { 45 | return ([self.children count] == 0); 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Categories/DDNumber.m: -------------------------------------------------------------------------------- 1 | #import "DDNumber.h" 2 | 3 | @implementation NSNumber (DDNumber) 4 | 5 | + (BOOL)parseString:(NSString *)string intoSInt64:(SInt64 *)integer { 6 | 7 | if (string == nil) { 8 | *integer = 0; 9 | return NO; 10 | } 11 | 12 | errno = 0; 13 | // On both 32-bit and 64-bit machines, long long = 64 bit 14 | *integer = strtoll([string UTF8String], NULL, 10); 15 | 16 | if (errno != 0) return NO; 17 | return YES; 18 | 19 | } 20 | 21 | + (BOOL)parseString:(NSString *)string intoUInt64:(UInt64 *)integer { 22 | 23 | if (string == nil) { 24 | *integer = 0; 25 | return NO; 26 | } 27 | 28 | errno = 0; 29 | // On both 32-bit and 64-bit machines, unsigned long long = 64 bit 30 | *integer = strtoll([string UTF8String], NULL, 10); 31 | 32 | if(errno != 0) return NO; 33 | return YES; 34 | 35 | } 36 | 37 | + (BOOL)parseString:(NSString *)string intoNSInteger:(NSInteger *)integer { 38 | 39 | if (string == nil) { 40 | *integer = 0; 41 | return NO; 42 | } 43 | 44 | errno = 0; 45 | // On LP64, NSInteger = long = 64 bit 46 | // Otherwise, NSInteger = int = long = 32 bit 47 | *integer = strtol([string UTF8String], NULL, 10); 48 | 49 | if(errno != 0) return NO; 50 | return YES; 51 | 52 | } 53 | 54 | + (BOOL)parseString:(NSString *)string intoNSUInteger:(NSUInteger *)integer 55 | { 56 | if (string == nil) { 57 | *integer = 0; 58 | return NO; 59 | } 60 | 61 | errno = 0; 62 | // On LP64, NSUInteger = unsigned long = 64 bit 63 | // Otherwise, NSUInteger = unsigned int = unsigned long = 32 bit 64 | *integer = strtoul([string UTF8String], NULL, 10); 65 | 66 | if(errno != 0) return NO; 67 | return YES; 68 | 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBTemplatesViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBTemplatesViewController.m 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 2/20/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBTemplatesViewController.h" 10 | #import "TBSiteDocument.h" 11 | #import "TBAsset.h" 12 | #import "TBSite.h" 13 | 14 | @implementation TBTemplatesViewController 15 | 16 | - (NSString *)defaultNibName { 17 | return @"TBTemplatesView"; 18 | } 19 | 20 | - (NSString *)title { 21 | return @"Templates"; 22 | } 23 | 24 | - (void)awakeFromNib { 25 | [self.tableView setTarget:self]; 26 | [self.tableView setDoubleAction:@selector(doubleClickRow:)]; 27 | } 28 | 29 | - (NSArray *)templates { 30 | NSArray *nameSort = @[[NSSortDescriptor sortDescriptorWithKey:@"displayName" ascending:YES]]; 31 | return [self.document.site.templateAssets sortedArrayUsingDescriptors:nameSort]; 32 | } 33 | 34 | - (void)doubleClickRow:(NSOutlineView *)outlineView { 35 | NSArray *assets = [self.assets selectedObjects]; 36 | NSArray *assetURLS = [assets valueForKey:@"URL"]; 37 | [assetURLS enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 38 | NSArray *singleFileArray = @[obj]; 39 | BOOL fileOpened = [[NSWorkspace sharedWorkspace] openURLs:singleFileArray withAppBundleIdentifier:nil options:NSWorkspaceLaunchAsync additionalEventParamDescriptor:nil launchIdentifiers:NULL]; 40 | if(!fileOpened){ 41 | [[NSWorkspace sharedWorkspace] openURLs:singleFileArray withAppBundleIdentifier:@"com.apple.TextEdit" options:NSWorkspaceLaunchAsync additionalEventParamDescriptor:nil launchIdentifiers:NULL]; 42 | } 43 | }]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleFileUploadServer/SimpleFileUploadServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "DDLog.h" 4 | #import "DDTTYLogger.h" 5 | #import "MyHTTPConnection.h" 6 | // Log levels: off, error, warn, info, verbose 7 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 8 | 9 | 10 | @implementation AppDelegate 11 | 12 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 13 | { 14 | // Configure our logging framework. 15 | // To keep things simple and fast, we're just going to log to the Xcode console. 16 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 17 | 18 | // Initalize our http server 19 | httpServer = [[HTTPServer alloc] init]; 20 | 21 | // Tell the server to broadcast its presence via Bonjour. 22 | // This allows browsers such as Safari to automatically discover our service. 23 | [httpServer setType:@"_http._tcp."]; 24 | 25 | // Normally there's no need to run our server on any specific port. 26 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 27 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 28 | // [httpServer setPort:12345]; 29 | 30 | // Serve files from the standard Sites folder 31 | NSString *docRoot = [[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"web"] stringByDeletingLastPathComponent]; 32 | DDLogInfo(@"Setting document root: %@", docRoot); 33 | 34 | [httpServer setDocumentRoot:docRoot]; 35 | 36 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 37 | 38 | NSError *error = nil; 39 | if(![httpServer start:&error]) 40 | { 41 | DDLogError(@"Error starting HTTP Server: %@", error); 42 | } 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | The SecureHTTPServer examples demonstrates creating a HTTPS server. 4 | 5 | In order to do this, all connections must be secured using SSL/TLS. 6 | And in order to do that, you need to have a X509 certificate. 7 | Normally you PAY MONEY for these. 8 | For example, you purchase them via Verisign. 9 | However, for our example we're going to create a self-signed certificate. 10 | 11 | This means that when you browse the server in Safari, it may present a warning saying the certificate is untrusted. (Which makes sense since you didn't pay money to a trusted 3rd party certificate agency.) To make things easier for testing, when Safari presents this warning, click the "show certificate" button. And then click the "always trust this certificate" button. 12 | 13 | Also, the first time you run the server, it will automatically create a self-signed certificate and add it to your keychain (under the name SecureHTTPServer). Now the SecureHTTPServer is authorized to access this keychain item - unless of course the binary changes. So if you make changes, or simply switch between debug/release builds, you'll keep getting prompted by the Keychain utility. To solve this problem, open the Keychain Access application. Find the "SecureHTTPServer" private key, and change it's Access Control to "Allow all applications to access this item". 14 | 15 | INSTRUCTIONS: 16 | 17 | Open the Xcode project, and build and go. 18 | 19 | On the Xcode console you'll see a message saying: 20 | "Started HTTP server on port 59123" 21 | 22 | Now open your browser and type in the URL: 23 | https://localhost:59123 24 | 25 | Notice that you're using "https" and not "http". 26 | 27 | (Replace 59123 with whatever port the server is actually running on.) 28 | 29 | Enjoy. -------------------------------------------------------------------------------- /Mac App/Views/TBTableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBTableView.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 10/8/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBTableView.h" 11 | #import 12 | 13 | @implementation TBTableView 14 | - (void)keyDown:(NSEvent *)event { 15 | NSString* key = [event charactersIgnoringModifiers]; 16 | if([key isEqual:@" "]) { 17 | if ([QLPreviewPanel sharedPreviewPanel].isKeyWindow) { 18 | [[QLPreviewPanel sharedPreviewPanel] close]; 19 | } 20 | else { 21 | [[QLPreviewPanel sharedPreviewPanel] updateController]; 22 | [[QLPreviewPanel sharedPreviewPanel] reloadData]; 23 | [QLPreviewPanel sharedPreviewPanel].currentPreviewItemIndex = self.selectedRow; 24 | [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:self]; 25 | } 26 | } 27 | else { 28 | [super keyDown:event]; 29 | } 30 | } 31 | - (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel { 32 | return YES; 33 | } 34 | - (void)beginPreviewPanelControl:(QLPreviewPanel *)panel { 35 | panel.delegate = (id )self.delegate; 36 | panel.dataSource = (id )self.delegate; 37 | } 38 | - (void)endPreviewPanelControl:(QLPreviewPanel *)panel { 39 | return; 40 | } 41 | - (IBAction)deleteSelectedRows:(id)sender { 42 | NSObject *delegate = (NSObject *)self.delegate; 43 | if (![delegate respondsToSelector:@selector(tableView:shouldDeleteRows:)]) return; 44 | [delegate tableView:self shouldDeleteRows:self.selectedRowIndexes]; 45 | } 46 | - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { 47 | if (menuItem.action != @selector(deleteSelectedRows:)) return YES; 48 | return ([self.selectedRowIndexes count] ? YES : NO); 49 | } 50 | @end 51 | -------------------------------------------------------------------------------- /Dependencies/CZAFileWatcher/Readme.md: -------------------------------------------------------------------------------- 1 | # CZAFileWatcher # 2 | 3 | CZAFileWatcher is a simple Objective-C wrapper around Apple's [FSEvents][fsevents] system for watching files. It is small (less than 100 lines of code), compact (a single header/implementation pair, no dependencies), and provides a convenient way of monitoring the filesystem for activity. CZAFileWatcher uses Automatic Reference Counting (ARC) and Objective-C Blocks. 4 | 5 | ### Installation ### 6 | 7 | Just add `CZAFileWatcher.h` and `CZAFileWatcher.m` to your project and `#import "CZAFileWatcher.h"` whenever you need to access the class. 8 | 9 | ### Usage ### 10 | 11 | First, set up an array of filesystem URLs: 12 | 13 | NSURL *desktopURL = [[NSFileManager defaultManager] URLForDirectory:NSDesktopDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; 14 | NSArray *URLs = @[desktopURL]; 15 | 16 | Next, instantiate a CZAFileWatcher object, keeping in mind that the object is immutable after creation: 17 | 18 | CZAFileWatcher *watcher = [CZAFileWatcher fileWatcherForURLs:@[desktopURL] changesHandler:^(NSArray *changedURLs) { 19 | // Respond to the change... 20 | }]; 21 | 22 | And start the watcher: 23 | 24 | [watcher startWatching]; 25 | 26 | That's all there is to it! You can always stop watching the URLs by calling `-stopWatching`. 27 | 28 | A working example program (`watch-file.m`) is included in this repository. The watch-file command-line interface (CLI) accepts file paths as arguments and watches them, printing a message whenever a change is detected. 29 | 30 | ### License ### 31 | 32 | CZAFileWatcher is released under the MIT License, which can be found in the License.md file. 33 | 34 | [fsevents]: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/FSEvents_Ref/Reference/reference.html -------------------------------------------------------------------------------- /Mac App/Controllers/TBPublishSheetController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBPublishSheetController.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/29/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBPublishSheetController.h" 11 | #import "TBPublisher.h" 12 | #import "TBMacros.h" 13 | 14 | @interface TBPublishSheetController () 15 | @property (nonatomic, assign) IBOutlet NSProgressIndicator *indicator; 16 | @property (nonatomic, strong) TBPublisher *publisher; 17 | @end 18 | 19 | @implementation TBPublishSheetController 20 | 21 | - (id)init { 22 | self = [super initWithWindowNibName:@"TBPublishSheet"]; 23 | return self; 24 | } 25 | 26 | - (void)runModalForWindow:(NSWindow *)window site:(TBSite *)site { 27 | 28 | [self loadWindow]; 29 | self.site = site; 30 | self.indicator.doubleValue = 0.0; 31 | self.indicator.indeterminate = YES; 32 | [self.indicator startAnimation:nil]; 33 | 34 | self.publisher = [TBPublisher publisherWithSite:site]; 35 | 36 | MAWeakSelfDeclare(); 37 | [self.publisher setProgressHandler:^(NSInteger progress, NSInteger total) { 38 | MAWeakSelfImport(); 39 | self.indicator.indeterminate = NO; 40 | self.indicator.doubleValue = ((double)progress/(double)total) * 100.0; 41 | }]; 42 | 43 | [self.publisher setCompletionHandler:^() { 44 | MAWeakSelfImport(); 45 | self.indicator.doubleValue = 100; 46 | [NSApp endSheet:self.window]; 47 | [self.window orderOut:nil]; 48 | }]; 49 | 50 | [self.publisher setErrorHandler:^(NSError *error) { 51 | MAWeakSelfImport(); 52 | [NSApp endSheet:self.window]; 53 | [self.window orderOut:nil]; 54 | }]; 55 | 56 | [NSApp beginSheet:self.window modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; 57 | 58 | [self.publisher publish]; 59 | 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PasswdHTTPServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "MyHTTPConnection.h" 4 | #import "DDLog.h" 5 | #import "DDTTYLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation AppDelegate 12 | 13 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 14 | { 15 | // Configure our logging framework. 16 | // To keep things simple and fast, we're just going to log to the Xcode console. 17 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 18 | 19 | // Initalize our http server 20 | httpServer = [[HTTPServer alloc] init]; 21 | 22 | // Tell the server to broadcast its presence via Bonjour. 23 | // This allows browsers such as Safari to automatically discover our service. 24 | [httpServer setType:@"_http._tcp."]; 25 | 26 | // Normally there's no need to run our server on any specific port. 27 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 28 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 29 | // [httpServer setPort:12345]; 30 | 31 | // We're going to extend the base HTTPConnection class with our MyHTTPConnection class. 32 | // This allows us to do custom password protection on our sensitive directories. 33 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 34 | 35 | // Serve files from the standard Sites folder 36 | NSString *docRoot = [@"~/Sites" stringByExpandingTildeInPath]; 37 | DDLogInfo(@"Setting document root: %@", docRoot); 38 | 39 | [httpServer setDocumentRoot:docRoot]; 40 | 41 | NSError *error = nil; 42 | if (![httpServer start:&error]) 43 | { 44 | DDLogError(@"Error starting HTTP Server: %@", error); 45 | } 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/PostHTTPServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "MyHTTPConnection.h" 4 | #import "DDLog.h" 5 | #import "DDTTYLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation AppDelegate 12 | 13 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 14 | { 15 | // Configure our logging framework. 16 | // To keep things simple and fast, we're just going to log to the Xcode console. 17 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 18 | 19 | // Initalize our http server 20 | httpServer = [[HTTPServer alloc] init]; 21 | 22 | // Tell the server to broadcast its presence via Bonjour. 23 | // This allows browsers such as Safari to automatically discover our service. 24 | [httpServer setType:@"_http._tcp."]; 25 | 26 | // Normally there's no need to run our server on any specific port. 27 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 28 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 29 | // [httpServer setPort:12345]; 30 | 31 | // We're going to extend the base HTTPConnection class with our MyHTTPConnection class. 32 | // This allows us to do all kinds of customizations. 33 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 34 | 35 | // Serve files from our embedded Web folder 36 | NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; 37 | DDLogInfo(@"Setting document root: %@", webPath); 38 | 39 | [httpServer setDocumentRoot:webPath]; 40 | 41 | 42 | NSError *error = nil; 43 | if(![httpServer start:&error]) 44 | { 45 | DDLogError(@"Error starting HTTP Server: %@", error); 46 | } 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/README.markdown: -------------------------------------------------------------------------------- 1 | Welcome to CocoaHTTPServer! 2 | 3 | This project provides you (the developer) with an embedded HTTP server. It was built using standard networking sockets and streams, and offers a wealth of features for your app: 4 | 5 | - Built in support for bonjour broadcasting 6 | - IPv4 and IPv6 support automatically 7 | - Asynchronous networking 8 | - Multithreading support 9 | - Password protection using either digest access or basic authentication 10 | - TLS/SSL encryption support 11 | - Range request support for partial downloads and pause/resume 12 | - Support for LARGE files (up to 16 exabytes) 13 | - Heavily commented code 14 | 15 | As is the nature of embedded servers, you probably want to do something cool with it. Perhaps you simply want to serve up files, but maybe you want to provide dynamic content or allow user uploads. No problem - you can use this code to do any/all of these tasks. 16 | 17 | The suggested way to implement your custom server is by extending the HTTPServer and/or HTTPConnection classes. You'll find several methods in these classes with documentation that says "override me to add support for..." For example, if you wanted to add password protection to various resources, simply override the "isPasswordProtected" and "passwordForUser" methods. 18 | 19 | If you have questions, you may email the mailing list: 20 | http://groups.google.com/group/cocoahttpserver 21 | 22 | PLEASE NOTE: 23 | 24 | All sample xcode projects are simple examples of how to accomplish some task using CocoaHTTPServer. 25 | 26 | Don't forget to use source control to stay up-to-date with the latest version of the code. 27 | 28 | If you've implemented your custom server by extending the HTTPServer and HTTPConnection classes, it should be relatively easy to merge the latest improvements from subversion into your project. 29 | 30 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "HTTPResponse.h" 3 | #import "HTTPAsyncFileResponse.h" 4 | 5 | /** 6 | * This class is designed to assist with dynamic content. 7 | * Imagine you have a file that you want to make dynamic: 8 | * 9 | * 10 | * 11 | *

ComputerName Control Panel

12 | * ... 13 | *
  • System Time: SysTime
  • 14 | * 15 | * 16 | * 17 | * Now you could generate the entire file in Objective-C, 18 | * but this would be a horribly tedious process. 19 | * Beside, you want to design the file with professional tools to make it look pretty. 20 | * 21 | * So all you have to do is escape your dynamic content like this: 22 | * 23 | * ... 24 | *

    %%ComputerName%% Control Panel

    25 | * ... 26 | *
  • System Time: %%SysTime%%
  • 27 | * 28 | * And then you create an instance of this class with: 29 | * 30 | * - separator = @"%%" 31 | * - replacementDictionary = { "ComputerName"="Black MacBook", "SysTime"="2010-04-30 03:18:24" } 32 | * 33 | * This class will then perform the replacements for you, on the fly, as it reads the file data. 34 | * This class is also asynchronous, so it will perform the file IO using its own GCD queue. 35 | * 36 | * All keys for the replacementDictionary must be NSString's. 37 | * Values for the replacementDictionary may be NSString's, or any object that 38 | * returns what you want when its description method is invoked. 39 | **/ 40 | 41 | @interface HTTPDynamicFileResponse : HTTPAsyncFileResponse 42 | { 43 | NSData *separator; 44 | NSDictionary *replacementDict; 45 | } 46 | 47 | - (id)initWithFilePath:(NSString *)filePath 48 | forConnection:(HTTPConnection *)connection 49 | separator:(NSString *)separatorStr 50 | replacementDictionary:(NSDictionary *)dictionary; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Mac App/Scripting/TBSiteDocument+Scripting.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBSiteDocument+Scripting.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 2/7/12. 6 | // Copyright (c) 2012 Opt-6 Products, LLC. All rights reserved. 7 | // 8 | 9 | #import "TBSiteDocument+Scripting.h" 10 | #import "TBSiteWindowController.h" 11 | #import "TBPostsViewController.h" 12 | #import "TBSite.h" 13 | #import "TBHTTPServer.h" 14 | 15 | @implementation TBSiteDocument (Scripting) 16 | - (void)startPreviewFromScript:(NSScriptCommand *)command { 17 | 18 | if (self.server.isRunning) return; 19 | 20 | [command suspendExecution]; 21 | 22 | TBSiteWindowController *windowController = (self.windowControllers)[0]; 23 | TBPostsViewController *postsViewController = nil; 24 | for (TBViewController *viewController in windowController.viewControllers) { 25 | if ([viewController class] == [TBPostsViewController class]) { 26 | postsViewController = (TBPostsViewController *)viewController; 27 | continue; 28 | } 29 | } 30 | if (!postsViewController) return; 31 | 32 | [self startPreview:^(NSURL *localURL, NSError *error) { 33 | if (error) { 34 | command.scriptErrorNumber = (int)error.code; 35 | command.scriptErrorString = error.localizedDescription; 36 | } 37 | [command resumeExecutionWithResult:nil]; 38 | }]; 39 | 40 | } 41 | - (void)stopPreviewFromScript:(NSScriptCommand *)command { 42 | 43 | if (!self.server.isRunning) return; 44 | 45 | TBSiteWindowController *windowController = (self.windowControllers)[0]; 46 | TBPostsViewController *postsViewController = nil; 47 | for (TBViewController *viewController in windowController.viewControllers) { 48 | if ([viewController class] == [TBPostsViewController class]) { 49 | postsViewController = (TBPostsViewController *)viewController; 50 | continue; 51 | } 52 | } 53 | if (!postsViewController) return; 54 | 55 | [self stopPreview]; 56 | 57 | } 58 | @end 59 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Categories/DDData.m: -------------------------------------------------------------------------------- 1 | #import "DDData.h" 2 | #import 3 | 4 | @implementation NSData (DDData) 5 | 6 | - (NSData *)md5Digest { 7 | unsigned char result[CC_MD5_DIGEST_LENGTH]; 8 | CC_MD5(self.bytes, (CC_LONG)[self length], result); 9 | return [NSData dataWithBytes:result length:CC_MD5_DIGEST_LENGTH]; 10 | } 11 | 12 | - (NSData *)sha1Digest { 13 | unsigned char result[CC_SHA1_DIGEST_LENGTH]; 14 | CC_SHA1(self.bytes, (CC_LONG)[self length], result); 15 | return [NSData dataWithBytes:result length:CC_SHA1_DIGEST_LENGTH]; 16 | } 17 | 18 | - (NSString *)hexStringValue { 19 | NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([self length] * 2)]; 20 | const unsigned char *dataBuffer = [self bytes]; 21 | for (NSUInteger i = 0; i < [self length]; ++i) { 22 | [stringBuffer appendFormat:@"%02lx", (unsigned long)dataBuffer[i]]; 23 | } 24 | return stringBuffer; 25 | } 26 | 27 | - (NSString *)base64Encoded { 28 | CFDataRef data = (__bridge CFDataRef)self; 29 | SecTransformRef encoder = SecEncodeTransformCreate(kSecBase64Encoding, NULL); 30 | SecTransformSetAttribute(encoder, kSecTransformInputAttributeName, data, NULL); 31 | CFDataRef encodedData = SecTransformExecute(encoder, NULL); 32 | CFStringRef encodedString = CFStringCreateFromExternalRepresentation(NULL, encodedData, kCFStringEncodingUTF8); 33 | CFRelease(encoder); 34 | CFRelease(encodedData); 35 | return (__bridge_transfer NSString *)encodedString; 36 | } 37 | 38 | - (NSData *)base64Decoded { 39 | CFDataRef data = (__bridge CFDataRef)self; 40 | SecTransformRef decoder = SecDecodeTransformCreate(kSecBase64Encoding, NULL); 41 | SecTransformSetAttribute(decoder, kSecTransformInputAttributeName, data, NULL); 42 | CFDataRef decodedData = SecTransformExecute(decoder, NULL); 43 | CFRelease(decoder); 44 | return (__bridge_transfer NSData *)decodedData; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Dependencies/CZAFileWatcher/CZAFileWatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // CZAFileWatcher.h 3 | // 4 | // Created by Carter Allen on 8/7/13. 5 | // Copyright (c) 2013 Carter Allen. 6 | // 7 | // Released under the MIT License. 8 | // See the included License.md file for details. 9 | // 10 | 11 | #import 12 | 13 | /*! 14 | @class CZAFileWatcher 15 | @discussion A file watcher monitors an array of filesystem URLs for changes, 16 | and executes a block whenever changes occur. File watcher objects are 17 | immutable, therefore the URLs and handler block provided during initialization 18 | cannot be changed. CZAFileWatcher is implemented using OS X's FSEvents 19 | facility, and requires a Grand Central Dispatch queue to function properly. 20 | A run loop, however, is not necessary. 21 | */ 22 | 23 | @interface CZAFileWatcher : NSObject 24 | 25 | typedef void(^TBFileWatcherChangesHandler)(NSArray *changedURLs); 26 | 27 | /*! 28 | Create a file watcher, configured to watch an array of filesystem URLs and call 29 | a handler block when changes are detected. 30 | @param URLs 31 | An array of filesystem URLs to watch for changes. 32 | @param changesHandler 33 | A block to execute whenever changes to the specified URLs occur. The handler 34 | will be passed an array of the URLs that were affected by the change. 35 | */ 36 | + (instancetype)fileWatcherForURLs:(NSArray *)URLs 37 | changesHandler:(TBFileWatcherChangesHandler)changesHandler; 38 | 39 | /*! 40 | Starts watching the URLs for changes. If the watcher is already running, this 41 | method does nothing. 42 | */ 43 | - (void)startWatching; 44 | 45 | /*! 46 | Stops watching the URLs for changes. If the watcher is already stopped, this 47 | method does nothing. 48 | */ 49 | - (void)stopWatching; 50 | 51 | /*! 52 | The filesystem URLs watched by the file watcher. 53 | */ 54 | @property (readonly) NSArray *URLs; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Categories/DDRange.h: -------------------------------------------------------------------------------- 1 | /** 2 | * DDRange is the functional equivalent of a 64 bit NSRange. 3 | * The HTTP Server is designed to support very large files. 4 | * On 32 bit architectures (ppc, i386) NSRange uses unsigned 32 bit integers. 5 | * This only supports a range of up to 4 gigabytes. 6 | * By defining our own variant, we can support a range up to 16 exabytes. 7 | * 8 | * All effort is given such that DDRange functions EXACTLY the same as NSRange. 9 | **/ 10 | 11 | #import 12 | #import 13 | 14 | @class NSString; 15 | 16 | typedef struct _DDRange { 17 | UInt64 location; 18 | UInt64 length; 19 | } DDRange; 20 | 21 | typedef DDRange *DDRangePointer; 22 | 23 | NS_INLINE DDRange DDMakeRange(UInt64 loc, UInt64 len) { 24 | DDRange r; 25 | r.location = loc; 26 | r.length = len; 27 | return r; 28 | } 29 | 30 | NS_INLINE UInt64 DDMaxRange(DDRange range) { 31 | return (range.location + range.length); 32 | } 33 | 34 | NS_INLINE BOOL DDLocationInRange(UInt64 loc, DDRange range) { 35 | return (loc - range.location < range.length); 36 | } 37 | 38 | NS_INLINE BOOL DDEqualRanges(DDRange range1, DDRange range2) { 39 | return ((range1.location == range2.location) && (range1.length == range2.length)); 40 | } 41 | 42 | FOUNDATION_EXPORT DDRange DDUnionRange(DDRange range1, DDRange range2); 43 | FOUNDATION_EXPORT DDRange DDIntersectionRange(DDRange range1, DDRange range2); 44 | FOUNDATION_EXPORT NSString *DDStringFromRange(DDRange range); 45 | FOUNDATION_EXPORT DDRange DDRangeFromString(NSString *aString); 46 | 47 | NSInteger DDRangeCompare(DDRangePointer pDDRange1, DDRangePointer pDDRange2); 48 | 49 | @interface NSValue (NSValueDDRangeExtensions) 50 | 51 | + (NSValue *)valueWithDDRange:(DDRange)range; 52 | - (DDRange)ddrangeValue; 53 | 54 | - (NSInteger)ddrangeCompare:(NSValue *)ddrangeValue; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/DynamicServer/DynamicServerAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "DynamicServerAppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "MyHTTPConnection.h" 4 | #import "DDLog.h" 5 | #import "DDTTYLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation DynamicServerAppDelegate 12 | 13 | @synthesize window; 14 | 15 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 16 | { 17 | // Configure our logging framework. 18 | // To keep things simple and fast, we're just going to log to the Xcode console. 19 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 20 | 21 | // Initalize our http server 22 | httpServer = [[HTTPServer alloc] init]; 23 | 24 | // Tell server to use our custom MyHTTPConnection class. 25 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 26 | 27 | // Tell the server to broadcast its presence via Bonjour. 28 | // This allows browsers such as Safari to automatically discover our service. 29 | [httpServer setType:@"_http._tcp."]; 30 | 31 | // Normally there's no need to run our server on any specific port. 32 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 33 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 34 | // [httpServer setPort:12345]; 35 | 36 | // Serve files from our embedded Web folder 37 | NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; 38 | DDLogVerbose(@"Setting document root: %@", webPath); 39 | 40 | [httpServer setDocumentRoot:webPath]; 41 | 42 | // Start the server (and check for problems) 43 | 44 | NSError *error; 45 | BOOL success = [httpServer start:&error]; 46 | 47 | if(!success) 48 | { 49 | DDLogError(@"Error starting HTTP Server: %@", error); 50 | } 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m: -------------------------------------------------------------------------------- 1 | #import "HTTPDataResponse.h" 2 | #import "HTTPLogging.h" 3 | 4 | #if ! __has_feature(objc_arc) 5 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 6 | #endif 7 | 8 | // Log levels : off, error, warn, info, verbose 9 | // Other flags: trace 10 | static const int httpLogLevel = HTTP_LOG_LEVEL_OFF; // | HTTP_LOG_FLAG_TRACE; 11 | 12 | 13 | @implementation HTTPDataResponse 14 | 15 | - (id)initWithData:(NSData *)dataParam 16 | { 17 | if((self = [super init])) 18 | { 19 | HTTPLogTrace(); 20 | 21 | offset = 0; 22 | data = dataParam; 23 | } 24 | return self; 25 | } 26 | 27 | - (void)dealloc 28 | { 29 | HTTPLogTrace(); 30 | 31 | } 32 | 33 | - (UInt64)contentLength 34 | { 35 | UInt64 result = (UInt64)[data length]; 36 | 37 | HTTPLogTrace2(@"%@[%p]: contentLength - %llu", THIS_FILE, self, result); 38 | 39 | return result; 40 | } 41 | 42 | - (UInt64)offset 43 | { 44 | HTTPLogTrace(); 45 | 46 | return offset; 47 | } 48 | 49 | - (void)setOffset:(UInt64)offsetParam 50 | { 51 | HTTPLogTrace2(@"%@[%p]: setOffset:%lu", THIS_FILE, self, (unsigned long)offset); 52 | 53 | offset = (NSUInteger)offsetParam; 54 | } 55 | 56 | - (NSData *)readDataOfLength:(NSUInteger)lengthParameter 57 | { 58 | HTTPLogTrace2(@"%@[%p]: readDataOfLength:%lu", THIS_FILE, self, (unsigned long)lengthParameter); 59 | 60 | NSUInteger remaining = [data length] - offset; 61 | NSUInteger length = lengthParameter < remaining ? lengthParameter : remaining; 62 | 63 | void *bytes = (void *)([data bytes] + offset); 64 | 65 | offset += length; 66 | 67 | return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:NO]; 68 | } 69 | 70 | - (BOOL)isDone 71 | { 72 | BOOL result = (offset == [data length]); 73 | 74 | HTTPLogTrace2(@"%@[%p]: isDone - %@", THIS_FILE, self, (result ? @"YES" : @"NO")); 75 | 76 | return result; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/SimpleWebSocketServerAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SimpleWebSocketServerAppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "MyHTTPConnection.h" 4 | #import "DDLog.h" 5 | #import "DDTTYLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation SimpleWebSocketServerAppDelegate 12 | 13 | @synthesize window; 14 | 15 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 16 | { 17 | // Configure our logging framework. 18 | // To keep things simple and fast, we're just going to log to the Xcode console. 19 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 20 | 21 | // Create server using our custom MyHTTPServer class 22 | httpServer = [[HTTPServer alloc] init]; 23 | 24 | // Tell server to use our custom MyHTTPConnection class. 25 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 26 | 27 | // Tell the server to broadcast its presence via Bonjour. 28 | // This allows browsers such as Safari to automatically discover our service. 29 | [httpServer setType:@"_http._tcp."]; 30 | 31 | // Normally there's no need to run our server on any specific port. 32 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 33 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 34 | // [httpServer setPort:12345]; 35 | 36 | // Serve files from our embedded Web folder 37 | NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; 38 | DDLogInfo(@"Setting document root: %@", webPath); 39 | 40 | [httpServer setDocumentRoot:webPath]; 41 | 42 | // Start the server (and check for problems) 43 | 44 | NSError *error; 45 | if(![httpServer start:&error]) 46 | { 47 | DDLogError(@"Error starting HTTP Server: %@", error); 48 | } 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Shared/TBAsset.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBAsset.h 3 | // Tribo 4 | // 5 | // Created by Samuel Goodwin on 2/20/12. 6 | // Copyright (c) 2013 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | /*! 11 | @class TBAsset 12 | @discussion An asset represents a file or folder inside a site's root 13 | directory. A site object manages a tree of assets which mirrors the on-disk 14 | structure of the site. Thus, assets are recursive in nature, and should be 15 | thought of as a tree data structure. Currently, the asset tree is primarily 16 | used for user interface purposes, but it should be integrated into the site 17 | compilation system eventually. 18 | */ 19 | 20 | @interface TBAsset : NSObject 21 | 22 | /*! 23 | Create a tree of TBAsset objects, rooted in the given directory. 24 | @param URL 25 | A directory in which to begin building the asset tree. 26 | @param error 27 | If the return value is nil, then this argument will contain an NSError 28 | object describing what went wrong. 29 | @return 30 | An array of assets, or nil if an error was encountered. 31 | */ 32 | + (NSArray *)assetsFromDirectory:(NSURL*)URL error:(NSError **)error; 33 | 34 | /*! 35 | @property URL 36 | The filesystem URL of the asset. 37 | */ 38 | @property (nonatomic, strong) NSURL *URL; 39 | 40 | /*! 41 | @property displayName 42 | The localized display name of the asset (i.e. what the user would see if 43 | they examined the file in Finder.) 44 | */ 45 | @property (nonatomic, copy) NSString *displayName; 46 | 47 | /*! 48 | @property type 49 | The Uniform Type Identifier (UTI) of the asset. 50 | */ 51 | @property (nonatomic, copy) NSString *type; 52 | 53 | /*! 54 | @property children 55 | An array of child assets, or nil if the asset is a leaf. 56 | */ 57 | @property (nonatomic, strong) NSArray *children; 58 | 59 | /*! 60 | @return 61 | YES if the asset has no children, NO if it does. 62 | */ 63 | - (BOOL)isLeaf; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/SecureWebSocketServer/SecureWebSocketServerAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SecureWebSocketServerAppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "MyHTTPConnection.h" 4 | #import "DDLog.h" 5 | #import "DDTTYLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation SecureWebSocketServerAppDelegate 12 | 13 | @synthesize window; 14 | 15 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 16 | { 17 | // Configure our logging framework. 18 | // To keep things simple and fast, we're just going to log to the Xcode console. 19 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 20 | 21 | // Create server using our custom MyHTTPServer class 22 | httpServer = [[HTTPServer alloc] init]; 23 | 24 | // Tell server to use our custom MyHTTPConnection class. 25 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 26 | 27 | // Tell the server to broadcast its presence via Bonjour. 28 | // This allows browsers such as Safari to automatically discover our service. 29 | [httpServer setType:@"_http._tcp."]; 30 | 31 | // Normally there's no need to run our server on any specific port. 32 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 33 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 34 | // [httpServer setPort:12345]; 35 | 36 | // Serve files from our embedded Web folder 37 | NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; 38 | DDLogInfo(@"Setting document root: %@", webPath); 39 | 40 | [httpServer setDocumentRoot:webPath]; 41 | 42 | // Start the server (and check for problems) 43 | 44 | NSError *error; 45 | if(![httpServer start:&error]) 46 | { 47 | DDLogError(@"Error starting HTTP Server: %@", error); 48 | } 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureHTTPServer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "HTTPServer.h" 3 | #import "MyHTTPConnection.h" 4 | #import "DDLog.h" 5 | #import "DDTTYLogger.h" 6 | 7 | // Log levels: off, error, warn, info, verbose 8 | static const int ddLogLevel = LOG_LEVEL_VERBOSE; 9 | 10 | 11 | @implementation AppDelegate 12 | 13 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 14 | { 15 | // Configure our logging framework. 16 | // To keep things simple and fast, we're just going to log to the Xcode console. 17 | [DDLog addLogger:[DDTTYLogger sharedInstance]]; 18 | 19 | // Initalize our http server 20 | httpServer = [[HTTPServer alloc] init]; 21 | 22 | // Tell the server to broadcast its presence via Bonjour. 23 | // This allows browsers such as Safari to automatically discover our service. 24 | // [httpServer setType:@"_http._tcp."]; 25 | 26 | // Note: Clicking the bonjour service in Safari won't work because Safari will use http and not https. 27 | // Just change the url to https for proper access. 28 | 29 | // Normally there's no need to run our server on any specific port. 30 | // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. 31 | // However, for easy testing you may want force a certain port so you can just hit the refresh button. 32 | // [httpServer setPort:12345]; 33 | 34 | // We're going to extend the base HTTPConnection class with our MyHTTPConnection class. 35 | // This allows us to customize the server for things such as SSL and password-protection. 36 | [httpServer setConnectionClass:[MyHTTPConnection class]]; 37 | 38 | // Serve files from the standard Sites folder 39 | NSString *docRoot = [@"~/Sites" stringByExpandingTildeInPath]; 40 | DDLogInfo(@"Setting document root: %@", docRoot); 41 | 42 | [httpServer setDocumentRoot:docRoot]; 43 | 44 | NSError *error = nil; 45 | if(![httpServer start:&error]) 46 | { 47 | DDLogError(@"Error starting HTTP Server: %@", error); 48 | } 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Command Line Interface/tribo.m: -------------------------------------------------------------------------------- 1 | // 2 | // Tribo.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 9/25/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBSite.h" 11 | #import "TBHTTPServer.h" 12 | #import "CZAFileWatcher.h" 13 | #import 14 | 15 | void printHeader(const char *header); 16 | void printError(const char *errorMessage); 17 | 18 | int main (int argumentCount, const char *arguments[]) { 19 | 20 | @autoreleasepool { 21 | 22 | printHeader("Compiling website..."); 23 | TBSite *site = [TBSite siteWithRoot:[NSURL fileURLWithPath:[NSFileManager defaultManager].currentDirectoryPath]]; 24 | 25 | NSError *error = nil; 26 | if (![site process:&error]) { 27 | printError([[error localizedDescription] cStringUsingEncoding:NSUTF8StringEncoding]); 28 | exit((int)[error code]); 29 | } 30 | 31 | TBHTTPServer *server = [TBHTTPServer new]; 32 | server.documentRoot = site.destination.path; 33 | server.port = 4000; 34 | [server start:nil]; 35 | printHeader("Development server started at http://localhost:4000/"); 36 | printHeader("Opening website in default web browser..."); 37 | LSOpenCFURLRef((__bridge CFURLRef)[NSURL URLWithString:@"http://localhost:4000/"], NULL); 38 | 39 | CZAFileWatcher *watcher = [CZAFileWatcher fileWatcherForURLs:@[site.sourceDirectory, site.postsDirectory, site.templatesDirectory] changesHandler:^(NSArray *changedURLs) { 40 | [site process:nil]; 41 | [server refreshPages]; 42 | }]; 43 | [watcher startWatching]; 44 | 45 | dispatch_main(); 46 | 47 | } 48 | 49 | return EXIT_SUCCESS; 50 | 51 | } 52 | 53 | void printHeader(const char *header) { 54 | printf("\e[1m\e[34m==>\e[0m\e[0m "); 55 | printf("\e[1m%s\e[0m\n", header); 56 | } 57 | 58 | void printError(const char *errorMessage) { 59 | fprintf(stderr, "\e[1m\e[34m==>\e[0m\e[0m "); 60 | fprintf(stderr, "\e[1m%s\e[0m\n", errorMessage); 61 | } 62 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m: -------------------------------------------------------------------------------- 1 | #import "PUTResponse.h" 2 | #import "HTTPLogging.h" 3 | 4 | // HTTP methods: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html 5 | // HTTP headers: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 6 | // HTTP status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 7 | 8 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; 9 | 10 | @implementation PUTResponse 11 | 12 | - (id) initWithFilePath:(NSString*)path headers:(NSDictionary*)headers body:(id)body { 13 | if ((self = [super init])) { 14 | if ([headers objectForKey:@"Content-Range"]) { 15 | HTTPLogError(@"Content-Range not supported for upload to \"%@\"", path); 16 | _status = 400; 17 | } else { 18 | BOOL overwrite = [[NSFileManager defaultManager] fileExistsAtPath:path]; 19 | BOOL success; 20 | if ([body isKindOfClass:[NSString class]]) { 21 | [[NSFileManager defaultManager] removeItemAtPath:path error:NULL]; 22 | success = [[NSFileManager defaultManager] moveItemAtPath:body toPath:path error:NULL]; 23 | } else { 24 | success = [body writeToFile:path atomically:YES]; 25 | } 26 | if (success) { 27 | _status = overwrite ? 200 : 201; 28 | } else { 29 | HTTPLogError(@"Failed writing upload to \"%@\"", path); 30 | _status = 403; 31 | } 32 | } 33 | } 34 | return self; 35 | } 36 | 37 | - (id) initWithFilePath:(NSString*)path headers:(NSDictionary*)headers bodyData:(NSData*)body { 38 | return [self initWithFilePath:path headers:headers body:body]; 39 | } 40 | 41 | - (id) initWithFilePath:(NSString*)path headers:(NSDictionary*)headers bodyFile:(NSString*)body { 42 | return [self initWithFilePath:path headers:headers body:body]; 43 | } 44 | 45 | - (UInt64) contentLength { 46 | return 0; 47 | } 48 | 49 | - (UInt64) offset { 50 | return 0; 51 | } 52 | 53 | - (void) setOffset:(UInt64)offset { 54 | ; 55 | } 56 | 57 | - (NSData*) readDataOfLength:(NSUInteger)length { 58 | return nil; 59 | } 60 | 61 | - (BOOL) isDone { 62 | return YES; 63 | } 64 | 65 | - (NSInteger) status { 66 | return _status; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Dependencies/BLAKE3/blake3.h: -------------------------------------------------------------------------------- 1 | #ifndef BLAKE3_H 2 | #define BLAKE3_H 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define BLAKE3_VERSION_STRING "1.3.1" 12 | #define BLAKE3_KEY_LEN 32 13 | #define BLAKE3_OUT_LEN 32 14 | #define BLAKE3_BLOCK_LEN 64 15 | #define BLAKE3_CHUNK_LEN 1024 16 | #define BLAKE3_MAX_DEPTH 54 17 | 18 | // This struct is a private implementation detail. It has to be here because 19 | // it's part of blake3_hasher below. 20 | typedef struct { 21 | uint32_t cv[8]; 22 | uint64_t chunk_counter; 23 | uint8_t buf[BLAKE3_BLOCK_LEN]; 24 | uint8_t buf_len; 25 | uint8_t blocks_compressed; 26 | uint8_t flags; 27 | } blake3_chunk_state; 28 | 29 | typedef struct { 30 | uint32_t key[8]; 31 | blake3_chunk_state chunk; 32 | uint8_t cv_stack_len; 33 | // The stack size is MAX_DEPTH + 1 because we do lazy merging. For example, 34 | // with 7 chunks, we have 3 entries in the stack. Adding an 8th chunk 35 | // requires a 4th entry, rather than merging everything down to 1, because we 36 | // don't know whether more input is coming. This is different from how the 37 | // reference implementation does things. 38 | uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN]; 39 | } blake3_hasher; 40 | 41 | const char *blake3_version(void); 42 | void blake3_hasher_init(blake3_hasher *self); 43 | void blake3_hasher_init_keyed(blake3_hasher *self, 44 | const uint8_t key[BLAKE3_KEY_LEN]); 45 | void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context); 46 | void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, 47 | size_t context_len); 48 | void blake3_hasher_update(blake3_hasher *self, const void *input, 49 | size_t input_len); 50 | void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, 51 | size_t out_len); 52 | void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, 53 | uint8_t *out, size_t out_len); 54 | void blake3_hasher_reset(blake3_hasher *self); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* BLAKE3_H */ 61 | -------------------------------------------------------------------------------- /Mac App/Controllers/TBNewSiteSheetController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBNewSiteSheetController.m 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 3/19/12. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBNewSiteSheetController.h" 11 | 12 | @interface TBNewSiteSheetController () 13 | @property (nonatomic, copy) TBNewSiteSheetCompletionHandler handler; 14 | @property (nonatomic, weak) IBOutlet NSTextField *nameField; 15 | @property (nonatomic, weak) IBOutlet NSTextField *authorField; 16 | - (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; 17 | - (IBAction)next:(id)sender; 18 | - (IBAction)cancel:(id)sender; 19 | @end 20 | 21 | @implementation TBNewSiteSheetController 22 | 23 | - (id)init { 24 | self = [super initWithWindowNibName:@"TBNewSiteSheet"]; 25 | return self; 26 | } 27 | 28 | - (void)runModalForWindow:(NSWindow *)window completionHandler:(TBNewSiteSheetCompletionHandler)handler { 29 | self.handler = handler; 30 | [NSApp beginSheet:self.window modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil]; 31 | } 32 | 33 | - (IBAction)next:(id)sender { 34 | 35 | NSString *name = self.nameField.stringValue; 36 | NSString *author = self.authorField.stringValue; 37 | 38 | NSSavePanel *savePanel = [NSSavePanel savePanel]; 39 | savePanel.extensionHidden = YES; 40 | savePanel.nameFieldStringValue = [name stringByAppendingString:@".tribo"]; 41 | [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { 42 | if (result == NSFileHandlingPanelCancelButton) return; 43 | if (self.handler) self.handler(name, author, savePanel.URL); 44 | [NSApp endSheet:self.window returnCode:NSOKButton]; 45 | }]; 46 | 47 | } 48 | 49 | - (IBAction)cancel:(id)sender { 50 | [NSApp endSheet:self.window returnCode:NSCancelButton]; 51 | } 52 | 53 | - (void)windowDidLoad { 54 | [super windowDidLoad]; 55 | } 56 | 57 | - (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { 58 | if (self.handler) { 59 | if (returnCode == NSCancelButton) { 60 | self.handler(nil, nil, nil); 61 | } 62 | } 63 | [sheet orderOut:self]; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SecureWebSocketServer/README.markdown: -------------------------------------------------------------------------------- 1 | INFO: 2 | 3 | The SecureWebSocketServer examples demonstrates two technologies: 4 | - Creating a HTTPS server 5 | - WebSockets 6 | 7 | To create a secure HTTPS server, all connections must be secured using SSL/TLS. 8 | And in order to do that, you need to have a X509 certificate. 9 | Normally you PAY MONEY for these. 10 | For example, you purchase them via Verisign. 11 | However, for our example we're going to create a self-signed certificate. 12 | 13 | This means that when you browse the server in Safari, it may present a warning saying the certificate is untrusted. (Which makes sense since you didn't pay money to a trusted 3rd party certificate agency.) To make things easier for testing, when Safari presents this warning, click the "show certificate" button. And then click the "always trust this certificate" button. 14 | 15 | Also, the first time you run the server, it will automatically create a self-signed certificate and add it to your keychain (under the name SecureHTTPServer). Now the SecureHTTPServer is authorized to access this keychain item - unless of course the binary changes. So if you make changes, or simply switch between debug/release builds, you'll keep getting prompted by the Keychain utility. To solve this problem, open the Keychain Access application. Find the "SecureHTTPServer" private key, and change it's Access Control to "Allow all applications to access this item". 16 | 17 | The sample includes a Web folder which is added to the project, copied into the application's resources folder, and is set as the document root of the http server. It contains a simple index.html file and the client-side code (run in the web browser) for the websocket stuff. 18 | 19 | It is fairly straight-forward. It will query the server for the time every second, and present the result on the page. 20 | 21 | Take a look at the MyWebSocket class to see the related server code. 22 | 23 | INSTRUCTIONS: 24 | 25 | Open the Xcode project, and build and go. 26 | 27 | On the Xcode console you'll see a message saying: 28 | "Started HTTP server on port 59123" 29 | 30 | Now open a browser that supports WebSockets (e.g. Google Chrome or Safari) 31 | and type in the URL: 32 | https://localhost:59123 33 | 34 | Notice that you're using "https" and not "http". 35 | 36 | (Replace 59123 with whatever port the server is actually running on.) 37 | 38 | Enjoy. -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Vendor/CocoaLumberjack/About.txt: -------------------------------------------------------------------------------- 1 | CocoaLumberjack is under the New BSD License. 2 | https://github.com/robbiehanson/CocoaLumberjack 3 | 4 | Extensive documentation, tutorials, etc are available: 5 | https://github.com/robbiehanson/CocoaLumberjack/wiki 6 | 7 | Overview of the project (copied from google code homepage): 8 | 9 | 10 | 11 | The lumberjack framework is fast & simple, yet powerful & flexible. 12 | It is similar in concept to other popular logging frameworks such as log4j, yet is designed specifically for objective-c, and takes advantage of features such as multi-threading, grand central dispatch (if available), lockless atomic operations, and the dynamic nature of the objective-c runtime. 13 | 14 | Lumberjack is fast: 15 | In most cases it is an order of magnitude faster than NSLog. 16 | 17 | Lumberjack is simple: 18 | It takes as little as a single line of code to configure lumberjack when your application launches. Then simply replace your NSLog statements with DDLog statements and that's about it. (And the DDLog macros have the exact same format and syntax as NSLog, so it's super easy.) 19 | 20 | Lumberjack is powerful: 21 | One log statement can be sent to multiple loggers, meaning you can log to a file and the console simultaneously. Want more? Create your own loggers (it's easy) and send your log statements over the network. Or to a database or distributed file system. The sky is the limit. 22 | 23 | Lumberjack is flexible: 24 | Configure your logging however you want. Change log levels per file (perfect for debugging). Change log levels per logger (verbose console, but concise log file). Change log levels per xcode configuration (verbose debug, but concise release). Have your log statements compiled out of the release build. Customize the number of log levels for your application. Add your own fine-grained logging. Dynamically change log levels during runtime. Choose how & when you want your log files to be rolled. Upload your log files to a central server. Compress archived log files to save disk space... 25 | 26 | 27 | 28 | This framework is for you if: 29 | 30 | You're looking for a way to track down that impossible-to-reproduce bug that keeps popping up in the field. 31 | You're frustrated with the super short console log on the iPhone. 32 | You're looking to take your application to the next level in terms of support and stability. 33 | You're looking for an enterprise level logging solution for your application (Mac or iPhone). -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Samples/SimpleWebSocketServer/MyHTTPConnection.m: -------------------------------------------------------------------------------- 1 | #import "MyHTTPConnection.h" 2 | #import "HTTPMessage.h" 3 | #import "HTTPResponse.h" 4 | #import "HTTPDynamicFileResponse.h" 5 | #import "GCDAsyncSocket.h" 6 | #import "MyWebSocket.h" 7 | #import "HTTPLogging.h" 8 | 9 | // Log levels: off, error, warn, info, verbose 10 | // Other flags: trace 11 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE; 12 | 13 | 14 | @implementation MyHTTPConnection 15 | 16 | - (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path 17 | { 18 | HTTPLogTrace(); 19 | 20 | if ([path isEqualToString:@"/WebSocketTest2.js"]) 21 | { 22 | // The socket.js file contains a URL template that needs to be completed: 23 | // 24 | // ws = new WebSocket("%%WEBSOCKET_URL%%"); 25 | // 26 | // We need to replace "%%WEBSOCKET_URL%%" with whatever URL the server is running on. 27 | // We can accomplish this easily with the HTTPDynamicFileResponse class, 28 | // which takes a dictionary of replacement key-value pairs, 29 | // and performs replacements on the fly as it uploads the file. 30 | 31 | NSString *wsLocation; 32 | 33 | NSString *wsHost = [request headerField:@"Host"]; 34 | if (wsHost == nil) 35 | { 36 | NSString *port = [NSString stringWithFormat:@"%hu", [asyncSocket localPort]]; 37 | wsLocation = [NSString stringWithFormat:@"ws://localhost:%@/service", port]; 38 | } 39 | else 40 | { 41 | wsLocation = [NSString stringWithFormat:@"ws://%@/service", wsHost]; 42 | } 43 | 44 | NSDictionary *replacementDict = [NSDictionary dictionaryWithObject:wsLocation forKey:@"WEBSOCKET_URL"]; 45 | 46 | return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path] 47 | forConnection:self 48 | separator:@"%%" 49 | replacementDictionary:replacementDict]; 50 | } 51 | 52 | return [super httpResponseForMethod:method URI:path]; 53 | } 54 | 55 | - (WebSocket *)webSocketForURI:(NSString *)path 56 | { 57 | HTTPLogTrace2(@"%@[%p]: webSocketForURI: %@", THIS_FILE, self, path); 58 | 59 | if([path isEqualToString:@"/service"]) 60 | { 61 | HTTPLogInfo(@"MyHTTPConnection: Creating MyWebSocket..."); 62 | 63 | return [[MyWebSocket alloc] initWithRequest:request socket:asyncSocket]; 64 | } 65 | 66 | return [super webSocketForURI:path]; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h: -------------------------------------------------------------------------------- 1 | 2 | #import "MultipartMessageHeader.h" 3 | 4 | /* 5 | Part one: http://tools.ietf.org/html/rfc2045 (Format of Internet Message Bodies) 6 | Part two: http://tools.ietf.org/html/rfc2046 (Media Types) 7 | Part three: http://tools.ietf.org/html/rfc2047 (Message Header Extensions for Non-ASCII Text) 8 | Part four: http://tools.ietf.org/html/rfc4289 (Registration Procedures) 9 | Part five: http://tools.ietf.org/html/rfc2049 (Conformance Criteria and Examples) 10 | 11 | Internet message format: http://tools.ietf.org/html/rfc2822 12 | 13 | Multipart/form-data http://tools.ietf.org/html/rfc2388 14 | */ 15 | 16 | @class MultipartFormDataParser; 17 | 18 | //----------------------------------------------------------------- 19 | // protocol MultipartFormDataParser 20 | //----------------------------------------------------------------- 21 | 22 | @protocol MultipartFormDataParserDelegate 23 | @optional 24 | - (void) processContent:(NSData*) data WithHeader:(MultipartMessageHeader*) header; 25 | - (void) processEndOfPartWithHeader:(MultipartMessageHeader*) header; 26 | - (void) processPreambleData:(NSData*) data; 27 | - (void) processEpilogueData:(NSData*) data; 28 | - (void) processStartOfPartWithHeader:(MultipartMessageHeader*) header; 29 | @end 30 | 31 | //----------------------------------------------------------------- 32 | // interface MultipartFormDataParser 33 | //----------------------------------------------------------------- 34 | 35 | @interface MultipartFormDataParser : NSObject { 36 | NSMutableData* pendingData; 37 | NSData* boundaryData; 38 | MultipartMessageHeader* currentHeader; 39 | 40 | BOOL waitingForCRLF; 41 | BOOL reachedEpilogue; 42 | BOOL processedPreamble; 43 | BOOL checkForContentEnd; 44 | 45 | #if __has_feature(objc_arc_weak) 46 | __weak id delegate; 47 | #else 48 | __unsafe_unretained id delegate; 49 | #endif 50 | int currentEncoding; 51 | NSStringEncoding formEncoding; 52 | } 53 | 54 | - (BOOL) appendData:(NSData*) data; 55 | 56 | - (id) initWithBoundary:(NSString*) boundary formEncoding:(NSStringEncoding) formEncoding; 57 | 58 | #if __has_feature(objc_arc_weak) 59 | @property(weak, readwrite) id delegate; 60 | #else 61 | @property(unsafe_unretained, readwrite) id delegate; 62 | #endif 63 | @property(readwrite) NSStringEncoding formEncoding; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDLog.h" 3 | 4 | @class ContextFilterLogFormatter; 5 | 6 | /** 7 | * Welcome to Cocoa Lumberjack! 8 | * 9 | * The project page has a wealth of documentation if you have any questions. 10 | * https://github.com/robbiehanson/CocoaLumberjack 11 | * 12 | * If you're new to the project you may wish to read the "Getting Started" page. 13 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted 14 | * 15 | * 16 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist. 17 | * 18 | * A log formatter can be added to any logger to format and/or filter its output. 19 | * You can learn more about log formatters here: 20 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters 21 | * 22 | * You can learn more about logging context's here: 23 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomContext 24 | * 25 | * But here's a quick overview / refresher: 26 | * 27 | * Every log statement has a logging context. 28 | * These come from the underlying logging macros defined in DDLog.h. 29 | * The default logging context is zero. 30 | * You can define multiple logging context's for use in your application. 31 | * For example, logically separate parts of your app each have a different logging context. 32 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context. 33 | **/ 34 | @interface ContextWhitelistFilterLogFormatter : NSObject 35 | 36 | - (id)init; 37 | 38 | - (void)addToWhitelist:(int)loggingContext; 39 | - (void)removeFromWhitelist:(int)loggingContext; 40 | 41 | - (NSArray *)whitelist; 42 | 43 | - (BOOL)isOnWhitelist:(int)loggingContext; 44 | 45 | @end 46 | 47 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 48 | #pragma mark - 49 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 50 | 51 | /** 52 | * This class provides a log formatter that filters log statements from a logging context on the blacklist. 53 | **/ 54 | @interface ContextBlacklistFilterLogFormatter : NSObject 55 | 56 | - (id)init; 57 | 58 | - (void)addToBlacklist:(int)loggingContext; 59 | - (void)removeFromBlacklist:(int)loggingContext; 60 | 61 | - (NSArray *)blacklist; 62 | 63 | - (BOOL)isOnBlacklist:(int)loggingContext; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Shared/TBError.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBError.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 7/27/13. 6 | // Copyright (c) 2013 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBError.h" 11 | 12 | NSString * const TBErrorDomain = @"com.opt-6.Tribo.ErrorDomain"; 13 | NSString * const TBErrorStringsTable = @"TBError"; 14 | 15 | enum { 16 | TBErrorMissingPostsDirectory = 42, 17 | TBErrorMissingPostPartial, 18 | TBErrorBadPostFileName, 19 | TBErrorMissingSourceDirectory, 20 | TBErrorFilterStandardError, 21 | }; 22 | 23 | static NSError *missingPostsDirectory(NSURL *postsDirectory) { 24 | NSString *description = [NSString stringWithFormat:NSLocalizedStringFromTable(@"MISSING_POSTS_DIRECTORY", TBErrorStringsTable, nil), postsDirectory.path]; 25 | return [NSError errorWithDomain:TBErrorDomain code:TBErrorMissingPostsDirectory userInfo:@{NSLocalizedDescriptionKey: description}]; 26 | } 27 | 28 | static NSError *missingPostPartial(NSURL *partialURL) { 29 | NSString *description = [NSString stringWithFormat:NSLocalizedStringFromTable(@"MISSING_POST_PARTIAL", TBErrorStringsTable, nil), partialURL.path]; 30 | return [NSError errorWithDomain:TBErrorDomain code:TBErrorMissingPostPartial userInfo:@{NSLocalizedDescriptionKey: description}]; 31 | } 32 | 33 | static NSError *badPostFileName(NSURL *postURL) { 34 | NSString *description = [NSString stringWithFormat:NSLocalizedStringFromTable(@"BAD_POST_FILE_NAME", TBErrorStringsTable, nil), postURL.path]; 35 | return [NSError errorWithDomain:TBErrorDomain code:TBErrorBadPostFileName userInfo:@{NSLocalizedDescriptionKey: description}]; 36 | } 37 | 38 | static NSError *missingSourceDirectory(NSURL *sourceDirectory) { 39 | NSString *description = [NSString stringWithFormat:NSLocalizedStringFromTable(@"MISSING_SOURCE_DIRECTORY", TBErrorStringsTable, nil), sourceDirectory.path]; 40 | return [NSError errorWithDomain:TBErrorDomain code:TBErrorMissingSourceDirectory userInfo:@{NSLocalizedDescriptionKey: description}]; 41 | } 42 | 43 | static NSError *filterStandardError(NSURL *filterURL, NSString *standardError) { 44 | NSString *description = [NSString stringWithFormat:NSLocalizedStringFromTable(@"FILTER_STANDARD_ERROR", TBErrorStringsTable, nil), filterURL.path, standardError]; 45 | return [NSError errorWithDomain:TBErrorDomain code:TBErrorFilterStandardError userInfo:@{NSLocalizedDescriptionKey: description}]; 46 | } 47 | 48 | const struct TBError TBError = { 49 | .missingPostsDirectory = missingPostsDirectory, 50 | .missingPostPartial = missingPostPartial, 51 | .badPostFileName = badPostFileName, 52 | .missingSourceDirectory = missingSourceDirectory, 53 | .filterStandardError = filterStandardError, 54 | }; 55 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/HTTPMessage.m: -------------------------------------------------------------------------------- 1 | #import "HTTPMessage.h" 2 | 3 | #if ! __has_feature(objc_arc) 4 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 5 | #endif 6 | 7 | @implementation HTTPMessage { 8 | CFHTTPMessageRef _message; 9 | } 10 | 11 | - (id)initEmptyRequest { 12 | self = [super init]; 13 | if (self) { 14 | _message = CFHTTPMessageCreateEmpty(NULL, YES); 15 | } 16 | return self; 17 | } 18 | 19 | - (id)initRequestWithMethod:(NSString *)method URL:(NSURL *)URL version:(NSString *)version { 20 | self = [super init]; 21 | if (self) { 22 | _message = CFHTTPMessageCreateRequest(NULL, (__bridge CFStringRef)method, (__bridge CFURLRef)URL, (__bridge CFStringRef)version); 23 | } 24 | return self; 25 | } 26 | 27 | - (id)initResponseWithStatusCode:(NSInteger)code description:(NSString *)description version:(NSString *)version { 28 | self = [super init]; 29 | if (self) { 30 | _message = CFHTTPMessageCreateResponse(NULL, (CFIndex)code, (__bridge CFStringRef)description, (__bridge CFStringRef)version); 31 | } 32 | return self; 33 | } 34 | 35 | - (void)dealloc { 36 | if (_message) CFRelease(_message); 37 | } 38 | 39 | - (BOOL)appendData:(NSData *)data { 40 | return CFHTTPMessageAppendBytes(_message, [data bytes], [data length]); 41 | } 42 | 43 | - (BOOL)isHeaderComplete { 44 | return CFHTTPMessageIsHeaderComplete(_message); 45 | } 46 | 47 | - (NSString *)version { 48 | return (__bridge_transfer NSString *)CFHTTPMessageCopyVersion(_message); 49 | } 50 | 51 | - (NSString *)method { 52 | return (__bridge_transfer NSString *)CFHTTPMessageCopyRequestMethod(_message); 53 | } 54 | 55 | - (NSURL *)URL { 56 | return (__bridge_transfer NSURL *)CFHTTPMessageCopyRequestURL(_message); 57 | } 58 | 59 | - (NSInteger)statusCode { 60 | return (NSInteger)CFHTTPMessageGetResponseStatusCode(_message); 61 | } 62 | 63 | - (NSDictionary *)allHeaderFields { 64 | return (__bridge_transfer NSDictionary *)CFHTTPMessageCopyAllHeaderFields(_message); 65 | } 66 | 67 | - (NSString *)valueForHeaderField:(NSString *)headerField { 68 | return (__bridge_transfer NSString *)CFHTTPMessageCopyHeaderFieldValue(_message, (__bridge CFStringRef)headerField); 69 | } 70 | 71 | - (void)setValue:(NSString *)value forHeaderField:(NSString *)headerField { 72 | CFHTTPMessageSetHeaderFieldValue(_message, (__bridge CFStringRef)headerField, (__bridge CFStringRef)value); 73 | } 74 | 75 | - (NSData *)messageData { 76 | return (__bridge_transfer NSData *)CFHTTPMessageCopySerializedMessage(_message); 77 | } 78 | 79 | - (NSData *)body { 80 | return (__bridge_transfer NSData *)CFHTTPMessageCopyBody(_message); 81 | } 82 | 83 | - (void)setBody:(NSData *)body { 84 | CFHTTPMessageSetBody(_message, (__bridge CFDataRef)body); 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Shared/TBPost.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBPost.h 3 | // Tribo 4 | // 5 | // Created by Carter Allen on 9/25/11. 6 | // Copyright (c) 2012 The Tribo Authors. 7 | // See the included License.md file. 8 | // 9 | 10 | #import "TBPage.h" 11 | 12 | /*! 13 | @class TBPost 14 | @discussion A post represents a piece of writing, loaded from disk, with its 15 | content styled using Markdown. Posts are loaded from a Tribo site file's 16 | Posts directory (typically just /Posts inside the bundle), and their content 17 | is converted to HTML before being rendered using the Post template found in 18 | the site's Templates directory. 19 | 20 | As a data structure, posts are fairly simple. TBPost inherits from TBPage, 21 | which gives the class properties that apply to any rendered file in a site. 22 | In addition to the standard page properties, posts have author, date, and 23 | slug properties, along with a property to access the unprocessed Markdown 24 | content of the post. More information about the derivation of each property 25 | can be found in the specific descriptions. 26 | */ 27 | 28 | @interface TBPost : TBPage 29 | 30 | /*! 31 | Create a TBPost object from a file on-disk. 32 | @param URL 33 | A filesystem URL pointing to the post file. 34 | @param site 35 | The TBSite object which contains the post. 36 | @param error 37 | If the return value is nil, then this argument will contain an NSError 38 | object describing what went wrong. 39 | @return 40 | A TBPost object, or nil if an error was encountered. 41 | */ 42 | + (instancetype)postWithURL:(NSURL *)URL 43 | inSite:(TBSite *)site 44 | error:(NSError **)error; 45 | 46 | /*! 47 | Parse the contents of the markdownContent property, saving the HTML output 48 | to the content property. 49 | */ 50 | - (void)parseMarkdownContent; 51 | 52 | /*! 53 | @property author 54 | The name of the person who wrote the post. This property is not 55 | currently implemented. 56 | */ 57 | @property (nonatomic, strong) NSString *author; 58 | 59 | /*! 60 | @property date 61 | The publishing date of the post. Derived from the filename of the post, 62 | which must begin with a calendar date in the form YYYY-MM-DD. 63 | */ 64 | @property (nonatomic, strong) NSDate *date; 65 | 66 | /*! 67 | @property slug 68 | Appears in the site output in the URL of the post. Should be a URL-safe 69 | string, and is typically a shortened version of the post's title with 70 | any spaces replaced with dashes. Derived from the filename of the post, 71 | where the slug must immediately follow the date, separated by a dash. 72 | */ 73 | @property (nonatomic, strong) NSString *slug; 74 | 75 | /*! 76 | @property markdownContent 77 | The original content of the post, before being converted to HTML by the 78 | Markdown parser. 79 | */ 80 | @property (nonatomic, strong) NSString *markdownContent; 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Dependencies/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MultipartMessagePart.m 3 | // HttpServer 4 | // 5 | // Created by Валерий Гаврилов on 29.03.12. 6 | // Copyright (c) 2012 LLC "Online Publishing Partners" (onlinepp.ru). All rights reserved. 7 | 8 | #import "MultipartMessageHeader.h" 9 | #import "MultipartMessageHeaderField.h" 10 | 11 | #import "HTTPLogging.h" 12 | 13 | //----------------------------------------------------------------- 14 | #pragma mark log level 15 | 16 | #ifdef DEBUG 17 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; 18 | #else 19 | static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; 20 | #endif 21 | 22 | //----------------------------------------------------------------- 23 | // implementation MultipartMessageHeader 24 | //----------------------------------------------------------------- 25 | 26 | 27 | @implementation MultipartMessageHeader 28 | @synthesize fields,encoding; 29 | 30 | 31 | - (id) initWithData:(NSData *)data formEncoding:(NSStringEncoding) formEncoding { 32 | if( nil == (self = [super init]) ) { 33 | return self; 34 | } 35 | 36 | fields = [[NSMutableDictionary alloc] initWithCapacity:1]; 37 | 38 | // In case encoding is not mentioned, 39 | encoding = contentTransferEncoding_unknown; 40 | 41 | char* bytes = (char*)data.bytes; 42 | NSUInteger length = data.length; 43 | int offset = 0; 44 | 45 | // split header into header fields, separated by \r\n 46 | uint16_t fields_separator = 0x0A0D; // \r\n 47 | while( offset < length - 2 ) { 48 | 49 | // the !isspace condition is to support header unfolding 50 | if( (*(uint16_t*) (bytes+offset) == fields_separator) && ((offset == length - 2) || !(isspace(bytes[offset+2])) )) { 51 | NSData* fieldData = [NSData dataWithBytesNoCopy:bytes length:offset freeWhenDone:NO]; 52 | MultipartMessageHeaderField* field = [[MultipartMessageHeaderField alloc] initWithData: fieldData contentEncoding:formEncoding]; 53 | if( field ) { 54 | [fields setObject:field forKey:field.name]; 55 | HTTPLogVerbose(@"MultipartFormDataParser: Processed Header field '%@'",field.name); 56 | } 57 | else { 58 | NSString* fieldStr = [[NSString alloc] initWithData:fieldData encoding:NSASCIIStringEncoding]; 59 | HTTPLogWarn(@"MultipartFormDataParser: Failed to parse MIME header field. Input ASCII string:%@",fieldStr); 60 | } 61 | 62 | // move to the next header field 63 | bytes += offset + 2; 64 | length -= offset + 2; 65 | offset = 0; 66 | continue; 67 | } 68 | ++ offset; 69 | } 70 | 71 | if( !fields.count ) { 72 | // it was an empty header. 73 | // we have to set default values. 74 | // default header. 75 | [fields setObject:@"text/plain" forKey:@"Content-Type"]; 76 | } 77 | 78 | return self; 79 | } 80 | 81 | - (NSString *)description { 82 | return [NSString stringWithFormat:@"%@",fields]; 83 | } 84 | 85 | 86 | @end 87 | --------------------------------------------------------------------------------