Panda's future

I'm happy about what Panda is today, yet there are a few things that could be improved / experimented:

MVC

The MVC pattern, applied in the whole application scope, is a little bit bold right now. The controller is handling all the requests, like the Rails way. I think it sucks. There is no visible alternatives yet, but this should be done better.

The state data is passed explicitly into views, and I like it this way. However, it might have to change, since views should get smarter, in particular, they should have their own states and be able to handle local effects.

Routing

Routing is done in Kibro. I would like automatic RESTful routes, or even custom module that does custom parsing on URLs. Haskell is statically typed, so there has to be a joint point somewhere.

This means that finally I'm going to have to look into Kibro's implementation, I was being so lazy.

Module

The current extension framework in Panda is a hack. There is no extension framework, the running of extension code is guarded based on global variables. Unfortunately, I don't know how to properly design a module system.

Slice

How should functionality be abstracted. The Rails way is to use web resources; WordPress to uses plugins; Cocoa to implement delegates. Since haskell is static, the Rails way is the most doable, but does it mean to post a comment to a resource, there has to be an RPC? Again, it can only be answered by experiments.

Extra

  • better error handling in IOs
  • form validation with informative feedbacks ( both client side and server side )
  • tools that facilitate blogging
  • models should really return Maybe type or Either type, while exception handled locally
  • some logging support ( right now, it just reports when exception occurs :D )

These are problems that I'm aware of, but not critical enough for me to implement.

Conclusion

I guess nothing is easy, even for something as simple as a blog engine ( Panda is basically built on CGI ). Kibro did a great job at providing a safe platform for me to pick my own tools, make my own designs and use any library I wished. Very few framework does this. Heck, Kibro is just a Monad, hardly a framework :D

BTW, how stable is Panda / Kibro / Haskell? From my experience, there could be logic errors ( false result ) or IO exceptions ( file not found ), but absolutely no crash, neither on production, nor development. No crash ever.

Haskell is just weird.

Customize footer

One more feature for Panda 2008 :)

The footer can be customized by putting footer_file_name under db/custom, and add

footer = footer_file_name

in site.txt.

For example, my footer is named footer.html with content

©2008 C大调
<br />
Powered by <a href="http://www.haskell.org/haskellwiki/Panda">Panda</a>
using <a href="http://www.haskell.org/">Haskell</a>

The reason I'm using html here is that markdown will generate <p> tags, which really screws up text alignment.

I consider Panda 2008 complete, updates will be bug fixes and critical add-ons.

There will be a Panda2 or PandaCute or something like that which continues the development of Panda, with new ideas. I wanted a simple blog engine, therefore piling up features is not going to happen in Panda's development. Panda is stable now.

Yeah :)

Panda has 1068 SLOC

Wow, I didn't expect that.

I spent a morning refactoring the code.

  • More static typing: configuration options used to be runtime strings, it's now checked by the compiler.
1
2
3
4
5
6
7
8
9
data ConfigData = 
BlogTitle
| BlogSubtitle
| HostName
| AuthorEmail
| PerPage
| Navigation
| Root
...
  • Default value: use data-default
1
2
instance Default State where
def = State def def def def def def
  • Rails style humanized string conversion
1
show_data = show >>> snake_case

In conclusion, the code gets better ( I think ... ), yet correctness maintained, for not that I'm any good, quite the contrary, I suck. Then why I'm still blindly happily refactoring code without sophisticated tools or test suites as backups?

Haskell rocks

Tests are useful for sure, but coming from a dynamic world, trained to spec everything and constantly hold every piece of code in addition to the runtime in mind, Haskell just feels simple, relaxed :)

BTW, Panda is big enough. I used to hope to keep the code size under 700, but it didn't work out :) This is it. If more features are to be added, they should come as extensions. Though I need to find out a way to do that first...

Post summary

Post summaries can be enabled in site.txt:

summary_for_root = y
summary_for_tag  = y
summary_for_rss  = y

cut = ✂-----

cut is a user defined string that cuts the content into a summary and a continuation. It can be ignored completely, as usual.

An example post in this format would look like:

Post summaries can be enabled in `site.txt`:

    summary_for_root = y
    summary_for_tag  = y
    summary_for_rss  = y

    cut = ✂-----

✂------✂------✂------✂------✂------✂------✂------✂------✂------✂------

`cut` is a user defined string that cuts the content into a summary 
and a continuation. It can be ignored completely, as usual.

An example post in this format would look like:
Pretty URLs

Some updates on the development of Panda (on git).

Customize file naming conventions:

## db date format

post_date_format    = %y-%m-%d
comment_date_format = %y-%m-%d %T

Customize how post urls are generated / parsed:

## pretty url

### example wordpress style
#- url_date_format          = %Y/%m/%d
#- url_date_matcher         = \d{4}/\d{2}/\d{2}
#- url_title_subs           = (" ", "-")
#- url_date_title_seperator = /

These are pretty advanced settings, leaving them out completely in site.txt will use the old default style.

A development note:

There are many more things could be made configurable to the end user. See Panda/Config/Global.hs, not exposed to keep it simple.

Syntax highlighting

Example in HTML (flickr slideshow snippet)

<object 
  type="text/html" 
  data="http://www.flickr.com/slideShow/index.gne
    ? user_id=
      56167317@N00
    & tags=
      cat-hack"
  width="500"
  height="500">
</object>

Highlighting is done on the client side using Highlight.js, no code changed in Panda!!

Since it all happens in the browser, updates are made in panda-tempalte.

Styling is configured at config/theme/blueprint.txt, just change highlight/default to any css inside theme/blueprint/css/highlight.

Note: Only HTML syntax is enabled by default for performance, specified inside public/theme/blueprint/js/custom.js:

// syntax highlighting
// to enable all:
// hljs.initHighlightingOnLoad();
// to enable selected:
// hljs.initHighlightingOnLoad("html", "ruby", "python");

document.write(
  '<script>hljs.initHighlightingOnLoad("html");</script>'
);