Re: [Emacsweblogs] Maintaining the same blog on two servers

2010-03-07 Thread Mark A. Hershberger
Ted Smith ted...@gmail.com writes:

 It seems to me that it would be a lot better to have the configuration
 support groups of blogs natively, instead of having a hack going through
 each blog and posting to it. This way, you could have more than one
 logical blog hosted on more than one blogging server each.

Agreed.  The functionality that is there is still buggy since it doesn't
track server-side information.  It just barely works.

 in emacs 23 (emacs-snapshot in Ubuntu karmic), but when I removed
 the /usr/share/emacs/site-lisp/easypg directory as per the debian bug
 report[1], encrypting it to my key failed (for some reason).

Interesting.  I may have run into the easypa bug in the past as well (I
don't recall) but I don't have any trouble encrypting files.  FWIW, I
use Gnome's seahorse-agent in Ubuntu to do passphrase caching.

Mark.

-- 
http://hexmode.com/

The only alternative to Tradition is bad tradition.
  — Jaraslov Pelikan


___
Emacsweblogs mailing list
Emacsweblogs@nongnu.org
http://lists.nongnu.org/mailman/listinfo/emacsweblogs


Re: [Emacsweblogs] Maintaining the same blog on two servers

2010-03-07 Thread Ted Smith
On Sun, 2010-03-07 at 19:22 -0500, Mark A. Hershberger wrote:
 Ted Smith ted...@gmail.com writes:
  in emacs 23 (emacs-snapshot in Ubuntu karmic), but when I removed
  the /usr/share/emacs/site-lisp/easypg directory as per the debian bug
  report[1], encrypting it to my key failed (for some reason).
 
 Interesting.  I may have run into the easypa bug in the past as well (I
 don't recall) but I don't have any trouble encrypting files.  FWIW, I
 use Gnome's seahorse-agent in Ubuntu to do passphrase caching.

Apparently I was just encrypting to the wrong key. PE(ed)BKAC.


signature.asc
Description: This is a digitally signed message part
___
Emacsweblogs mailing list
Emacsweblogs@nongnu.org
http://lists.nongnu.org/mailman/listinfo/emacsweblogs


Re: [Emacsweblogs] Maintaining the same blog on two servers

2010-03-02 Thread Mark A. Hershberger
Ted Smith ted...@gmail.com writes:

 I've never really hacked emacs lisp seriously, nor do I have much
 expertise in other lisps, so I doubt I'd be able to do it. If you think
 it would be simple for a beginner and were willing to hold my hand a
 bit, I could give it a shot, though...

Sure.  So, you can see the basic structure of a defun from looking
around, but if you need a more information on that, see the intro to
emacs lisp.
http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/defun.html

For simplicity, we'll assume that all the weblogs we're publishing to
are WordPress.  There are some differences between how weblogger.el
interacts with different weblog engines, but we won't let that bother us
for the moment.

Let's create a new key binding to publish to all configured weblogs in
weblogger-config-alist.  (Later we may want to be able to set up a way
to only publish to some of those, but, for now, let's keep it simple.)

Find the line reading

(define-key map \C-c\C-e 'weblogger-toggle-edit-body)

And add

(define-key map (kbd C-c C-m) 'weblogger-publish-to-all-weblogs)

(I'm switching to kbd here because it seems to provide a little better
cross-emacsen support.)

For information on key binding conventions, what is acceptable and what
isn't, see
http://www.gnu.org/software/emacs/elisp/html_node/Key-Binding-Conventions.html

Now we need to write the weblogger-publish-to-all-weblogs function:

(defun weblogger-publish-to-all-weblogs ()
  Publish to all weblogs in weblog-config-alist.
  (interactive)
  (let ((entry (weblogger-entry-buffer-to-struct))
weblogger-config-name weblogger-server-url
weblogger-server-username weblogger-server-password
weblogger-weblog-id)
(mapc (lambda (config)
(weblogger-switch-configuration (car config))
(weblogger-api-new-entry entry t))
  weblogger-config-alist)))

If you're reading this email in Emacs, you can put the point right
after the last parenthesis and hit “C-x C-e” to evaluate and load it.
Otherwise, you can copy-paste the above function into your *scratch*
buffer and use “C-x C-e” to evaluate it.

Notes on this function:

1. (interactive)

   This is required to tell Emacs that this function is interactive an
   should be made available to keystrokes.

2. (let ((entry (weblogger-entry-buffer-to-struct)) …

   Call the function weblogger-entry-buffer-to-struct and store the
   result in the temporary variable named “entry”.

3. (let (…
 weblogger-config-name weblogger-server-url
 weblogger-server-username weblogger-server-password
 weblogger-weblog-id)

Temporarily bind these variables to nil.  Their old values will be
restored once we're out of let's scope.

4. (mapc …
   weblogger-config-alist)

   mapc will iterate over each item in the variable
   weblogger-config-alist and pass it as an argument to the lambda
   function I've elided here.  This variable looks like this on my
   system:

((blogger test http://www.blogger.com/api; hexm...@gmail.com  
2462596)
 (wp_test http://www.winkyfrown.com/wordpress/xmlrpc.php; hexmode  
1)
 (movable_type http://www.winkyfrown.com/cgi-bin/mt/mt-xmlrpc.cgi; 
hexmode  1)
 (wordpress http://hexmode.wordpress.com/xmlrpc.php; hexmode  
1647614)
 (default http://www.openweblog.com/interface/blogger/; hexmode  
hexmode))

   On the first call, the lambda function will get

(blogger test http://www.blogger.com/api; hexm...@gmail.com  
2462596)

   in its config argument.  On the second call, 

(wp_test http://www.winkyfrown.com/wordpress/xmlrpc.php; hexmode  
1)

   and so on.

5. (lambda (config)
  (weblogger-switch-configuration (car config))
  (weblogger-api-new-entry entry t))

   The lambda just creates an anonymous function and returns it to mapc
   for use.  This function is pretty simple, it just switches the
   configuration.  Note that (car config) just returns the first element
   of config (blogger test, wp_test, etc) which then gets passed to
   weblogger-switch-configuration.

   Behind the scenes, weblogger-switch-configuration is changing those
   variables we temporarily bound to nil back in step 3.

   weblogger-api-new-entry takes the entry we stored in step 2 and
   published it.  The t indicates that the entry should be published and
   not saved as a draft (t and nil are Emacs Lisp's booleans).

6. I've split out some functionality from weblogger-select-configuration
   (an interactive function) and put it in a utility function.  You'll
   need this as well:

   (defun weblogger-switch-configuration (config)
Switch the configuration.
(let ((conf (cdr (assoc config weblogger-config-alist
  (setq weblogger-config-name config
weblogger-server-url  (nth 0 conf)
weblogger-server-username (nth 1 conf)
weblogger-server-password (nth 2 conf)
weblogger-weblog-id   (nth 3 conf

I've tested the 

Re: [Emacsweblogs] Maintaining the same blog on two servers

2010-03-02 Thread Ted Smith
On Tue, 2010-03-02 at 16:33 -0500, Mark A. Hershberger wrote:
 Ted Smith ted...@gmail.com writes:
 
  I've never really hacked emacs lisp seriously, nor do I have much
  expertise in other lisps, so I doubt I'd be able to do it. If you think
  it would be simple for a beginner and were willing to hold my hand a
  bit, I could give it a shot, though...
 
 Sure.  So, you can see the basic structure of a defun from looking
 around, but if you need a more information on that, see the intro to
 emacs lisp.
 http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/defun.html
 
 For simplicity, we'll assume that all the weblogs we're publishing to
 are WordPress.  There are some differences between how weblogger.el
 interacts with different weblog engines, but we won't let that bother us
 for the moment...
snip
 ...I've tested the above functions and they work.
 
Wow, thanks. I've done some functional programming (OCaml) and was able
to understand that fine. Thank you much for this; I can't tell you
enough how awesome this has been. I fully expected to get a response
like You're the first to bring it up; patches are welcome at best, but
I've been totally blown away.

 Oh, if you look over this, you'll notice that I don't store my passwords
 in weblogger-config-alist.  If you (or anyone else) is interested, I'll
 show you how you can store them in a separate file that is optionally
 GPG-encrypted.
I'd definitely be interested. 

  Thanks again! If all free software communities/developers were as
  inviting as you, we'd be a lot farther along the World Domination
  Roadmap :-)
 
 Aw, gee…  Well, don't get too used to it.  I had a lot of
 procrastinating to do today. ;)

I'll try not to :-). Thanks again!


signature.asc
Description: This is a digitally signed message part
___
Emacsweblogs mailing list
Emacsweblogs@nongnu.org
http://lists.nongnu.org/mailman/listinfo/emacsweblogs