From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: Converting org-mode/org-contacts to VCard (importing to Android) Date: Sat, 23 Nov 2013 16:36:22 +0800 Message-ID: <87li0fms55.fsf@news.tumashu-localhost.org> References: <2013-11-22T17-28-29@devnull.Karl-Voit.at> <3414130.xOGDSAomuL@descartes> <2013-11-22T17-57-08@devnull.Karl-Voit.at> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vk8l4-00045Z-3b for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 03:40:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vk8kz-0004rp-S4 for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 03:40:06 -0500 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]:44768) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vk8kz-0004pI-E6 for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 03:40:01 -0500 Received: by mail-pd0-f182.google.com with SMTP id v10so2404814pde.13 for ; Sat, 23 Nov 2013 00:39:59 -0800 (PST) Received: from news.tumashu-localhost.org ([120.4.247.91]) by mx.google.com with ESMTPSA id ik1sm31755400pbc.9.2013.11.23.00.39.57 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 23 Nov 2013 00:39:58 -0800 (PST) Received: from feng by news.tumashu-localhost.org with local (Exim 4.80) (envelope-from ) id 1Vk8hS-00057B-Dw for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 16:36:22 +0800 In-Reply-To: <2013-11-22T17-57-08@devnull.Karl-Voit.at> (Karl Voit's message of "Fri, 22 Nov 2013 18:09:42 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Karl Voit writes: > * R=FCdiger Sonderfeld wrote: >> On Friday 22 November 2013 17:37:01 Karl Voit wrote: >>> The reason I wrote it in Python is that I don't know ELISP well >>> enough. The reason I wrote the script instead of using existing >>> export methods: I only want to export a small sub-set (names, phone >>> numbers, email addresses, contact image) due to privacy reasons. >> >> That should be possible with the existing VCard export. See `org-contac= ts- >> ignore-property' to ignore specific properties. And `org-contacts-expor= t-as- >> vcard' takes a NAME parameter to limit the names. > > Fair enough :-) > > However, I did additional things like checks, filtering, and so > forth that were important to my data-set. E.g., my contact template > does contain "0043/" as a pre-filled content for phone numbers. I > wanted to ignore those fields that got only this template and not a > complete phone number. I also wanted to get warnings in case some > data does not fulfill certain other requirements. use (replace-regexp-in-string "^[0-9]\\{4,4\\}/" "" "0043/333/333") #+begin_src (defun org-contacts-vcard-format (contact) "Formats CONTACT in VCard 3.0 format." (let* ((properties (caddr contact)) (name (org-contacts-vcard-escape (car contact))) (n (org-contacts-vcard-encode-name name)) (email (cdr (assoc-string org-contacts-email-property properties))) (tel (cdr (assoc-string org-contacts-tel-property properties))) (ignore-list (cdr (assoc-string org-contacts-ignore-property properties))) (ignore-list (when ignore-list (org-contacts-split-property ignore-list))) (note (cdr (assoc-string org-contacts-note-property properties))) (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthday= -property properties)))) (addr (cdr (assoc-string org-contacts-address-property properties))) (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname= -property properties)))) (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name)) emails-list result phones-list) (concat head (when email (progn (setq emails-list (org-contacts-remove-ignored-property-values ignore-= list (org-contacts-split-property email))) (setq result "") (while emails-list (setq result (concat result "EMAIL:" (org-contacts-strip-link (car = emails-list)) "\n")) (setq emails-list (cdr emails-list))) result)) (when addr (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr))) (when tel (progn (setq phones-list (org-contacts-remove-ignored-property-values ignore-li= st (org-contacts-split-property tel))) (setq result "") (while phones-list (setq result (concat result "TEL:" (replace-regexp-in-string "^[0-9]= \\{4,4\\}/" "" (org-link-unescape (org-contacts-strip-link (car phones-lis= t)))) "\n")) (setq phones-list (cdr phones-list))) result)) (when bday (let ((cal-bday (calendar-gregorian-from-absolute (org-time-string-t= o-absolute bday)))) (format "BDAY:%04d-%02d-%02d\n" (calendar-extract-year cal-bday) (calendar-extract-month cal-bday) (calendar-extract-day cal-bday)))) (when nick (format "NICKNAME:%s\n" nick)) (when note (format "NOTE:%s\n" note)) "END:VCARD\n\n"))) #+end_src > > I have to admit that I don't know the feature-set of the Org-mode > export. I would be very surprised, if the Org-mode export method is > able to follow my custom "photo:" link I am using, grab the image > file, test if it has a image format that works with VCard > 2.1 on Android, and encodes it in base64 accordingly. > > You see: I want to have ways to tweak the export process. And as > long as I don't know ELISP that well, I stick to the tools I know. > > > A side remark of mine: a couple of months ago I tried to find out > how to store address information, phone numbers, and so on in > org-contact properties. AFAIR I could not find anything except the > :EMAIL: property. Is there a standard out there that answers > questions like "separate street from house number?", "how to cope > with multiple addresses for one contact?", and so forth? I created > something on my own as you can see on [1]. > > > I am happy if you can get benefit from my little project and I am > also happy when Org-mode offers a great export functionality for the > rest of us :-) > > 1. https://raw.github.com/novoid/org-contacts2vcard/master/testdata/tes= tcontacts.org--=20 > mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > > get Memacs from https://github.com/novoid/Memacs < > > https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on gi= thub --=20