Created
September 25, 2012 14:54
-
-
Save syohex/3782422 to your computer and use it in GitHub Desktop.
View yapc asia schedule with helm interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; yapc-schedule.el --- View YAPC::Asia 2012 schedule with helm interface | |
;; Copyright (C) 2012 by Syohei YOSHIDA | |
;; Author: Syohei YOSHIDA <[email protected]> | |
;; URL: | |
;; Version: 0.01 | |
;; This program is free software; you can redistribute it and/or modify | |
;; it under the terms of the GNU General Public License as published by | |
;; the Free Software Foundation, either version 3 of the License, or | |
;; (at your option) any later version. | |
;; This program is distributed in the hope that it will be useful, | |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
;; GNU General Public License for more details. | |
;; You should have received a copy of the GNU General Public License | |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
;;; Commentary: | |
;;; Code: | |
(eval-when-compile | |
(require 'cl)) | |
(require 'helm) | |
(require 'json) | |
(defvar yapc-sched:url "http://yapcasia.org/2012/talk/schedule?format=json") | |
(defvar yapc-sched:dates '("2012-09-27" "2012-09-28" "2012-09-29")) | |
(defun yapc-sched:construct-url (date-str) | |
(format "%s&date=%s" yapc-sched:url date-str)) | |
(defun yapc-sched:get-schedule (url) | |
(with-temp-buffer | |
(let* ((cmd (format "curl -s '%s'" url)) | |
(ret (call-process-shell-command cmd nil t))) | |
(unless (zerop ret) | |
(error (format "Can't download: %s" url))) | |
(json-read-from-string (buffer-substring-no-properties | |
(point-min) (point-max)))))) | |
(defun yapc-sched:parse-schedule (json) | |
(loop for room across (assoc-default 'talks_by_venue json) | |
appending | |
(loop for talks across room | |
for title = (assoc-default 'title talks) | |
for abstract = (assoc-default 'abstract talks) | |
for start = (assoc-default 'start_on talks) | |
for speaker-info = (assoc-default 'speaker talks) | |
for name = (assoc-default 'nickname speaker-info) | |
collect | |
(cons (format "%s:%s@%s" start name title) abstract)))) | |
(defun yapc-sched:schedule () | |
(let* ((date (completing-read "Date: " yapc-sched:dates nil t)) | |
(url (yapc-sched:construct-url date))) | |
(yapc-sched:parse-schedule (yapc-sched:get-schedule url)))) | |
(defvar yapc-sched:abstract-buffer (get-buffer-create "*helm abstract*")) | |
(defvar yapc-sched:source | |
'((name . "YAPC Schedule") | |
(candidates . (lambda () | |
(sort* (yapc-sched:schedule) #'string< :key #'car))) | |
(persistent-action . (lambda (c) | |
(helm-c-switch-to-buffer yapc-sched:abstract-buffer) | |
(erase-buffer) | |
(insert (replace-regexp-in-string " | |
" "" c)))))) | |
(defun helm-yapc-schedule () | |
(interactive) | |
(let ((buf (get-buffer-create "*helm yapc schedule*"))) | |
(helm :sources '(yapc-sched:source) :buffer buf))) | |
(provide 'yapc-schedule) | |
;;; yapc-schedule.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment