ConfigurationUserThis sets the necessary access parameters to the del.icio.us site: (setq delicious-api-user "MyUsername") (setq delicious-api-password "MyPassword") (setq delicious-api-from "MyMail") StorageI do store the links in a folder that also holds my website because the links are primarily used on the website. delicious-posts-file-name (concat work-dir "/private/links/delicious") delicious-cache-file (concat work-dir "/private/links/delicious-cache") Publishing links with museMy versionThis is currently still a very rough hack and could use some improvement. Wonder when I'll find the time for it... In order to have del.icio.us link sections in muse several pieces are necessary. Two new tags need to be defined for the muse mode: delistart and deliend. In order for muse to understand the constructs I added a publishing directive for these tags:
(defun muse-publish-delicious-tags (beg end)
(muse-publish-escape-specials beg end)
(let ((tags (buffer-substring-no-properties beg end)))
(delete-region beg end)
(if (string-match "^\\s-+" tags)
(setq tags (replace-match "" nil t tags)))
(if (string-match "\\s-+$" tags)
(setq tags (replace-match "" nil t tags)))
(while (string-match "\\s-+" tags)
(setq tags (replace-match "+" nil t tags)))
(insert (muse-markup-text 'begin-delicious))
(insert delicious-api-user)
(insert (muse-markup-text 'middle-delicious))
(insert tags)
(insert (muse-markup-text 'end-delicious))
(muse-publish-mark-read-only beg (point))))
(defun muse-publish-delicious-end-tags (beg end)
(muse-publish-escape-specials beg end)
(let ((tags (buffer-substring-no-properties beg end)))
(delete-region beg end)))
(setq muse-html-markup-strings
(append '((begin-delicious . "<div class='delitags'><a href='http://del.icio.us/")
(middle-delicious . "/")
(end-delicious . "'>Same section in del.icio.us</a></div>"))
muse-html-markup-strings))
(setq muse-publish-markup-tags
(append '(("delistart" t nil muse-publish-delicious-tags)
("deliend" t nil muse-publish-delicious-end-tags))
muse-publish-markup-tags))
This replaces the <delistart>tag1 tag2</delistart>section with a link to the corresponding del.icio.us page and ignores the deliend tags. In order to actually add the data to the Links section the following function is used:
(defun muse-delicious-paste ()
"Search for a delicious section and replace it with the links matching
the tags specified in the header of the section."
(interactive)
(widen)
(goto-char (point-min))
(while (re-search-forward "\\s-*<delistart>\\(.*\\)</delistart>\\s-*$" nil t)
(save-excursion
(save-restriction
(let ((beghead (match-beginning 0))
(endhead (match-end 0))
(tags (match-string 1))
(endsection (if (re-search-forward "<deliend>\\(.*\\)</deliend>\\s-*$" nil t)
(match-beginning 0) (point-max))))
(narrow-to-region beghead endsection)
(delete-region endhead endsection)
(insert "\n")
(mapc
(lambda (post)
(let* ((href (cdr (assoc "href" post)))
(desc (cdr (assoc "description" post)))
(link (planner-make-link href desc)))
(insert " - " link "\n")))
(delicious-posts-matching-tags tags))
(insert "\n"))))))
This will delete any content between the two tags and insert the selected links. Currently I use this function interactively so the links on the pages are only up-to-date if I actually run the function before publishing. There are certainly ways to automatize this process but I still have to determine how to achieve that. John Sullivans versionThis is the current version from John who programmed delicious.el. I still have to go through this and see what he changed. And ultimately it would be nice to get the redundant delistart and deliend tags reduced to a single delicious tag. (defun muse-publish-delicious-tags (beg end)
(defun muse-publish-delicious-end-tags (beg end)
(add-to-list 'muse-publish-markup-tags '("delistart" t nil muse-publish-delicious-tags)) (add-to-list 'muse-publish-markup-tags '("deliend" t nil muse-publish-delicious-end-tags)) ;; Write functions using SORT to compare the date fields. (defun delicious-sort-date-descending (posts)
(defun delicious-sort-date-ascending (posts)
Back to Personal Wiki |