From ced2a27468018b6fc076ec1ffa13e9d9f219fdd6 Mon Sep 17 00:00:00 2001 From: Dale Tournemille Date: Sun, 10 Nov 2013 17:06:45 -0800 Subject: [PATCH 1/7] Added support for Notification Center in OS X Mavericks. Added a Notifcation Center alert when uploading individual or multiple assets to Shopify. Users must install the gem 'terminal-notifier'. Also, this change requires TextMate 2 preview in order for the icon to show up correctly in Notification Center. --- Support/assets/upload.php | 8 +++++++- Support/assets/upload_multi.php | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 Support/assets/upload.php mode change 100644 => 100755 Support/assets/upload_multi.php diff --git a/Support/assets/upload.php b/Support/assets/upload.php old mode 100644 new mode 100755 index 9069606..679f875 --- a/Support/assets/upload.php +++ b/Support/assets/upload.php @@ -17,12 +17,18 @@ $response = send_asset($api_key, $password, $store ,$xmlFile); if('200' == response_code($response)) { - echo "Uploaded {$assetKey} to {$config->current}."; + + /* Add by Dale Tournemille 2013. This invokes terminal-notifier (by Eloy Durán) and displays the success upload message using OS X Notification Center. */ + echo "Uploaded {$assetKey} to {$config->current}."; + echo exec("/usr/local/bin/terminal-notifier -title 'File Uploaded' -message 'The file {$assetKey} has been uploaded to your {$config->current} theme on Shopify.' -sender com.macromates.TextMate.preview"); + + } else { // Not ideal, but it works. Problem (though not much of one ): // response on a fail will return the full curl page: ie, shopify 404 full html, + error code at the bottom // Will robustify if it becomes an issue. echo "*Error: Could not upload {$assetKey} to {$config->current}." ; + echo exec("/usr/local/bin/terminal-notifier -title 'Upload Error' -message 'Houston, we have a problem. The file {$assetKey} was NOT uploaded to {$config->current}.' -sender com.macromates.TextMate.preview"); output_error($response); } //And clean up diff --git a/Support/assets/upload_multi.php b/Support/assets/upload_multi.php old mode 100644 new mode 100755 index 7b51f2d..e7816d2 --- a/Support/assets/upload_multi.php +++ b/Support/assets/upload_multi.php @@ -33,11 +33,13 @@ if('200' == response_code($response)) { echo "Uploaded: {$assetKey}
"; + echo exec("/usr/local/bin/terminal-notifier -title 'File Uploaded' -message 'The file {$assetKey} has been uploaded to Shopify.' -sender com.macromates.TextMate.preview"); } else { // Not ideal, but it works. Problem (though not much of one ): // response on a fail will return the full curl page: ie, shopify 404 full html, + error code at the bottom // Will robustify if it becomes an issue. echo "*Error: Could not upload {$assetKey} to {$config->current}." ; + echo exec("/usr/local/bin/terminal-notifier -title 'Upload Error' -message 'Houston, we have a problem. The file {$assetKey} was NOT uploaded to {$config->current}.' -sender com.macromates.TextMate.preview"); output_error($response, array('line_break' => '
')); } //And clean up From 7c0f32ee3cc5b6b6582d1f897e1db30e0cec8461 Mon Sep 17 00:00:00 2001 From: Dale Tournemille Date: Tue, 12 Nov 2013 11:32:02 -0800 Subject: [PATCH 2/7] Update readme.markdown --- readme.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.markdown b/readme.markdown index 55b9338..e689bf7 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,6 +1,12 @@ Shopify Textmate Bundle (now compatible with e-texteditor) ========================================================== +Nov. 10, 2013 - Notification Center support: +-------------- + +* This fork include support for Notification Center in OS X Mavericks. To use it, you must have terminal-notifier installed. You must also be using the latest preview edition of TextMate. + + Available Commands: ------------------- From 414ff2aa796c0e3699a76dd9a26e21aa317fd4a5 Mon Sep 17 00:00:00 2001 From: Dale Tournemille Date: Tue, 12 Nov 2013 11:33:24 -0800 Subject: [PATCH 3/7] Update readme.markdown --- readme.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.markdown b/readme.markdown index e689bf7..28b8667 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,10 +1,10 @@ Shopify Textmate Bundle (now compatible with e-texteditor) ========================================================== -Nov. 10, 2013 - Notification Center support: +Nov. 10, 2013 - Notification Center support in OS X Mavericks -------------- -* This fork include support for Notification Center in OS X Mavericks. To use it, you must have terminal-notifier installed. You must also be using the latest preview edition of TextMate. +* This fork include support for Notification Center in OS X Mavericks. To use it, you must have the gem "terminal-notifier" installed (if you're using homebrew, just type $brew install terminal-notifier). You must also be using the latest preview edition of TextMate. Available Commands: From 3e3b1cc54640fe2b70e4dd514d4a07bf7b18bac0 Mon Sep 17 00:00:00 2001 From: Dale Tournemille Date: Wed, 20 Nov 2013 11:17:23 -0800 Subject: [PATCH 4/7] Forked source from https://github.com/ROFISH which adds multiple theme support. --- Commands/Download Theme.tmCommand | 0 Commands/Edit Config (TM Only).tmCommand | 0 Commands/Get Rendered CSS file from _css_liquid.tmCommand | 0 Commands/New Config (TM Only).tmCommand | 0 Commands/Open Store Admin.tmCommand | 0 Commands/Pages: Download All.tmCommand | 0 Commands/Pages: Preview Current.tmCommand | 0 Commands/Pages: Upload Current.tmCommand | 0 Commands/Remove Selected Assets from Shopify.tmCommand | 0 Commands/Send Asset to Shopify.tmCommand | 0 Commands/Send Selected Assets to Shopify.tmCommand | 0 Commands/Switch Shop (TM Only).tmCommand | 0 Commands/Test: New Framework.tmCommand | 0 Commands/Test: Ruby.tmCommand | 0 Commands/Test: config (TM Only).tmCommand | 0 Commands/Update Selected Files From Shopify.tmCommand | 0 Commands/Update Template From Shopify.tmCommand | 0 Commands/Wiki: Liquid.tmCommand | 0 Snippets/asset_url: css.tmSnippet | 0 Snippets/asset_url: js.tmSnippet | 0 Snippets/setting: file upload.tmSnippet | 0 Snippets/setting: multi line.tmSnippet | 0 Snippets/setting: single line.tmSnippet | 0 Support/config.php | 0 Support/functions.php | 0 Support/head.php | 0 Support/lib/escape.php | 0 Support/lib/ui.php | 0 Support/liquid/filters.rb | 0 Support/pages/download_all.php | 0 Support/pages/upload.php | 0 Support/shopify-tmbundle-example.ini | 0 Support/vars.php | 0 Test/test_arb.php | 0 info.plist | 0 readme-windows.markdown | 0 readme.markdown | 0 37 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Commands/Download Theme.tmCommand mode change 100644 => 100755 Commands/Edit Config (TM Only).tmCommand mode change 100644 => 100755 Commands/Get Rendered CSS file from _css_liquid.tmCommand mode change 100644 => 100755 Commands/New Config (TM Only).tmCommand mode change 100644 => 100755 Commands/Open Store Admin.tmCommand mode change 100644 => 100755 Commands/Pages: Download All.tmCommand mode change 100644 => 100755 Commands/Pages: Preview Current.tmCommand mode change 100644 => 100755 Commands/Pages: Upload Current.tmCommand mode change 100644 => 100755 Commands/Remove Selected Assets from Shopify.tmCommand mode change 100644 => 100755 Commands/Send Asset to Shopify.tmCommand mode change 100644 => 100755 Commands/Send Selected Assets to Shopify.tmCommand mode change 100644 => 100755 Commands/Switch Shop (TM Only).tmCommand mode change 100644 => 100755 Commands/Test: New Framework.tmCommand mode change 100644 => 100755 Commands/Test: Ruby.tmCommand mode change 100644 => 100755 Commands/Test: config (TM Only).tmCommand mode change 100644 => 100755 Commands/Update Selected Files From Shopify.tmCommand mode change 100644 => 100755 Commands/Update Template From Shopify.tmCommand mode change 100644 => 100755 Commands/Wiki: Liquid.tmCommand mode change 100644 => 100755 Snippets/asset_url: css.tmSnippet mode change 100644 => 100755 Snippets/asset_url: js.tmSnippet mode change 100644 => 100755 Snippets/setting: file upload.tmSnippet mode change 100644 => 100755 Snippets/setting: multi line.tmSnippet mode change 100644 => 100755 Snippets/setting: single line.tmSnippet mode change 100644 => 100755 Support/config.php mode change 100644 => 100755 Support/functions.php mode change 100644 => 100755 Support/head.php mode change 100644 => 100755 Support/lib/escape.php mode change 100644 => 100755 Support/lib/ui.php mode change 100644 => 100755 Support/liquid/filters.rb mode change 100644 => 100755 Support/pages/download_all.php mode change 100644 => 100755 Support/pages/upload.php mode change 100644 => 100755 Support/shopify-tmbundle-example.ini mode change 100644 => 100755 Support/vars.php mode change 100644 => 100755 Test/test_arb.php mode change 100644 => 100755 info.plist mode change 100644 => 100755 readme-windows.markdown mode change 100644 => 100755 readme.markdown diff --git a/Commands/Download Theme.tmCommand b/Commands/Download Theme.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Edit Config (TM Only).tmCommand b/Commands/Edit Config (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Get Rendered CSS file from _css_liquid.tmCommand b/Commands/Get Rendered CSS file from _css_liquid.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/New Config (TM Only).tmCommand b/Commands/New Config (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Open Store Admin.tmCommand b/Commands/Open Store Admin.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Pages: Download All.tmCommand b/Commands/Pages: Download All.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Pages: Preview Current.tmCommand b/Commands/Pages: Preview Current.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Pages: Upload Current.tmCommand b/Commands/Pages: Upload Current.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Remove Selected Assets from Shopify.tmCommand b/Commands/Remove Selected Assets from Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Send Asset to Shopify.tmCommand b/Commands/Send Asset to Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Send Selected Assets to Shopify.tmCommand b/Commands/Send Selected Assets to Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Switch Shop (TM Only).tmCommand b/Commands/Switch Shop (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Test: New Framework.tmCommand b/Commands/Test: New Framework.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Test: Ruby.tmCommand b/Commands/Test: Ruby.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Test: config (TM Only).tmCommand b/Commands/Test: config (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Update Selected Files From Shopify.tmCommand b/Commands/Update Selected Files From Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Update Template From Shopify.tmCommand b/Commands/Update Template From Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Wiki: Liquid.tmCommand b/Commands/Wiki: Liquid.tmCommand old mode 100644 new mode 100755 diff --git a/Snippets/asset_url: css.tmSnippet b/Snippets/asset_url: css.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/asset_url: js.tmSnippet b/Snippets/asset_url: js.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/setting: file upload.tmSnippet b/Snippets/setting: file upload.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/setting: multi line.tmSnippet b/Snippets/setting: multi line.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/setting: single line.tmSnippet b/Snippets/setting: single line.tmSnippet old mode 100644 new mode 100755 diff --git a/Support/config.php b/Support/config.php old mode 100644 new mode 100755 diff --git a/Support/functions.php b/Support/functions.php old mode 100644 new mode 100755 diff --git a/Support/head.php b/Support/head.php old mode 100644 new mode 100755 diff --git a/Support/lib/escape.php b/Support/lib/escape.php old mode 100644 new mode 100755 diff --git a/Support/lib/ui.php b/Support/lib/ui.php old mode 100644 new mode 100755 diff --git a/Support/liquid/filters.rb b/Support/liquid/filters.rb old mode 100644 new mode 100755 diff --git a/Support/pages/download_all.php b/Support/pages/download_all.php old mode 100644 new mode 100755 diff --git a/Support/pages/upload.php b/Support/pages/upload.php old mode 100644 new mode 100755 diff --git a/Support/shopify-tmbundle-example.ini b/Support/shopify-tmbundle-example.ini old mode 100644 new mode 100755 diff --git a/Support/vars.php b/Support/vars.php old mode 100644 new mode 100755 diff --git a/Test/test_arb.php b/Test/test_arb.php old mode 100644 new mode 100755 diff --git a/info.plist b/info.plist old mode 100644 new mode 100755 diff --git a/readme-windows.markdown b/readme-windows.markdown old mode 100644 new mode 100755 diff --git a/readme.markdown b/readme.markdown old mode 100644 new mode 100755 From f146e52d15a05333c74fb5838fd3207115b094d4 Mon Sep 17 00:00:00 2001 From: Dale Tournemille Date: Wed, 20 Nov 2013 11:21:22 -0800 Subject: [PATCH 5/7] Trying to merge notification support code with multiple theme support code. --- Commands/Download Theme.tmCommand | 0 Commands/Edit Config (TM Only).tmCommand | 0 Commands/Get Rendered CSS file from _css_liquid.tmCommand | 0 Commands/New Config (TM Only).tmCommand | 0 Commands/Open Store Admin.tmCommand | 0 Commands/Pages: Download All.tmCommand | 0 Commands/Pages: Preview Current.tmCommand | 0 Commands/Pages: Upload Current.tmCommand | 0 Commands/Remove Selected Assets from Shopify.tmCommand | 0 Commands/Send Asset to Shopify.tmCommand | 0 Commands/Send Selected Assets to Shopify.tmCommand | 0 Commands/Switch Shop (TM Only).tmCommand | 0 Commands/Test: New Framework.tmCommand | 0 Commands/Test: Ruby.tmCommand | 0 Commands/Test: config (TM Only).tmCommand | 0 Commands/Update Selected Files From Shopify.tmCommand | 0 Commands/Update Template From Shopify.tmCommand | 0 Commands/Wiki: Liquid.tmCommand | 0 Snippets/asset_url: css.tmSnippet | 0 Snippets/asset_url: js.tmSnippet | 0 Snippets/setting: file upload.tmSnippet | 0 Snippets/setting: multi line.tmSnippet | 0 Snippets/setting: single line.tmSnippet | 0 Support/config.php | 0 Support/functions.php | 0 Support/head.php | 0 Support/lib/escape.php | 0 Support/lib/ui.php | 0 Support/liquid/filters.rb | 0 Support/pages/download_all.php | 0 Support/pages/upload.php | 0 Support/shopify-tmbundle-example.ini | 0 Support/vars.php | 0 Test/test_arb.php | 0 info.plist | 0 readme-windows.markdown | 0 readme.markdown | 0 37 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Commands/Download Theme.tmCommand mode change 100644 => 100755 Commands/Edit Config (TM Only).tmCommand mode change 100644 => 100755 Commands/Get Rendered CSS file from _css_liquid.tmCommand mode change 100644 => 100755 Commands/New Config (TM Only).tmCommand mode change 100644 => 100755 Commands/Open Store Admin.tmCommand mode change 100644 => 100755 Commands/Pages: Download All.tmCommand mode change 100644 => 100755 Commands/Pages: Preview Current.tmCommand mode change 100644 => 100755 Commands/Pages: Upload Current.tmCommand mode change 100644 => 100755 Commands/Remove Selected Assets from Shopify.tmCommand mode change 100644 => 100755 Commands/Send Asset to Shopify.tmCommand mode change 100644 => 100755 Commands/Send Selected Assets to Shopify.tmCommand mode change 100644 => 100755 Commands/Switch Shop (TM Only).tmCommand mode change 100644 => 100755 Commands/Test: New Framework.tmCommand mode change 100644 => 100755 Commands/Test: Ruby.tmCommand mode change 100644 => 100755 Commands/Test: config (TM Only).tmCommand mode change 100644 => 100755 Commands/Update Selected Files From Shopify.tmCommand mode change 100644 => 100755 Commands/Update Template From Shopify.tmCommand mode change 100644 => 100755 Commands/Wiki: Liquid.tmCommand mode change 100644 => 100755 Snippets/asset_url: css.tmSnippet mode change 100644 => 100755 Snippets/asset_url: js.tmSnippet mode change 100644 => 100755 Snippets/setting: file upload.tmSnippet mode change 100644 => 100755 Snippets/setting: multi line.tmSnippet mode change 100644 => 100755 Snippets/setting: single line.tmSnippet mode change 100644 => 100755 Support/config.php mode change 100644 => 100755 Support/functions.php mode change 100644 => 100755 Support/head.php mode change 100644 => 100755 Support/lib/escape.php mode change 100644 => 100755 Support/lib/ui.php mode change 100644 => 100755 Support/liquid/filters.rb mode change 100644 => 100755 Support/pages/download_all.php mode change 100644 => 100755 Support/pages/upload.php mode change 100644 => 100755 Support/shopify-tmbundle-example.ini mode change 100644 => 100755 Support/vars.php mode change 100644 => 100755 Test/test_arb.php mode change 100644 => 100755 info.plist mode change 100644 => 100755 readme-windows.markdown mode change 100644 => 100755 readme.markdown diff --git a/Commands/Download Theme.tmCommand b/Commands/Download Theme.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Edit Config (TM Only).tmCommand b/Commands/Edit Config (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Get Rendered CSS file from _css_liquid.tmCommand b/Commands/Get Rendered CSS file from _css_liquid.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/New Config (TM Only).tmCommand b/Commands/New Config (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Open Store Admin.tmCommand b/Commands/Open Store Admin.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Pages: Download All.tmCommand b/Commands/Pages: Download All.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Pages: Preview Current.tmCommand b/Commands/Pages: Preview Current.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Pages: Upload Current.tmCommand b/Commands/Pages: Upload Current.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Remove Selected Assets from Shopify.tmCommand b/Commands/Remove Selected Assets from Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Send Asset to Shopify.tmCommand b/Commands/Send Asset to Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Send Selected Assets to Shopify.tmCommand b/Commands/Send Selected Assets to Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Switch Shop (TM Only).tmCommand b/Commands/Switch Shop (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Test: New Framework.tmCommand b/Commands/Test: New Framework.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Test: Ruby.tmCommand b/Commands/Test: Ruby.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Test: config (TM Only).tmCommand b/Commands/Test: config (TM Only).tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Update Selected Files From Shopify.tmCommand b/Commands/Update Selected Files From Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Update Template From Shopify.tmCommand b/Commands/Update Template From Shopify.tmCommand old mode 100644 new mode 100755 diff --git a/Commands/Wiki: Liquid.tmCommand b/Commands/Wiki: Liquid.tmCommand old mode 100644 new mode 100755 diff --git a/Snippets/asset_url: css.tmSnippet b/Snippets/asset_url: css.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/asset_url: js.tmSnippet b/Snippets/asset_url: js.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/setting: file upload.tmSnippet b/Snippets/setting: file upload.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/setting: multi line.tmSnippet b/Snippets/setting: multi line.tmSnippet old mode 100644 new mode 100755 diff --git a/Snippets/setting: single line.tmSnippet b/Snippets/setting: single line.tmSnippet old mode 100644 new mode 100755 diff --git a/Support/config.php b/Support/config.php old mode 100644 new mode 100755 diff --git a/Support/functions.php b/Support/functions.php old mode 100644 new mode 100755 diff --git a/Support/head.php b/Support/head.php old mode 100644 new mode 100755 diff --git a/Support/lib/escape.php b/Support/lib/escape.php old mode 100644 new mode 100755 diff --git a/Support/lib/ui.php b/Support/lib/ui.php old mode 100644 new mode 100755 diff --git a/Support/liquid/filters.rb b/Support/liquid/filters.rb old mode 100644 new mode 100755 diff --git a/Support/pages/download_all.php b/Support/pages/download_all.php old mode 100644 new mode 100755 diff --git a/Support/pages/upload.php b/Support/pages/upload.php old mode 100644 new mode 100755 diff --git a/Support/shopify-tmbundle-example.ini b/Support/shopify-tmbundle-example.ini old mode 100644 new mode 100755 diff --git a/Support/vars.php b/Support/vars.php old mode 100644 new mode 100755 diff --git a/Test/test_arb.php b/Test/test_arb.php old mode 100644 new mode 100755 diff --git a/info.plist b/info.plist old mode 100644 new mode 100755 diff --git a/readme-windows.markdown b/readme-windows.markdown old mode 100644 new mode 100755 diff --git a/readme.markdown b/readme.markdown old mode 100644 new mode 100755 From 7225283707879e4b4e0fcff9a05721cb41a93cf2 Mon Sep 17 00:00:00 2001 From: Dale Tournemille Date: Wed, 20 Nov 2013 11:43:31 -0800 Subject: [PATCH 6/7] Trying to add files to swticher branch. --- Commands/Download Theme.tmCommand | 13 +++-- Commands/Edit Config (TM Only).tmCommand | 2 +- ...ndered CSS file from _css_liquid.tmCommand | 2 +- Commands/New Config (TM Only).tmCommand | 2 +- Commands/Open Store Admin.tmCommand | 2 +- ...ove Selected Assets from Shopify.tmCommand | 2 +- Commands/Switch Shop (TM Only).tmCommand | 2 +- Commands/Test: New Framework.tmCommand | 2 +- Commands/Test: config (TM Only).tmCommand | 2 +- ...date Selected Files From Shopify.tmCommand | 2 +- .../Update Template From Shopify.tmCommand | 2 +- Commands/Wiki: Liquid.tmCommand | 2 +- Support/assets/upload.php | 12 +--- Support/assets/upload_multi.php | 6 +- Support/config.php | 3 + Support/functions.php | 57 ++++++++++++------- Support/pages/download_all.php | 2 +- Support/pages/upload.php | 2 +- Support/vars.php | 1 + Test/test_arb.php | 3 +- readme.markdown | 6 -- 21 files changed, 67 insertions(+), 60 deletions(-) diff --git a/Commands/Download Theme.tmCommand b/Commands/Download Theme.tmCommand index 913a2a7..bd20b2a 100755 --- a/Commands/Download Theme.tmCommand +++ b/Commands/Download Theme.tmCommand @@ -7,7 +7,6 @@ command #!/usr/bin/env php <?php - //Kinda sucks, but this will need to be in each script, as opposed to be loaded //Make some assumptions if running under windows. //This is for compat with Environment: Cygwin generic mode, which gives us access to curl @@ -30,8 +29,14 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; //Request Asset URL Template // %1: API KEY, %2: PASSWORD, %3: STORE, %4: ASSET NAME -$requestUrlTemp = 'https://%1$s:%2$s@%3$s/admin/assets.json'; -$requestUrl = sprintf($requestUrlTemp, $api_key, $password, $store); +if ($theme_id == "") { + $requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/assets.json'; + $requestUrl = sprintf($requestUrlTemp, $api_key, $password, $store); +} +else { + $requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.json'; + $requestUrl = sprintf($requestUrlTemp, $api_key, $password, $store, $theme_id); +} // yes, I am aware php has curl. This is just simpler. echo "Getting theme asset list...<br>"; @@ -68,7 +73,7 @@ foreach ($assetFiles as $file) { } echo "Fetching {$file}...<br>"; - $asset = get_asset($api_key, $password, $store, $file); + $asset = get_asset($api_key, $password, $store, $theme_id, $file); if(false === $asset) { echo "*Error fetching: ($file)<br>"; diff --git a/Commands/Edit Config (TM Only).tmCommand b/Commands/Edit Config (TM Only).tmCommand index 5a320b4..46a9f7c 100755 --- a/Commands/Edit Config (TM Only).tmCommand +++ b/Commands/Edit Config (TM Only).tmCommand @@ -13,7 +13,7 @@ mate "$TM_PROJECT_DIRECTORY/.shopify-tmbundle" input none name - Edit Config + Edit Config (TM Only) output discard uuid diff --git a/Commands/Get Rendered CSS file from _css_liquid.tmCommand b/Commands/Get Rendered CSS file from _css_liquid.tmCommand index f99f783..3fb8e67 100755 --- a/Commands/Get Rendered CSS file from _css_liquid.tmCommand +++ b/Commands/Get Rendered CSS file from _css_liquid.tmCommand @@ -36,7 +36,7 @@ if(false !== strpos($filepath, '.css.liquid')) { echo "Fetching {$filepath}...<br>"; -$asset = get_asset($api_key, $password, $store, $filepath); +$asset = get_asset($api_key, $password, $store, $theme_id, $filepath); if(false == $asset) { //Do Nothing. echo '*Error: Could not get '. $filepath .'<br>'; diff --git a/Commands/New Config (TM Only).tmCommand b/Commands/New Config (TM Only).tmCommand index 8f093e3..0dd723f 100755 --- a/Commands/New Config (TM Only).tmCommand +++ b/Commands/New Config (TM Only).tmCommand @@ -15,7 +15,7 @@ mate "$TM_PROJECT_DIRECTORY/.shopify-tmbundle" input none name - New Config + New Config (TM Only) output discard uuid diff --git a/Commands/Open Store Admin.tmCommand b/Commands/Open Store Admin.tmCommand index 1752a1e..87b5a71 100755 --- a/Commands/Open Store Admin.tmCommand +++ b/Commands/Open Store Admin.tmCommand @@ -22,7 +22,7 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; input none name - Open Store Admin In Default Browser + Open Store Admin In Default Browser (TM Only) output discard uuid diff --git a/Commands/Remove Selected Assets from Shopify.tmCommand b/Commands/Remove Selected Assets from Shopify.tmCommand index d9cb782..8063235 100755 --- a/Commands/Remove Selected Assets from Shopify.tmCommand +++ b/Commands/Remove Selected Assets from Shopify.tmCommand @@ -37,7 +37,7 @@ foreach ($selectedFiles as $file) { $assetKey = calc_asset_key($file); echo "Removing $assetKey... "; - if(remove_asset($api_key, $password, $store, $assetKey)) { + if(remove_asset($api_key, $password, $store, $theme_id, $assetKey)) { echo "removed¡<br>"; } else { diff --git a/Commands/Switch Shop (TM Only).tmCommand b/Commands/Switch Shop (TM Only).tmCommand index 168d12f..eef3ff0 100755 --- a/Commands/Switch Shop (TM Only).tmCommand +++ b/Commands/Switch Shop (TM Only).tmCommand @@ -19,7 +19,7 @@ exit_create_new_document input none name - Switch Shop + Switch Shop (TM Only) output discard uuid diff --git a/Commands/Test: New Framework.tmCommand b/Commands/Test: New Framework.tmCommand index 3516675..cdcedae 100755 --- a/Commands/Test: New Framework.tmCommand +++ b/Commands/Test: New Framework.tmCommand @@ -16,7 +16,7 @@ source "$TM_SUPPORT_PATH/lib/bash_init.sh" name Test: New Framework output - showAsHTML + openAsNewDocument uuid 25889F17-382C-4A90-87B3-F594690AAAA9 diff --git a/Commands/Test: config (TM Only).tmCommand b/Commands/Test: config (TM Only).tmCommand index 07090f5..43e9370 100755 --- a/Commands/Test: config (TM Only).tmCommand +++ b/Commands/Test: config (TM Only).tmCommand @@ -12,7 +12,7 @@ var_dump($config); input none name - Test: config + Test: config (TM Only) output openAsNewDocument uuid diff --git a/Commands/Update Selected Files From Shopify.tmCommand b/Commands/Update Selected Files From Shopify.tmCommand index 93e61bc..6f63e2e 100755 --- a/Commands/Update Selected Files From Shopify.tmCommand +++ b/Commands/Update Selected Files From Shopify.tmCommand @@ -36,7 +36,7 @@ foreach ($selectedFiles as $file) { $assetKey = calc_asset_key($file); echo "Fetching {$assetKey}...<br>"; - $asset = get_asset($api_key, $password, $store, $assetKey); + $asset = get_asset($api_key, $password, $store, $theme_id, $assetKey); if(false == $asset) { //Do Nothing. echo '*Error: Could not update asset '. $assetKey .'<br>'; diff --git a/Commands/Update Template From Shopify.tmCommand b/Commands/Update Template From Shopify.tmCommand index 70497e4..09c60bf 100755 --- a/Commands/Update Template From Shopify.tmCommand +++ b/Commands/Update Template From Shopify.tmCommand @@ -27,7 +27,7 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; // File path, based on theme restriction of no nested folder, so we make certain assumptions $filepath = calc_asset_key(getenv('TM_FILEPATH')); -$asset = get_asset($api_key, $password, $store, $filepath); +$asset = get_asset($api_key, $password, $store, $theme_id, $filepath); // clean out the \r 's - mac uses \n only. if(false !== $asset && property_exists($asset, 'value')) { diff --git a/Commands/Wiki: Liquid.tmCommand b/Commands/Wiki: Liquid.tmCommand index 5bd09a0..7e6df61 100755 --- a/Commands/Wiki: Liquid.tmCommand +++ b/Commands/Wiki: Liquid.tmCommand @@ -24,7 +24,7 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; keyEquivalent ^h name - Wiki: Liquid + Wiki: Liquid (TM Only) output showAsTooltip scope diff --git a/Support/assets/upload.php b/Support/assets/upload.php index 679f875..d9e4d7a 100755 --- a/Support/assets/upload.php +++ b/Support/assets/upload.php @@ -14,21 +14,15 @@ $xmlFile = tempnam('/tmp', 'foo').'.xml'; file_put_contents($xmlFile, $reqData); -$response = send_asset($api_key, $password, $store ,$xmlFile); +$response = send_asset($api_key, $password, $store , $theme_id, $xmlFile); -if('200' == response_code($response)) { - - /* Add by Dale Tournemille 2013. This invokes terminal-notifier (by Eloy Durán) and displays the success upload message using OS X Notification Center. */ - echo "Uploaded {$assetKey} to {$config->current}."; - echo exec("/usr/local/bin/terminal-notifier -title 'File Uploaded' -message 'The file {$assetKey} has been uploaded to your {$config->current} theme on Shopify.' -sender com.macromates.TextMate.preview"); - - +if('200' == $response) { + echo "Uploaded {$assetKey} to {$config->current}."; } else { // Not ideal, but it works. Problem (though not much of one ): // response on a fail will return the full curl page: ie, shopify 404 full html, + error code at the bottom // Will robustify if it becomes an issue. echo "*Error: Could not upload {$assetKey} to {$config->current}." ; - echo exec("/usr/local/bin/terminal-notifier -title 'Upload Error' -message 'Houston, we have a problem. The file {$assetKey} was NOT uploaded to {$config->current}.' -sender com.macromates.TextMate.preview"); output_error($response); } //And clean up diff --git a/Support/assets/upload_multi.php b/Support/assets/upload_multi.php index e7816d2..98b8ac6 100755 --- a/Support/assets/upload_multi.php +++ b/Support/assets/upload_multi.php @@ -29,17 +29,15 @@ file_put_contents($xmlFile, $reqData); echo "Sending asset: {$assetKey}...
"; - $response = send_asset($api_key, $password, $store ,$xmlFile); + $response = send_asset($api_key, $password, $store , $theme_id, $xmlFile); - if('200' == response_code($response)) { + if('200' == $response) { echo "Uploaded: {$assetKey}
"; - echo exec("/usr/local/bin/terminal-notifier -title 'File Uploaded' -message 'The file {$assetKey} has been uploaded to Shopify.' -sender com.macromates.TextMate.preview"); } else { // Not ideal, but it works. Problem (though not much of one ): // response on a fail will return the full curl page: ie, shopify 404 full html, + error code at the bottom // Will robustify if it becomes an issue. echo "*Error: Could not upload {$assetKey} to {$config->current}." ; - echo exec("/usr/local/bin/terminal-notifier -title 'Upload Error' -message 'Houston, we have a problem. The file {$assetKey} was NOT uploaded to {$config->current}.' -sender com.macromates.TextMate.preview"); output_error($response, array('line_break' => '
')); } //And clean up diff --git a/Support/config.php b/Support/config.php index bce5303..e9cfd13 100755 --- a/Support/config.php +++ b/Support/config.php @@ -18,6 +18,8 @@ class mConfig { var $store = null; + var $theme_id = null; + //Used to output to user what shop they are pushing to. Reads better than full shop name. var $current = 'default'; @@ -33,6 +35,7 @@ function __construct($path) { $this->api_key = getenv('SHOPIFY_API_KEY'); $this->password = getenv('SHOPIFY_PASSWORD'); $this->store = getenv('SHOPIFY_STORE'); + $this->theme_id = getenv('SHOPIFY_THEME_ID'); if( (!$this->api_key) || (!$this->password) || (!$this->store) ) { echo "No config file found here: {$path} ?"; diff --git a/Support/functions.php b/Support/functions.php index 99edc17..fe5d9d7 100755 --- a/Support/functions.php +++ b/Support/functions.php @@ -28,11 +28,6 @@ function is_binary($filepath) { } -// pull the http respone code from the response string -function response_code($response) { - return substr($response, -3); -} - /** * Output error from XML curl response * @@ -44,8 +39,6 @@ function output_error($response, $options = array()) { $options = $options + array('line_break'=> "\n"); - $http_code = response_code($response); - //Clean off the response - comes with http code attached $response = substr($response, 0, (strripos($response, '>')+1)); // echo $response; @@ -54,7 +47,6 @@ function output_error($response, $options = array()) { foreach ($errors as $error) { echo $options['line_break']."{$error}"; } - echo $options['line_break']."{$http_code}"; } /** @@ -66,12 +58,19 @@ function output_error($response, $options = array()) { * @param string $key Key of asset we are downloading * @return object Asset / false on failure **/ -function get_asset($api_key, $password, $store, $key) { +function get_asset($api_key, $password, $store, $theme_id, $key) { //Request Asset URL Template // %1: API KEY, %2: PASSWORD, %3: STORE, %4: ASSET NAME - $requestUrl = sprintf('https://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', - $api_key, $password, $store, $key - ); + if ($theme_id == "") { + $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', + $api_key, $password, $store, $key + ); + } + else { + $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.json?asset[key]=%5$s', + $api_key, $password, $store, $theme_id, $key + ); + } $responseTxt = `curl -s -g '$requestUrl'`; $response = json_decode($responseTxt); @@ -91,11 +90,18 @@ function get_asset($api_key, $password, $store, $key) { * @param string $xmlFile Path to the XML File with the contents to upload. * @return string **/ -function send_asset($api_key, $password, $store ,$xmlFile) { +function send_asset($api_key, $password, $store, $theme_id, $xmlFile) { - $requestUrl = sprintf('https://%1$s:%2$s@%3$s/admin/assets.xml', - $api_key, $password, $store - ); + if ($theme_id == "") { + $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/assets.xml', + $api_key, $password, $store + ); + } + else { + $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.xml', + $api_key, $password, $store, $theme_id + ); + } // Right now, not bothering with dumping the full response/error handling. Will add if it becomes an issue. //We just collect the http_code and will display message if it's Not 200 @@ -113,16 +119,23 @@ function send_asset($api_key, $password, $store ,$xmlFile) { * @param string $key Key of asset we are downloading * @return object Asset / false on failure **/ -function remove_asset($api_key, $password, $store, $key) { +function remove_asset($api_key, $password, $store, $theme_id, $key) { //Request Asset URL Template // %1: API KEY, %2: PASSWORD, %3: STORE, %4: ASSET NAME - $requestUrl = sprintf('https://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', - $api_key, $password, $store, $key - ); + if ($theme_id == "") { + $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', + $api_key, $password, $store, $key + ); + } + else { + $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.json?asset[key]=%5$s', + $api_key, $password, $store, $theme_id, $key + ); + } - $response = `curl -w'%{http_code}' -X DELETE -s -g '$requestUrl'`; + $response = json_decode(`curl -w'%{http_code}' -X DELETE -s -g '$requestUrl'`); - if(response_code($response) == 200) { + if($response == 200) { return true; } return false; diff --git a/Support/pages/download_all.php b/Support/pages/download_all.php index 78297ef..bdee95e 100755 --- a/Support/pages/download_all.php +++ b/Support/pages/download_all.php @@ -2,7 +2,7 @@ echo "

Downloading all pages from
{$config->store}

"; -$requestUrlTemp = 'https://%1$s:%2$s@%3$s/admin/pages.json?limit=250'; +$requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/pages.json?limit=250'; $requestUrl = sprintf($requestUrlTemp, $config->api_key, $config->password, $config->store); $response = json_decode(`curl --connect-timeout 20 -s -g '$requestUrl'`); diff --git a/Support/pages/upload.php b/Support/pages/upload.php index f21783b..ab0880e 100755 --- a/Support/pages/upload.php +++ b/Support/pages/upload.php @@ -8,7 +8,7 @@ $payload = Escape::sh(json_encode($page)); -$requestUrlTemp = 'https://%1$s:%2$s@%3$s/admin/pages/%4$s.json'; +$requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/pages/%4$s.json'; $requestUrl = sprintf($requestUrlTemp, $config->api_key, $config->password, $config->store, $page_id); // $response = `curl --connect-timeout 20 -X PUT -s -g '$requestUrl' -H 'Content-Type: application/json' --data-binary $payload`; diff --git a/Support/vars.php b/Support/vars.php index 8d377aa..29341d6 100755 --- a/Support/vars.php +++ b/Support/vars.php @@ -7,6 +7,7 @@ $api_key = $config->api_key; //getenv('SHOPIFY_API_KEY'); $password = $config->password; //getenv('SHOPIFY_PASSWORD'); $store = $config->store; //getenv('SHOPIFY_STORE'); +$theme_id = $config->theme_id; define('TM_PROJECT_DIRECTORY',getenv('TM_PROJECT_DIRECTORY')); diff --git a/Test/test_arb.php b/Test/test_arb.php index f903643..360f287 100755 --- a/Test/test_arb.php +++ b/Test/test_arb.php @@ -1,4 +1,3 @@ Date: Wed, 20 Nov 2013 12:08:44 -0800 Subject: [PATCH 7/7] Revert ced2a27..20ae0d6 This rolls back to commit ced2a27468018b6fc076ec1ffa13e9d9f219fdd6. --- Commands/Download Theme.tmCommand | 13 ++--- Commands/Edit Config (TM Only).tmCommand | 2 +- ...ndered CSS file from _css_liquid.tmCommand | 2 +- Commands/New Config (TM Only).tmCommand | 2 +- Commands/Open Store Admin.tmCommand | 2 +- Commands/Pages: Download All.tmCommand | 0 Commands/Pages: Preview Current.tmCommand | 0 Commands/Pages: Upload Current.tmCommand | 0 ...ove Selected Assets from Shopify.tmCommand | 2 +- Commands/Send Asset to Shopify.tmCommand | 0 .../Send Selected Assets to Shopify.tmCommand | 0 Commands/Switch Shop (TM Only).tmCommand | 2 +- Commands/Test: New Framework.tmCommand | 2 +- Commands/Test: Ruby.tmCommand | 0 Commands/Test: config (TM Only).tmCommand | 2 +- ...date Selected Files From Shopify.tmCommand | 2 +- .../Update Template From Shopify.tmCommand | 2 +- Commands/Wiki: Liquid.tmCommand | 2 +- Snippets/asset_url: css.tmSnippet | 0 Snippets/asset_url: js.tmSnippet | 0 Snippets/setting: file upload.tmSnippet | 0 Snippets/setting: multi line.tmSnippet | 0 Snippets/setting: single line.tmSnippet | 0 Support/assets/upload.php | 12 +++- Support/assets/upload_multi.php | 6 +- Support/config.php | 3 - Support/functions.php | 57 +++++++------------ Support/head.php | 0 Support/lib/escape.php | 0 Support/lib/ui.php | 0 Support/liquid/filters.rb | 0 Support/pages/download_all.php | 2 +- Support/pages/upload.php | 2 +- Support/shopify-tmbundle-example.ini | 0 Support/vars.php | 1 - Test/test_arb.php | 3 +- info.plist | 0 readme-windows.markdown | 0 readme.markdown | 0 39 files changed, 54 insertions(+), 67 deletions(-) mode change 100755 => 100644 Commands/Download Theme.tmCommand mode change 100755 => 100644 Commands/Edit Config (TM Only).tmCommand mode change 100755 => 100644 Commands/Get Rendered CSS file from _css_liquid.tmCommand mode change 100755 => 100644 Commands/New Config (TM Only).tmCommand mode change 100755 => 100644 Commands/Open Store Admin.tmCommand mode change 100755 => 100644 Commands/Pages: Download All.tmCommand mode change 100755 => 100644 Commands/Pages: Preview Current.tmCommand mode change 100755 => 100644 Commands/Pages: Upload Current.tmCommand mode change 100755 => 100644 Commands/Remove Selected Assets from Shopify.tmCommand mode change 100755 => 100644 Commands/Send Asset to Shopify.tmCommand mode change 100755 => 100644 Commands/Send Selected Assets to Shopify.tmCommand mode change 100755 => 100644 Commands/Switch Shop (TM Only).tmCommand mode change 100755 => 100644 Commands/Test: New Framework.tmCommand mode change 100755 => 100644 Commands/Test: Ruby.tmCommand mode change 100755 => 100644 Commands/Test: config (TM Only).tmCommand mode change 100755 => 100644 Commands/Update Selected Files From Shopify.tmCommand mode change 100755 => 100644 Commands/Update Template From Shopify.tmCommand mode change 100755 => 100644 Commands/Wiki: Liquid.tmCommand mode change 100755 => 100644 Snippets/asset_url: css.tmSnippet mode change 100755 => 100644 Snippets/asset_url: js.tmSnippet mode change 100755 => 100644 Snippets/setting: file upload.tmSnippet mode change 100755 => 100644 Snippets/setting: multi line.tmSnippet mode change 100755 => 100644 Snippets/setting: single line.tmSnippet mode change 100755 => 100644 Support/config.php mode change 100755 => 100644 Support/functions.php mode change 100755 => 100644 Support/head.php mode change 100755 => 100644 Support/lib/escape.php mode change 100755 => 100644 Support/lib/ui.php mode change 100755 => 100644 Support/liquid/filters.rb mode change 100755 => 100644 Support/pages/download_all.php mode change 100755 => 100644 Support/pages/upload.php mode change 100755 => 100644 Support/shopify-tmbundle-example.ini mode change 100755 => 100644 Support/vars.php mode change 100755 => 100644 Test/test_arb.php mode change 100755 => 100644 info.plist mode change 100755 => 100644 readme-windows.markdown mode change 100755 => 100644 readme.markdown diff --git a/Commands/Download Theme.tmCommand b/Commands/Download Theme.tmCommand old mode 100755 new mode 100644 index bd20b2a..913a2a7 --- a/Commands/Download Theme.tmCommand +++ b/Commands/Download Theme.tmCommand @@ -7,6 +7,7 @@ command #!/usr/bin/env php <?php + //Kinda sucks, but this will need to be in each script, as opposed to be loaded //Make some assumptions if running under windows. //This is for compat with Environment: Cygwin generic mode, which gives us access to curl @@ -29,14 +30,8 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; //Request Asset URL Template // %1: API KEY, %2: PASSWORD, %3: STORE, %4: ASSET NAME -if ($theme_id == "") { - $requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/assets.json'; - $requestUrl = sprintf($requestUrlTemp, $api_key, $password, $store); -} -else { - $requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.json'; - $requestUrl = sprintf($requestUrlTemp, $api_key, $password, $store, $theme_id); -} +$requestUrlTemp = 'https://%1$s:%2$s@%3$s/admin/assets.json'; +$requestUrl = sprintf($requestUrlTemp, $api_key, $password, $store); // yes, I am aware php has curl. This is just simpler. echo "Getting theme asset list...<br>"; @@ -73,7 +68,7 @@ foreach ($assetFiles as $file) { } echo "Fetching {$file}...<br>"; - $asset = get_asset($api_key, $password, $store, $theme_id, $file); + $asset = get_asset($api_key, $password, $store, $file); if(false === $asset) { echo "*Error fetching: ($file)<br>"; diff --git a/Commands/Edit Config (TM Only).tmCommand b/Commands/Edit Config (TM Only).tmCommand old mode 100755 new mode 100644 index 46a9f7c..5a320b4 --- a/Commands/Edit Config (TM Only).tmCommand +++ b/Commands/Edit Config (TM Only).tmCommand @@ -13,7 +13,7 @@ mate "$TM_PROJECT_DIRECTORY/.shopify-tmbundle" input none name - Edit Config (TM Only) + Edit Config output discard uuid diff --git a/Commands/Get Rendered CSS file from _css_liquid.tmCommand b/Commands/Get Rendered CSS file from _css_liquid.tmCommand old mode 100755 new mode 100644 index 3fb8e67..f99f783 --- a/Commands/Get Rendered CSS file from _css_liquid.tmCommand +++ b/Commands/Get Rendered CSS file from _css_liquid.tmCommand @@ -36,7 +36,7 @@ if(false !== strpos($filepath, '.css.liquid')) { echo "Fetching {$filepath}...<br>"; -$asset = get_asset($api_key, $password, $store, $theme_id, $filepath); +$asset = get_asset($api_key, $password, $store, $filepath); if(false == $asset) { //Do Nothing. echo '*Error: Could not get '. $filepath .'<br>'; diff --git a/Commands/New Config (TM Only).tmCommand b/Commands/New Config (TM Only).tmCommand old mode 100755 new mode 100644 index 0dd723f..8f093e3 --- a/Commands/New Config (TM Only).tmCommand +++ b/Commands/New Config (TM Only).tmCommand @@ -15,7 +15,7 @@ mate "$TM_PROJECT_DIRECTORY/.shopify-tmbundle" input none name - New Config (TM Only) + New Config output discard uuid diff --git a/Commands/Open Store Admin.tmCommand b/Commands/Open Store Admin.tmCommand old mode 100755 new mode 100644 index 87b5a71..1752a1e --- a/Commands/Open Store Admin.tmCommand +++ b/Commands/Open Store Admin.tmCommand @@ -22,7 +22,7 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; input none name - Open Store Admin In Default Browser (TM Only) + Open Store Admin In Default Browser output discard uuid diff --git a/Commands/Pages: Download All.tmCommand b/Commands/Pages: Download All.tmCommand old mode 100755 new mode 100644 diff --git a/Commands/Pages: Preview Current.tmCommand b/Commands/Pages: Preview Current.tmCommand old mode 100755 new mode 100644 diff --git a/Commands/Pages: Upload Current.tmCommand b/Commands/Pages: Upload Current.tmCommand old mode 100755 new mode 100644 diff --git a/Commands/Remove Selected Assets from Shopify.tmCommand b/Commands/Remove Selected Assets from Shopify.tmCommand old mode 100755 new mode 100644 index 8063235..d9cb782 --- a/Commands/Remove Selected Assets from Shopify.tmCommand +++ b/Commands/Remove Selected Assets from Shopify.tmCommand @@ -37,7 +37,7 @@ foreach ($selectedFiles as $file) { $assetKey = calc_asset_key($file); echo "Removing $assetKey... "; - if(remove_asset($api_key, $password, $store, $theme_id, $assetKey)) { + if(remove_asset($api_key, $password, $store, $assetKey)) { echo "removed¡<br>"; } else { diff --git a/Commands/Send Asset to Shopify.tmCommand b/Commands/Send Asset to Shopify.tmCommand old mode 100755 new mode 100644 diff --git a/Commands/Send Selected Assets to Shopify.tmCommand b/Commands/Send Selected Assets to Shopify.tmCommand old mode 100755 new mode 100644 diff --git a/Commands/Switch Shop (TM Only).tmCommand b/Commands/Switch Shop (TM Only).tmCommand old mode 100755 new mode 100644 index eef3ff0..168d12f --- a/Commands/Switch Shop (TM Only).tmCommand +++ b/Commands/Switch Shop (TM Only).tmCommand @@ -19,7 +19,7 @@ exit_create_new_document input none name - Switch Shop (TM Only) + Switch Shop output discard uuid diff --git a/Commands/Test: New Framework.tmCommand b/Commands/Test: New Framework.tmCommand old mode 100755 new mode 100644 index cdcedae..3516675 --- a/Commands/Test: New Framework.tmCommand +++ b/Commands/Test: New Framework.tmCommand @@ -16,7 +16,7 @@ source "$TM_SUPPORT_PATH/lib/bash_init.sh" name Test: New Framework output - openAsNewDocument + showAsHTML uuid 25889F17-382C-4A90-87B3-F594690AAAA9 diff --git a/Commands/Test: Ruby.tmCommand b/Commands/Test: Ruby.tmCommand old mode 100755 new mode 100644 diff --git a/Commands/Test: config (TM Only).tmCommand b/Commands/Test: config (TM Only).tmCommand old mode 100755 new mode 100644 index 43e9370..07090f5 --- a/Commands/Test: config (TM Only).tmCommand +++ b/Commands/Test: config (TM Only).tmCommand @@ -12,7 +12,7 @@ var_dump($config); input none name - Test: config (TM Only) + Test: config output openAsNewDocument uuid diff --git a/Commands/Update Selected Files From Shopify.tmCommand b/Commands/Update Selected Files From Shopify.tmCommand old mode 100755 new mode 100644 index 6f63e2e..93e61bc --- a/Commands/Update Selected Files From Shopify.tmCommand +++ b/Commands/Update Selected Files From Shopify.tmCommand @@ -36,7 +36,7 @@ foreach ($selectedFiles as $file) { $assetKey = calc_asset_key($file); echo "Fetching {$assetKey}...<br>"; - $asset = get_asset($api_key, $password, $store, $theme_id, $assetKey); + $asset = get_asset($api_key, $password, $store, $assetKey); if(false == $asset) { //Do Nothing. echo '*Error: Could not update asset '. $assetKey .'<br>'; diff --git a/Commands/Update Template From Shopify.tmCommand b/Commands/Update Template From Shopify.tmCommand old mode 100755 new mode 100644 index 09c60bf..70497e4 --- a/Commands/Update Template From Shopify.tmCommand +++ b/Commands/Update Template From Shopify.tmCommand @@ -27,7 +27,7 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; // File path, based on theme restriction of no nested folder, so we make certain assumptions $filepath = calc_asset_key(getenv('TM_FILEPATH')); -$asset = get_asset($api_key, $password, $store, $theme_id, $filepath); +$asset = get_asset($api_key, $password, $store, $filepath); // clean out the \r 's - mac uses \n only. if(false !== $asset && property_exists($asset, 'value')) { diff --git a/Commands/Wiki: Liquid.tmCommand b/Commands/Wiki: Liquid.tmCommand old mode 100755 new mode 100644 index 7e6df61..5bd09a0 --- a/Commands/Wiki: Liquid.tmCommand +++ b/Commands/Wiki: Liquid.tmCommand @@ -24,7 +24,7 @@ require_once TM_BUNDLE_SUPPORT.DIRECTORY_SEPARATOR.'functions.php'; keyEquivalent ^h name - Wiki: Liquid (TM Only) + Wiki: Liquid output showAsTooltip scope diff --git a/Snippets/asset_url: css.tmSnippet b/Snippets/asset_url: css.tmSnippet old mode 100755 new mode 100644 diff --git a/Snippets/asset_url: js.tmSnippet b/Snippets/asset_url: js.tmSnippet old mode 100755 new mode 100644 diff --git a/Snippets/setting: file upload.tmSnippet b/Snippets/setting: file upload.tmSnippet old mode 100755 new mode 100644 diff --git a/Snippets/setting: multi line.tmSnippet b/Snippets/setting: multi line.tmSnippet old mode 100755 new mode 100644 diff --git a/Snippets/setting: single line.tmSnippet b/Snippets/setting: single line.tmSnippet old mode 100755 new mode 100644 diff --git a/Support/assets/upload.php b/Support/assets/upload.php index d9e4d7a..679f875 100755 --- a/Support/assets/upload.php +++ b/Support/assets/upload.php @@ -14,15 +14,21 @@ $xmlFile = tempnam('/tmp', 'foo').'.xml'; file_put_contents($xmlFile, $reqData); -$response = send_asset($api_key, $password, $store , $theme_id, $xmlFile); +$response = send_asset($api_key, $password, $store ,$xmlFile); -if('200' == $response) { - echo "Uploaded {$assetKey} to {$config->current}."; +if('200' == response_code($response)) { + + /* Add by Dale Tournemille 2013. This invokes terminal-notifier (by Eloy Durán) and displays the success upload message using OS X Notification Center. */ + echo "Uploaded {$assetKey} to {$config->current}."; + echo exec("/usr/local/bin/terminal-notifier -title 'File Uploaded' -message 'The file {$assetKey} has been uploaded to your {$config->current} theme on Shopify.' -sender com.macromates.TextMate.preview"); + + } else { // Not ideal, but it works. Problem (though not much of one ): // response on a fail will return the full curl page: ie, shopify 404 full html, + error code at the bottom // Will robustify if it becomes an issue. echo "*Error: Could not upload {$assetKey} to {$config->current}." ; + echo exec("/usr/local/bin/terminal-notifier -title 'Upload Error' -message 'Houston, we have a problem. The file {$assetKey} was NOT uploaded to {$config->current}.' -sender com.macromates.TextMate.preview"); output_error($response); } //And clean up diff --git a/Support/assets/upload_multi.php b/Support/assets/upload_multi.php index 98b8ac6..e7816d2 100755 --- a/Support/assets/upload_multi.php +++ b/Support/assets/upload_multi.php @@ -29,15 +29,17 @@ file_put_contents($xmlFile, $reqData); echo "Sending asset: {$assetKey}...
"; - $response = send_asset($api_key, $password, $store , $theme_id, $xmlFile); + $response = send_asset($api_key, $password, $store ,$xmlFile); - if('200' == $response) { + if('200' == response_code($response)) { echo "Uploaded: {$assetKey}
"; + echo exec("/usr/local/bin/terminal-notifier -title 'File Uploaded' -message 'The file {$assetKey} has been uploaded to Shopify.' -sender com.macromates.TextMate.preview"); } else { // Not ideal, but it works. Problem (though not much of one ): // response on a fail will return the full curl page: ie, shopify 404 full html, + error code at the bottom // Will robustify if it becomes an issue. echo "*Error: Could not upload {$assetKey} to {$config->current}." ; + echo exec("/usr/local/bin/terminal-notifier -title 'Upload Error' -message 'Houston, we have a problem. The file {$assetKey} was NOT uploaded to {$config->current}.' -sender com.macromates.TextMate.preview"); output_error($response, array('line_break' => '
')); } //And clean up diff --git a/Support/config.php b/Support/config.php old mode 100755 new mode 100644 index e9cfd13..bce5303 --- a/Support/config.php +++ b/Support/config.php @@ -18,8 +18,6 @@ class mConfig { var $store = null; - var $theme_id = null; - //Used to output to user what shop they are pushing to. Reads better than full shop name. var $current = 'default'; @@ -35,7 +33,6 @@ function __construct($path) { $this->api_key = getenv('SHOPIFY_API_KEY'); $this->password = getenv('SHOPIFY_PASSWORD'); $this->store = getenv('SHOPIFY_STORE'); - $this->theme_id = getenv('SHOPIFY_THEME_ID'); if( (!$this->api_key) || (!$this->password) || (!$this->store) ) { echo "No config file found here: {$path} ?"; diff --git a/Support/functions.php b/Support/functions.php old mode 100755 new mode 100644 index fe5d9d7..99edc17 --- a/Support/functions.php +++ b/Support/functions.php @@ -28,6 +28,11 @@ function is_binary($filepath) { } +// pull the http respone code from the response string +function response_code($response) { + return substr($response, -3); +} + /** * Output error from XML curl response * @@ -39,6 +44,8 @@ function output_error($response, $options = array()) { $options = $options + array('line_break'=> "\n"); + $http_code = response_code($response); + //Clean off the response - comes with http code attached $response = substr($response, 0, (strripos($response, '>')+1)); // echo $response; @@ -47,6 +54,7 @@ function output_error($response, $options = array()) { foreach ($errors as $error) { echo $options['line_break']."{$error}"; } + echo $options['line_break']."{$http_code}"; } /** @@ -58,19 +66,12 @@ function output_error($response, $options = array()) { * @param string $key Key of asset we are downloading * @return object Asset / false on failure **/ -function get_asset($api_key, $password, $store, $theme_id, $key) { +function get_asset($api_key, $password, $store, $key) { //Request Asset URL Template // %1: API KEY, %2: PASSWORD, %3: STORE, %4: ASSET NAME - if ($theme_id == "") { - $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', - $api_key, $password, $store, $key - ); - } - else { - $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.json?asset[key]=%5$s', - $api_key, $password, $store, $theme_id, $key - ); - } + $requestUrl = sprintf('https://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', + $api_key, $password, $store, $key + ); $responseTxt = `curl -s -g '$requestUrl'`; $response = json_decode($responseTxt); @@ -90,18 +91,11 @@ function get_asset($api_key, $password, $store, $theme_id, $key) { * @param string $xmlFile Path to the XML File with the contents to upload. * @return string **/ -function send_asset($api_key, $password, $store, $theme_id, $xmlFile) { +function send_asset($api_key, $password, $store ,$xmlFile) { - if ($theme_id == "") { - $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/assets.xml', - $api_key, $password, $store - ); - } - else { - $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.xml', - $api_key, $password, $store, $theme_id - ); - } + $requestUrl = sprintf('https://%1$s:%2$s@%3$s/admin/assets.xml', + $api_key, $password, $store + ); // Right now, not bothering with dumping the full response/error handling. Will add if it becomes an issue. //We just collect the http_code and will display message if it's Not 200 @@ -119,23 +113,16 @@ function send_asset($api_key, $password, $store, $theme_id, $xmlFile) { * @param string $key Key of asset we are downloading * @return object Asset / false on failure **/ -function remove_asset($api_key, $password, $store, $theme_id, $key) { +function remove_asset($api_key, $password, $store, $key) { //Request Asset URL Template // %1: API KEY, %2: PASSWORD, %3: STORE, %4: ASSET NAME - if ($theme_id == "") { - $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', - $api_key, $password, $store, $key - ); - } - else { - $requestUrl = sprintf('http://%1$s:%2$s@%3$s/admin/themes/%4$s/assets.json?asset[key]=%5$s', - $api_key, $password, $store, $theme_id, $key - ); - } + $requestUrl = sprintf('https://%1$s:%2$s@%3$s/admin/assets.json?asset[key]=%4$s', + $api_key, $password, $store, $key + ); - $response = json_decode(`curl -w'%{http_code}' -X DELETE -s -g '$requestUrl'`); + $response = `curl -w'%{http_code}' -X DELETE -s -g '$requestUrl'`; - if($response == 200) { + if(response_code($response) == 200) { return true; } return false; diff --git a/Support/head.php b/Support/head.php old mode 100755 new mode 100644 diff --git a/Support/lib/escape.php b/Support/lib/escape.php old mode 100755 new mode 100644 diff --git a/Support/lib/ui.php b/Support/lib/ui.php old mode 100755 new mode 100644 diff --git a/Support/liquid/filters.rb b/Support/liquid/filters.rb old mode 100755 new mode 100644 diff --git a/Support/pages/download_all.php b/Support/pages/download_all.php old mode 100755 new mode 100644 index bdee95e..78297ef --- a/Support/pages/download_all.php +++ b/Support/pages/download_all.php @@ -2,7 +2,7 @@ echo "

Downloading all pages from
{$config->store}

"; -$requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/pages.json?limit=250'; +$requestUrlTemp = 'https://%1$s:%2$s@%3$s/admin/pages.json?limit=250'; $requestUrl = sprintf($requestUrlTemp, $config->api_key, $config->password, $config->store); $response = json_decode(`curl --connect-timeout 20 -s -g '$requestUrl'`); diff --git a/Support/pages/upload.php b/Support/pages/upload.php old mode 100755 new mode 100644 index ab0880e..f21783b --- a/Support/pages/upload.php +++ b/Support/pages/upload.php @@ -8,7 +8,7 @@ $payload = Escape::sh(json_encode($page)); -$requestUrlTemp = 'http://%1$s:%2$s@%3$s/admin/pages/%4$s.json'; +$requestUrlTemp = 'https://%1$s:%2$s@%3$s/admin/pages/%4$s.json'; $requestUrl = sprintf($requestUrlTemp, $config->api_key, $config->password, $config->store, $page_id); // $response = `curl --connect-timeout 20 -X PUT -s -g '$requestUrl' -H 'Content-Type: application/json' --data-binary $payload`; diff --git a/Support/shopify-tmbundle-example.ini b/Support/shopify-tmbundle-example.ini old mode 100755 new mode 100644 diff --git a/Support/vars.php b/Support/vars.php old mode 100755 new mode 100644 index 29341d6..8d377aa --- a/Support/vars.php +++ b/Support/vars.php @@ -7,7 +7,6 @@ $api_key = $config->api_key; //getenv('SHOPIFY_API_KEY'); $password = $config->password; //getenv('SHOPIFY_PASSWORD'); $store = $config->store; //getenv('SHOPIFY_STORE'); -$theme_id = $config->theme_id; define('TM_PROJECT_DIRECTORY',getenv('TM_PROJECT_DIRECTORY')); diff --git a/Test/test_arb.php b/Test/test_arb.php old mode 100755 new mode 100644 index 360f287..f903643 --- a/Test/test_arb.php +++ b/Test/test_arb.php @@ -1,3 +1,4 @@