emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Blogging from org-mode


From: Samuel Wales
Subject: Re: [Orgmode] Blogging from org-mode
Date: Sun, 16 Jan 2011 15:59:12 -0700

On 2011-01-16, Tom Breton (Tehom) <address@hidden> wrote:
> Please tell me if I've missed any other org-based blogging software (other
> than the blog hosting software which is a different category).

Right, there are hosted blogs (like Blogger) and self-hosted blogs
(where you run the software).

Here is the latest version of my Blogger command.

I wrote it for these reasons:

  1) should work with all recent versions of Emacs including 22
  2) works on subtrees (not files)
  3) does not require any downloads of Google software (self-contained)
  4) handles H levels correctly
  5) uses subtree top level headline as a title
  6) shows you the HTML
  7) doesn't include stuff I don't want there (author etc.)

The only change I would make, but cannot do for health
reasons, is to make it work with mail2blogger.

I would be delighted if there were some other protocol that
it could use.

Could your API work to send the result to Blogger?  If so,
how?  Do you have to sign up with Google in some special way
or does it work just through the web?

Thanks.

Samuel


(defun alpha-org-blog-subtree ()
  "Copy the subtree, converted to HTML, for pasting into Blogger
as a blog post.

No other software needs to be installed.

===

For an example of this code in action, see
http://thekafkapandemic.blogspot.com/ .

You have to turn off Blogger's conversion of newline to br tags
in two places.  This requires the new editor.

mail2blogger is a very intriguing option here and I'd like to do
that.  Avoids the web entirely.  See comments.

To display the results in a browser, use M-x browse-url-of-buffer
.

No temporary file is created.

===

Mark pages (About, Contribute, etc.) with the tag, :page:.  This
will remove the top headline.  The reason is that Blogger pages
always include the title as the name of the page and it looks
silly to have two titles.

===

You should turn off Blogger's showing of titles.

Turning off the titles has one convenience: you don't have to
enter it manually.  It also has one drawback: people who link to
your post by copying that link cannot do so (they can get it from
other places, including the URL bar and Archives in the sidebar).
Perhaps mail2blogger will fix that by letting you set the title
by email subject.

Of course you can manually enter the title.  In which case
use :page:.

===

I use Blogger.com instead of Wordpress.com because it appears to
have a better attitude toward accessibility.
"
  (interactive)

;;; todo list
;;;
;;; === mail2blogger ===
;;;
;;; I tried using mail2blogger, but the HTML got posted.  There might
;;; be a way to fix this.  How do you do an HTML email in a format
;;; that gets recognized as HTML?
;;;
;;; We want to use raw programmatic email, such as sent using msmtp
;;; or the built-in Emacs client.  The ability to do so will obviate
;;; the need to use Google's command line client or to run Emacs 23.
;;;
;;; This is the next thing to try.  Patch welcome.  I have no idea
;;; how to do it.
;;;
;;; ===
;;;
;;; Another good thing to try would be to automate grabbing the source from
;;; the page automatically to compare what you just created with ediff or
;;; git diff --color-words.  This is for edits.
;;;
;;; Also, export whole blog before each post for git.  Requires post
;;; method maybe.  How to do that?
;;;
;;; Also, check for fixmes.  (Or org could check for fixmes before
;;; all export.  Is there a hook?)
;;;
;;; Also, remind you to extract big chunks of comments for possible ohter
;;; blog entries.
;;;
;;; /Also, remind you to make sure all links work and review formatting/.
;;;
;;; ===
;;;
;;; Is there HTML for a title?  I will guess not.

  (save-excursion
    ;;say about to publish editing or about to publish post.  with
    ;;mail2blogger, we can automate this and assume publish.
    ;;
    ;;technically, this should be later in case you kill something inside
    ;;the note.
    ;;
    ;;(let ((k kill-ring))
    ;;(let ((c (car kill-ring)))
    (org-add-note)
    ;;
    ;;could add sugu here.  donekeep or tag should be done manually.
    ;;
    ;;how do we want blogs to sort?  probably donekeep.  probably not by
    ;;latest edit but by publish.

    ;;i have an issue with "--", which is perfect for emdash in ascii, but
    ;;gets converted to endash in html.  i'd like it to be emdash in html.
    ;;is there an option for that?
    ;;
    ;;if not, we have to replace -- with --- somehow here before exporting.
    ;;that requires a temporary buffer.

    ;;org converts headlines to html h numbers according to the level in the
    ;;org file, not the level in the region.  i prefer the latter.
    ;;
    ;;kludge it.
    ;;
    ;;for a blog we want it to start with delta 0 = h1.  delta 1 respects
    ;;the variable.
    ;;
    ;;for some reason, blogger does not format h2 bold on firefox.  so h3
    ;;looks bigger?  if so, do delta 2.  css wizards please weigh in on this.
    (let ((delta 2))
      (outline-mark-subtree)
      (when (member "page" (org-get-tags))
        ;;remove title
        (forward-line 1)
        ;;might be nice to add hr here
        ;;we will start with the first headilne's title
        (decf delta))
      (switch-to-buffer
       (let ((org-export-html-toplevel-hlevel
              (+ delta (- org-export-html-toplevel-hlevel
                          (org-reduced-level (org-current-level)))))
             (org-export-headline-levels
              (+ delta (- org-export-headline-levels
                          (org-reduced-level (org-current-level)))))
             org-export-with-tags
             org-export-with-todo-keywords
             org-export-with-timestamps
             ;;note: priority must be after todo kw for export
             ;;already nil org-export-with-priority
             )
         (org-export-region-as-html (region-beginning)
                                    (region-end)
                                    t
                                    ;;seems to erase, which we want
                                    (get-buffer-create
                                     ;;this should work if it is a *buffer*
                                     ;;but some might prefer html mode.
                                     ;;this does not save to a file unless
                                     ;;you do.
                                     "alpha-org-blog-subtree.html")))

       ;;one drawback is it leaves spaces around text.  like "tag> text".  there
       ;;might be other drawbacks.
       ;;(hoka-unfill-region-special (point-min) (point-max))
       ;;(goto-char (point-min))
       ;;this does not work because it will join lines with no space in between;
       ;;we have to actually fill paragraphs.
;;;   (while (search-forward "\n" nil t)
;;;     (replace-match ""))
;;;   (insert "\n")
       ;;unnec if blogger knows to treat whitespace as insignificant
;;;   (goto-char (point-min))
;;;   (delete-matching-lines "^$")
       (kill-ring-save (point-min) (point-max))))))

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com
I support WPI: http://www.wpinstitute.org/xmrv/index.html -- PLEASE DONATE
===
I want to see the original (pre-hold) Lo et al. 2010 NIH/FDA/Harvard MLV paper.
 -- [[file:~/Desktop/K/kpc/org/todo-new--a.org]]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]