From 1b7204e4c273f9429f6a8314018c4a518233566d Mon Sep 17 00:00:00 2001 From: Kent Karlsson Date: Fri, 11 Mar 2016 12:35:42 -0800 Subject: [PATCH] =?UTF-8?q?Added=20`emojize`=20parameter=20to=20translate?= =?UTF-8?q?=20`:mushroom:`=20into=20=F0=9F=8D=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ App/BitBar.xcodeproj/project.pbxproj | 21 +++++++++++++++++++ .../xcshareddata/BitBar.xcscmblueprint | 7 +++++++ App/BitBar/Plugin.m | 7 +++++++ App/Vendor/NSStringEmojize | 1 + README.md | 1 + 6 files changed, 40 insertions(+) create mode 160000 App/Vendor/NSStringEmojize diff --git a/.gitmodules b/.gitmodules index fe702d744..ccf27e810 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "App/Vendor/AHProxySettings"] path = App/Vendor/AHProxySettings url = https://github.com/eahrold/AHProxySettings.git +[submodule "App/Vendor/NSStringEmojize"] + path = App/Vendor/NSStringEmojize + url = https://github.com/diy/NSStringEmojize.git diff --git a/App/BitBar.xcodeproj/project.pbxproj b/App/BitBar.xcodeproj/project.pbxproj index 76595679c..402c7a2a6 100644 --- a/App/BitBar.xcodeproj/project.pbxproj +++ b/App/BitBar.xcodeproj/project.pbxproj @@ -66,6 +66,9 @@ A22AF32A189F823E0011DFCD /* NSColor+Hex.m in Sources */ = {isa = PBXBuildFile; fileRef = A22AF328189F823E0011DFCD /* NSColor+Hex.m */; }; A281BDB5189066DE00C380A4 /* ExecutablePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = A281BDB4189066DE00C380A4 /* ExecutablePlugin.m */; }; A281BDB81890670800C380A4 /* HTMLPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = A281BDB71890670800C380A4 /* HTMLPlugin.m */; }; + AE3C16791C93F716009AF7CA /* NSString+Emojize.m in Sources */ = {isa = PBXBuildFile; fileRef = AE7303D81C935BDE00AF5499 /* NSString+Emojize.m */; }; + AE3C167A1C93F71B009AF7CA /* NSString+Emojize.m in Sources */ = {isa = PBXBuildFile; fileRef = AE7303D81C935BDE00AF5499 /* NSString+Emojize.m */; }; + AE7303DB1C935BDE00AF5499 /* NSString+Emojize.m in Sources */ = {isa = PBXBuildFile; fileRef = AE7303D81C935BDE00AF5499 /* NSString+Emojize.m */; }; AE7303DD1C93721600AF5499 /* TestPlugins in Resources */ = {isa = PBXBuildFile; fileRef = AE7303DC1C93721600AF5499 /* TestPlugins */; }; AE7303E01C93848400AF5499 /* PluginManager+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = AE7303DF1C93848400AF5499 /* PluginManager+Test.m */; }; AE7303E11C9386CE00AF5499 /* PluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 05DAE02C1833274100409786 /* PluginManager.m */; }; @@ -146,6 +149,9 @@ A281BDB4189066DE00C380A4 /* ExecutablePlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ExecutablePlugin.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; A281BDB61890670800C380A4 /* HTMLPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLPlugin.h; sourceTree = ""; }; A281BDB71890670800C380A4 /* HTMLPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = HTMLPlugin.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + AE7303D61C935BDE00AF5499 /* emojis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = emojis.h; sourceTree = ""; }; + AE7303D71C935BDE00AF5499 /* NSString+Emojize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Emojize.h"; sourceTree = ""; }; + AE7303D81C935BDE00AF5499 /* NSString+Emojize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Emojize.m"; sourceTree = ""; }; AE7303DC1C93721600AF5499 /* TestPlugins */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestPlugins; sourceTree = ""; }; AE7303DE1C93848400AF5499 /* PluginManager+Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginManager+Test.h"; sourceTree = ""; }; AE7303DF1C93848400AF5499 /* PluginManager+Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PluginManager+Test.m"; sourceTree = ""; }; @@ -198,6 +204,7 @@ 055EB10C183472C400FF83A6 /* Vendor */ = { isa = PBXGroup; children = ( + AE7303D51C935BDE00AF5499 /* NSStringEmojize */, F8D03BB01C3D95E600A64968 /* AHProxySettings */, 7B9A21541B9F0F10002539F7 /* DateTools */, 7B9A214F1B9F0BE6002539F7 /* STPrivilegedTask.h */, @@ -310,6 +317,17 @@ path = Vendor/DateTools/DateTools; sourceTree = SOURCE_ROOT; }; + AE7303D51C935BDE00AF5499 /* NSStringEmojize */ = { + isa = PBXGroup; + children = ( + AE7303D61C935BDE00AF5499 /* emojis.h */, + AE7303D71C935BDE00AF5499 /* NSString+Emojize.h */, + AE7303D81C935BDE00AF5499 /* NSString+Emojize.m */, + ); + name = NSStringEmojize; + path = Vendor/NSStringEmojize/NSStringEmojize; + sourceTree = SOURCE_ROOT; + }; F8D03BB01C3D95E600A64968 /* AHProxySettings */ = { isa = PBXGroup; children = ( @@ -478,6 +496,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AE3C167A1C93F71B009AF7CA /* NSString+Emojize.m in Sources */, F8D03BB71C3D95E600A64968 /* AHProxy.m in Sources */, 05DAE007183323DD00409786 /* AppDelegate.m in Sources */, 7B9A21661B9F0F10002539F7 /* DTConstants.m in Sources */, @@ -504,6 +523,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AE3C16791C93F716009AF7CA /* NSString+Emojize.m in Sources */, AE7303EA1C9387F300AF5499 /* NSUserDefaults+Settings.m in Sources */, AE7303E51C93871200AF5499 /* AHProxy.m in Sources */, AE7303E61C93871200AF5499 /* AHProxySettings.m in Sources */, @@ -565,6 +585,7 @@ 36DCD8CE1C76027C004DE286 /* LaunchAtLoginController.m in Sources */, 36DCD8CF1C76027C004DE286 /* AHProxySettings.m in Sources */, 36DCD8D01C76027C004DE286 /* DTTimePeriod.m in Sources */, + AE7303DB1C935BDE00AF5499 /* NSString+Emojize.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/App/BitBar.xcodeproj/project.xcworkspace/xcshareddata/BitBar.xcscmblueprint b/App/BitBar.xcodeproj/project.xcworkspace/xcshareddata/BitBar.xcscmblueprint index 34cf05b59..ece6a04d2 100644 --- a/App/BitBar.xcodeproj/project.xcworkspace/xcshareddata/BitBar.xcscmblueprint +++ b/App/BitBar.xcodeproj/project.xcworkspace/xcshareddata/BitBar.xcscmblueprint @@ -6,6 +6,7 @@ "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { "C0AF55779579B522417152BFAB32AD2A49AFBDFE" : 0, "F8622BA04EBD09F8BA8DC9C0C199149407552BFA" : 0, + "EFCDA5DAAD3299C621AB4AD8A1985311413BE697" : 0, "4FA437A61B0C4384CD084682AFD40F7D2624731D" : 0, "5A18CC4105103F3DCAAD74EC93EFD3FF8BB5508A" : 0, "300A25E6089E8365F1B9BCC0BF644BF304850FDB" : 0 @@ -14,6 +15,7 @@ "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { "C0AF55779579B522417152BFAB32AD2A49AFBDFE" : "bitbar\/App\/Vendor\/AHProxySettings\/", "F8622BA04EBD09F8BA8DC9C0C199149407552BFA" : "bitbar\/App\/Vendor\/DateTools\/", + "EFCDA5DAAD3299C621AB4AD8A1985311413BE697" : "bitbar\/App\/Vendor\/NSStringEmojize\/", "4FA437A61B0C4384CD084682AFD40F7D2624731D" : "bitbar\/App\/Vendor\/LaunchAtLoginController\/", "5A18CC4105103F3DCAAD74EC93EFD3FF8BB5508A" : "bitbar\/App\/Vendor\/STPrivilegedTask\/", "300A25E6089E8365F1B9BCC0BF644BF304850FDB" : "bitbar" @@ -42,6 +44,11 @@ "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C0AF55779579B522417152BFAB32AD2A49AFBDFE" }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/diy\/NSStringEmojize.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "EFCDA5DAAD3299C621AB4AD8A1985311413BE697" + }, { "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/MatthewYork\/DateTools.git", "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", diff --git a/App/BitBar/Plugin.m b/App/BitBar/Plugin.m index af00fba9a..ede674d98 100644 --- a/App/BitBar/Plugin.m +++ b/App/BitBar/Plugin.m @@ -11,6 +11,7 @@ #import "STPrivilegedTask.h" #import "NSDate+DateTools.h" #import "NSColor+Hex.h" +#import "NSString+Emojize.h" #define DEFAULT_TIME_INTERVAL_SECONDS ((double)60.) @@ -51,6 +52,9 @@ - (NSMenuItem*) buildMenuItemWithParams:(NSDictionary *)params { } NSString * fullTitle = params[@"title"]; + if ([[params[@"emojize"] lowercaseString] isEqualToString:@"true"]) { + fullTitle = [fullTitle emojizedString]; + } if (![[params[@"trim"] lowercaseString] isEqualToString:@"false"]) { fullTitle = [fullTitle stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; } @@ -94,6 +98,9 @@ - (NSMenuItem*) buildMenuItemWithParams:(NSDictionary *)params { - (NSAttributedString*) attributedTitleWithParams:(NSDictionary *)params { NSString * fullTitle = params[@"title"]; + if ([[params[@"emojize"] lowercaseString] isEqualToString:@"true"]) { + fullTitle = [fullTitle emojizedString]; + } if (![[params[@"trim"] lowercaseString] isEqualToString:@"false"]) { fullTitle = [fullTitle stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; } diff --git a/App/Vendor/NSStringEmojize b/App/Vendor/NSStringEmojize new file mode 160000 index 000000000..00d954ea1 --- /dev/null +++ b/App/Vendor/NSStringEmojize @@ -0,0 +1 @@ +Subproject commit 00d954ea1e161b5040929a6ef56b53e2cbd08586 diff --git a/README.md b/README.md index 4198cefe2..e38e7a7df 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ If you want to contribute, please send us a pull request and we'll add it to our * `alternate=true` to mark a line as an alternate to the previous one for when the Option key is pressed in the dropdown * `templateImage=..` set an image for this item. The image data must be passed as base64 encoded string and should consist of only black and clear pixels. The alpha channel in the image can be used to adjust the opacity of black content, however. This is the recommended way to set an image for the statusbar. The imageformat can be any of the formats supported by Mac OS X * `image=..` set an image for this item. The image data must be passed as base64 encoded string. The imageformat can be any of the formats supported by Mac OS X + * `emojize=true` will convert github style `:mushroom:` into :mushroom: ### Metadata