Latest Tweets

Find Posts by Category
Find Posts by Tag
Twitter

Entries in blogging (8)

Monday
Nov092009

How to Create a Custom 404 Page on Squarespace

I just recently switched my blog from a self-hosted Graffiti installation to a completely managed solution on Squarespace. This is fantastic because it takes the job of patching and coding almost completely away. The downside is that some of the things I took for granted are unavailable. Like a custom 404 page. Why is this an issue? Well, if you are moving from one engine to another, they probably have different URLs for the same article. The last thing I want is for one of the rare visitors to my blog is some unhelpful error saying that the page could not be found. If you want an example of this happening, go to Squarespace’s own blog and look at this post from September 2008. Now click on the video link. Unless they have fixed it recently, you will see this:

image

The built in solution for this is called URL Shortcuts. The idea is that you plug in the old url and the new url into the configuration area, and anytime someone enters the old url, they are sent to the new one instead. Great…if you have 5 pages. But if you have been blogging for a while, then the job of entering those URLs is going to suck. Squarespace probably realizes this which is why you see that screenshot above. So what is the solution?

If you write to support, they will say that URL Shortcuts is the solution. But there is a better way. I found a post on their developer forum about customizing the Page Not Found form. The solution seemed pretty simple. Create a custom 404 page on your site, the paste this in the Extra Header Code section (I am pretty sure this means you need an Advanced level package from them):

<script type="text/javascript">
   //Redirect from error page to your new custom error page 
   var redirectURL = "http://ENTER YOUR NEW ERROR PAGE URL HERE";

   if(document.title == Squarespace.Constants.WEBSITE_TITLE + " - Page Not Found"){ 
      location = redirectURL; 
   }; 
</script>

The only thing to change in that code is the page url. Actually, mine only worked when I put /custom404 rather than http://technovangelist.com/custom404.

On my Custom404 page, I put in some apologetic text explaining the situation, directing visitors to the search box. But I wanted to take it a bit further. I wanted to auto suggest a link for where they really intended to go. It might not work, but I figured it was good to try. On the Graffiti site, page urls were formatted as <site>/<category>/<page>. So I had some that were /technology/blah, and others that were /travel/blah. On the new site, all posts were under blog, so /blog/blah. What I needed was a way to convert all /travel/ and /technology/ to /blog/. I think this would be a good time to tell you that I don’t know anything about javascript other than how to spell Google.com.

A little searching on the net combined with some newbie code wrangling and I ended up with something like this:

prevurl = document.referrer;      
document.write("<font size=-1><b>You came here from "+prevurl+"</b></font>");

So that told me where I came from. When I figured out how to manipulate text I got the rest:

if(prevurl.indexOf("technology")!=-1) {
   newurl= prevurl.replace("technology","blog");
   newurl = newurl.substr(0, newurl.length-1);
   newurl = newurl +".html";
   document.write("<font size=-1><b><br>I think you wanted <a href="+ newurl +">"+ newurl +"</a></b></font>"); }

That combined with my apology was a pretty good first step. Then tonight I realized there was a problem. I looked at my Woopra stats and saw that /custom404 was one of my more popular pages. I couldn’t quickly see which page caused the problem. Woopra shows the page title, which was now “Technovangelist – Custom404”. So I had to change that title. In order to change the title, I needed to pass the bad URL somehow. A query parameter seemed like a good choice. So I changed the line that initialized redirectURL to this.

var redirectURL = "/custom404?ref="+location.href;

That got me the all the info I needed. Perhaps too much information. Now to tweak the title. I headed back to the Extra Header Code in Website Settings. After that first If clause in the script, I added another:

else if (document.title == "Technovangelist - Custom404"){
   document.title = "Technovangelist - 404 - "+location.href;

This is good, but the url in Woopra is now really long. So another edit got me this:

else if (document.title == "Technovangelist - Custom404"){ 
   document.title = "Technovangelist - 404 - "+location.href.substring(67); };

Why is 67 in there? Well, I am sure there is a cooler way, but there are 67 letters in the URL before the unique part of the url. I want to see Technovangelist – 404 - /technology/badsite, not the way too long Technovangelist – 404 – http://technovangelist.com/Custom404?http://technovangelist.com/technology/badsite.

I then added a search box to the custom404 page just in case my guess didn’t work, but I think it’s a good first step. Want to try it? Go to http://technovangelist.com/technology/time-to-move-away-from-graffiti/ and see the custom 404 page that comes up. Now click the link that I suggested. In Woopra I will see something like this:

image

I am very happy with this solution. Would have been easier I think to be able to override a 404 page, but this will do. Any thoughts on how I can improve this approach??? Let me know in the comments.

Saturday
Nov072009

Time to Move Away From Graffiti

Blogging for me has always been something I enjoyed, but I managed to not do much of it. I let the tools get in my way far too much. In the early days of this blog site, I wanted to create my own software. First it was a Linux based site, running Apache, Postgresql, and PHP/FI. The a few years later (well over 10 years ago now) I switched over to a Windows-based site. That switch happened to coincide with my hiring at Microsoft. It was hosted with a variety of providers including WinISP (an MS internal project that seems to be dead now). When Telligent got started I switched over to Community Server. I entered their theme building contest with an embarrassment of a theme and won a free license. After a few years there, I moved to Graffiti. Both CS and Graffiti were hosted on my current provider: Server Intellect. But it was always a lot of work. There was no real community around either Community Server or Graffiti and although creating styles was easier than doing it yourself, it was still hard. And then there was a security problem recently. Since I was hosting it myself, I had to deal with fixing it. Ughh. 

Blogging has become a chore. But I don't want it to be a chore. I want to have a site that is easy to maintain, easy to tweak, and no real management on my part. I want an engine that doesn't feel like a kludge, ruling out a lot of the industry leaders. 

I have long loved Diggnation, having watched a good 90% of all of their shows. Recently they have been advertising SquareSpace. I always skipped over the ads so never really saw what it was about. Then I saw NewToYork.com because of a blog post about it's footer design. From there I saw other Squarespace sites, then the main site and the videos. I was amazed at how easy it all looked. I was ready to change over.

The last few days have been a lot of fun (and some frustrations). I think I have a site that I can live with at squarespace and this blog will be moving over very soon. I hope this causes the last few subscribers I have minimal downtime. I should work out all the kinks very soon.

 

Monday
May122008

First Look at GTech (a Graffiti theme for the Technovangelist)

I switched over to Graffiti on Saturday and also took on creating my own theme for the site. I did this with Community Server and it was quite difficult. I spent over a week with it and I came up with a terrible theme. But I entered it into the theme contest at Telligent and won a free CS license. There were less than 10 entries which probably shows how difficult it is to come up with a theme for CS.

I was a bit worried I would have the same problem with Graffiti. It started out badly...I searched for documentation and found the same thing as with CS: what little documentation for Graffiti is out there is really awful. In fact, when you go to the Graffiti site, much of the documentation you have to search for. But when you are new to a topic, you don't know what to search for. Also, the little bit of documentation out there only explains how to do something, not necessarily why you want to do it.

Anyway, I plugged away and by late Sunday night, I have something that I actually really like. I am not a fan of the bright and colorful sites out there but I also hate seeing the more boring plain text sites. So I wanted something a bit in the middle. I feel that there is enough interesting style to this layout without being too gaudy.

I still have some tweaking to do but the majority of it is there. Tomorrow is a holiday here in the Netherlands, but I will really try hard to get outside into the gorgeous weather...perhaps out for a nice drive... Oh well, time for bed now.

UPDATE: oops, no ability to post comments, back to one of the default themes

UPDATE 2: OK, now I have enabled comments in GTech.

Click to read more ...

Sunday
May112008

Switching to graffiti...

I have this love/hate relationship with this blog. I love having posted to it, but I hate posting to it. Having a poorly performing and poorly laid out site only added to the hate side of that relationship. So I switched the site just now from Community Server to Graffiti. Been playing around with Graffiti themes today and hope to have something interesting here soon.

Click to read more ...

Wednesday
Mar192008

Update

Wow, its been some time since I last posted here. Lots of travel, and mostly being sick. I moved into my new apartment at the end of January and then about 2 weeks later I got sick. Very Sick. 2 weeks later, I got on a plane to go to Argentina...still sick. Then I spent a hard week of working in Buenos Aires (It WAS alot of work), while still sick. Then a week in Seattle. I thought I had gotten better but then a tickle in the throat started. By the end of the week I was feeling like death again. The flight was hell and when I landed in Amsterdam, my ears hadn't popped. The taxi back to my apartment was tough, constantly coughing. An hour in my apartment to shower and repack a bag, and I was off to Central Station for a train to Brussels. I was actually heading to a much smaller town south of Brussels where Dialogic has an office. Dialogic is a very important partner for Captaris and I was going to attend a Fax over IP class they were holding. I was to change trains at Brussels North, but the connecting train got cancelled...twice. An hour on a cold wet train platform totally sucked. So then I took a cab instead. That first day in class was tough. The instructor's voice was fading(she was sick too, but was still going, amazing) and my ears still hadn't popped so I couldn't hear anything. Thankfully two Theraflus that night at the hotel fixed me up and by morning I could hear. The second day of class was much more successful, but the instructor's voice was down to a whisper (but she kept going!!). By the weekend, the illness had come back in full force. Monday I returned to the doctor, and yesterday got an X-Ray to try to figure out what is wrong. But I think I am on the mend. Still a bit of a cough, but nowhere near as bad as I was a month ago, or even 3 days ago.

Click to read more ...

Tuesday
Dec112007

Adding a Simile Timeline to Community Server

In case you have visited this site recently, you may have noticed the cool timeline in the Blog Archives page. This is an amazing bit of Javascript that displays a any content you like on a long virtual sheet. Its kind of like those great "entire history of the world" posters that you grew up with. I found this after looking at Scott Hanselman's web site a few days ago. I figured that I had plenty of time, so I did the same thing. It wasn't very hard, but it wasn't exactly brain dead easy either.

To start off, I went up to the source page for the project at MIT. The examples on there are great. The documentation is a bit basic, but most of your needs are covered. After searching around a bit, I found a few other articles that were helpful, including a couple from LifeCycle Solutions and Ryan Kanno. Then it was just a matter of trying it out.

First, I added the javascript tag on my Blog Archives page:
<script type="text/javascript" src="http://simile.mit.edu/timeline/api/timeline-api.js"></script>

Further down I added a div where the timeline was actually going to go:
<div id="my-timeline" style="height: 450px; border: 1px solid #aaa; margin-right:20px;" />

Next I created a new .js file to hold my javascript. I think I will use this file for lots of other stuff, so I made a new namespace just for the timeline code. Here is the entire file:

   1:  var TECHNOVANGELIST = {};
2: TECHNOVANGELIST.TimeLine = function() {
3: var tl;
4: var resizeTimerID = null;
5:
6: return {
7:  
8: createTimeLine: function () {
9: var eventSource = new Timeline.DefaultEventSource();
10: var theme = Timeline.ClassicTheme.create();
11: theme.event.bubble.width=520;
12: theme.event.bubble.height=120;
13: var curdate = new Date()
14: var bandInfos = [
15: Timeline.createBandInfo({
16: eventSource: eventSource,
17: date: curdate.toGMTString(),
18: width: "80%",
19: intervalUnit: Timeline.DateTime.WEEK,
20: intervalPixels: 50
21: }),
22: Timeline.createBandInfo({
23: showEventText: false,
24: trackHeight: 0.5,
25: trackGap: 0.2,
26: eventSource: eventSource,
27: date: curdate.toGMTString(),
28: width: "20%",
29: intervalUnit: Timeline.DateTime.MONTH,
30: intervalPixels: 100
31: })
32: ];
33: bandInfos[1].syncWith = 0;
34: bandInfos[1].highlight = true;
35: bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());
36: tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
37: Timeline.loadXML(http://technovangelist.com/BlogTimelineSource.ashx,
function(xml, url) { eventSource.loadXML(xml, url); });
38: },
39:
40: onResize: function() {
41: if (resizeTimerID == null) {
42: resizeTimerID = window.setTimeout(function() {
43: resizeTimerID = null;
44: tl.layout();
45: }, 500);
46: }
47: }
48: };
49: } ();

Back in the Blog Archives page, I added the pointer to that js file:

<CSControl:Script src="../Common/TVLIB.js" runat="server" />
<script type="text/javascript">
   window.onload=TECHNOVANGELIST.TimeLine.createTimeLine;
   window.onresize=TECHNOVANGELIST.TimeLine.onResize;
</script>

You can try that out to see if it works so far, but your eventsource isn't working yet. I have that pointing to a BlogTimelineSource.ashx which we haven't created...yet. So here is the full file for BlogTimelineSource.ashx:

   1:  <%@ WebHandler Language="C#" Class="BlogTimeLineSource" Debug="true" %>
2: 
3: using System;
4: using System.Web;
5: using CommunityServer.Blogs.Controls;
6: using CommunityServer.Blogs.Components;
7: using System.Collections.Generic;
8: using CommunityServer.Components;
9: 
10: public class BlogTimeLineSource : IHttpHandler {
11:
12: public void ProcessRequest (HttpContext context) {
13: context.Response.ContentType = "text/xml";
14: context.Response.Write("<data>");
15: BlogThreadQuery query;
16: query = BlogThreadQuery.CreateNewAggregateQuery();
17:
18: query.PostConfig = BlogPostConfig.IsAggregated;
19: query.PageIndex = 0;
20: query.PageSize = 5000;
21: query.IncludeCategories = true;
22: query.BlogPostType = BlogPostType.Post | BlogPostType.Article;
23: 
24: ThreadSet ts = WeblogPosts.GetBlogThreads(query);
25: 
26: foreach (WeblogPost p in ts.Threads)
27: {
28: context.Response.Write("<event start=\"" + p.PostDate + "\" link=\""
+ p.ViewPostURL + "\" title=\"" + p.Subject + "\">");
29: context.Response.Write(context.Server.HtmlEncode(p.ForceExcerpt) + "</event>");
30: }
31: context.Response.Write("</data>");
32: }
33:
34: public bool IsReusable {
35: get {
36: return false;
37: }
38: }
39: 
40: }
At this point you run into a problem. The ashx file probably can't be found still. Its there, but Community Server doesn't know about it yet, so you may have to modify you SiteUrls_Override.config. I just added the following in an <override> block:
    <location name="BlogTimeLineSource" themeDir="common"  path="/" >
      <url name = "BlogTimelineSource"  path="/BlogTimelineSource.ashx" 
              pattern="/BlogTimelineSource.ashx" physicalPath="##themeDir##" 
              vanity="{2}" page="BlogTimelineSource.ashx"/>
    </location>

That's it!! The toughest parts for me were trying to figure out how to reference the javascript file on a CS site, figuring out Javascript namespaces, and then doing the query in the ashx file. Then I spent a while tweaking the look...changing the height (though its referenced as width) of the bands and changing the size of the popup. Let me know if this is useful for you...

Tuesday
Dec112007

A new theme in the works...posted now

So I am updating the theme on this site. Its not done, but there are already a lot of changes I am pretty excited about. Its still not perfect, but I have a bit of time on my hands right now.

Whats working and is pretty cool:

  • Current Twitter Status - ok that was there before
  • Upcoming Travel from 30Boxes - Its grabbing my future travel schedule from 30B. When a date goes past, it will no longer show up on the page...automatically
  • Recent Del.icio.us Tags - Its grabbing the last 5 or 6 days worth of links I have tagged.
  • Captaris Developer Program Posts - I also occasionally post to the Captaris Developer Program. This is a list of all of those posts. As with the above items, this is dynamic.
  • Blog Flare - Took a while to figure this out. Each post can be added to Digg, Facebook, Technorati....ok, they won't, but they could.
  • Full vs Excerpts - The most recent 3 posts are the full post. Then there are a bunch more that are just excerpts.
  • Cool icons from FamFamFam: Silk
  • Simile Timeline - This is one of the coolest new features. Rather than a traditional calendar of previous items, I am now showing an interactive timeline of all blog posts here.

Click to read more ...

Thursday
Feb092006

Holy crap! two comments in two days

Wow, what the hell happened. I must have inadvertently switch from the boring crap I usually write to something somewhat interesting. In the last two days I have attracted enough interest to generate 2 (TWO) whole comments. And they are not comments about levitra or viagra or phenta something….those are the comments I delete nightly. No, they are real comments. WOOHOO!!!

Click to read more ...