[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Re: viewing appointments
From: |
Sacha Chua |
Subject: |
[emacs-wiki-discuss] Re: viewing appointments |
Date: |
Thu, 08 Jun 2006 12:43:43 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Phillip Lord <address@hidden> writes:
> views...the problem has been that you only get to see what you are
> doing today, rather than the result of the week coming up. This is
> fine until you find out at the beginning of the day that you are
> supposed to be at a meeting in Manchester and you are in Newcastle.
I have an HTML view somewhere.
;; Totally idiosyncratic way to display scheduled tasks on a weekly calendar
;; Example: http://sacha.free.net.ph/notebook/wiki/2005.10.02.php
;; Assembles weekly calendar through clever use of CSS and absolute
;; positioning inside relative-positioned blocks.
;; Code quirks: Calls planner-backend-output-file, which is something
;; like muse-output-file in planner-muse and emacs-wiki-published-file
;; in emacs-wiki. If you're not using planner--duo or planner--merge,
;; tweak this...
;; Add this to your CSS:
;; .week_calendar TD A { display: block; position: absolute; width: 100%;
overflow: hidden }
;; .week_calendar .timed TD { position: relative; height: 375px; width: 100px }
;; .week_calendar TD { width: 100px; }
;; .week_calendar TD DIV { position: relative }
;; .week_calendar LI { overflow: hidden; }
;; .q1 { background-color: red }
;; .q2 { background-color: yellow }
;; .unknown { background-color: gray }
;; Add this to a planner page:
;; <planner-tasks-table from="." to="+7">
(defun sacha/planner-tasks-table-tag (tag-beg tag-end attrs)
"Mark up tasks for this week.
Tags are of the form <planner-tasks-table from=\".\" to=\"+7\">."
(insert "<nowiki>" (sacha/planner-weekly-table (cdr (assoc "from" attrs))
(cdr (assoc "to" attrs)))
"</nowiki>"))
(add-to-list 'planner-publish-markup-tags '("planner-tasks-table" nil t
sacha/planner-tasks-table-tag))
;; Everything else is bubblegum and duct tape
(defun sacha/planner-weekly-class (task-info)
"Stylesheet class for TASK-INFO.
A Q1 task is urgent and important - red tasks.
A Q2 task is not urgent but is important - yellow tasks.
Everything else is colored gray."
(cond
((string-match "Q1" (planner-task-description task-info)) "q1")
((string-match "Q2" (planner-task-description task-info)) "q2")
(t "unknown")))
(defun sacha/planner-weekly-timed-task-line (info target)
"Turn INFO into a block describing the timed task, linking to TARGET."
(let ((info (or info (planner-current-task-info)))
start-time end-time
(pixels-per-hour 20)
(day-start (* 7 60)))
(unless (string= (planner-task-status info) "C")
(when (string-match
"@\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9][0-9][0-9]\\)"
(planner-task-description info))
(setq start-time (string-to-number (match-string 1
(planner-task-description info))))
(setq end-time (string-to-number (match-string 2
(planner-task-description info))))
(setq start-time (+ (% start-time 100) (* (/ start-time 100) 60)))
(setq end-time (+ (% end-time 100) (* (/ end-time 100) 60))))
(when (and start-time end-time)
(format "<a href=\"%s\" title=\"%s\" class=\"%s\" style=\"top: %spx;
height: %spx\">%s</a>\n"
target
(planner-task-description info)
(sacha/planner-weekly-class info)
(number-to-string (round (* (/ (- start-time day-start) 60.0)
pixels-per-hour)))
(number-to-string (round (* (/ (- end-time start-time) 60.0)
pixels-per-hour)))
(planner-task-description info))))))
(defun sacha/planner-weekly-timed-tasks-for-day (target)
"Return a list of all the timed tasks in the current buffer, linked to
TARGET."
(goto-char (point-min))
(let (lines)
(while (re-search-forward planner-task-regexp nil t)
(setq lines (concat lines (or (sacha/planner-weekly-timed-task-line
(planner-current-task-info) target) ""))))
(concat "<div>" lines "</div>")))
;; I thought about using this, but then I dropped it.
(defun sacha/planner-weekly-untimed-tasks-for-day (target)
"Return a list of all the untimed tasks in the current buffer, linked to
TARGET."
(goto-char (point-min))
(let (lines)
(while (re-search-forward planner-task-regexp nil t)
(let ((info (planner-current-task-info)))
(unless (string-match
"@\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9][0-9][0-9]\\)"
(planner-task-description info))
(setq lines (concat lines
(format "<li><a href=\"%s\" title=\"%s\"
class=\"%s\">%s</a></li>"
target
(planner-task-description info)
class
(planner-task-description info)))))))
(concat "<ul>" lines "</ul>")))
(defun sacha/planner-weekly-table (from to)
"Create a table with timed task entries defined by FROM and TO."
(let* ((planner-dates-relative-to-today-flag nil)
(pages (planner-get-day-pages (planner-expand-name from)
(planner-expand-name to)))
result-timed
result-untimed
header
date)
(with-temp-buffer
(with-planner
(while pages
(erase-buffer)
(insert-file-contents (planner-page-file (car pages)))
(setq date (planner-filename-to-calendar-date (car pages)))
(setq header (concat (format "<th><a href=\"%s\">%s %d</a></th>"
(concat (car pages) ".php")
(calendar-day-name date t)
(extract-calendar-day date)) header))
(setq result-timed
(concat "<td>" (sacha/planner-weekly-timed-tasks-for-day
(concat (car pages) ".php")) "</td>"
result-timed))
(setq pages (cdr pages))))
(setq result (concat "<table class=\"week_calendar\"><tr>" header
"</tr><tr class=\"timed\">" result-timed
"</tr></table>")))
result))
--
Sacha Chua <address@hidden> - http://sacha.free.net.ph/
Technology evangelist wannabe and apprentice of all things
University of Toronto - IBM Center for Advanced Studies, Toronto
Interest: enterprise social computing (particularly bookmarking)