New Archive Calendar
16 years ago
This afternoon, for want of anything better to do with the freezing cold outside and the housework inside, I wrote an archive calendar chalk extension for the website. It's over there on the far sidebar.
At present, it's a chalk extension and not a widget, although a widget should probably make more sense, given that it's in one of the Graffiti sidebars. However, for this first iteration I wanted to make a monthly calendar with links for those days when I'd published posts.
User stories were these:
-
The calendar should show a single complete month, with days when I'd posted something displayed as links.
-
The caption should show name of the month being displayed in the calendar.
-
The calendar caption should show the number of posts for that month.
-
Clicking on the calendar caption should go to a page listing the posts for that month. The calendar should stay the same on that new page.
-
Clicking on a day (providing it has posts and is a link) should go to the page listing the posts for that exact date. The calendar on that new page should show the month for the date whose posts are being displayed.
-
Underneath the calendar there should be a link to the previous month. Clicking it should do two things, first display the page for that month, and second change the calendar to display that new month.
-
Also underneath the calendar there should be a link to the next month, providing that this month is not in our future (so, for example, on the home page, there is no link to the next month). Clicking it should display the page for that month, and also change the calendar to display the new month.
-
Tooltips for the links should be specific to the month or date.
Up until now, I've been using an open-source Archive Widget, but haven't been that happy with it (for a start, it produces HTML that doesn't validate, you can only show posts for a single month, etc). Since it's written in VB, I wasn't particularly enamored with fixing it (I'm a C# guy at heart) and I really wanted a month calendar. But, nevertheless, I liked the way it worked, so I resolved to use the same infrastructure (that is, the same folder /archive
, the same views (at least their names), and the same request structure for passing the date along to the page).
Still to do:
-
Make it a widget so that it can play in the admin setup for sidebar widgets.
-
Employ some kind of caching for the lists of posts in a given month. In essence the same list is generated to display the page as is to display the month in the calendar (the calendar needs the list in order to work out which days to make links and also for the post count in the caption). So for displaying the complete page for December 2008, for example, the same query is run twice on the database. The original archive widget had caching, so I ought to implement something similar.
-
Clean up the code. At the moment it's a huge violation of the SRP (Single Responsibility Principle), although no method exceeds CC 5.
I'll admit I'd started out trying to use DevExpress' ASPxCalendar control, but I ran into issues of how to host an external control inside a Graffiti view — let alone a sidebar widget. I shall have to play with that some more at a later stage (I fancy creating a page that shows the posts as a schedule using ASPxScheduler). So, for this implementation I wrote the calendar display code from scratch, although I did employ the same techniques as I used in 1991 for a Turbo Vision calendar control (scary, eh?). I used the look-n-feel that Eric Meyer has on his blog.
Now playing:
Eighth Wonder - J'ai Pas Peur
(from I'm Not Scared)
Loading links to posts on similar topics...
No Responses
Feel free to add a comment...
Leave a response
Note: some MarkDown is allowed, but HTML is not. Expand to show what's available.
_emphasis_
**strong**
[text](url)
`IEnumerable`
* an item
1. an item
> Now is the time...
Preview of response