Tao of the MachineProgramming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind. |
Front page Last 10 archives 2002-07-27 2002-08-03 Category archives bettas books CCGs Charm esoterica Firedrop games general ideas internet Kaa linkstuffs Lisp manga music Mygale Nederland nostalgia programming Python SGI switch Wax Zoids :: Search All posts ...by category ...by date ![]() :: About me :: Oasis Digital :: Resume :: GeoURL :: RSS :: Atom ![]() ![]() |
Macros!Kaa-macros, baby. Kaa-macros.As seen on diveintomark... I present a stunning example of "me, too" software development. <wink> Inspired by the aforementioned post, I decided to hack up a simple macro system for Kaa. If MT can do it, so can we. Kaa-macros, baby. Kaa-macros. ;-) As a test, I defined an acronym or two, which should now be included automatically. GPL is one such acronym. Position your mouse over it to see the effect of the <acronym> tag. (It works on IE5.5, at least.) You can now define a file htmlmacros.txt with lines like this: ("GPL", "acronym", "title", "GNU General Public License") ("MT", "acronym", "title", "Movable Type")Those are Python tuples, and will be treated as such upon loading. See Mark Pilgrim's post for an explanation about how this works... it's basically the same, the 4-tuple consists of (literal, tag, attribute, value). After rendering all the HTML, Kaa loops over its macro list, replacing the literals with something like Of course, Python itself can be used for this as well. Just define a bunch of Python strings (or other values, but strings seem most appropriate), then use them like this: <% foo %>to expand them to the value of variable foo. This is useful for often-used URLs, strings, or anything else that you don't want to type over and over again. Trivial to add, too. Maybe in the next release... In visible silenceInteresting new features were added to Kaa today. First of all, I coded a basis for entry attributes. Right now it's still rudimentary; showing an entry's attributes just prints a dictionary to stdout, and the only attribute that can be set is visible.
The effects are kind of obvious... a message with the visible attribute set to 0 (or any value that evaluates as false, for that matter) becomes "invisible", i.e. it doesn't show up in HTML anymore. Not in archives, and not on the front page. A nontrivial overhaul of some crucial code was necessary to make this work smoothly. More attributes will be added later. This feature will also pave the way for categories and such... New upload mechanism implementedThe new version is 0.6. It's not available for download yet... I have to test for bugs and stuff. But, it basically does what I described in the earlier message. No new files are generated if it's not necessary. And files older than the last publish_date are not uploaded.Of course, you can disable these features by setting the appropriate options in the bloginfo dialog. time.struct_timeJust learned something new... in Python 2.2:>>> import time >>> time.struct_time <type 'time.struct_time'> >>> t = time.localtime(time.time()) >>> t (2002, 8, 13, 23, 11, 54, 1, 225, 1) >>> type(t) <type 'time.struct_time'>In Python 2.1, though: >>> import time >>> time.struct_time Traceback (most recent call last): File "<pyshell#1>", line 1, in ? time.struct_time AttributeError: 'time' module has no attribute 'struct_time' >>> t = time.localtime(time.time()) >>> t (2002, 8, 13, 23, 13, 3, 1, 225, 1) >>> type(t) <type 'tuple'>Hmm. I didn't know this changed. I was under the impression that this was still just a 9-tuple. I wonder why it changed? No doubt the answer can be found in python-dev somewhere... An interesting problem...I was going to restrict the number of uploaded files by using the following method:
Of course, if you change the template, or the Kaa version changes, etc, then you're out of luck, because all pages will be different. But that should not happen too often. In practice, I have code in my template that looks like <# import date print date.Date().isodate() + "." #>The posting date is inserted, and of course this will be different every time something is posted. In other words, new files are generated all the time, cancelling out the possible benefits of the slick upload trick. I guess the "solution" is, that I remove that date. Whoever wants something like this, can use it, but will not be able to have the upload benefit. State of the KaaLet's see how much Kaa can do compared to its peers... based on the comparison table from BlogComp. (I better use a smaller font, because this may be a lot of text... :-)
1. multiple blogs? Yes. You can make as many blogs as you like. There's still a lot of work to do, but we're getting there... UploadingCurrently, everything in the HTML directory is uploaded. This feature is very handy; you simply throw in a file, and it's uploaded the next time you publish. It also has a drawback though: when your blog grows bigger, it becomes cumbersome and slow to upload all files again and again whenever you write a new entry.
So, what to do about that? It would be nice if only files that have changed were uploaded. Files that didn't change since "last time" should be ignored. If a "post" command writes all the new files it generates, then they will all be uploaded. So, it needs to be more selective... if the generated HTML is exactly the same as an existing local file, then the new file should not be written. Let's see if I can make this work...
[9:54 PM] Obviously it doesn't work. The dates on the server indicate when the file was written; they're not a copy of the dates of the local files. I should have known that. Later, there should be another publishing option, something that says, "make sure the files in the HTML directory are all uploaded, and any files on the server that are not present locally are removed". This should be useful for clearing out obsolete files and such. 0.5.2Kaa 0.5.2 is released under the GPL. Download it here (zip file).I said it before and I'll say it again: At this stage, Kaa is not quite suitable for serious weblogging. Although it's getting there. Version 0.5.2 has the following features:
En dan dit...I also souped by my template today... I think it looks better, but YMMV...Also added a list of archives. There's a nifty little method that generates this list, blog.archive_list(), but such a list can of course be generated by hand too. Also added some new fields in the bloginfo options. You can now set the number of entries for the front page, and set a default author. As it is, Kaa 0.5.2 (the current version, obviously) is already an acceptable blogging tool, methinks. If you're willing to settle for something that doesn't support multiple users or categories (yet), then it may be suitable for you, too. However, I still consider it pre-alpha (who knows what is going to change in the near future), so use with caution. I don't think the database is going to change anymore, but you never know... AnchorsIn many blogs, people can link to messages directly. Kaa now supports this as well. Of course, it's all a matter of putting the right things in the template.First, create a HTML anchor. For any message, Kaa expects the anchor to be "e" + the id of the message. Like this: <a name="e<% entry.blogentry_id %>"></a>Then, use entry.anchor to make a clickable link to the anchor: <a href="<% entry.anchor %>">#</a>That's all. For an entry in the archives, the .anchor attribute points to itself. For an entry in the first page, it points to the archive (if any), otherwise it points to itself. The latter is not very useful since the link may disappear with the message. Any external links to that message will then become invalid. All this isn't thoroughly tested yet... I don't know exactly if it all works with other archive methods (like by ID), or no archives. -- Generated by Firedrop2. |