From cf272a95bb21761bb3f09a812ed9dce36c0874d4 Mon Sep 17 00:00:00 2001 From: Matt Wigham Date: Wed, 22 Apr 2015 16:32:56 -0600 Subject: [PATCH] Move testing options from config.ru to .dugway.json --- CHANGELOG.md | 34 +++++++++++++++++++++------ README.md | 34 ++++++++++++++------------- lib/dugway.rb | 2 +- lib/dugway/cli/create.rb | 1 + lib/dugway/cli/templates/config.tt | 26 +++++++------------- lib/dugway/cli/templates/dugway.tt | 27 +++++++++++++++++++++ lib/dugway/cli/templates/gitignore.tt | 1 + lib/dugway/version.rb | 2 +- 8 files changed, 84 insertions(+), 43 deletions(-) create mode 100644 lib/dugway/cli/templates/dugway.tt diff --git a/CHANGELOG.md b/CHANGELOG.md index 86b99ea..72bb8de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,36 @@ ## Version History +#### 0.10.3 + +* Added `.dugway.json` as a better way to [test your theme](https://github.com/bigcartel/dugway#testing-your-theme) without needing to modify `config.ru` + +#### 0.10.2 + +* Misc bug fixes and improvements + +#### 0.10.1 + +* Misc bug fixes and improvements + +#### 0.10.0 + +* Added support for default images in `settings.json` + #### 0.9.0 - * Added support for `theme_font_url` liquid filter - * Added fonts directory, serve fonts from there - * `dugway build` will include font files in the zip + +* Added support for `theme_font_url` liquid filter +* Added fonts directory, serve fonts from there +* `dugway build` will include font files in the zip #### 0.8.4 - * Support `image_sets` in `settings.json` - * Support the new [constrain](http://help.bigcartel.com/developers/themes/#constrainurl-width-height) filter + +* Support `image_sets` in `settings.json` +* Support the new [constrain](http://help.bigcartel.com/developers/themes/#constrainurl-width-height) filter #### 0.7.0 - * Rename `scripts.js` and `styles.css` to `theme.js` and `theme.css` + +* Rename `scripts.js` and `styles.css` to `theme.js` and `theme.css` #### Pre-0.7.0 - * Initial launch and bug fixes + +* Initial launch and bug fixes diff --git a/README.md b/README.md index 8b4a042..979e8b3 100644 --- a/README.md +++ b/README.md @@ -134,32 +134,34 @@ Tired of all the manual starting and stopping? Good news, Dugway is built on top ## Testing your theme -Part of building a great theme is making sure it works well in a variety of contexts and with a variety of content. Dugway makes it easy to test your theme's versatility by customizing the **options** in the **config.ru** file. +Part of building a great theme is making sure it works well in a variety of contexts and with a variety of content. Dugway makes it easy to test your theme's versatility by utilizing the **.dugway.json** file. This file will be specific to your computer for your own testing, and shouldn't be checked into source control. -*Note:* changing the **config.ru** file will require you to restart the [server](#running-your-theme). +*Note:* changing **.dugway.json** will require you to restart the [server](#running-your-theme). ### Store content -The best way to see your theme under a different light is by previewing it with a different store's products, categories, pages, currency, and other content. To do this, simply set the **:store** option to any Big Cartel store's subdomain, and Dugway will bring in their content using the standard [Big Cartel API](http://help.bigcartel.com/developers/api/). By default we use **dugway** for [dugway.bigcartel.com](http://dugway.bigcartel.com). +The best way to see your theme under a different light is by previewing it with a different store's products, categories, pages, currency, and other content. To do this, simply set the **store.subdomain** variable in **.dugway.json** to any Big Cartel store's subdomain, and Dugway will bring in their content using the standard [Big Cartel API](http://help.bigcartel.com/developers/api/). By default we use **dugway** for [dugway.bigcartel.com](http://dugway.bigcartel.com). - options[:store] = 'beeteeth' + "store": { + "subdomain": "beeteeth" + } *Note:* don't worry, any sensitive data like inventory levels and discount codes is faked by Dugway. ### Store customization -Another important thing to consider is how store owners will customize your theme. You establish what can be customized in your [settings.json](#settings) file, and Dugway allows you to simulate potential values people could choose by setting them in the **:customization** option. By default we use the **default** values from your **[settings.json](#settings)** file. - - options[:customization] = { - :logo => { - :url => 'http://placehold.it/200x50/000000/ffffff&text=My+Logo', - :width => 200, - :height => 50 - }, - :background_color => '#CCCCCC', - :show_search => true, - :twitter_username => 'mytwitter' - } +Another important thing to consider is how store owners will customize your theme. You establish what can be customized in your [settings.json](#settings) file, and Dugway allows you to simulate potential values people could choose by setting them in the **customization** variable in **.dugway.json**. By default we use the **default** values from your **[settings.json](#settings)** file. + + "customization": { + "logo": { + "url": "http://placehold.it/200x50/000000/ffffff&text=My+Logo", + "width": 200, + "height": 50 + }, + "background_color": "#CCCCCC", + "show_search": true, + "twitter_username": "bigcartel" + } ## Building your theme diff --git a/lib/dugway.rb b/lib/dugway.rb index 2d28bed..2e9c8ac 100644 --- a/lib/dugway.rb +++ b/lib/dugway.rb @@ -48,7 +48,7 @@ def application(options={}) end def store - @store ||= Store.new(options && options[:store] || 'dugway') + @store ||= Store.new(options && options[:store] && options[:store][:subdomain] || 'dugway') end def theme diff --git a/lib/dugway/cli/create.rb b/lib/dugway/cli/create.rb index f86b730..9feafb3 100644 --- a/lib/dugway/cli/create.rb +++ b/lib/dugway/cli/create.rb @@ -26,6 +26,7 @@ def variables def core template('config.tt', "#{ @theme_dir }/config.ru") + template('dugway.tt', "#{ @theme_dir }/.dugway.json") template('source/settings.json', "#{ source_dir }/settings.json") end diff --git a/lib/dugway/cli/templates/config.tt b/lib/dugway/cli/templates/config.tt index b8c70ac..8c2cadc 100644 --- a/lib/dugway/cli/templates/config.tt +++ b/lib/dugway/cli/templates/config.tt @@ -1,22 +1,12 @@ require 'dugway' -options = {} - -# Use data from any store to make sure your theme looks great with all sorts of products, pages, -# categories, and more. Just give us the subdomain. Default is "dugway" for dugway.bigcartel.com. -# options[:store] = 'mystore' - -# Simulate the customization done by store owners by passing values to different variables. -# Default values are based on the "default" for each setting in your settings.json. -# options[:customization] = { -# :logo => { -# :url => 'http://placehold.it/200x50/000000/ffffff&text=My+Logo', -# :width => 200, -# :height => 50 -# }, -# :background_color => '#CCCCCC', -# :show_search => true, -# :twitter_username => 'mytwitter' -# } +begin + file = File.read('.dugway.json') + json = JSON.parse(file) + options = HashWithIndifferentAccess.new(json) +rescue Exception => e + puts e + options = {} +end run Dugway.application(options) diff --git a/lib/dugway/cli/templates/dugway.tt b/lib/dugway/cli/templates/dugway.tt new file mode 100644 index 0000000..e55067d --- /dev/null +++ b/lib/dugway/cli/templates/dugway.tt @@ -0,0 +1,27 @@ +// Use this file to test your theme with different stores and customization variations. +// Learn more at: // https://github.com/bigcartel/dugway#testing-your-theme +// DON'T CHECK THIS FILE INTO SOURCE CONTROL + +{ + + // Use data from any store to make sure your theme looks great with all sorts of products, pages, + // categories, and more. Just give us the subdomain. Default is "dugway" for dugway.bigcartel.com. + + // "store": { + // "subdomain": "mystore" + // }, + + // Simulate the customization done by store owners by passing values to different variables. + // Default values are based on the "default" for each setting in your settings.json. + + // "customization": { + // "logo": { + // "url": "http://placehold.it/200x50/000000/ffffff&text=My+Logo", + // "width": 200, + // "height": 50 + // }, + // "background_color": "#CCCCCC", + // "show_search": true, + // "twitter_username": "bigcartel" + // } +} diff --git a/lib/dugway/cli/templates/gitignore.tt b/lib/dugway/cli/templates/gitignore.tt index 1068be5..b58fcb7 100644 --- a/lib/dugway/cli/templates/gitignore.tt +++ b/lib/dugway/cli/templates/gitignore.tt @@ -1,6 +1,7 @@ .bundle .DS_Store .sass-cache +.dugway.json build tmp diff --git a/lib/dugway/version.rb b/lib/dugway/version.rb index 9ce8954..36b9961 100644 --- a/lib/dugway/version.rb +++ b/lib/dugway/version.rb @@ -1,3 +1,3 @@ module Dugway - VERSION = "0.10.2" + VERSION = "0.10.3" end