Re: [O] another blog exporter

2014-03-04 Thread Robert Klein
Hello,

thank you very much for your feedback.


On 02/10/2014 12:30 PM, Nicolas Goaziou wrote:
> Hello,
> 
> Bastien  writes:
> 
>> Somehow this calls for a way to let a backend use several affiliated
>> keywords.  For example you would have:
>>
>> #+ATTR_HTML: :width 400px
>> #+ATTR_BLOG: :lineno t
> 
> Org already provided a syntax to number lines in source blocks. Couldn't
> it be used instead?
> 
>   #+begin_src emacs-lisp -n
>   ...
>   #+end_src
> 

Thanks a lot, I didn't know about this feature. Now I use the -n/+n
flags.  When using -n flag the ATTR_BLOG attribute :firstline is used as
the first line number; the default is 1 as in the LaTeX exporter.


>> and the exporter would take both into account, letting you to simply
>> export to HTML without the need to add redundant information.
>>
>> Nicolas, did this cross your mind?  Or maybe this is already feasible?
> 
> This is already feasible. See `org-beamer-plain-list' for an example.
> Both #+attr_latex and #+attr_beamer are read but the latter has
> precedence over the former.

I already use this, but I felt a need to document those attributes that
get extra treatment: wordpress uses class="alignleft" instead of HTML
align="right"  and I changed the style handling to support surrounding
double quotes ( :style "margin: 9pt; background: red;" )

Best regards
Robert




Re: [O] another blog exporter

2014-02-10 Thread Nicolas Goaziou
Hello,

Bastien  writes:

> Somehow this calls for a way to let a backend use several affiliated
> keywords.  For example you would have:
>
> #+ATTR_HTML: :width 400px
> #+ATTR_BLOG: :lineno t

Org already provided a syntax to number lines in source blocks. Couldn't
it be used instead?

  #+begin_src emacs-lisp -n
  ...
  #+end_src

> and the exporter would take both into account, letting you to simply
> export to HTML without the need to add redundant information.
>
> Nicolas, did this cross your mind?  Or maybe this is already feasible?

This is already feasible. See `org-beamer-plain-list' for an example.
Both #+attr_latex and #+attr_beamer are read but the latter has
precedence over the former.


Regards,

-- 
Nicolas Goaziou



Re: [O] another blog exporter

2014-02-10 Thread Bastien
Hi Robert,

Robert Klein  writes:

> I posted the latest three posts on http://www.xyzzy.de using
> ox-blog.

Neat, thanks!

> I can use #+ATTR_HTML, but I wasn't sure about using new attributes,
> e.g. :highlight and :lineno for source blocks.  I didn't want to pollute
> ATTR_HTML with things that are of no use for the HTML exporter.

You're right.

Somehow this calls for a way to let a backend use several affiliated
keywords.  For example you would have:

#+ATTR_HTML: :width 400px
#+ATTR_BLOG: :lineno t

and the exporter would take both into account, letting you to simply
export to HTML without the need to add redundant information.

Nicolas, did this cross your mind?  Or maybe this is already feasible?

> If you don't see a problem in #+ATTR_HTML, I'll happily change this.

No, that will pollute the HTML export (I don't expect anything weird
in the HTML output with unknown attributes, but the document will not
validate correctly, and this is confusing anyway.)

Thanks!

-- 
 Bastien



Re: [O] another blog exporter

2014-02-09 Thread Robert Klein
Hi Bastien,

On 02/09/2014 08:55 AM, Bastien wrote:
> Hi Robert,
> 
> Robert Klein  writes:
> 
>> I put ox-blog on github:
>>
>> https://github.com/roklein/ox-blog
> 
> Thanks for your work on this, looks neat.
> 
> Do you have an example website produced by ox-blog?
> 
> Also, I see you use a new #+ATTR_BLOG keyword.
> Is this needed for images and such?  I'd expect
> #+ATTR_HTML would be enough here, users won't
> want to use both #+ATTR_HTML and #+ATTR_BLOG
> I guess.

I posted the latest three posts on http://www.xyzzy.de using ox-blog.


I can use #+ATTR_HTML, but I wasn't sure about using new attributes,
e.g. :highlight and :lineno for source blocks.  I didn't want to pollute
ATTR_HTML with things that are of no use for the HTML exporter.

If you don't see a problem in #+ATTR_HTML, I'll happily change this.

Thanks for the feed-back!

Best regards
Robert






Re: [O] another blog exporter

2014-02-08 Thread Bastien
Hi Robert,

Robert Klein  writes:

> I put ox-blog on github:
>
> https://github.com/roklein/ox-blog

Thanks for your work on this, looks neat.

Do you have an example website produced by ox-blog?

Also, I see you use a new #+ATTR_BLOG keyword.
Is this needed for images and such?  I'd expect
#+ATTR_HTML would be enough here, users won't
want to use both #+ATTR_HTML and #+ATTR_BLOG
I guess.

Best,

-- 
 Bastien



Re: [O] another blog exporter

2014-02-08 Thread Robert Klein
Hi,

I put ox-blog on github:

https://github.com/roklein/ox-blog

I removed the unnecessary org-blog-example-block and added some
attributes to be used with source blocks (line numbers, highlighting of
lines, title).

Best regards
Robert



On 02/07/2014 06:10 PM, Robert Klein wrote:
> Hi,
> 
> around the org-mode 8.0 release I began to write a new blog exporter
> using the new export framework.
> 
> I wanted one feature org2blog didn't offer, support for different syntax
> highlighters, and i wanted to learn about the new exporter and Emacs
> programming.
> 
> Around Christmas I did some polishing to make it ready for a greater public.
> 
> Would there a place for it in contrib/ or is it better suited for a
> github repository?
> 
> Thanks and best regards
> Robert
> 




Re: [O] another blog exporter

2014-02-08 Thread Robert Klein
Hi Ken

On 02/08/2014 01:27 AM, Ken Mankoff wrote:
> Hi Robert,
> 
> On Fri, 7 Feb 2014, Robert Klein wrote:
>> around the org-mode 8.0 release I began to write a new blog exporter
>> using the new export framework.
>>
>> I wanted one feature org2blog didn't offer, support for different
>> syntax highlighters, and i wanted to learn about the new exporter and
>> Emacs programming.
> 
> Does your exporter work across multiple files (one file per post), or
> only one file?
> 
>   -k.
> 


It works both ways, just like the other exporters:

C-c C-e b ... exports the whole file
C-c C-e C-s b ... exports the current subtree

If you set up the `org-blog-project-alist', all files in the
`base-directory' can be exported.


Best regards
Robert



Re: [O] another blog exporter

2014-02-07 Thread Ken Mankoff

Hi Robert,

On Fri, 7 Feb 2014, Robert Klein wrote:
around the org-mode 8.0 release I began to write a new blog 
exporter using the new export framework.


I wanted one feature org2blog didn't offer, support for different 
syntax highlighters, and i wanted to learn about the new exporter 
and Emacs programming.


Does your exporter work across multiple files (one file per post), 
or only one file?


  -k.



Re: [O] another blog exporter

2014-02-07 Thread Robert Klein
Hi Rasmus,


thank you very much for your feedback!

On 02/07/2014 06:35 PM, Rasmus wrote:
> Could you provide an example blog so that we can see the output?

The two latest posts ("FreeBSD" and "DHCP") at http://www.xyzzy.de/

I put the original org for download at the end of both posts.


>> ;;; Transcode Functions
>>
>>  Example Block
>>
>> (defun org-blog-example-block (example-block contents info)
>>   "Transcode a EXAMPLE-BLOCK element from Org to HTML.
>> CONTENTS is nil.  INFO is a plist holding contextual
>> information."
>>   (if (org-export-read-attribute :attr_html example-block :textarea)
>>   (org-html--textarea-block example-block)
>> ;;; beginnin here we need org/wp-syntac/syntaxhl information
>> (format "\n%s"
>>  (org-html-format-code example-block info
> 
> Isn't this an exact copy of the corresponding entry in ox-html (Less
> the name)?  Why?
> 

- org-blog-example-block /is/ an exact copy, I planned to add the
  highlighters here, too, and to support line numbers.  Forgot it :(

- org-blog-latex-environment adds support for =#+ATTR_BLOG:=

- org-blog-latex-fragment currently also is an exact copy.  I'm not sure
  mathjax works, so I put it here for further work.

- org-blog-link supports =attr_blog= and fills the list of images to be
  uploaded. (I really hated to copy this one... in an earler version I
  cl-flet-ted org-html--format-image to avoid copying this one.

for org-blog-export-[as|to]-blog, I had no choice. :)


I just found out, when I introduced scheduled posting I broke unscheduled
posting; this is the patch:

--- emacs/ox-blog.el2014-01-21 10:57:50 +
+++ emacs/ox-blog.el2014-02-07 18:38:52 +

@@ -1089,7 +1089,7 @@
;; administrator may post
(post-status (cond ((equal draft-or-publish-p "draft") "draft")
   ((equal "contributor" user-role) "pending")
-  ((and publish-datetime
+  ((and (not (string= "" publish-datetime))
 (or (equal "author" user-role)
 (equal "administrator" user-role)))
"future")


Best regards and thank you very much for the feedback,
Robert




Re: [O] another blog exporter

2014-02-07 Thread Rasmus
Robert Klein  writes:

> Hi,
>
> around the org-mode 8.0 release I began to write a new blog exporter
> using the new export framework.
>
> I wanted one feature org2blog didn't offer, support for different syntax
> highlighters, and i wanted to learn about the new exporter and Emacs
> programming.
>
> Around Christmas I did some polishing to make it ready for a greater public.

Cool.

Could you provide an example blog so that we can see the output?

> ;;; Transcode Functions
>
>  Example Block
>
> (defun org-blog-example-block (example-block contents info)
>   "Transcode a EXAMPLE-BLOCK element from Org to HTML.
> CONTENTS is nil.  INFO is a plist holding contextual
> information."
>   (if (org-export-read-attribute :attr_html example-block :textarea)
>   (org-html--textarea-block example-block)
> ;;; beginnin here we need org/wp-syntac/syntaxhl information
> (format "\n%s"
>   (org-html-format-code example-block info

Isn't this an exact copy of the corresponding entry in ox-html (Less
the name)?  Why?

>  Latex Environment
>
> (defun org-blog-latex-environment (latex-environment contents info)
>   "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
> CONTENTS is nil.  INFO is a plist holding contextual information."
>   (let ((processing-type (plist-get info :with-latex))
>   (latex-frag (org-remove-indentation
>(org-element-property :value latex-environment)))
>   (attributes (org-combine-plists
>  (org-export-read-attribute :attr_html latex-environment)
>  (org-export-read-attribute :attr_blog 
> latex-environment
> (case processing-type
>   ((t mathjax)
>(org-html-format-latex latex-frag 'mathjax info))
>   ((dvipng imagemagick)
>(let ((formula-link
> (org-html-format-latex latex-frag processing-type info)))
>(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
>  ;; Do not provide a caption or a name to be consistent with
>  ;; `mathjax' handling.
>  (org-html--wrap-image
>   (org-blog--format-image
>(match-string 1 formula-link) attributes info) info
>   (t latex-frag

Same.  There seems to be a couple of these. . .

Rasmus

-- 
Don't panic!!!




[O] another blog exporter

2014-02-07 Thread Robert Klein
Hi,

around the org-mode 8.0 release I began to write a new blog exporter
using the new export framework.

I wanted one feature org2blog didn't offer, support for different syntax
highlighters, and i wanted to learn about the new exporter and Emacs
programming.

Around Christmas I did some polishing to make it ready for a greater public.

Would there a place for it in contrib/ or is it better suited for a
github repository?

Thanks and best regards
Robert

;;; ox-blog.el --- Blog Back-End for Org Export Engine

;; Copyright (C) 2013, 2014  Robert Klein

;; Author: Robert Klein 
;; Keywords: WordPress, HTML

;; This file is not part of GNU Emacs.

;; 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 .

;;; Commentary:

;; This library implements an blog back-end for the Org
;; generic exporter.

;; To test it, run:
;;
;;   M-x org-blog-export-as-html
;;
;; in an Org mode buffer.  See ox.el and ox-html.el for more details
;; on how this exporter works.

;;; Code:
(require 'ox-html)  ;; in turn requires ox-publish and ox.
(require 'xml-rpc)
; (require 'wp-xml-rpc)
; (require 'cl)

(org-export-define-derived-backend 'blog 'html
  :menu-entry
  '(?b "Export to WP Blog Presentation"
   ((?H "To temporary buffer" org-blog-export-as-html)
	(?h "To file" org-blog-export-to-html)
(?d "To blog as draft" org-blog-export-to-blog-as-draft)
(?p "To blog and publish" org-blog-export-to-blog-as-publish)
	(?o "To file and open"
	(lambda (a s v b)
	  (if a (org-blog-export-to-html t s v b)
		(org-open-file (org-blog-export-to-html nil s v b)))
  :options-alist
  '((:blog-url "BLOG_URL" nil nil t)
(:blog-username "BLOG_USERNAME" nil nil t)
(:blog-id "BLOG_ID" nil nil t)
(:blog-password "BLOG_PASSWORD" nil nil t)
(:blog-post-id "BLOG_POST_ID" nil nil t)
(:blog-publish-datetime "BLOG_PUBLISH_DATETIME" nil nil t)
(:blog-post-type "BLOG_POST_TYPE" "post-type" org-blog-post-type t)
(:blog-syntax-highlighter "BLOG_SYNTAX_HIGHLIGHTER" "bloghl"
  org-blog-syntax-highlighter t)
(:blog-timezone "BLOG_TIMEZONE" "blogtz" nil t)
(:blog-tags "BLOG_TAGS" nil org-blog-tags newline)
(:blog-confirm-new-tags "BLOG_CONFIRM_NEW_TAGS" nil
org-blog-confirm-new-tags t)
(:blog-categories "BLOG_CATEGORIES" nil org-blog-categories newline)
(:blog-confirm-new-categories "BLOG_CONFIRM_NEW_CATEGORIES"
  nil org-blog-confirm-new-categories t)
(:blog-use-tags-as-categories "BLOG_USE_TAGS_AS_CATEGORIES" nil nil t)
(:blog-upload-filetypes "BLOG_UPLOAD_FILETYPES" nil org-blog-upload-filetypes split))
  :translate-alist
  '(;(inner-template . org-blog-inner-template) ;; use org-html-inner-template
(example-block . org-blog-example-block)
(keyword . org-blog-keyword)
(latex-environment . org-blog-latex-environment)
(latex-fragment . org-blog-latex-fragment)
(link . org-blog-link)
(src-block . org-blog-src-block)
(template . org-blog-template)))



;;; Internal variables

;(defvar org-blog-id 1
;  "ID of blog.  Typically 1.")


(defvar org-blog-files-to-upload nil
  "A list containing the file names to upload to the blog.")


(defvar org-blog-image-list nil
  "Images to upload/change URL in buffer.")


;;; User Configuration Variables

(defgroup org-export-blog nil
  "Options for exporting Org mode files to a wordpress based blog."
  :tag "Org Export Blog"
  :group 'org-export)

(defcustom org-blog-project-alist nil
  "Association list to control blog publication behavior.
Eash element of the alist is a blog 'project.'  The CAR of each
element is a string, uniquely identifying the project.  The CDR
of each element is in the following form:

1. A well-formed property list with an even number of elements,
   alternating keys and values, specifying parameters for the
   publishing process.

When a property is given a value in `org-blog-project-alist',
its setting overrides the value of the corresponding user
variable (if any) during publishing.  However, options set within
a file override everything.

Most properties are optional, but some should always be set:

  `:base-directory'

Directory containing publishing source files.

  `:blog-url'

Blog where posts will be published.

  `:blog-id'

Blog ID; usually `1'.

Some properties control details of the Org publishing proces