Modeling a "Customized" Blog

101 views
Skip to first unread message

ne...@vidyasource.com

unread,
Jun 14, 2013, 11:56:52 PM6/14/13
to mezzani...@googlegroups.com
I am building a website that will have a blog (working pretty much the way Mezzanine has it out of the box), but it will also have "tutorials." The more I think about it, the more I realize a tutorial is basically a glorified blog with a publish date and keywords and a title and all that--but also with URL's representing a YouTube video location and a GitHub code location. 

Naturally, I would like to steal...err, reuse...all the existing blog infrastructure for the tutorials while adding those extra amenities. 

What's the easiest way to do that? Can I create a model that inherits from Blog? How would I customize the views and URLconf? Or should I do something different?

Any insight is appreciated.

Thanks.

Ken Bolton

unread,
Jun 15, 2013, 12:46:32 AM6/15/13
to mezzanine-users
Hi Neil,

Is a tutorial really like a BlogPost? For example, Khan Academy organizes their videos along subject sorted from introductory through advanced. The Coursera class I have taken is structured chronologically in weekly segments, but the order of a week's video set is not based on publication date, afaict.

One approach would be to use the BlogCategory model to group your tutorials, your "blog", and any other blog-like content. Inject the fields[0] you need into the BlogPost model. Create custom url patterns, views, and templates that return the categorized posts as needed.

Another approach is to build your own Mezzanine app. Do not subclass BlogPost! Instead, inherit from the same parents as BlogPost[1]. Copy as much of that BlogPost code as you need to your Tutorial model. Consider cloning BlogCategory to TutorialCategory or Course, depending on how you are structuring your system. Add your fields, meta, methods, etc., to your models.

The former is fairly mezzanine-y, and could be low-hanging fruit. I think I would take the latter if the spec could ever change (and we know it do).
hth,
ken



--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

ne...@vidyasource.com

unread,
Jun 15, 2013, 1:28:59 AM6/15/13
to mezzani...@googlegroups.com
Hey Ken,

You're right. A tutorial is really like a BlogPost. However, it isn't, at least as currently envisioned, as sophisticated as the Khan Academy and Coursera courses you mentioned. Funny you should mention those though since I do intend to have courses in the future. But that is going beyond the scope of this question. I'll cross that bridge eventually when I have a better feel for what I want out of courses.

For now, the tutorials are going to be short videos (like 5 minutes max) with some text and a link to GitHub. 

I think I will go with the second option you mentioned. As you say, it is harder, but it is also more loosely coupled. Since time isn't a huge factor, I think it makes the most sense to go that route.

Thanks for your help.

Eduardo Rivas

unread,
Jun 15, 2013, 12:29:14 PM6/15/13
to mezzani...@googlegroups.com
Hello Neil.
I've done something very similar, creating an app where there are multiple "blogs" (instead of only one) and each blog post has an associated YouTube url, among other things. I can confirm that writting your app copying (not extending) Mezzanine's blog seems like the best way to go. This is not only in the model layer, but also in the views and templates.

ne...@vidyasource.com

unread,
Jun 15, 2013, 1:23:19 PM6/15/13
to mezzani...@googlegroups.com
Thanks for the confirmation, Eduardo.

There are some folders that I am not sure need to be copied: locale, management, and migrations. I'm guessing, for no particular reason, that by being made available once they are available for the entire site. Is this correct? Or do I need to include all these files as well in my copy?

I simply would like to keep the codebase as lean as possible.

Thanks again.

Josh Cartmell

unread,
Jun 16, 2013, 11:59:23 PM6/16/13
to mezzani...@googlegroups.com
Hey Neil one other idea/thought I just had was to use Mezzanine field injection to add the required fields to BlogPost and then always put them in a specific category and style "BlogPosts" differently depending on whether or not the additional fields are null or not.

It sounds like you already have a good direction to move in but I figured I'd mention that idea I just had.


--

ne...@vidyasource.com

unread,
Jun 17, 2013, 12:16:13 AM6/17/13
to mezzani...@googlegroups.com
Hey Josh,

That's actually a pretty clever idea. The more I think about it though, I feel like a Tutorial and a BlogPost should be different models. While there is certainly a strong coincidence between them, there are key differences in behavior. For example, an RSS feed for a Tutorial, as I envision it, wouldn't be appropriate. For that reason, I'm wary of tight coupling between the two since I don't know how both will evolve over time. 

Still, it is nice to have an alternative approach in my back pocket in case Plan A blows up in my face. Thanks for that.

Josh Cartmell

unread,
Jun 17, 2013, 12:31:37 PM6/17/13
to mezzani...@googlegroups.com
Definitely, Plan A definitely sounds like it will work better for you so I hope it doesn't blow up in your face!
Reply all
Reply to author
Forward
0 new messages