<?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"
	>

<channel>
	<title>Ben McRedmond.com</title>
	<atom:link href="http://benmcredmond.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://benmcredmond.com/blog</link>
	<description>A Social Media and Web Development Blog.</description>
	<pubDate>Sat, 12 Jul 2008 21:15:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Installing and Configuring Subversion on Ubuntu</title>
		<link>http://benmcredmond.com/blog/2008/07/12/installing-and-configuring-subversion-on-ubuntu/</link>
		<comments>http://benmcredmond.com/blog/2008/07/12/installing-and-configuring-subversion-on-ubuntu/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 21:15:11 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Project Management]]></category>

		<category><![CDATA[subversion]]></category>

		<category><![CDATA[subversion clients]]></category>

		<category><![CDATA[svn]]></category>

		<category><![CDATA[ubuntu]]></category>

		<category><![CDATA[ubuntu 8]]></category>

		<category><![CDATA[versions]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/?p=21</guid>
		<description><![CDATA[For a long time I&#8217;ve hosted my sites on a MediaTemple VPS or Virtual Private Server. For a pricey $50 a month you get a pretty nice package and 24/7 support but recently I was turned onto Slicehost. They offer great plans for very reasonable prices and great support too (always important). 

They also offer [...]]]></description>
			<content:encoded><![CDATA[<p>For a long time I&#8217;ve hosted my sites on a <a href="http://mediatemple.net">MediaTemple</a> VPS or Virtual Private Server. For a pricey $50 a month you get a pretty nice package and 24/7 support but recently I was turned onto <a href="http://slicehost.com">Slicehost</a>. They offer great plans for very reasonable prices and great support too (always important). </p>

<p>They also offer a choice of operating systems, not forcing me to use my now least favourite operating system: centOS. I chose ubuntu and following on from last weeks post about project management, I will talk about <strong>how to install and configure a subversion server</strong> running on Ubuntu 8.0.4.</p>

<p><span id="more-21"></span></p>

<p>I&#8217;m assuming you have basic developer tools installed and have a good enough concept of the command line + *nix. Start by installing subversion.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># apt-get install subversion</pre></div></div>


<p>This gives us all the subversion admin and client tools. We&#8217;ll start by creating a central location for our repositories under <strong>/home/svn</strong>.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># mkdir /home/svn
# cd /home/svn</pre></div></div>


<p>Now lets create a repository, replace <em>myrepo</em> with the name of your repository.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># svnadmin create myrepo</pre></div></div>


<p>If you do an <em>ls</em> in this directory you&#8217;ll see subversion created a new directory called &#8220;myrepo&#8221;. We&#8217;re going to setup http access to our repository, so we need to ensure apache can read and write the files.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># cd /home
# chown -R www-data:www-data svn
# chmod -R 770 svn</pre></div></div>


<p>We need to create some users to login to our subversion server, after running each htpasswd command it will prompt for a password which will be the login password for the user.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># cd /home/svn
# htpasswd -c .htpasswd firstuser
# htpasswd .htpasswd seconduser
# htpasswd .htpasswd thirduser</pre></div></div>


<p>Now we have our repository setup we need to connect apache to it. I&#8217;m assuming you have apache setup and installed. Next we need to install apache subversion bindings and enable webdav.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># apt-get install libapache2-svn
# cd /etc/apache2
# a2enmod dav</pre></div></div>


<p>Finally we need to configure apache.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># cd /etc/apache2/sites-available
# nano svn.mydomain.com</pre></div></div>


<p>This will create a new file called svn.mydomain.com and open a blank file in a text editor. Copy the below into it and replace <strong>yourdomain</strong> with the correct value wherever mentioned.</p>


<div class="wp_syntax"><div class="code"><pre class="apache">&lt;VirtualHost *:<span style="color: #ff0000;">80</span>&gt;
&nbsp;
  	<span style="color: #adadad; font-style: italic;"># Admin email, Server Name (domain name) and any aliases</span>
  	<span style="color: #00007f;">ServerAdmin</span> admin@yourdomain.com
  	<span style="color: #00007f;">ServerName</span>  svn.yourdomain.com
&nbsp;
	&lt;Location /&gt;
		<span style="color: #00007f;">AuthType</span> Basic
		<span style="color: #00007f;">AuthUserFile</span> /home/svn/.htpasswd
		<span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;Dev Team Only&quot;</span>
		<span style="color: #00007f;">require</span> valid-<span style="color: #00007f;">user</span>
		DAV svn
		SVNPath /home/svn/hippstr/
	&lt;/Location&gt;
&nbsp;
&lt;/VirtualHost&gt;</pre></div></div>


<p>Now we need to enable and restart apache.</p>


<div class="wp_syntax"><div class="code"><pre class="text"># cd /home/apache2
# a2ensite svn.yourdomain.com
# apache2ctl graceful</pre></div></div>


<p>If everything went well we should now be able to access are subversion server at <strong>svn.yourdomain.com</strong>. But we need a subversion client on our desktop machine to access the repository.</p>

<h3>Subversion clients</h3>

<p>My favourite gui subversion client is currently an os x app called <a href="http://versionsapp.com">Versions</a>. Which I&#8217;ll talk a little about below but if you&#8217;re not on os x I would recommend either <a href="http://tortoisesvn.tigris.org/">Tortoise SVN</a> on windows or the standard subversion command line client on any os. Available <a href="http://subversion.tigris.org/">here</a>. </p>

<p>You also need to learn how to use subversion by reading <a href="http://svnbook.red-bean.com/">the free subversion book</a>, there&#8217;s a small learning curve to understanding subversion and integrating it into your workflow but you&#8217;ll get used to it eventually!</p>

<p><a href='http://benmcredmond.com/blog/wp-content/uploads/2008/07/versions.png'><img src="http://benmcredmond.com/blog/wp-content/uploads/2008/07/versions.png" alt="" title="Versions" class="alignnone size-medium wp-image-22" /></a></p>

<p>To setup subversion in versions click &#8220;add new repository bookmark&#8221; and enter the following information. The user and password are what you set above when running the htpasswd commands. </p>

<p><a href='http://benmcredmond.com/blog/wp-content/uploads/2008/07/versions-1.png'><img src="http://benmcredmond.com/blog/wp-content/uploads/2008/07/versions-1.png" alt="" title="versions-1" class="alignnone size-full wp-image-23" /></a></p>

<p>There&#8217;s a small learning curve now to understanding subversion, as mentioned above and it&#8217;s all explained better than I could ever explain it in the subversion book mentioned above. Good luck! Ask any questions you still have in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2008/07/12/installing-and-configuring-subversion-on-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How I Manage Projects, Part 1</title>
		<link>http://benmcredmond.com/blog/2008/06/29/how-i-manage-projects/</link>
		<comments>http://benmcredmond.com/blog/2008/06/29/how-i-manage-projects/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 22:47:04 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[HiPPstr]]></category>

		<category><![CDATA[Project Management]]></category>

		<category><![CDATA[37signals]]></category>

		<category><![CDATA[basecamp]]></category>

		<category><![CDATA[projects]]></category>

		<category><![CDATA[subversion]]></category>

		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/?p=19</guid>
		<description><![CDATA[Managing projects is hard. I&#8217;ve come to learn this over the last year. [poor] Project management is also without a doubt one of the factors why Hippstr has been delayed for almost a year now. So I&#8217;m going to share with you a few of the tools, services and practices that have helped improve my [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Managing projects is hard.</strong> I&#8217;ve come to learn this over the last year. [poor] Project management is also without a doubt one of the factors why Hippstr has been delayed for almost a year now. So I&#8217;m going to share with you a few of the tools, services and practices that have helped improve my productivity and my team&#8217;s.</p>

<p>Those who are around me often will know I never shut up about how great <strong>basecamp</strong> is. And it really is.</p>

<blockquote>&#8220;Basecamp is the smarter, easier, more elegant way to collaborate on your internal and client projects.&#8221;<br/><cite>37signals</cite></blockquote>

<p>Basecamp is a really simple and easy-to-use project management system. With great to-do management, a forum like &#8220;messages&#8221; section and milestones (There&#8217;s more but this is the important sutff).
<span id="more-19"></span>
To-dos are with out a doubt the most useful aspect of Basecamp. They allow me to assign a task to any individual. When this task is complete it can be checked off. This will show up in the project summary page also (pictured below).</p>

<p><a href='http://benmcredmond.com/blog/wp-content/uploads/2008/06/basecamp-dashboard.png'><img src="http://benmcredmond.com/blog/wp-content/uploads/2008/06/basecamp-dashboard.png" alt="basecamp dashboard" title="The basecamp dashboard." width="580" height="349" class="aligncenter size-full wp-image-20" /></a></p>

<p>I use messages mostly for brainstorming. Where I post an idea which is blasted out to all my team via email (They can reply to the message by replying to the email). <strong>Why is this useful?</strong> When you&#8217;re working with a global team or even a local one, that are not all around at the same time, this is an indisposable tool. Reducing the amount of required meetings (which are a pain to schedule across timezones) and including all the team without the use of a messy mailing list solution.</p>

<blockquote>&#8220;Basecamp is the iPod of project collaboration.&#8221; <br/><cite>Joshua Peterson, CEO, 43things</cite></blockquote>

<p>Both messages and to-dos can all be associated with a particular milestone. For example at the moment all hippstr to-do&#8217;s are associated with the <em>private beta 1</em> milestone. Meaning we&#8217;re all working towards <strong>a set target, which is important.</strong> </p>

<p>In summary basecamp allows all the team to stay in touch, keep up to date with everything that&#8217;s happening and track progress (which is key and a moral booster on those bad days). I&#8217;ve used it with just myself to teams of 20 and it has always been a success. <strong>Basecamp can be described in one word, &#8220;phenomenal&#8221;</strong>. Sign up for free today at <a href="http://basecamphq.com">http://basecamphq.com</a>.</p>

<p><strong>Subversion</strong>. Subversion (aka. svn) is a version control system. <em>In english</em>, subversion keeps track of all the changes made to a code base (It can be used with anything though, word files, pictures, text files, etc. I just happen to use it for code). Allowing us to revert to a previous version when we break something, instead of wasting hours trying to find <strong>that</strong> thing we changed which broke everything. </p>

<p>Subversion also doubles up as a backup solution as it&#8217;s hosted on a remote server. Meaning if my house burns down all my work isn&#8217;t lost (although I think I have bigger problems if my house burns down). Subversion&#8217;s usefulness is greatly increased when working in teams as it manages conflicts. If two people change the same file, instead of one set of changes being lost, subversion presents you with a choice to merge the changes or choose which you would like to keep. </p>

<p>Previously I would&#8217;ve recommended trac in conjunction with subversion, but really it&#8217;s <strong>completely useless and difficult to use.</strong> I&#8217;m yet to find a bug tracking + svn interface system I like. Nevertheless subversion is an indispensable tool, get started today at <a href="http://subversion.tigris.org/">http://subversion.tigris.org/</a>. <em>Soon there will be an article on how to configure subversion.</em></p>

<p>Coming up in part 2. I will talk about campfire, getting real, practices and what I don&#8217;t use.</p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2008/06/29/how-i-manage-projects/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to correctly use i, em, b and strong</title>
		<link>http://benmcredmond.com/blog/2008/05/13/how-to-correctly-use-i-em-b-and-strong/</link>
		<comments>http://benmcredmond.com/blog/2008/05/13/how-to-correctly-use-i-em-b-and-strong/#comments</comments>
		<pubDate>Tue, 13 May 2008 11:31:53 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[Accessiblity]]></category>

		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/?p=16</guid>
		<description><![CDATA[There is a subtle difference between the &#60;b&#62;, &#60;strong&#62;, &#60;i&#62; and &#60;em&#62; html tags: they are commonly misused when styling text as bold or italic.

The &#60;b&#62; and &#60;i&#62; tags are presentation elements and are to be used where there is no &#8220;semantic&#8221; meaning, for example in a site footer. The &#60;strong&#62; and &#60;em&#62; tags are [...]]]></description>
			<content:encoded><![CDATA[<p>There is a <em>subtle</em> difference between the <code>&lt;b&gt;</code>, <code>&lt;strong&gt;</code>, <code>&lt;i&gt;</code> and <code>&lt;em&gt;</code> html tags: they are commonly misused when styling text as bold or italic.</p>

<p>The <code>&lt;b&gt;</code> and <code>&lt;i&gt;</code> tags are presentation elements and are to be used where there is no &#8220;semantic&#8221; meaning, for example in a site footer. The <code>&lt;strong&gt;</code> and <code>&lt;em&gt;</code> tags are used where emphasis is to be put on a word and there is semantic meaning, as above with &#8220;subtle&#8221;.</p>

<blockquote>Semantic: &#8220;relating to meaning in language or logic.&#8221;<br/><cite>New Oxford American Dictionary</cite></blockquote>

<p><strong>Why does this matter?</strong> The correct use of these tags help computers understand language. Currently,</p>

<blockquote>&#8220;&#8230; web pages are designed to be read by people, not machines.&#8221; <br/><cite><a href="http://en.wikipedia.org/wiki/Semantic_Web/">Wikipedia</a></cite></blockquote>

<p>By correctly using these tags we help computers understand in what context we meant something we wrote. The most important use of these tags is for accessibility, em and strong tags are read with emphasis on a screen reader while i and b are read as normal text; since they&#8217;re designed for presentation use only.</p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2008/05/13/how-to-correctly-use-i-em-b-and-strong/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is Social Networking a Viable Business Model?</title>
		<link>http://benmcredmond.com/blog/2008/04/11/is-social-networking-a-viable-business-model/</link>
		<comments>http://benmcredmond.com/blog/2008/04/11/is-social-networking-a-viable-business-model/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 22:53:05 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[HiPPstr]]></category>

		<category><![CDATA[Social Media]]></category>

		<category><![CDATA[Money]]></category>

		<category><![CDATA[New Media]]></category>

		<category><![CDATA[Social Networking]]></category>

		<category><![CDATA[VC]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/2008/04/11/is-social-networking-a-viable-business-model/</guid>
		<description><![CDATA[It&#8217;s been about a year and a half now since I originally conceived the idea of HiPPstr; a new social network, a unique social network. During that time, I&#8217;ve learnt a lot; more than you could imagine. Today I&#8217;m going to talk about social networking as a viable business model. People keep pressing the question [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been about a year and a half now since I originally conceived the idea of HiPPstr; a new social network, a unique social network. During that time, I&#8217;ve learnt a lot; more than you could imagine. Today I&#8217;m going to talk about social networking as a viable business model. People keep pressing the question to me, <em>how will you make money?</em></p>

<p>My answer is usually, I Don&#8217;t Know. The obvious path is targeted advertising, the current model that supports all the <em>big social networks</em>, Facebook, MySpace and Bebo. Although is it a viable business model? There are two problems at the moment, with social networking as a business.</p>

<ol>
<li>The founders are developers not business men.</li>
<li>Ads at best, break even.</li>
</ol>

<p>Most of you will argue the first point is good, which it is but not if you want to make money. Developers are interested in <strong>having a successful product</strong>; if you offered them 100m dollars, they would sure take it, but it&#8217;s not usually their goal. On the other hand we saw the disaster that was caused by the so called <em>Web 1.0</em> start-ups, founded by business men. I&#8217;ve said since the start that my goal with HiPPstr is not to become a billionaire but to advance technology.</p>

<p>So, if none of &#8220;us&#8221; want to make money, where does the problem lie? Social networking start-ups can only live of VC funding for so long. Bills need to be paid but more importantly so do employees. </p>

<p><em>How is this fixed</em>, the current problem is that the internet is still expensive. It&#8217;s expensive to get 1 million visitors at once and it&#8217;s expensive to handle that traffic. So the answer to this problem is not more advertising but better infrastructure, infrastructure that is paid for by the ISP not the content provider, infrastructure that allows for cheap bandwidth. </p>

<p>In this particular article I&#8217;ve used Social Networking as the example but this applies to the new internet: IPTV, Social Networks, File Sharing, Video Conferencing, VOIP, etc. </p>

<p>Is social networking a viable business model, not yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2008/04/11/is-social-networking-a-viable-business-model/feed/</wfw:commentRss>
		</item>
		<item>
		<title>OpenSocial, The future of the web?</title>
		<link>http://benmcredmond.com/blog/2007/11/13/opensocial-the-future-of-the-web/</link>
		<comments>http://benmcredmond.com/blog/2007/11/13/opensocial-the-future-of-the-web/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 22:27:17 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[HiPPstr]]></category>

		<category><![CDATA[opensocial]]></category>

		<category><![CDATA[web 3.0]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/?p=8</guid>
		<description><![CDATA[Last week Google released it&#8217;s new platform OpenSocial, this platform allows a developer to write an application for MySpace for example, or Orkut (Google&#8217;s unknown social network, it&#8217;s popular in Brazil&#8230;).

I&#8217;m going to talk about why I like opensocial from two standpoints, the developer and the end-user.  

OpenSocial from a developer&#8217;s standpoint is a [...]]]></description>
			<content:encoded><![CDATA[<p>Last week Google released it&#8217;s new platform OpenSocial, this platform allows a developer to write an application for MySpace for example, or Orkut (Google&#8217;s unknown social network, it&#8217;s popular in Brazil&#8230;).</p>

<p>I&#8217;m going to talk about why I like opensocial from two standpoints, the developer and the end-user.  </p>

<p>OpenSocial from a developer&#8217;s standpoint is a godsend, from both sides, on the HiPPstr side it allows me to really easily have hundreds of great apps of which users can put on their profile, on the other side it allows great traction I can instantly have an application deployed all over the web, before you had to write your app for Facebook, not too hard, what about if you write a Mac OS X app, porting that too windows isn&#8217;t easy.  </p>

<p>I think this is the future of computing, a thin client that accesses, could be <strong>Web 3.0</strong> (This idea is brought up a lot by the infamous Molly Wood); a diverse and open platform where I can write an application and it will work universally any where.  </p>

<p>From a user standpoint OpenSocial is just as exciting, lets look forward a few years, when OpenSocial is a developed and mature platform, imagine the things OpenSocial will be able to do, essentially this is the death of Facebook, which in my opinion will result in huge fragmentation of the Social Networking space. There will be lots of small networks interconnected by an open platform, OpenSocial. Greatly improving the user experience, when it no longer matters if half your friends are on Bebo and half on MySpace. You might say, &#8220;You&#8217;re an idiot, OpenSocial is for widgets not interconnecting social networks&#8221;, true that&#8217;s the use at the moment, it has been talked about that in the future OpenSocial, will provide methods for sharing data between different networks.  </p>

<p>This seems to be a common Google strategy (mentioned on TWiT), if you can&#8217;t buy a market fragment it, or at least try because all of above is irrelevant unless this catches on and at the moment with partners such as Bebo and MySpace I am not doubting it will be popular.</p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2007/11/13/opensocial-the-future-of-the-web/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating Ajax Comments with CodeIginiter and JQuery</title>
		<link>http://benmcredmond.com/blog/2007/10/20/creating-ajax-comments-with-codeiginiter-and-jquery/</link>
		<comments>http://benmcredmond.com/blog/2007/10/20/creating-ajax-comments-with-codeiginiter-and-jquery/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 18:56:39 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Design]]></category>

		<category><![CDATA[HiPPstr]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[codeigniter]]></category>

		<category><![CDATA[comments]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/?p=6</guid>
		<description><![CDATA[While working on the HiPPstr comments, I didn&#8217;t understand why other sites required you to go to another page to submit a comment, maybe to prevent over submission, Well I went ahead with it anyway.

I settled on JQuery for my Javascript Framework, it seemed to do a lot out of the box, with lots of [...]]]></description>
			<content:encoded><![CDATA[<p>While working on the HiPPstr comments, I didn&#8217;t understand why other sites required you to go to another page to submit a comment, maybe to prevent over submission, Well I went ahead with it anyway.</p>

<p>I settled on <a href="http://jquery.com/">JQuery</a> for my Javascript Framework, it seemed to do a lot out of the box, with lots of plugins and a big community, also the base distribution was a lot smaller than other tools such as <a href="http://mootools.net">MooTools</a>.</p>

<p>I had never done any Ajax Before so this was a little bit of an <em>adventure</em>. If you don&#8217;t know ajax is really just a buzz word it stands for Asynchronous Javascript and XML, it&#8217;s a very commonly used technology in web 2.0 web applications, which allows actions and http requests to be done without requiring the page to be reloaded. This gives web applications more of a desktop feel.</p>

<p><span id="more-6"></span></p>

<p>I started by downloading and installing the base jquery library to the static folder I created for all static images, stylesheets and javascripts. Next I put it in my <em>header.php</em> view which generates the headers for all my pages.</p>


<div class="wp_syntax"><div class="code"><pre>&lt;script language=&quot;javascript&quot; src=&quot;&lt;?=base_url()?&gt;static/js/jquery.js&quot; &gt;&lt;/script&gt;</pre></div></div>


<p>I decided to load it on every page as I just assumed I&#8217;d be using a lot of javascript, I also put in another few lines to dynamically load any other scripts or plugins I might need for jquery.</p>


<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">isset</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$scripts</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$scripts</span> <span style="color: #b1b100;">as</span> <span style="color: #ff0000">$script</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;script language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> src<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?=base_url()?&gt;static/js/&lt;?=$script?&gt;&quot;</span><span style="color: #66cc66;">&gt;&lt;/</span>script<span style="color: #66cc66;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<p>To add another script I simply set <strong>$data[&#8217;scripts&#8217;]= array(&#8221;script1.js&#8221;, &#8220;script2.js&#8221;);</strong> in my controller. This was the simple bit. Next I just wrote a standard method to insert the comment into the database taking the variables from a <em>posted</em> form and inserting them into the database using a model (see <a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC on Wikpedia</a>). </p>

<p>Now I had to write the AJAX bit. Since I&#8217;d never used Javascript/AJAX before, I looked around the very good <a href="http://docs.jquery.com">JQuery Docs</a> and started to cobble together something that would work. It turns out it was very simple, AJAX always looks scary from someone looking from the outside but when you actually get into it it&#8217;s not hard.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="javascript">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;.addcomment&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// Hide the comment form</span>
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#message&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;	<span style="color: #009900; font-style: italic;">// Hide The Message Div</span>
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;.actions a.show&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <span style="color: #009900; font-style: italic;">// Show the comment form</span>
		$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parents</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">prev</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;.addcomment&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">slideToggle</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> options = <span style="color: #66cc66;">&#123;</span> 
		beforeSubmit: validate,
	    target: <span style="color: #3366CC;">'#comments'</span>,
		success: formSuccess
    <span style="color: #66cc66;">&#125;</span>; 
&nbsp;
   	<span style="color: #009900; font-style: italic;">// bind form using 'ajaxForm' </span>
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#newcomment'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ajaxForm</span><span style="color: #66cc66;">&#40;</span>options<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.comment-links a'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> link = $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #66cc66;">&#41;</span>;
		$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#comments'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">empty</span>;
		$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#comments'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span>link<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>


<p>Above is the basic javascript that was required, the first line hides the comment form which is accessible via an &#8220;add a comment&#8221; link which is bound on the 3rd lines, so when clicked it shows the <strong>.addcomment</strong> div. Then I bind the form using the <a href="http://www.malsup.com/jquery/form/">JQuery Form Plugin&#8217;s</a> ajaxForm function to bind the form, I pass to it the options var which contains three arguments, firstly it runs the validate function (not shown above), it sets the target, whatever the http post request returns will be put into the #comments div, in this case when a comment is posted it returns a new list of comments, so if the user is on the page for five minutes, if they post a comment, a comment posted 4 minutes ago will also show, this <em>could</em> be problematical, I&#8217;ll just have to see. The formSuccess function (also not shown), prepares #message to display a success message, as well as fades out the comment form.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> validate<span style="color: #66cc66;">&#40;</span>formData, jqForm, options<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i=<span style="color: #CC0000;">0</span>; i <span style="color: #66cc66;">&lt;</span> formData.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
    	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>formData<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
            $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;You can't submit a blank comment... sorry&quot;</span><span style="color: #66cc66;">&#41;</span>;
			$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'success'</span><span style="color: #66cc66;">&#41;</span>;
		    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'error'</span><span style="color: #66cc66;">&#41;</span>;
			$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#message&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">2000</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>; 
        <span style="color: #66cc66;">&#125;</span> 
    <span style="color: #66cc66;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> formSuccess<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">empty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'error'</span><span style="color: #66cc66;">&#41;</span>;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'success'</span><span style="color: #66cc66;">&#41;</span>;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #66cc66;">&#41;</span>;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;It worked... you can see your comment below, YAY&quot;</span><span style="color: #66cc66;">&#41;</span>;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.addcomment'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeOut</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#message&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">oneTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">8000</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fadeOut</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">4000</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<p>Above are the validate and success functions.
Well I hope that was useful, now you know how to do ajax comments.</p>

<p><strong>Note Ajax comments are not enabled on this blog, this is just a tutorial.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2007/10/20/creating-ajax-comments-with-codeiginiter-and-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Who, What, Why?</title>
		<link>http://benmcredmond.com/blog/2007/10/19/who-what-why/</link>
		<comments>http://benmcredmond.com/blog/2007/10/19/who-what-why/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 19:49:51 +0000</pubDate>
		<dc:creator>Ben McRedmond</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://benmcredmond.com/blog/?p=3</guid>
		<description><![CDATA[Hi, Hopefully this works, I&#8217;m Ben and welcome to my new blog. I&#8217;m the project leader of HiPPstr, a new social network. Soon I should start posting regularly, about coding, design and other random tidbits of my life&#8230; Ben 
]]></description>
			<content:encoded><![CDATA[<p>Hi, Hopefully this works, I&#8217;m Ben and welcome to my new blog. I&#8217;m the project leader of HiPPstr, a new social network. Soon I should start posting regularly, about coding, design and other random tidbits of my life&#8230; Ben </p>
]]></content:encoded>
			<wfw:commentRss>http://benmcredmond.com/blog/2007/10/19/who-what-why/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
