On Friday 07 February 2003 8:42 am, Dave Thomas wrote: > Wesley J Landaker wrote: > >>pragprog.com/pragdave is Ruby powered (thinking about it, it should > >>probably say that). I wanted something that would accept multiple > >>input formats, and that would work from both normal files and from > >>CVS repositories. > > > > Any chance that you'd make the code availible? It would be > > interesting to see how you've implemented things. =) > > Yup: see > > http://pragprog.com/pragdave/Tech/Blog/SourceCode.rdoc,v Very cool. =) I actually am most interested in your CVS stuff. I'm currently working a little ruby weblog myself; most of the base stuff of what I have implemented is similar to blogtari and your rublog (it can handle plugable filters, templates, heirarchies, etc) but I'm adding a few other things I like to it: o CVS support - not only can it read from CVS, it will allow the display of more than one version while preserving chronological flow. For example, if I make a new entry on Monday, a new entry Tuesday, and a new entry Wednesday, chronologically it'll look something like this: Wednesday's Entry [link] [CVS: 1.1] Tuesday Entry [link] [CVS: 1.1] Monday's Entry [link] [CVS: 1.1] But then I *update* the entry I made Monday on Friday, you'll see something like this when looking at the weblog chronologically: Monday's Entry (Updated Friday) [link] [CVS: 1.2] Wednesday's Entry [link] [CVS: 1.1] Tuesday Entry [link] [CVS: 1.1] Monday's Entry (Updated Friday) [link] [CVS: 1.2 1.1] The key here being that things stay put chronologically and get linked in whereever they are updated, but it's always possible to see the revision history (unless the admin, for some reason, wants to make a version unavailable--but that's not that much different than how you just remove a blog entry permenantly; usually some direct repository surgery is quick enough ;) o Stupidly easy template support - there are a lot of Ruby template engines, and I admit I'm impressed by some of them (narf, in particular, seems very well made). However, for my little weblog, I didn't want a big template engine; instead I just let my templates have ruby code in them. For instance, my template for entries looks something like (Dave may notice that this block looks *very* familiar -- for testing purposes only ;) <table class="entry" width="80%"> <tr class="entrytitlebar"> <td rowspan="2" class="entrytitle">#{WebLog.entry.title}</td> <td class="entrytitledate">#{WebLog.entry.date}</td> </tr> <tr class="entrytitlebar"> <td class="entrytitlelink"> [ <a href="#{WebLog.url + WebLog.entry.link}"> #{WebLog.entry.link} </a> ] </td> </tr> <tr class="entrytext"> <td colspan="2" class="entrytext"> #{WebLog.entry.text} </td> </tr> </table> I call this template with: grab_entries(".",'blog').each { |WebLog.entry| File.open(template) { |file| puts file.read.gsub(/\#\{(.*)\}/) { |cmd| eval $1 } } } Which has the not-annoying-to-me-but-might-be-to-other-people property of not being able to handle more than one #{} on a line, and forcing the entire #{} to be on a line. The magic "WebLog" object just looks something like: class WebLog class << self attr_accessor :name, :url, :entry end end Which, of course, is just a class pretending to be a singleton. ;) Anyway, blogtari looks nice, and I'm going to take a look at rublog after I stop yapping. I'm of course curious how the CVS stuff is done (I was planning on use the CVS command itself on a checked out tree instead of the repository itself) and what kind of input filters you're using right now (much harder than writing the weblog code is deciding how you want the input to be formatted ;) Well, when I get this little piece of code cleaned up a little, I'll post it here. I'm mostly writing it for the fun of it and to use personally, but hopefully any "cool" things I think to add to it may inspire others--I've certainly been pilfering inspiration from other rubists along the way. ;) -- Wesley J. Landaker - wjl / icecavern.net OpenPGP FP: C99E DF40 54F6 B625 FD48 B509 A3DE 8D79 541F F830