Browse Source

v2.0 which included Rmd preview/edit

master
boB Rudis 3 years ago
parent
commit
7d12a876f4
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 23
      .gitignore
  2. BIN
      QuickLookR.qlgenerator.zip
  3. 116
      QuickLookR.qlgenerator/Contents/Info.plist
  4. BIN
      QuickLookR.qlgenerator/Contents/MacOS/QuickLookR
  5. 115
      QuickLookR.qlgenerator/Contents/_CodeSignature/CodeResources
  6. 51
      QuickLookR.xcodeproj/project.pbxproj
  7. 8
      QuickLookR.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  8. 5
      QuickLookR.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  9. 2
      QuickLookR.xcodeproj/xcuserdata/bob.xcuserdatad/xcschemes/QuickLookR.xcscheme
  10. 63
      QuickLookR/GeneratePreviewForURL.m
  11. 72
      QuickLookR/Info.plist

23
.gitignore

@ -0,0 +1,23 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

BIN
QuickLookR.qlgenerator.zip

Binary file not shown.

116
QuickLookR.qlgenerator/Contents/Info.plist

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>18F131a</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>QLGenerator</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
</dict>
<string>UTTypeTagSpecification</string>
<dict>
<key>public.filename-extension</key>
<array>
<string>rmd</string>
<string>rdata</string>
<string>rda</string>
<string>rds</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>QuickLookR</string>
<key>CFBundleIdentifier</key>
<string>is.rud.QuickLookR</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>QuickLookR</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<dict>
<key>786049CE-3ED2-49F7-8F4E-588A57CA2BDB</key>
<string>QuickLookGeneratorPluginFactory</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
<key>5E2D9680-5022-40FA-B806-43349622E5B9</key>
<array>
<string>786049CE-3ED2-49F7-8F4E-588A57CA2BDB</string>
</array>
</dict>
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>10E1001</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>18E219</string>
<key>DTSDKName</key>
<string>macosx10.14</string>
<key>DTXcode</key>
<string>1020</string>
<key>DTXcodeBuild</key>
<string>10E1001</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Bob Rudis. All rights reserved.</string>
<key>QLNeedsToBeRunInMainThread</key>
<false/>
<key>QLPreviewHeight</key>
<real>600</real>
<key>QLPreviewWidth</key>
<real>800</real>
<key>QLSupportsConcurrentRequests</key>
<false/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>R Data file</string>
<key>UTTypeIdentifier</key>
<string>is.rdata.quicklook</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>rmd</string>
<string>rdata</string>
<string>rda</string>
<string>rds</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>

BIN
QuickLookR.qlgenerator/Contents/MacOS/QuickLookR

Binary file not shown.

115
QuickLookR.qlgenerator/Contents/_CodeSignature/CodeResources

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict/>
<key>files2</key>
<dict/>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>

51
QuickLookR.xcodeproj/project.pbxproj

@ -17,8 +17,8 @@
C4291BFA1D552C60001238D2 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "~/Library/QuickLook";
dstSubfolderSpec = 0;
dstPath = "";
dstSubfolderSpec = 16;
files = (
C4291BFB1D552C7A001238D2 /* QuickLookR.qlgenerator in CopyFiles */,
);
@ -51,7 +51,9 @@
C4291BED1D552859001238D2 /* QuickLookR */,
C4291BEC1D552859001238D2 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
C4291BEC1D552859001238D2 /* Products */ = {
isa = PBXGroup;
@ -110,20 +112,23 @@
C4291BE21D552859001238D2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Bob Rudis";
TargetAttributes = {
C4291BEA1D552859001238D2 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = CBY22P58G8;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = C4291BE51D552859001238D2 /* Build configuration list for PBXProject "QuickLookR" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = C4291BE11D552859001238D2;
productRefGroup = C4291BEC1D552859001238D2 /* Products */;
@ -163,18 +168,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
@ -196,7 +212,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
@ -207,18 +223,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
@ -234,7 +261,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
@ -243,15 +270,19 @@
C4291BF81D552859001238D2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = CBY22P58G8;
INFOPLIST_FILE = QuickLookR/Info.plist;
INSTALL_PATH = /Library/QuickLook;
INSTALL_PATH = "~/Library/QuickLook";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/QuickLookR",
);
PRODUCT_BUNDLE_IDENTIFIER = is.rud.QuickLookR;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
WRAPPER_EXTENSION = qlgenerator;
};
name = Debug;
@ -259,15 +290,19 @@
C4291BF91D552859001238D2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = CBY22P58G8;
INFOPLIST_FILE = QuickLookR/Info.plist;
INSTALL_PATH = /Library/QuickLook;
INSTALL_PATH = "~/Library/QuickLook";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/QuickLookR",
);
PRODUCT_BUNDLE_IDENTIFIER = is.rud.QuickLookR;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
WRAPPER_EXTENSION = qlgenerator;
};
name = Release;

8
QuickLookR.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

5
QuickLookR.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

2
QuickLookR.xcodeproj/xcuserdata/bob.xcuserdatad/xcschemes/QuickLookR.xcscheme

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

63
QuickLookR/GeneratePreviewForURL.m

@ -17,33 +17,52 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
NSURL *myURL = (__bridge NSURL *)url ;
NSString *ext = [ [ myURL pathExtension ] lowercaseString ];
NSString *contents = [ myURL absoluteString ] ;
NSLog(@"Generating preview for %@", contents) ;
NSPipe *pipe = [ NSPipe pipe ] ;
NSFileHandle *file = pipe.fileHandleForReading ;
NSString *cmd = @"rdatainfo::get_info('" ;
cmd = [ cmd stringByAppendingString: contents ] ;
cmd = [ cmd stringByAppendingString: @"')" ] ;
NSTask *task = [ [ NSTask alloc ] init] ;
task.launchPath = @"/usr/local/bin/Rscript";
task.arguments = @[ @"-e", cmd ];
task.standardOutput = pipe;
[task launch];
NSData *data = [ file readDataToEndOfFile ] ;
[ file closeFile ];
NSString *rOutput = [ [ NSString alloc ] initWithData: data encoding: NSUTF8StringEncoding ] ;
if ([ ext isEqualToString: @"rmd" ]) {
QLPreviewRequestSetURLRepresentation(
preview,
url,
kUTTypePlainText,
NULL
);
return noErr;
} else {
NSPipe *pipe = [ NSPipe pipe ] ;
NSFileHandle *file = pipe.fileHandleForReading ;
NSString *cmd = @"rdatainfo::get_info('" ;
cmd = [ cmd stringByAppendingString: contents ] ;
cmd = [ cmd stringByAppendingString: @"')" ] ;
NSTask *task = [ [ NSTask alloc ] init] ;
task.launchPath = @"/usr/local/bin/Rscript";
task.arguments = @[ @"-e", cmd ];
task.standardOutput = pipe;
[task launch];
NSData *data = [ file readDataToEndOfFile ] ;
[ file closeFile ];
NSString *rOutput = [ [ NSString alloc ] initWithData: data encoding: NSUTF8StringEncoding ] ;
if (false == QLPreviewRequestIsCancelled(preview)) {
QLPreviewRequestSetDataRepresentation(preview,
(__bridge CFDataRef)([ rOutput dataUsingEncoding:NSUTF8StringEncoding ]),
kUTTypePlainText, NULL) ;
if (false == QLPreviewRequestIsCancelled(preview)) {
QLPreviewRequestSetDataRepresentation(
preview,
(__bridge CFDataRef)([ rOutput dataUsingEncoding:NSUTF8StringEncoding ]),
kUTTypePlainText, NULL
) ;
}
}
}

72
QuickLookR/Info.plist

@ -2,28 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//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>is.rdata.quicklook</string>
<key>UTTypeDescription</key>
<string>R Data file</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>rdata</string>
<string>rda</string>
<string>rds</string>
</array>
</dict>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
@ -34,18 +14,17 @@
<string>public.data</string>
</array>
</dict>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>rdata</string>
<string>rda</string>
<string>rds</string>
</array>
</dict>
<string>UTTypeTagSpecification</string>
<dict>
<key>public.filename-extension</key>
<array>
<string>rmd</string>
<string>rdata</string>
<string>rda</string>
<string>rds</string>
</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@ -55,7 +34,7 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
@ -79,7 +58,7 @@
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Bob Rudis. All rights reserved.</string>
<string>Copyright © 2019 Bob Rudis. All rights reserved.</string>
<key>QLNeedsToBeRunInMainThread</key>
<false/>
<key>QLPreviewHeight</key>
@ -90,5 +69,28 @@
<false/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>R Data file</string>
<key>UTTypeIdentifier</key>
<string>is.rdata.quicklook</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>rmd</string>
<string>rdata</string>
<string>rda</string>
<string>rds</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>

Loading…
Cancel
Save