`
Tech NotesThis might look like a blog, but it's not. For my blog, see my blog. This is just a blog-like dumping ground for technical notes and programming tips that I either discover, invent, or in many cases, re-discover. Git The Hell OutI've used lots of different revision control tools in the past, but never really settled on the one true tool for all my needs (mostly lone programmer projects, of a prototype nature). Lately I've been intrigued by git, and so after playing around with it for a while, I've started my first git-enabled project. There is however, one little glitch that drove me nuts for a while. As with most Pythonistas, I want git to ignore my litter of .pyc files. So I just added a quick ~/.gitignore file, stuck the necessary incantations into it, and told git to go forth and obey. (See Paul's notes for detailed instructions.) Unfortunately, it didn't work. Every time I ran git status, I was presented with the list of all the .pyc files I should be tracking. I spent an hour or two (admittedly, late at night, when I'm not at my most perceptive) trying different ways to fix it. I created a global .gitignore file. I copied it into a local .gitignore file. I tried changing the *pyc incantation to a *.pyc - but nothing would make those pesky files vanish from my status report. So I went to bed. This morning I had a brainwave, which I immediately looked into. Yup. There were spaces at the end of the line in the .gitignore file. Instead of ignoring “*.pyc”, I was ignoring “*.pyc ”. And of course, I had no such files in my project to ignore. Is it a bug? I'm not sure. I'll go check the git bugbase to see if others have reported and been scoffed at. Customizing CSS themes in Dokuwiki per namespaceI've used lots of different blogs and CMS engines over the years, but the one I keep coming back to is Dokuwiki. I like it because it is small, lightweight, easy to install, easy to use and has a vibrant community to support and extend it. On some of my sites (including this one), I find that I want to be able to modify, extend or replace elements of the site theme within the specific context of some sub-section. Dokuwiki lets me create these subsections via its built-in namespace support, but I haven't found a built-in way to customize the theme for these sub-pages. So I hacked one. If you'd like do something similar, all it requires is to add 3 lines of code at the end of the header section in the main.php file in your active theme directory. <?php if (getNS($ID)) { ?>
<?php $localCSS = $DOKU_TPL.'/'.getNS($ID) . ".css"; ?>
<link rel="stylesheet" type="text/css" href="$localCSS" />
<?php } ?>
The first line ensures that this block will only be processed if the current page is part of a namespace. The second line assembles the URL of the local CSS file in the form nsname.css (where nsname is just the namespace string you are currently in. Line 3 tells the browser to load that additional CSS file, and the last line is just the closure of the if statement from line 1. With this in your main page template, you can change the way all the pages in namespace foo render by creating foo.css in your theme directory. As long as you tucked those new lines of PHP code at the end of the HTML header, anything in your namespace CSS will override the settings declared in higher level CSS files. |