Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Thumbnail preview #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions GenerateThumbnailForURL.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#import <QuickLook/QuickLook.h>
#import <WebKit/WebKit.h>

#import "markdown.h"

OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url,
CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize);
void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbnail);
Expand All @@ -17,7 +19,7 @@ OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thum
OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url,
CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize) {

NSString *content = [NSString stringWithContentsOfURL:(__bridge NSURL *)url encoding:NSUTF8StringEncoding error:nil];
NSString *content = renderMarkdown((__bridge NSURL *)url);

if (content) {
// Encapsulate the content of the .strings file in HTML
Expand All @@ -30,7 +32,7 @@ OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thum

// Create the webview to display the thumbnail
WebView *_webView = [[WebView alloc] initWithFrame:_rect];
[_webView scaleUnitSquareToSize:_scaleSize];
[_webView.mainFrame.frameView scaleUnitSquareToSize:_scaleSize];
[_webView.mainFrame.frameView setAllowsScrolling:NO];
[_webView.mainFrame loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil];

Expand Down