org2blog/common/l2r-remote-url treats "file:///" prefix now
[org2blog.git] / common / l2r.el
blobab2014ce9f7d6ae2afe19f095b5e19e198664fd4
1 ;;;_ org2blog/common/l2r.el --- Persistence for org2blog
3 ;;;_. Headers
4 ;;;_ , License
5 ;; Copyright (C) 2010 Tom Breton (Tehom)
7 ;; Author: Tom Breton (Tehom) <tehom@panix.com>
8 ;; Keywords: lisp, internal
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 ;; Acquisition functionality for particular modules is in the
28 ;; respective modules (all two of them)
31 ;;;_ , Requires
33 (require 'tinydb/persist)
35 ;;;_. Body
37 ;;;_ , Convert links as Atom indicates
38 ;;;_ . Customization
39 ;;Should be absolutized (another variable, internal?). And should
40 ;;fetch it on a per-directory basis.
41 (defcustom org2blog/common/l2r-alist-file
42 "~/.org2blog-local2remote-alist"
43 "File that contains the persisting alist from local filenames to
44 remote URLs"
45 :type 'file
46 :group 'org)
47 ;;;_ . Variables
48 (defvar org2blog/common/l2r-tq
49 (tinydb-persist-make-q org2blog/common/l2r-alist-file '())
50 "Tiny db object for org2blog/common/l2r" )
52 ;;;_ . org2blog/common/l2r-remote-url
53 (defun org2blog/common/l2r-remote-url (path)
54 "Return the persisting translation of PATH."
55 (let*
56 ( (path
57 (if (string-match "file://" path)
58 (substring path (match-end 0))
59 path))
60 (true-path (expand-file-name path)))
61 (cadr
62 (tinydb-alist-assoc org2blog/common/l2r-tq true-path))))
64 ;;;_ . org2blog/common/l2r-cvt-link
65 (defun org2blog/common/l2r-cvt-link (opt-plist type path)
66 "Convert arguments to (type path) list of the remote url."
67 (declare (ignored opt-plist))
68 (let
69 ((cvted-path
70 (org2blog/common/l2r-remote-url path)))
71 (when cvted-path
72 (list type cvted-path))))
74 ;;;_ . org2blog/common/l2r-store-remote-url
75 (defun org2blog/common/l2r-store-remote-url (filepath url)
76 "Persistingly store the translation from FILEPATH to URL."
77 (assert (file-name-absolute-p filepath) t)
78 (tinydb-alist-pushnew
79 org2blog/common/l2r-tq filepath (list url)))
80 ;;;_ . org2blog/common/l2r-store-remote-url-yx
81 ;;;###autoload
82 (defun org2blog/common/l2r-store-remote-url-yx (url filepath)
83 "Persistingly store the translation from FILEPATH to URL.
84 An arg-conformant version of `org2blog/common/l2r-store-remote-url'"
85 (assert (file-name-absolute-p filepath) t)
86 (tinydb-alist-pushnew
87 org2blog/common/l2r-tq filepath (list url)))
89 ;;;_. Footers
90 ;;;_ , Provides
92 (provide 'org2blog/common/l2r)
94 ;;;_ * Local emacs vars.
95 ;;;_ + Local variables:
96 ;;;_ + mode: allout
97 ;;;_ + End:
99 ;;;_ , End
100 ;;; org2blog/common/l2r.el ends here