Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 9a5b20d1a0c5f8e68d18ff8ad2bbe8f8834de546 Phillip Toland committed Jul 8, 2008
@@ -0,0 +1,4 @@
+.DS_Store
+build
+*.xcodeproj/*.pbxuser
+*.xcodeproj/*.mode1v3
Binary file not shown.
@@ -0,0 +1,28 @@
+#import <QuickLook/QuickLook.h>
+#import <Cocoa/Cocoa.h>
+#include "markdown.h"
+
+/* -----------------------------------------------------------------------------
+ Generate a preview for file
+
+ This function's job is to create preview for designated file
+ -------------------------------------------------------------------------- */
+
+OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
+ CFURLRef url, CFStringRef contentTypeUTI,
+ CFDictionaryRef options)
+{
+ CFDataRef data = (CFDataRef) renderMarkdown((NSURL*) url);
+
+ if (data) {
+ CFDictionaryRef props = (CFDictionaryRef) [NSDictionary dictionary];
+ QLPreviewRequestSetDataRepresentation(preview, data, kUTTypeHTML, props);
+ }
+
+ return noErr;
+}
+
+void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
+{
+ // implement only if supported
+}
@@ -0,0 +1,70 @@
+#import <QuickLook/QuickLook.h>
+#import <Cocoa/Cocoa.h>
+#import <WebKit/WebKit.h>
+#include "markdown.h"
+
+/* -----------------------------------------------------------------------------
+ Generate a thumbnail for file
+
+ This function's job is to create thumbnail for designated file as fast as
+ possible
+ -------------------------------------------------------------------------- */
+
+//The minimum aspect ratio (width / height) of a thumbnail.
+#define MINIMUM_ASPECT_RATIO (1.0/2.0)
+
+
+OSStatus GenerateThumbnailForURL(void *thisInterface,
+ QLThumbnailRequestRef thumbnail,
+ CFURLRef url, CFStringRef contentTypeUTI,
+ CFDictionaryRef options, CGSize maxSize)
+{
+ NSData *data = renderMarkdown((NSURL*) url);
+
+ if (data) {
+ NSRect viewRect = NSMakeRect(0.0, 0.0, 600.0, 800.0);
+ float scale = maxSize.height / 800.0;
+ NSSize scaleSize = NSMakeSize(scale, scale);
+ CGSize thumbSize = NSSizeToCGSize(
+ NSMakeSize((maxSize.width * (600.0/800.0)),
+ maxSize.height));
+
+ WebView* webView = [[WebView alloc] initWithFrame: viewRect];
+ [webView scaleUnitSquareToSize: scaleSize];
+ [[[webView mainFrame] frameView] setAllowsScrolling:NO];
+ [[webView mainFrame] loadData: data
+ MIMEType: @"text/html"
+ textEncodingName: @"utf-8"
+ baseURL: nil];
+
+ while([webView isLoading]) {
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
+ }
+
+ [webView display];
+
+ CGContextRef context =
+ QLThumbnailRequestCreateContext(thumbnail, thumbSize, false, NULL);
+
+ if (context) {
+ NSGraphicsContext* nsContext =
+ [NSGraphicsContext
+ graphicsContextWithGraphicsPort: (void*) context
+ flipped: [webView isFlipped]];
+
+ [webView displayRectIgnoringOpacity: [webView bounds]
+ inContext: nsContext];
+
+ QLThumbnailRequestFlushContext(thumbnail, context);
+
+ CFRelease(context);
+ }
+ }
+
+ return noErr;
+}
+
+void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail)
+{
+ // implement only if supported
+}
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>UTImportedTypeDeclarations</key>
+ <array>
+ <dict>
+ <key>UTTypeIdentifier</key>
+ <string>net.daringfireball.markdown</string>
+ <key>UTTypeReferenceURL</key>
+ <string>http://daringfireball.net/projects/markdown/</string>
+ <key>UTTypeDescription</key>
+ <string>Markdown document</string>
+ <key>UTTypeIconFile</key>
+ <string>public.text.icns</string>
+ <key>UTTypeConformsTo</key>
+ <array>
+ <string>public.text</string>
+ </array>
+ <key>UTTypeTagSpecification</key>
+ <dict>
+ <key>public.filename-extension</key>
+ <array>
+ <string>markdown</string>
+ <string>mdown</string>
+ </array>
+ </dict>
+ </dict>
+ </array>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>QLGenerator</string>
+ <key>LSItemContentTypes</key>
+ <array>
+ <string>net.daringfireball.markdown</string>
+ </array>
+ </dict>
+ </array>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.fiatdev.QLMarkdown</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1</string>
+ <key>CFPlugInDynamicRegisterFunction</key>
+ <string></string>
+ <key>CFPlugInDynamicRegistration</key>
+ <string>NO</string>
+ <key>CFPlugInFactories</key>
+ <dict>
+ <key>984AED87-72B9-4060-B7BC-935561C2221B</key>
+ <string>QuickLookGeneratorPluginFactory</string>
+ </dict>
+ <key>CFPlugInTypes</key>
+ <dict>
+ <key>5E2D9680-5022-40FA-B806-43349622E5B9</key>
+ <array>
+ <string>984AED87-72B9-4060-B7BC-935561C2221B</string>
+ </array>
+ </dict>
+ <key>CFPlugInUnloadFunction</key>
+ <string></string>
+ <!-- Change following property to <true/> if the generators supports
+ multiple concurrent requests -->
+ <key>QLSupportsConcurrentRequests</key>
+ <false/>
+ <!-- Change following property to <true/> if the generators needs
+ to be run on main thread -->
+ <key>QLNeedsToBeRunInMainThread</key>
+ <false/>
+ <!-- Change following property to indicate the minimum useful size for a thumbnail the generator
+ can produce. If your generator is fast enough, you can remove the minimum size so to appear in lists -->
+ <key>QLThumbnailMinimumSize</key>
+ <real>17</real>
+ <!-- Change following properites to indicate the preview size to use if preview generation takes too long -->
+ <key>QLPreviewWidth</key>
+ <real>800</real>
+ <key>QLPreviewHeight</key>
+ <real>600</real>
+</dict>
+</plist>
@@ -0,0 +1,30 @@
+Copyright (c) 2004, John Gruber
+<http://daringfireball.net/>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+* Neither the name "Markdown" nor the names of its contributors may
+ be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+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.
Oops, something went wrong.

0 comments on commit 9a5b20d

Please sign in to comment.