Snogs

If there's ever a quintessential application to build when you first dive into a framework, it's the blog. That's what I did with Snook.ca when I first got into CakePHP.

Then for a recent client project, also built using CakePHP, I was asked to integrate a blog. I took this opportunity to take a chunk of the code I used to build my own site and break it out into its own blog plugin: Snogs.

Snogs is Snook's Blogs and is a simple multi-blog engine for CakePHP. It's hosted over at CakeForge where you can download the application, access the Subversion repository or supply feedback.

I'm releasing this as open source. If you're interested in joining the project and enhancing Snogs then by all means let me know. Also of note, I've included the spam component I talked about previously.

While my own site doesn't run off of it, it will. I'm intending to rebuild much of Snook.ca using Snogs to see how well everything integrates and it will no doubt inspire me to add some features I find useful.

(And let me know if you're getting tired of all these Sn- prefixed projects. I think it's fun but there's always too much of a good thing.)

Published June 09, 2008
Categorized as CakePHP
Short URL: https://snook.ca/s/895

Conversation

50 Comments · RSS feed
Dean said on June 09, 2008

Sounds interesting, I've been interested in trying out CakePHP for a while, but haven't managed to find a suitable project (or the time), if I ever get around to using Cake, I'll be sure to try out Snog. I assume it takes care of some of the back-end admin stuff behind a 'blog' as well?

And for the record I quite like the Sn- prefixed names, no different to (but much more creative than) Apple sticking 'i' infront of everything, or Automattic adding -press to everything.

Adriaan said on June 09, 2008

I always liked the Sn names, it's all about building a name for yourself isn't it, and I like it.

I have used the Zend framework in the past, and am going to enjoy going through your code, thanks for sharing it.

Andrew said on June 09, 2008

Just in time, I'm currently building my site/blog with Cake. Maybe I can find some interesting code in Snog.

Nils R said on June 10, 2008

I work with cake since a 3/4 year. And since i didnt have the time to build up my own blog maybe i have the time to contribute to yours ;)

btw: i like snog.

Steve Oliveira said on June 10, 2008

Awesome! Definitely going to try it out.

Voyagerfan5761 said on June 10, 2008

I like the Sn- prefix. It's much more interesting (and more grammatically correct ;-) than iBlogs, don't you think (taking Dean's Apple comment)?

Lucian Lature said on June 10, 2008

I'm going to try this out as soon as possibile, I'm very interested of this project.
Thanks for release!

Sumesh said on June 10, 2008

I love 'Sn'. Perhaps the most attractive of them is Snitter, which feels and sounds like Twitter :)

But I guess too many will be bad, so maybe you should start naming them Jonalog/Jonitter or something (just kidding).

Stewart Curry said on June 10, 2008

You know that snogs and snogging means 'making out' in Ireland and the UK?

Richard@Home said on June 10, 2008

Just downloaded it to give it a whirl.

First thing I noticed: You've used a mixture of php short tags (<? ?>) and long tags (<?php ?>). I'm presuming the long tags are from baked code.

This is going to break on a fair few installs (mine included) :-(

Tarique Sani said on June 10, 2008

#1 The zip file has some .svn files - no big deal
#2 The default class for Author is set to be User would be better if it was Author - things would work more out of the box
#3 Some kind of namespacing of tables is needed - comments, categories are very commonly used models - robs the plugin of some plugable-ness.
#4 Gave an SQL error on line 64 of posts_controller with RC1 - the syntax has changed.
#5 +1 to what Richard said

That said - there are a lot of code ideas which I am going to pick up from the plugin - thanks a lot for sharing

Steve Killen said on June 10, 2008

I love the 'sn' prefixes, great marketing tool and will never get old I think. Wish I could do that with my name but that would probably involve putting 'Kill' in front of everything. Guess it doesn't always help having a distinctive name. :)

Pete B said on June 10, 2008

Sorry, that name is hilarious if you come from the UK - http://www.dearcupid.org/question/how-to-snog.html

snowdog said on June 10, 2008

Great idea - I have to try it and learn something new to use in my own CakePHP blog/cms project (GreenTea also hosted on CakeForge).

I already used there two of your great ideas - elemental and spam blocker, so expect a lot more from snog...

Jonathan Snook said on June 10, 2008

@Richard/Tarique: Thanks for the feedback. The short tags are a habit of mine and I knew that'd be one of the first things people would point out. I also haven't used "var $name" which is necessary for PHP4 support (or at least it was). Namespacing the table and the Model names are equal issues, imo. I wish PHP had package support like Java to help prevent namespacing issues.

@Tarique: lots of helpful advice. awesome!

I'm always happy to hear that people are getting ideas out of how the code is put together. To be honest, I always feel like I'm not doing it the "CakePHP way". Of course, in the end, as long as it works. :)

CSdread said on June 10, 2008

you also need to do some schema work. The SQL file is good but if you generated a cakephp scheme and some unit testing then this would be rockin! Great job Jonathan.

J. Bradford Dillon said on June 10, 2008

Sir, I won't be happy until all of my daily applications are replaced by their Snooky counterparts.

Seriously though, I look forward to giving Snogs a try. You got me into CakePHP in the beginning, and I've enjoyed using it. Can't wait to see this project grow.

Jonathan Snook said on June 10, 2008

@CSdread: indeed. I didn't get into unit testing until after I put the blog stuff together but even then, it's a habit I still need to get into.

Richard@Home said on June 10, 2008

Reading back, my comments sounded more negative than I intended. You've done a great thing and I don't want to detract from that! :-)

Nik Chankov said on June 10, 2008

Building a blog is very easy /ok, for people familiar with the framework syntax and functions/, but unfortunately it cannot compete with big platforms such as Wordpress. So I think using as main blog system is not appropriate.

Anyway, good to know there is such plug-in for Cake. Who knows if I build a system and somebody ask me for blog plug-in I would know where to find it ;)

Cheers

Ryan Oldham said on June 10, 2008

Is this plugin released under the MIT License like cakephp?

Jonathan Snook said on June 10, 2008

@Ryan: I figured the page would show the license I chose but it doesn't seem to be. In any case, yes, it's the same license as CakePHP.

Nate Klaiber said on June 10, 2008

Snook, aside from what others have mentioned above (namespacing would definitely be nice), was there a a reason that a post can only be attached to one category? Your post table has a category_id, what if a user wanted to attach a post to more than one category?

I like the work you put into the spam prevention, those extra steps make it very nice.

Other than that...i think it's awesome that you released this as open source for others to use. And, obviously, the sn prefix fits perfectly, it's part of your brand, so it must stay, always.

Jonathan Snook said on June 10, 2008

@nate: I debated whether or not to do a HABTM relationship, along with possibly adding separate support for tags. I decided to do just a simple hasMany with the intention of adding tags down the road. It came down mostly to my own needs first and I don't use multiple tags (despite the fact that my own blog actually uses a HABTM relationship).

pablasso said on June 10, 2008

I like the 'Sn' branding, it doesn't gets old :-)

Dardo Sordi said on June 10, 2008

Hi Jonathan,

I've started to play with it and I like the idea, just wanted to contribute and I'm implementing Tarique's suggestions:

#2, #3, #4 and #5 are done.

I'm working on switching the SQL to schemas.

Also did some improvements:
- autogenerate slugs if none provided
- support for upercase letters in the slug (routes)

I can send you the patches (I'm working it with git) if you are interested.

- Regards.

Tarique Sani said on June 10, 2008

@Dardo Sordi - thanks you saved me some work today - I was going to fix those things but thought let me whine a bit first ;)

Some more improvements on my list are
#1 RSS feed for comments (all comments and one single post)
#2 Admin route protection if Auth component is being used

Jonathan Snook said on June 13, 2008

@Dardo: thanks a bunch for putting that together. If you could send me the patches, that'd be fantastic!

@Tarique: RSS feeds for comments on an individual post are already available (maybe I need to recheck that). Admin routing protection is a good idea.

klevo said on June 13, 2008

I've build my own blog engine or CMS on Cake too. It's open source and available at wf.klevo.sk. Check it out if interested.

peter said on June 23, 2008

Can you explain about status and junk_score in comments field?

Jonathan Snook said on June 23, 2008

peter: the status indicates whether the comment is approved (2), in moderation (1), or junked (0). The junk_score is the result of running the spam component on the comment, which gives you a score. It's a way of tracking how well certain comments perform and allows you to tweak the metrics as need be.

peter said on June 23, 2008

Thanks snook, its help me more understand about snogs so if I want to show approved comments related to one item of post I have to define where clause Comment.status=2 is that right?

Jonathan Snook said on June 23, 2008

peter: Yes, that's correct.

peter said on June 23, 2008

Thankyou verymuch, I'm going to learn CakePHP with your code;)

Steve Brice said on June 24, 2008

I have been using elemental and spam blocker, I am going to research more about snogs sound very promising. Thanks for the info !

reader said on June 26, 2008

nice point, thanks for the idea :)

vuego said on June 27, 2008

Hej Jonathan. Thanks for cool plugin. I've used it in my site where I needed exactly something like that. It short time (has it been only 20 days?) it grew, I implemented a few features, some are in progress. If you want to use any of them in snogs you can find it here.
Full credits to you. Thanks again.

Nasko said on June 29, 2008

@Jonathan: thanks for sharing your work with us!

Guys, how are you accessing the SVN? I've tried the URL, provided at CakeForge (https://svn.cakeforge.org/svn/snogs) passing my CakeForge usernane but I keep getting this error:

svn: PROPFIND request failed on '/svn/snogs'
svn: PROPFIND of '/svn/snogs': Server certificate verification failed: certificate has expired, certificate issued for a different hostname (https://svn.cakeforge.org)
error (1)

Aaron said on July 07, 2008

Is there a demo of this somewhere? Would like to see it in action. (Or is this the demo :))

cheers,

Aaron

Baz L said on July 14, 2008

Haven't given it a thorough look over yet, but I'm getting tons of errors with RC2, just FYI.

I'll look into it more, when I get home.

Jonathan Snook said on July 23, 2008

@Aaron: some of the code is directly from here but a bunch of it was new. However, my plan is to switch over to it when I redo the backend to my site.

@Baz: I have some patches to integrate but I'll look into things, especially as things get closer to a full release of CakePHP 1.2

Brett Wilton said on August 04, 2008

Thanks for allowing others to see your blog coding solution. Found your spam solution great, had implemented a kcaptcha solution but wanted to avoid the extra spam code data entry by the user, mainly as I find it a pain personally on other sites.

Robert said on August 18, 2008

Thanks for great code, I'm also looking for Elemental helper.

I have few questions. I want to replace categories with some tagging system. Do You recommend something or should I write something anew?

Do You plan to add some elements like "last blog posts" or "last commnets for all blogs"?

Thanks again for Your work, its great for learning cake.

Nasko said on August 20, 2008

Ok, I've managed to checkout finally. Apparently it was the GUI SVN client I'm using (eSvn) having issues handling the SSL auth.

@Jonathan: Is what's in the repository (rev. 2) the latest codebase? Any chance that some of the improvements mentioned by commenters in this thread might make their way through to the repo? I'm planning on migrating a wordpress blog to a CakePHP driven one and was hoping to use your code. But I guess I should wait for the CakePHP 1.2 final release before all patches are integrated. Thanks indeed!

Clow said on September 05, 2008

Did you know that 'snog' is slang for 'To kiss lengthily, passionately or lustfully' here in the uk?

Jonathan Snook said on September 05, 2008

Clow: that I did. Which is half the reason I went with it. :)

kiran aghor said on November 10, 2008

To use FCK I placed 'Fck' component in posts controller. But it gives error - 'Error: The helper file app\views\helpers\fck.php can not be found or does not exist.' Wht to do?

Janet Keller said on November 16, 2008

Jonathan, I don't post on your blog but have been reading it for a while, this code looks to be very promising. When do you find the time for these projects I need some of your organization skills !

Justin said on December 07, 2008

What, would you say, is the benefit of building your own blog as opposed to using something like Wordpress? I would like to build my own blog in Ruby on Rails, but I don't know if it's worth the effort. I just learned RoR over the summer and love it. I have already used it on a project for one client. It was an easy switch from CakePHP (which I learned 2 years ago from your suggestion), but I feel it's much cleaner and easier to program in.

Jonathan Snook said on December 07, 2008

It all depends on what your needs are. The basic requirements of a blog are posts and comments. Maybe categories and/or tags. You get a system with only what you need. If you want any special fields, you can add them. Managing an application like that is simple.

But then you think about what something like WordPress can do... multiple authors, trackbacks and pingbacks, templating, plugins, etc. If you're trying to replicate all that, then maybe you should just use WordPress. You have to decide what that balance is. For me, going custom made the most sense (and that was after years of using Movable Type).

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.