Kiwi – brings your GitHub Wiki to your custom website

Kiwi is targeting one thing:

To enable you to easily bring your GitHub Wiki content, with its GitHub flavored markdown syntax, to your own site.

As of now, Kiwi only contains one module/component, “Kiwi.Markdown”.

It enables you to point to a directory with Markdown files and then turns them into HTML, with support for GitHub flavored markdown like CSharp code blocks.

Kiwi.Markdown relies on other open source components to handle most of the markdown transformations and syntax highlighting:

For latest version or more info, look at the Kiwi-projects Wiki.

Setup a Controller

For this example I will use a live one. The GitHub Wiki for SisoDb which also has the wiki at http://sisodb.com/wiki

My controller is really simple. One Action and a cache profile, nothing more.

WikiController

[HandleError]
public class WikiController : Controller
{
    [OutputCache(CacheProfile = "WikiCache")]
    public ActionResult Doc(string docId)
    {
        return View(MvcApplication.MarkdownService.GetDocument(docId));
    }
}

Web.config

<caching>
  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="WikiCache" duration="3600" varyByParam="docId"/>
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

Fix a route

My route is going to match http://sisodb.com/wiki and http://sisodb.com/wiki/{docid} where docId matches the name of the Markdown file except the file suffix.

Global.asax

routes.MapRoute(
    "Wiki", // Route name
    "wiki/{docId}", // URL with parameters
    new { controller = "wiki", action = "doc", docId = "home" } // Parameter defaults
);

Setup a MarkdownService

A bit temporary, but as for now I’ve just put a static member in Global.Asax.

MarkdownService = new MarkdownService(new FileContentProvider(Server.MapPath("~/App_Data/MarkdownFiles"));

You can also see that I have decided to reside my Markdow files under “~/App_Data/MarkdownFiles”. There’s nothing stopping you from using MarkdownService outside a webbapplication, it has no dependencies on any web stack.

Get the Markdown files

Go to the Wiki at your GitHub project and check under Git Access example. Bring down the files using git clone

Take the files and put them in the ASP.Net MVC application’s folder containing Markdown files (App_Data/Markdownfiles).

Tip

When moving the files to a server, you can use the strengths and features of Git.

# Clone and Get the Wiki locally
git clone git://github.com/danielwertheim/Kiwi.wiki.git

# Create a Zip which you can upload
git archive master --format=zip -o Kiwi-Package.zip

Setup the view

Wiki/Doc.cshtml

@using Kiwi.Markdown
@model Document

@{
    ViewBag.Title = @Model.Title;
}

<div class="post">
    <h1 class="title">@Model.Title</h1>

    <div class="entry">@Html.Raw(Model.Content)</div>
</div>

That’s it. Nothing more. There will be other Kiwi components coming that will assist you with the publishing etc of new Markdown files.

Coming feature

I’m working on a small MVC area that will let you complement the flow above with something like:

# Upload the Zip using Curl
curl --upload-file package=@Kiwi-New.zip http://sisodb.com/kiwi/package/put

Of course, the example above misses out setting headers for security, info but I guess you get the point.

Who is the unit and integration tests for?

The unit tests and integration tests are for the developers. And not only for the developer working with the item being implemented, but all the developers currently in the team; and all the developers that will join the team in the future. The unit tests and integration tests are not for the customer, they are there to give the developers a safety net; there to specify the intent of the code; there to embrace quality. I would go so far to say:

a customer should never question the existance of tests, only the lack of them

Isn’t unit tests enough?

No! If you would have to select one, integrations tests is the way I would go. Why? Well I guess you don’t plan to let every piece of your code run in isolation and never integrate with other parts of your’s or other’s systems. I also guess you intend to have some sort of persistence in your system, like a database. If you don’t do integration tests and regression tests, how would you know that

implementation or change of feature X doesn’t brake feature Y

Why don’t you write tests?

One thing is for sure: “since you aren’t testdriven”. I’m not going to state that you must be testdriven to succeed, but it shure does help.

Not having a good suite of tests make me feel like an electrician working with high voltage without knowing if the power is on or off

To the customer

If you are the reason for not writing tests and you instead rely on manual testing, how much does the/these tester/s doing manual arbitrary testing cost and how much coverage do you gain from those testers?

To the developer

How does it feel to be blamed when you push some changes and a new version of the software is shipped and shortly after (hopefully) the customer or user comes with an error report:

Hey, this thing just stopped working but it worked a hour ago. How can that be? Don’t you test your stuff before releasing them?

They are for all!

The tests are mainly for the team but the effect of them provides benefits for all. For the customer and the users and the families to all involved stakeholders, since they get happy relatives coming home from job. Enough said.

//Daniel

I like to dance

A couple of years ago me and my wife took dance lessons. I thought it was very challenging since I had no idea of how to get my body to move like the instructor showed us, in pace with the music and at the same time leading my partner and protecting her on the dance floor from getting hit by other dancers. After weeks and months of practice I managed to master dance after dance and it just got more and more of a joy. Why? Simple! I had learned to master the steps. Learned how to feel the music. Learned how to plan and create a choreography that was suitable for me and my partner – for our team.

As a software developer I have made many mistakes. I have been in scenarios where I have been to junior for the responsibility given to me. I have produced bugs and misinterpreted specifications. I have produces architectural solutions that didn’t make the cut. For every failure though, I have gone home, sat my self down, trying to evaluate and come up with other ideas. Studying other developers work to see alternative solutions. Everything for evolving my skills. And that’s a good start but still, no matter how smart solutions you produce, they mean nothing if the team isn’t on the same track. It doesn’t matter if you understand how every part works together. What matter is that everyone in the team feels comfortable with the solution and feel that they can be productive. It should also be easy to introduce new members in the team. That’s something I think is foreseen. To much focus is put on creating “hyped solutions” using the latest frameworks and “buzziest” patterns without looking at the maturity of the team. Without thinking about the developers that will administer the software when all consultants and/or initial staffing has left.

Balance. Yes, I know it’s a vague word, but you must try to balance the complexity of the solution seen to the team. That’s one of the most important thing I have learnt and used. Listen, back down and adapt and you will conquer. I know it’s tempting to be “cool”, but sometimes a step in another direction might be better. Keep this in mind and remember to be open minded.

//Daniel

Bad programmer attitude!

Note! This blogpost is not directed to any specific person but all the persons that
creates this attitude. And, yes, my attitude could of course be better. We all can improve there.

Yesterday I read this blog post where the following was said:

I’m a lazy slob – which is another way of saying that I’m a programmer.

Normally I don’t get upset by this kind of rallying, ironical parlance and it’s kind of an old statement… But WTF. I just couldn’t get passed those lines. Do you really think we programmers are lazy and slobs? I shure hope not and if you do, please look back at the incidents that has lead you to this conclusion. That person that brought you that feeling of lazy programmers, is that person perhaps this by nature? Isn’t this something lying in the human nature and not based on occupation or society? I mean, maybe he or she is this in more than just his or hers occupation? I guess so? Probably not pulling of the hours at home. Dodging bullets here and there. If that person is acting like this in his or hers proffesional occupation and you are the manager…. Sack them! They don’t deserve the job even if they are famous and has a great influence on the community. Especially then, since this is the people that youngsters and others should look up to. Let them go and find their real call in life.

//Daniel