Posts

Showing posts from March, 2012

Write your own blog engine, part 6

Adding features What new features can I add to this to make it more useful? Paging is one that would be immediately useful (right now I will return the most recent five posts but I have no way of getting to older ones). Comments are also necessary; I will keep them in mind for later. There are two aspects of paging: I need to return a list of links pointing to pages and I need to be able to display that page when I click on the link. A problem comes to mind: since the posts are sorted in descending order based on their date, each time I add a new post the content of all pages will change. I don't know how this affects something like search engines; you might want to use paging based on the month of the post instead. I'll start with the first part, the navigation links. I will return those using the new HTML5 nav tag: <nav> <ul> <li><a href="/Home/Index/1">1</a></li> <li><a href="/Home/Index/2">2</a>

Smoking causes cancer

Most people are idiots. You can easily prove this because they will agree with the claim in the title. If you try to give them a counterexample — like, you know, the vast majority of smokers not having cancer — they will counter it by "well, it doesn't cause cancer right away". Causality doesn't work like that; it's a "if X, then Y" relationship. Don't use the word if you mean something other than that; say "smoking increases the probability of getting cancer" (yes it does). As an additional counterexample to the claim, here's something most people will dis agree with: passing under a ladder brings bad luck. Mark Twain had a humorous take on this: a character tells another "X passed under a ladder and only six months later he fell and broke his arm" (I'm quoting from memory). That's exactly the same type of "causality" as in the case of smoking: you do X, then long after that bad thing Y happens, and you cl

World history History of the human race

Here's the official version: In the first ten thousand years, people didn't do much of anything. In the second ten thousand years, people didn't do much of anything. In the third ten thousand years, people didn't do much of anything. In the fourth ten thousand years, people didn't do much of anything. ... repeat for several million years ... Finally, in the last ten thousand years people have started spreading out and inventing cars, airplanes and other interesting stuff.

Write your own blog engine, part 5

Post management I have decided to change the scope of this chapter: it won't be limited just to deleting but instead it would be about general post management: identifying, adding, deleting and modifying posts. I will use the value of the Id field to identify posts; that means that an URL like /Home/Post/guid would take me to a specific post. However, before I start to go in that direction I realize that it makes more sense to create a new PostController class to handle everything about posts. That way, the URL for adding them would be /Post/Add and the one for displaying a single post would be /Post/Details/guid. That means changing a lot of tests; I verify that they're all green, including the one that I disabled earlier (they are) and then start searching for the AddPost string in the tests. The first one is in the acceptance test I just re-enabled so I'll change "Home/AddPost" to "Post/Add". It is now failing with a (404) Not Found. error.