Added org2blog-dir-add-new-photos
[org2blog.git] / main.el
blobcdb22ee1ebe544aae72578a450e34aff8e442021
1 ;;;_ org2blog/main.el --- Code for exporting org-mode to g-client
3 ;;;_. Headers
4 ;;;_ , License
5 ;; Copyright (C) 2010 Tom Breton (Tehom)
7 ;; Author: Tom Breton (Tehom) <tehom@panix.com>
8 ;; Keywords: convenience, tools, outlines
10 ;; This file is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; This file is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;;_ , Commentary:
27 ;;
30 ;;;_ , Requires
32 (require 'org)
33 (require 'org-exp)
34 (unless (boundp 'org-html-cvt-link-fn)
35 (error "Requires a different version of org-mode. See README.org"))
36 (require 'gblogger)
37 (require 'org2blog/l2r)
39 ;;;_. Body
40 ;;;_ , Setup
42 (add-hook 'g-app-afterpost-hook
43 #'org2blog-l2r-store-remote-url-yx)
45 ;;;_ , Make a post
46 ;;;###autoload
47 (defun org2blog-post ()
48 "Export the current org buffer to gblogger."
50 (interactive)
51 (unless (org-mode-p)
52 (error "Only useful in an org-mode buffer"))
54 (let*
56 (org-file-name (expand-file-name buffer-file-name))
57 (org-export-inbuffer-options-extra
58 '(("BLOGLABELS" :blog-labels)))
59 (plist (org-infile-export-plist))
60 (blog-labels
61 (let
62 ((labels-string
63 (plist-get plist :blog-labels)))
64 (if labels-string
65 (split-string labels-string "," t)
66 '())))
67 (title
68 (or
69 (plist-get plist :title)
70 nil))
71 (str
72 (let
73 ((org-html-cvt-link-fn #'org2blog-l2r-cvt-link))
74 (org-export-as-html nil nil nil 'string t)))
75 (url
76 (gblogger-blog->posting-url (gblogger-ensure-blog)))
77 (buffer
78 (gblogger-new-entry url title str org-file-name)))
79 (with-current-buffer buffer
80 (dolist (label blog-labels)
81 (gblogger-add-label label)))))
83 ;;;_ , org2blog-dir-add-new-photos
84 ;;;###autoload
85 (defun org2blog-dir-add-new-photos (directory album-name)
86 "Add photos in a directory to specified album except those
87 that are already on a remote site"
89 (interactive
90 (list
91 (read-directory-name "Directory: " default-directory nil t)
92 (gphoto-choose-album)))
93 (gphoto-directory-add-photos-x
94 directory
95 album-name
96 #'(lambda (file)
97 (not (org2blog-l2r-remote-url file)))))
100 ;;;_. Footers
101 ;;;_ , Provides
103 (provide 'org2blog/main)
105 ;;;_ * Local emacs vars.
106 ;;;_ + Local variables:
107 ;;;_ + mode: allout
108 ;;;_ + End:
110 ;;;_ , End
111 ;;; org2blog/main.el ends here