Skip to content

Commit

Permalink
Added plugin icon to manifest for Sketch 50.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Burns committed May 9, 2018
1 parent 7de2052 commit 0b968b8
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Jason Burns (Sonburn)
Copyright (c) 2018 Jason Burns (Sonburn)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To find your plugins directory...

# Changelog

* **0.3** - Added plugin icon to manifest for Sketch 50.
* **0.2** - Added section checkboxes, parameterized strings, and improved empty states.
* **0.1** - Initial commit.

Expand All @@ -52,4 +53,4 @@ If you find this plugin helpful, consider shouting me ☕️ via <a href="https:

# License

Copyright (c) 2017 Jason Burns (Sonburn). See LICENSE.md for further details.
Copyright (c) 2018 Jason Burns (Sonburn). See LICENSE.md for further details.
Binary file modified Unused Style Remover.sketchplugin/Contents/Resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 22 additions & 6 deletions Unused Style Remover.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,39 @@
{
"name" : "Unused Style Remover",
"shortcut" : "cmd option shift u",
"identifier" : "styleRemover",
"identifier" : "remover",
"description" : "Remove unused layer and text styles.",
"script" : "script.cocoascript",
"icon" : "icon-sr.png"
"icon" : "icon-sr.png",
"handler" : "remover"
},
{
"name": "Report Issue",
"identifier": "report",
"script" : "script.cocoascript",
"handler": "report"
},
{
"name": "Donate",
"identifier": "donate",
"script" : "script.cocoascript",
"handler": "donate"
}
],
"menu" : {
"title" : "Unused Style Remover",
"items" : [
"styleRemover"
],
"isRoot" : true
"remover",
"-",
"report",
"donate"
]
},
"identifier" : "com.sonburn.sketchplugins.unused-style-remover",
"version" : "0.2",
"version" : "0.3",
"description" : "Remove unused layer and text styles.",
"authorEmail" : "[email protected]",
"name" : "Unused Style Remover",
"icon" : "icon.png",
"appcast" : "https://raw.githubusercontent.com/sonburn/unused-style-remover/master/appcast.xml"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ var strPluginName = "Unused Style Remover",
strCancelButtonLabel = "Cancel",
strCloseButtonLabel = "Close",
strLayerStyleRemoved = " layer styles, and ",
strTextStyleRemoved = " text styles were removed";
strTextStyleRemoved = " text styles were removed",
debugMode = false;

var onRun = function(context) {
var remover = function(context) {
var alertWindow = COSAlertWindow.new(),
pluginIconPath = context.plugin.urlForResourceNamed("icon.png").path(),
pluginIcon = NSImage.alloc().initByReferencingFile(pluginIconPath);
Expand Down Expand Up @@ -142,9 +143,23 @@ var onRun = function(context) {
context.document.reloadInspector();

context.document.showMessage(layerStylesToRemove.length + strLayerStyleRemoved + textStylesToRemove.length + strTextStyleRemoved);

if (!debugMode) googleAnalytics(context,"remove","run");
} else return false;
}

var report = function(context) {
openUrl("https://github.com/sonburn/unused-style-remover/issues/new");

if (!debugMode) googleAnalytics(context,"report","report");
}

var donate = function(context) {
openUrl("https://www.paypal.me/sonburn");

if (!debugMode) googleAnalytics(context,"donate","donate");
}

function createBoldLabel(text,size,frame) {
var label = NSTextField.alloc().initWithFrame(frame);

Expand Down Expand Up @@ -225,6 +240,54 @@ function getUnusedStyles(type) {
return unusedStyles.sortedArrayUsingDescriptors([sortByName]);
}

function googleAnalytics(context,category,action,label,value) {
var trackingID = "UA-118988821-1",
uuidKey = "google.analytics.uuid",
uuid = NSUserDefaults.standardUserDefaults().objectForKey(uuidKey);

if (!uuid) {
uuid = NSUUID.UUID().UUIDString();
NSUserDefaults.standardUserDefaults().setObject_forKey(uuid,uuidKey);
}

var url = "https://www.google-analytics.com/collect?v=1";
// Tracking ID
url += "&tid=" + trackingID;
// Source
url += "&ds=sketch" + MSApplicationMetadata.metadata().appVersion;
// Client ID
url += "&cid=" + uuid;
// pageview, screenview, event, transaction, item, social, exception, timing
url += "&t=event";
// App Name
url += "&an=" + encodeURI(context.plugin.name());
// App ID
url += "&aid=" + context.plugin.identifier();
// App Version
url += "&av=" + context.plugin.version();
// Event category
url += "&ec=" + encodeURI(category);
// Event action
url += "&ea=" + encodeURI(action);
// Event label
if (label) {
url += "&el=" + encodeURI(label);
}
// Event value
if (value) {
url += "&ev=" + encodeURI(value);
}

var session = NSURLSession.sharedSession(),
task = session.dataTaskWithURL(NSURL.URLWithString(NSString.stringWithString(url)));

task.resume();
}

function openUrl(url) {
NSWorkspace.sharedWorkspace().openURL(NSURL.URLWithString(url));
}

function removeDuplicates(value,index,self) {
return self.indexOf(value) === index;
}
6 changes: 3 additions & 3 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<description>Remove unused layer and text styles.</description>
<language>en</language>
<item>
<title>Version 0.2</title>
<title>Version 0.3</title>
<description>
<![CDATA[
<ul>
<li>Added section checkboxes, parameterized strings, and improved empty states.</li>
<li>Added plugin icon to manifest for Sketch 50.</li>
</ul>
]]>
</description>
<enclosure url="https://github.com/sonburn/unused-style-remover/archive/master.zip" sparkle:version="0.2" />
<enclosure url="https://github.com/sonburn/unused-style-remover/archive/master.zip" sparkle:version="0.3" />
</item>
</channel>
</rss>

0 comments on commit 0b968b8

Please sign in to comment.