<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tonka Park &#187; development</title>
	<atom:link href="http://tonkapark.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://tonkapark.com</link>
	<description>Big Cartel Themes, Internet Marketing and E-Commerce</description>
	<lastBuildDate>Thu, 17 May 2012 15:40:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Building Wordsmith, a Spree Extension</title>
		<link>http://tonkapark.com/331/building-wordsmith-a-spree-extension/</link>
		<comments>http://tonkapark.com/331/building-wordsmith-a-spree-extension/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 15:00:28 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[spree]]></category>

		<guid isPermaLink="false">http://tonkapark.com/?p=331</guid>
		<description><![CDATA[Sharing the steps to build a Spree extension.
Related posts:<ol>
<li><a href='http://tonkapark.com/378/wordsmith-a-spree-extension/' rel='bookmark' title='Wordsmith 2.0 released'>Wordsmith 2.0 released</a></li>
<li><a href='http://tonkapark.com/337/deploying-spree-using-heroku/' rel='bookmark' title='Deploying Spree using Heroku'>Deploying Spree using Heroku</a></li>
<li><a href='http://tonkapark.com/1077/getting-started-with-spree-0-30-1-customizations/' rel='bookmark' title='Getting Started with Spree 0.30.1 Customizations'>Getting Started with Spree 0.30.1 Customizations</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://spreecommerce.com/">Spree</a> is an open source e-commerce solution written with ruby on rails. I recently chose Spree to use for a project building out a new website. Spree is robust in features and functionality but it does not cover everything. Several basic features I wanted to include were static content and a blog with comments. Spree claims to be a flexible and extensible platform and so far I believe that claim.</p>
<p>Here is a quick summary guide of how I built a new spree extension, <a href="http://github.com/tonkapark/spree-wordsmith">Wordsmith</a>. <a href="http://tonkapark.com/378/wordsmith-a-spree-extension/">Wordsmith</a> adds blogging functionality to your Spree site, with features such as comments and rss feeds.</p>
<p><strong>Spree <a href="http://tonkapark.com/378/wordsmith-a-spree-extension/">Wordsmith</a></strong></p>
<p>There are options to use other rails projects or wordpress with Spree or even the existing <a href="http://github.com/paulcc/spree-blog">spree-blog extension</a>. I tried the existing extension but it was lacking functionality that I thought should be included. Rather than forking the existing extension I started from scratch building my own blog engine inside spree named Wordsmith.</p>
<p><strong>Creating the Spree extension</strong></p>
<p>There is great documentation offered up by the Spree developers on how to create the extension so I will just summarize the steps I took. The first step once Spree is installed is to run the extension generator to get the default folder structure in the extension directory.</p>
<pre>script/generate extension</pre>
<p>Creating a model or controller is just as easy. You can either copy your code over from a previous rails project or start from scratch with the extension generators.</p>
<pre>script/generate extension_model  &lt;extension-name&gt; &lt;model-name&gt; column_name:data_type
script/generate extension_controller &lt;extension-name&gt; &lt;controller-name&gt;</pre>
<p>Don&#8217;t forget to run rake db:migrate to get your database up to date after you edit your migration files.</p>
<p><strong>Spree extension class</strong></p>
<p>The trick to the setup takes place in the _extension.rb file found in the root of the extension folder. You can include your dependent gems, add links to the Admin toolbar, add fields to the user forms, make your helpers available to all views, set/create app configuration preferences, and extend controller and model classes. I found that with at least two different gems you sometimes will have to include the setup from the gem init.rb file in the activate method inside your extension class. Not sure what causes this to be required but it happened with the subdomain_fu and formtastic gems. You can read this <a href="http://groups.google.com/group/spree-user/browse_thread/thread/ff2f2bb0df15fcb">thread </a>regarding a gem failing to load in a spree extension.</p>
<p><strong>Spree AppConfiguration</strong></p>
<p>In Wordsmith I created new AppConfiguration preferences to be used by my new code. Settings such as posts per page, default post status and also the slug used for the blog home path. These preferences can even be changed from inside the app if you include a view. I have provided a view to display the preferences and allow editing of those that do not require an app restart.</p>
<p><strong>Extension initializers</strong></p>
<p>Just like with other rails projects you can include your own initializers files in the provided extension config/initializers directory. These will get picked up when your application is loaded.</p>
<p><strong>Overriding Spree core</strong></p>
<p>The most useful part of Spree extensions is you can quickly and easily override any existing functionality or views. Simple add in your extension the file with the same path and name as the file in the core you want to override. In most cases this will be for customizing views but you can also easily change behavior if you choose. For Spree Wordsmith I did not have to override anything, but I have been working on an override for the entire admin section that I may make public if it works out.</p>
<p>I was very brief in my walkthrough since the documentation is very capable of getting you through most the setup. You can view the source code for <a href="http://github.com/tonkapark/spree-wordsmith">spree-wordsmith</a> at my github repository. Read more about Spree extensions at the <a href="http://spreecommerce.com/documentation/">Spree documentation</a> page.</p>
<p>An additional extension that I have found useful, and might integrate into Wordsmith is <a href="http://github.com/PeterBerkenbosch/spree-static-content">spree-static-content</a> by Peter Berkenbosch.</p>
<p>Related posts:<ol>
<li><a href='http://tonkapark.com/378/wordsmith-a-spree-extension/' rel='bookmark' title='Wordsmith 2.0 released'>Wordsmith 2.0 released</a></li>
<li><a href='http://tonkapark.com/337/deploying-spree-using-heroku/' rel='bookmark' title='Deploying Spree using Heroku'>Deploying Spree using Heroku</a></li>
<li><a href='http://tonkapark.com/1077/getting-started-with-spree-0-30-1-customizations/' rel='bookmark' title='Getting Started with Spree 0.30.1 Customizations'>Getting Started with Spree 0.30.1 Customizations</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://tonkapark.com/331/building-wordsmith-a-spree-extension/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deploying Spree using Heroku</title>
		<link>http://tonkapark.com/337/deploying-spree-using-heroku/</link>
		<comments>http://tonkapark.com/337/deploying-spree-using-heroku/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 21:54:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[spree]]></category>

		<guid isPermaLink="false">http://tonkapark.com/?p=337</guid>
		<description><![CDATA[Here is a guide on how I got a fresh install of Spree running on Heroku rails hosting.
Related posts:<ol>
<li><a href='http://tonkapark.com/331/building-wordsmith-a-spree-extension/' rel='bookmark' title='Building Wordsmith, a Spree Extension'>Building Wordsmith, a Spree Extension</a></li>
<li><a href='http://tonkapark.com/189/stuck-a-fork-in-clearance-by-thoughtbot/' rel='bookmark' title='Stuck a fork in Clearance by Thoughtbot'>Stuck a fork in Clearance by Thoughtbot</a></li>
<li><a href='http://tonkapark.com/1077/getting-started-with-spree-0-30-1-customizations/' rel='bookmark' title='Getting Started with Spree 0.30.1 Customizations'>Getting Started with Spree 0.30.1 Customizations</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was having trouble running <a href="http://spreecommerce.com">Spree </a>on my shared host where I have multiple sites running. I saw that some had success deploying spree on <a href="http://heroku.com">heroku</a> , so I thought I would give it a try. I was hoping to get an easy deployment process and also better responsiveness from the application. Also Heroku is free to start and you can pay to scale.</p>
<p>Here is a guide on how I got a fresh install of Spree running on Heroku rails hosting.</p>
<p><strong>Setting the stage</strong></p>
<p>I will assume ruby, rails, gems and git are all installed.</p>
<pre>gem install spree
spree &lt;app-name&gt;
cd &lt;app-name&gt;
git init
git add .
git commit -m "initial commit"
heroku create</pre>
<p>References: <a href="http://docs.heroku.com/quickstart">Heroku QuickStart</a> | <a href="http://spreecommerce.com/documentation/getting_started.html">Spree Getting Started</a></p>
<p>I created a .gitignore file, it is not a requirement, to exclude certain local files that are created during development, such as sqlite3 or db files, log and tmp directories and even the product images.</p>
<p><strong>Heroku gem manifest</strong></p>
<p>Heroku has many gems already installed on their servers and is even more up to date than other hosts. However, Spree has many gem dependencies. To resolve this you create a gem manifest that is placed in the RAILS_ROOT, name the file .gems. I have gone ahead and copied my <a href="http://gist.github.com/238230">gem manifest</a> that is necessary for Spree 0.9.2 gem to gist and is pasted below.</p>
<pre># .gems
activemerchant --version 1.4.1
activerecord-tableless --version '>= 0.1.0'
calendar_date_select --version 1.15
chronic --version '>= 0.2.3'
tlsmail --version 0.0.1
rspec --version '>= 1.2.9'
rspec-rails --version '>= 1.2.0'
will_paginate --version '>= 2.3.11'
authlogic --version '>= 2.0.11'
compass --version 0.8.17
stringex
whenever
spree --version 0.9.2</pre>
<p>Based on the manifest I have created and the events over the summer of github no longer hosting gems we need to edit the environment.rb file. Three lines in question need the gem name and source changed to match the new gemcutter.org hosting.</p>
<pre>#config/environment.rb
config.gem 'stringex', :lib => 'stringex', :source => "http://gemcutter.org"
config.gem 'whenever', :lib => false, :source => 'http://gemcutter.org'
config.gem 'will_paginate', :version => '~> 2.3.11', :lib => 'will_paginate', :source => 'http://gemcutter.org'</pre>
<p><strong>Heroku read only</strong></p>
<p>Heroku is a read-only filesystem. This means that many new gems and other application features are limited. One such case is the use of SASS for stylesheets. In Spree the stylesheets are now compiled at runtime. Instead of looking at reworking Spree there is an easier option. The engineers at Heroku responded in the last few months with a plugin to allow SASS to work on Heroku. Simply add this to your spree application.</p>
<pre>script/plugin install git://github.com/heroku/sass_on_heroku.git</pre>
<p>The Heroku read only filesystem comes into play again. Spree uses the rails :cache feature for javascript and stylesheets. This is talked about some on the Spree-user google group. The simplest solution is to remove the :cache from the tags in the layouts.</p>
<p>Additionally Heroku allows commands such as heroku rake db:migrate to be run. This is very helpful but there are limitations. Heroku does not allow rake commands that require user input. This is covered in the <a href="http://docs.heroku.com/rake">Heroku Rake Docs</a>. For Spree this is a problem because of the rake db:admin:create or rake db:bootstrap tasks used to setup the database. I came up with a solution to create a new task.</p>
<p>Both the :cache tag and the db:admin:create issues are addressed by a forked version of the extension spree-heroku. See the <a href="http://github.com/tonkapark/spree_heroku">spree heroku extension</a> code on my github repository. You can install it as an extension or take the ideas and add them to your site extension.</p>
<pre>script/extension install git://github.com/tonkapark/spree_heroku.git</pre>
<p>A admin_user.yml file is created in the extension config directory. You can leave it be or edit it for the different environments. It doesn&#8217;t matter because Spree allows users to change their email and passwords once logged in.</p>
<p><strong>Spree Heroku extension disclosure</strong></p>
<p>I want to disclose that I know my version of the heroku extension is incomplete for full production use. My version does not address the image storage issue that is covered in the <a href="http://github.com/goodkarma/spree_heroku">original version of the extension</a>. There are two reasons really. First I believe there is a solution that is more Spree extension like than previously done. And second I have not yet setup Amazon S3 account. I will address this shortly but wanted to get this information out right away.</p>
<p>In case you are interested the method for the image override belongs in your site_extension or heroku_extension.rb file. Here is a sample of how to override the default styles and sizes for paperclip in a spree extension inside the def activate block.</p>
<pre>Image.attachment_definitions[:attachment][:styles] = {
:mini =&gt; '48x48&gt;', :small =&gt; '100x100&gt;', :grid =&gt; '268x268&gt;',:product =&gt; '240x240&gt;', :large =&gt; '600x600&gt;'}</pre>
<p><strong>Preparing to deploy spree to heroku</strong></p>
<p>Spree comes with a few default preferences. One is to set SSL on in production. In Heroku you have to add SSL as an add-on. There is actually a free option but you have to submit your credit card for verification of identity and to allow you to upscale if needed. So be default Heroku won&#8217;t have SSL. This is a quick fix, with 3 lines added to the site_extension.rb file in vendor/extensions/site/ in the activate method.</p>
<pre>#site_extension.rb
def activate
  AppConfiguration.class_eval do
    preference :allow_ssl_in_production, :boolean, :default =&gt; false
  end
end</pre>
<p><strong>Deploy to Heroku</strong></p>
<pre>git add . &amp;&amp; git commit -m "heroku setup"
git push heroku master
heroku rake db:migrate
heroku rake db:seed</pre>
<p>These quick steps will add all the files to your local git repository, push them to your new heroku app, create the production database and seed the default values in the database.</p>
<p>Next is the custom task created in the spree-heroku extension that will create your admin user.</p>
<pre>heroku rake heroku:db:admin:create</pre>
<p>Finally you are ready to launch your application.</p>
<pre>heroku open</pre>
<p>I am going to continue working on this and should have an update to the <a href="http://github.com/tonkapark/spree_heroku">heroku extension</a> that addresses the image storage as I believe it should be. Also I will be working to deploy some other extensions and will possibly write up any future complications. </p>
<p>Related posts:<ol>
<li><a href='http://tonkapark.com/331/building-wordsmith-a-spree-extension/' rel='bookmark' title='Building Wordsmith, a Spree Extension'>Building Wordsmith, a Spree Extension</a></li>
<li><a href='http://tonkapark.com/189/stuck-a-fork-in-clearance-by-thoughtbot/' rel='bookmark' title='Stuck a fork in Clearance by Thoughtbot'>Stuck a fork in Clearance by Thoughtbot</a></li>
<li><a href='http://tonkapark.com/1077/getting-started-with-spree-0-30-1-customizations/' rel='bookmark' title='Getting Started with Spree 0.30.1 Customizations'>Getting Started with Spree 0.30.1 Customizations</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://tonkapark.com/337/deploying-spree-using-heroku/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Redesigning with WordPress</title>
		<link>http://tonkapark.com/309/redesigning-with-wordpress/</link>
		<comments>http://tonkapark.com/309/redesigning-with-wordpress/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 03:33:49 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://tonkapark.com/?p=309</guid>
		<description><![CDATA[I just finished redesigning tonkapark.com using wordpress. I share how I setup Wordpress in its own directory, short urls and category specific templates.
Related posts:<ol>
<li><a href='http://tonkapark.com/391/easy-steps-to-deploy-a-wordpress-using-capistrano/' rel='bookmark' title='Easy steps to deploy WordPress using Capistrano'>Easy steps to deploy WordPress using Capistrano</a></li>
<li><a href='http://tonkapark.com/1179/creating-a-big-cartel-and-wordpress-plugin/' rel='bookmark' title='Creating a Big Cartel and WordPress Integration Plugin'>Creating a Big Cartel and WordPress Integration Plugin</a></li>
<li><a href='http://tonkapark.com/1214/deployed-client-wordpress-site-to-production/' rel='bookmark' title='Deployed Client WordPress Site to Production'>Deployed Client WordPress Site to Production</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>So I just finished redesigning <strong>tonkapark.com</strong><strong> </strong>using wordpress as my CMS. I was already running my blog with wordpress so it was only a matter of extending a few theme pages and a few settings in wordpress. Let me share those steps here in case they can help someone else.</p>
<p><strong>Creating a theme</strong></p>
<p>A big part of the redesign with wordpress is simply creating a custom theme. There are hundreds of howto&#8217;s when it comes to wordpress theme development, I will not attempt to go into details here.</p>
<p>The key points in the theme development are creating individual page templates. This can be done by creating files with the name format of page-templatename.php.</p>
<p><code>&lt;?php<br />
/*<br />
Template Name: GrowthHome<br />
*/<br />
?&gt;</code></p>
<p>A page template can then be assigned when creating a new page in wordpress. This allows the Portfolio page to look different than the services page or the about page. I am actually using a Page template for my blog index page instead of the index.php default page.</p>
<p><strong>Different Sinlge Page by Category</strong></p>
<p>Another trick many developers are using with wordpress is to add a conditional statement to the single.php file in the theme. This file then selects a custom named file of your liking to display.</p>
<p><code>&lt;?php<br />
$post = $wp_query-&gt;post;<br />
if ( in_category('29') ) {<br />
include(TEMPLATEPATH . '/single-portfolio.php');<br />
} else {<br />
include(TEMPLATEPATH . '/single-blog.php');<br />
}<br />
?&gt;</code></p>
<p>This simple block allows my portfolio item posts to be displayed completely different than my individual blog posts. A handy trick indeed when working with WordPress as a CMS.</p>
<p><strong>Short Urls</strong></p>
<p>Something new I added to the site was a feature that several other websites now have and is becoming more common due to services like twitter. Many of the times when using twitter you have to shorten a url to fit your character limit. I have used bit.ly for url shortening but I don&#8217;t like having to use a third party domain to mask the actual endpoint when my domain is the one in question. I want to build name recognition and have trust in my links. So rather than using a plugin or a fancy solution to create my short urls and use hashes I took a simple approach that I believe to be pratical and elegant.</p>
<p>I changed the WordPress permalink structure from the previous /%year%/%month%/%postname%/ to /%post_id%/%postname%/. This change required no coding on my part, the previous links continued to redirect to the new structure and I get my short urls by cutting off the postname. I am not sure if there are any flaws to this approach yet but my existing links on twitter, my new links and my short urls all work. Using the All in One SEO plugin each of my pages is given a canonical link tag in the head section so the search engines will be able to index the full url even if the short url is used to link to my pages.</p>
<p><strong>Giving WordPress its Own Directory</strong></p>
<p>Finally to have the root of my website clear of all the wordpress php files I left the wordpress install in a folder (/blog) and followed the easy steps to copy the htaccess and index.php to the root so that you can have the front page outside of the wordpress directory. The steps are on the <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory" target="_blank">wordpress codex pages</a> and linked from within the WordPress Admin General Options</p>
<p>So those are the basic steps I took to setup wordpress to take over control of my website. I am sure there are plenty more steps I can take but for what I need this works.</p>
<p>Related posts:<ol>
<li><a href='http://tonkapark.com/391/easy-steps-to-deploy-a-wordpress-using-capistrano/' rel='bookmark' title='Easy steps to deploy WordPress using Capistrano'>Easy steps to deploy WordPress using Capistrano</a></li>
<li><a href='http://tonkapark.com/1179/creating-a-big-cartel-and-wordpress-plugin/' rel='bookmark' title='Creating a Big Cartel and WordPress Integration Plugin'>Creating a Big Cartel and WordPress Integration Plugin</a></li>
<li><a href='http://tonkapark.com/1214/deployed-client-wordpress-site-to-production/' rel='bookmark' title='Deployed Client WordPress Site to Production'>Deployed Client WordPress Site to Production</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://tonkapark.com/309/redesigning-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

