Using Apache's .htaccess to restrict a site for maintenance

Posted on

This is primarily a reminder for myself, since I have a hard time finding this when I need it. Use this to restrict access to a site by IP address and display a friendly message to users when doing an upgrade or maintenance.

<LIMIT GET POST >
Order Deny,Allow

Deny from All

Allow from 192.168.0.1

</LIMIT>

ErrorDocument 403 "Site Upgrades, please check back later."
─── ✧ ─── ✦ ─── ✧ ───

Quick tip: tracking link clicks with javascript

Posted on

You learn something new everyday. On SoccerBlogs.net, I've always tracked click thrus to gauge which posts represent active stories. Previously, I used to redirect clicks through my own url and then redirect to the final destination. This was a little slower for users, and I think its not super kosher from google's point of view. Using Jquery, it was trivial to send a request to my clickthru listener url via XHttpRequest. First, I added the class "clicktrack" to any a tag to record. The first version of my javascript listener was bound to the click event of each link.

\$(document).ready(function(){\ \$('a.clicktrack').click(function() {\ // tell big brother - 'this' is our url to spy on\ \$.get('/clicktrack/' + this + '/');\ return true;\ }); });

I've simplified a bit, since in my real listener I don't use the url but something more specific. The return true is important to make the browser actually go to the clicked link. Today, I noticed a curious behavior. In Firefox, when I used my middle-click button to open a link in a new tab, the XHttpRequest was never made. Turns out, and it makes sense, that middle-clicking on a link does not trigger the link's Click event. I hypothesize that Firefox must copy the url and open a new tab with it. But there is a solution, because middle clicking does trigger the MouseUp event. Changing one line in our Jquery code makes it all work again:

\$(document).ready(function(){\ \$('a.clicktrack').mouseup(function() {\ // tell big brother - 'this' is our url to spy on\ \$.get('/clicktrack/' + this + '/');\ return true;\ });\ });

Tags: Javascript, jQuery

─── ✧ ─── ✦ ─── ✧ ───

Soccerblogs.net tweaked and redesigned.

Posted on

I've updated SoccerBlogs, which has been requriing some of my attention for a while now. The obvious change is a much better design, at least as far as my skills go. I also changed how I was linking to external posts and now use a simple ajax request to count click-thrus, instead of more cumbersome, and less SEO friendly, HTTP Redirects.

I'm a bit disappointed how messy I'd let the code become, but taking a look at Pythong's Django and the Solar Framework for PHP really taught me a lot about how to structure a web application using MVC. My original goals were to reimplement my sites using either Django or Solar, but the slow pace of progress got to me. I'm not blaming either for the slow progress, since among the frameworks I looked at both had really good documentation and user communities behind them. I couldn't find enough time to really learn either well, and I really wanted to put the apps together in the correct way. I think the need to stick to a framework's convetions, even when it'd be quicker to hack a solution, requires a lot of patience and discipline. 

Tags: SoccerBlogs

─── ✧ ─── ✦ ─── ✧ ───