RSS | technovelty home | page of ian | ian@wienand.org
If you convert a docbook document in a chunked HTML form, it would presumably be very useful for you to place one of the various available javascript based trackers on each of your pages to see what is most popular, linked to etc.
I'm assuming you've already got to the point where you have your DSSSL stylesheet going (see something like my prior entry).
It doesn't appear you can get arbitrary output into the <head> tag -- the %html-header-tags% variable is really just designed for META tags and there doesn't appear to be anything else in the standard stylesheets to override.
So the trick is to use $html-body-start$. But you have to be a little bit tricky to actually get your javascript to slip past the SGML parser. After several attempts and a bit of googling I finally ended up with the following for a Google Analytics tracker, using string-append to get the javascript comment filtering in:
(define ($html-body-start$)
(make element gi: "script"
attributes: '(("language" "javascript")
("type" "text/javascript"))
(make formatting-instruction
data: (string-append "<" "!--
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// --" ">"))))
posted at: Sat, 22 Jan 2011 22:19 | in /web | permalink | add comment (0 others)
I think I've just about finished my Thanksgiving project easygeotag.info.
I'm a little bit obsessive about geotagging my photos and while I know there are many photo management solutions out there that can do it in various ways, I generally find it quicker and easier to use exiv2 and simple shell scripts to embed the location info directly into my files.
I've tried a number of things that have never worked out better than simply using Google Maps and panning around to find locations — I even bought a GPS tracker which would supposedly automatically tag my photos; assuming of course it could ever get a GPS lock, it hadn't run out of batteries and corrupted its filesystem, you had all times in sync and could figure out the various timezone issues, daylight savings changes, etc etc. I always feel safer having all my metadata embedded in the actual files just incase Yahoo ever does a del.icio.us to Flickr (I use a little Python script with IPTC bindings for comments, which I then backup similarly obsessively locally and to Amazon S3).
The site is fairly simple in concept — it allows you to search for locations, easily extract the geotag info and provides the ability to save frequently used locations for easy reference.
Mostly it was an exercise for me to implement something after reading the excellent Javascript patterns with YUI3, Google App Engine and OpenID — all of which of which I managed to cram in.
Although the audience may be limited (maybe just to me :) I hope someone else finds it useful for managaing their memories! If you think this might be useful and would like the output in some other format, just let me know.
posted at: Mon, 03 Jan 2011 23:14 | in /web | permalink | add comment (0 others)
After getting a flood of spam, I became suspicious that there was an exploit in my blog software allowing easy robo-posts. Despite a code audit I couldn't see anything, and thus wanted to log the incoming POST requests before any local processing at all.
It took me a while to figure out how to do this, hopefully this helps someone else. Firstly install libapache-mod-security, then the magic incarnation is
SecRuleEngine On SecAuditEngine on SecAuditLog /var/log/apache2/website-audit.log SecRequestBodyAccess on SecAuditLogParts ABIFHZ SecDefaultAction "nolog,noauditlog,allow,phase:2" SecRule REQUEST_METHOD "^POST$" "chain,allow,phase:2" SecRule REQUEST_URI ".*" "auditlog"
So, to break it down a little, the default action says to do nothing during phase 2 (when the body is available for inspection); the allow means that we're indicating that nothing further will happen in any of the remaining phases, so the module can shortcut through them. The two SecRules work together -- the first says that any POST requests should be tested by the next rule (i.e. the chained rule), which in this case says that any request should be sent to the audit log. After that, the similar allow/phase argument again says that nothing further is going to happen in any of the subsequent phases mod_security can work on. As per the parts between A and Z, we'll log the headers, the request body, the final response and trailer.
So, as it turns out, there is no exploit; it seems most likely there is an actual human behind the spam that gets through, because every time they take a guess it is correct. So I guess I'll take a glass-half-full kind of approach and rather than being annoyed at removing the spam, I'll just convince myself that I made a small donation from some spam overlord to one of their poor minions!
posted at: Thu, 21 Oct 2010 20:02 | in /web | permalink | add comment (1 others)
Some tips and things to check if your YUI ButtonGroup isn't behaving as you wish it would.
Double-check your <body> tag has class="yui-skin-sam"
Unlike in the documentation example, you can't just put a call to YAHOO.widget.ButtonGroup pointing to your div anywhere in your HTML and expect it to work. You've got to wait for it to be ready with something like:
<script type="text/javascript">
YAHOO.util.Event.onContentReady("my_button_div", function() {
var oButtonGroup = new YAHOO.widget.ButtonGroup("my_button_div");
});
</script>
You can easily get an image in each button. For example, if your button is defined as:
<span id="my-button-id" class="yui-button yui-radio-button yui-button-checked">
<span class="first-child">
<button type="button" hidefocus="true"></button>
</span>
</span>
Simply add a CSS class something like:
.yui-button#my-button-id button { background:url(http://server/image.jpg) 50% 50% no-repeat; }
Hopefully, this will save someone else a few hours!
posted at: Mon, 02 Mar 2009 23:36 | in /web | permalink | add comment (0 others)
tinymap.net just got another
thing ticked off its to-do list, as it now supports embedding maps in
an iframe on your website.
Coming up with an interface to do this was a bit of a pain, but you can see it in action here (or click on the "embed this map" link on every public map). I think there's still update bugs with the Google map inside a re-sizable panel, and every browser wants to layout the panels slightly differently.
But, all going well, you should be able to see a small embedded map just below!
posted at: Wed, 28 Mar 2007 22:44 | in /web | permalink | add comment (1 others)
I couldn't find a simple reference for the popular "accordion" style fold out menus with the YUI animation libraries (maybe because it is so easy!). Only traps are setting the overflow properties of the fold-out div, and the various DOM height elements.
<script src="http://yui.yahooapis.com/2.2.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script src="http://yui.yahooapis.com/2.2.0/build/animation/animation-min.js"></script>
<script type="text/javascript">
function swap_div(div_name) {
var div = document.getElementById(div_name);
var to_height = (div.offsetHeight == 0) ? div.scrollHeight : 0;
var from_height = (div.offsetHeight == 0) ? 0 : div.scrollHeight;
var ease_type = (from_height == 0) ? YAHOO.util.Easing.easeOut : YAHOO.util.Easing.easeIn;
var new_status = (from_height == 0) ? "collapse" : "expand";
var anim = new YAHOO.util.Anim(div_name, { height: {to: to_height, from: from_height} }, 0.5, ease_type);
anim.animate();
document.getElementById(div_name+"_status").innerHTML = new_status;
}
</script>
<div id="status">
<a id="expand_me_status" href="#" onclick="javascript:swap_div('expand_me');return false">expand</a>
</div>
<div id="expand_me" style="overflow:hidden; height: 0px; background:#eee">
<p>Hello, this is some text to be expanded out!</p>
</div>
And here's the example in action
Hello, this is some text to be expanded out!
A more advanced version might use the callbacks to regulate the swapping of the expand link, but with short swipe times (as one would want from a UI perspective) this isn't really an issue.
In related news, tinymap.net has had a bit of an overhaul (and includes expanding menus).
posted at: Fri, 16 Mar 2007 14:50 | in /web | permalink | add comment (1 others)
tinymap.net appears to have found a small niche, and is getting a lot more hits than I expected. Over a few nights it has gained
It is kind of strange and cool that the whole thing hangs together with a mash-up of Google, Yahoo and Amazon services. I considered using Amazon S3 to actually store the map database, but it isn't big enough yet, and I think latency would be an issue.
I have sitemaps that point to KML for public maps, and I was hoping that by pinging Google with the address they would index the KML with the page, and Adsense would serve more relevant, localised ads. So far, despite my pings, Google has not gone for any of the sitemaps -- I think you need to have them under your "webmaster tools" or something. If any Googlers are listening integrating Adsense with KML is going to be a killer app.
Some highlight links
I still have some more ideas, but I don't want to clutter it and loose the KISS approach I desired from the start. It sure is a lot of fun, even if Javascript is the most un-debuggable language ever invented.
posted at: Thu, 01 Mar 2007 18:09 | in /web | permalink | add comment (0 others)
Recently I've had some fun building tinymap.net which is best described as tinyurl for Google maps. You scribble on the map, and then you get a short URL to it. For example, to see my average trip to work go to http://www.tinymap.net/MkJVFx77KSX/.
I of course did no market research or planning and simply started coding, and have since found a few other similar (and fairly cool) sites such as Quikmaps and wayfaring. My site certainly has them beat in the KISS stakes, although it does involve a mashup, some AJAX and has been tagged a lot on del.icio.us so I'm claiming it is Web 2.0!
posted at: Wed, 21 Feb 2007 11:45 | in /web | permalink | add comment (3 others)
I love the idea of image metadata, but don't like the idea that if I invest the time in adding it to my photos and Flickr disappears then I've lost it all.
I wrote a Python wrapper for libiptcdata (coming to Debian if the NEW queue ever moves) and some tools to add titles, keywords and comments to IPTC data (embedded in the JPEG), which fixes one part of my problem.
Although one day I might have a camera that has a built-in GPS, until that day the next best thing is Google Maps. Since they added Australian street data, I can pretty much pin-point wherever I was in a matter of seconds with a place name search. Using their API I hacked up a latitude and longitude finder page which can search by address, and pops up information in a format suitable for pasting directly to the exiv2 command line to embed the location in the EXIF data. You can also click anywhere to add a mark and then click on it to get its location information.
The only problem was that EXIF expects locations with degrees, minutes and seconds rather than the more modern decimal points, which makes ye feel a bit like a scurvy old sea dog, ahhrrr.
Flickr can also apparently take geographic information from tags, if you paste them in and know the secret page to import it. However, when uploading with EXIF GPS data I found that it placed things on the map straight away and doesn't pollute your existing tags. Yahoo maps are however, at this point, unfortunately a fairly mediocre imitation of Google maps.
Yay Web 2.0!
posted at: Wed, 07 Feb 2007 15:41 | in /web | permalink | add comment (0 others)
I from time to time want to create a quick static web form to run where PHP etc isn't involved. The best way I've found to do this is with the HTML_QuickForm PEAR package.
To install it on Debian, just install the php-pear
package and run sudo pear install HTML_Common
HTML_QuickForm and then you can easily create really nifty
forms.
For example, the comments form below was created with the following input.
<?php
require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('comments_form');
$form->addElement('header', null, 'Add a comment');
$form->addElement('text', 'author', 'Name', array('size' => 50, 'maxlength' => 50));
$form->addRule('author', 'Please enter a name', 'required', null, 'client');
$form->addElement('text', 'email', 'Email', array('size' => 50, 'maxlength' => 50));
$form->addRule('email', 'Please enter an email', 'required', null, 'client');
$form->addElement('text', 'url', 'Website', array('size' => 50, 'maxlength' => 50));
$form->addElement('textarea', 'body', 'Comment:', array('rows'=>10,'cols'=>50));
$form->addRule('body', 'Please enter a comment', 'required', null, 'client');
$form->addElement('submit', null, 'Submit');
$form->display();
?>
It automagically does client side javascript to do first level
validation and makes the form look quite nice. You can just run
php file.php on the command line to scrape out the plain
HTML.
posted at: Wed, 04 Jan 2006 16:32 | in /web | permalink | add comment (0 others)
Google Alerts is a service that fires off an email with automated searches of Google news or new websites daily.
Bloglines has a feature where you can make an email address under your profile and any email that is received will be "blogged" and appear as any other feed ... sort of like an automated email->RSS generator.
Add them up, and you've got a really cool way of keeping up to date with things you're interested in. You'll probably end up finding articles you might otherwise never have found, amazing your friends and workmates.
The only problem is that you will need to keep your email subscriptions private in Bloglines, since you have to receive the confirmation email which has details on how to cancel the web alerts (and so does each email, for that matter).
posted at: Fri, 08 Apr 2005 13:39 | in /web | permalink | add comment (0 others)
Recently I started keeping track of "people" (trojaned Windows
boxes) looking for things like formail.cgi or
mt-comments.cgi on my work webserver. Having now hit the
1000 unique IP address mark I thought I'd graph the locations of the
offenders with geoip.
The full graph shows the USA on top by a large margin, but Spain not far behind with UK, Italy and France rounding out the top 5.
What does this mean? Nothing, really; except with a bit of coercion Openoffice can be made to make quite a nice graph (tip: to just export the graph copy it into a new "Drawing" then export that to PDF).
posted at: Fri, 11 Feb 2005 13:05 | in /web | permalink | add comment (0 others)
I've been through my fair share of cheap webhosts, and for the most part you get what you pay for. Since most of my sites are for hobby, downtime isn't too much of an issue for me.
However, I can so far say that unlimited-space.com has been a fantastic cheap webhost. They offer a full control panel so you can do most everything yourself, "unlimited" disk space, suitable bandwidth limits, and good features standard features like email, ftp users, mysql and an add-on domain. I've never even had to call on them for service, which for mine is a good sign. However last time I signed up an account it was ready in just a few hours.
You can also pay in $AU which is great. The only downside is the upfront payment -- often with the cheaper reseller based hosting services you pay upfront and never know how much service you're going to get. I have however had no problems with service quality and now have at least three sites running with them.
posted at: Wed, 02 Feb 2005 17:04 | in /web/hosting | permalink | add comment (0 others)

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.