Maintaining the same blog on two servers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Maintaining the same blog on two servers

Ted Smith-2
Is there any way to configure/hack weblogger such that you could publish
the same post to two different servers? Has this ever been done or
discussed?

Great package, by the way. I beginning to think I would have to write
blog posts in emacs, then copy/paste them into a GTK client. Thanks!

- Ted Smith

_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs

signature.asc (852 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Mark A. Hershberger
Ted Smith <[hidden email]> writes:

> Is there any way to configure/hack weblogger such that you could publish
> the same post to two different servers? Has this ever been done or
> discussed?

It hasn't been done.  I don't think anyone (but me) has discussed it.

But, now that you mention it, I think it is time to start working on it.

The change to enable this should be pretty simple.  Basically, create a
function that you can call with a post and a list of weblogs to post it
to.  It would then post to each of those weblogs.

If you want (and you have the Emacs Lisp skill), you can go ahead and do
that.  Otherwise, now that this has been bumped, I'll probably get it
done soon.

Mark.

--
http://hexmode.com/

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


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Ted Smith-2
On Mon, 2010-03-01 at 14:14 -0500, Mark A. Hershberger wrote:

> Ted Smith <[hidden email]> writes:
>
> > Is there any way to configure/hack weblogger such that you could publish
> > the same post to two different servers? Has this ever been done or
> > discussed?
>
> It hasn't been done.  I don't think anyone (but me) has discussed it.
>
> But, now that you mention it, I think it is time to start working on it.
>
Great! That's a pretty awesome response to a new community member's
first question/feature request. :-)

> The change to enable this should be pretty simple.  Basically, create a
> function that you can call with a post and a list of weblogs to post it
> to.  It would then post to each of those weblogs.
>
> If you want (and you have the Emacs Lisp skill), you can go ahead and do
> that.  Otherwise, now that this has been bumped, I'll probably get it
> done soon.

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

Thanks again! If all free software communities/developers were as
inviting as you, we'd be a lot farther along the World Domination
Roadmap :-)

- Ted

_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs

signature.asc (852 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Mark A. Hershberger
Ted Smith <[hidden email]> 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" "[hidden email]" "" "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" "[hidden email]" "" "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 above functions and they work.

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.

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

Mark.

--
http://hexmode.com/

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


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Ted Smith-2
On Tue, 2010-03-02 at 16:33 -0500, Mark A. Hershberger wrote:

> Ted Smith <[hidden email]> 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!

_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs

signature.asc (852 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Mark A. Hershberger
Ted Smith <[hidden email]> writes:

> I've been totally blown away.

It's all part of my secret plan to get more contributions to
weblogger.el et al.

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

I'm planning to write up a weblog post on this (something like a primer
for Elisp programmers on the correct way to handle passwords in Emacs)
and maybe contribute back some documentation to help direct developers
and users to this information.

So we'll consider this an overview from the user side of things.

weblogger.el (and other Emacs Lisp bits that use the auth-source.el)
will look for a username/password combo in ~/.authinfo.gpg  The format may
be familiar, but here's what weblogger.el looks for:

    machine hexmode.wordpress.com port http login hexmode password PASSWORD

The key bits are “machine”, “port”, “login”, and “password”, of course.

Since auth-source is looking for a .gpg file by default, it will try to
decrypt the file using gpg.

To create a GPG-encrypted file, you just open a file with the .gpg
extension in Emacs.  When you try to save the file for the first time,
you'll be prompted for the GPG key to encrypt it to.  Select your own.

Of course, that assumes you have GPG set up.  If you don't want to
bother with that, you can still use GPG with symetric encryption.

auth-source.el can be customized to use a different filename if you
want.

(Oh, and if you use tramp, tramp can use auth-source.el as well.)

HTH,

Mark.

--
http://hexmode.com/

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


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Ted Smith-2
On Wed, 2010-03-03 at 14:20 -0500, Mark A. Hershberger wrote:
> Ted Smith <[hidden email]> writes:
>
> > I've been totally blown away.
>
> It's all part of my secret plan to get more contributions to
> weblogger.el et al.
>
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. If I get
the skills and the time, I might try to implement this. I will
definitely feel welcome to. :-)

> >> 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.
>
> I'm planning to write up a weblog post on this (something like a primer
> for Elisp programmers on the correct way to handle passwords in Emacs)
> and maybe contribute back some documentation to help direct developers
> and users to this information.
>
> So we'll consider this an overview from the user side of things.
<snip>

Thanks! I got this error the first time I tried this:


> byte-code: Opening output file: integer-or-marker-p, nil

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). Symmetric
crypto worked fine, though.

[1]<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503480>

_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs

signature.asc (852 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Mark A. Hershberger
Ted Smith <[hidden email]> 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
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: Maintaining the same blog on two servers

Ted Smith-2
On Sun, 2010-03-07 at 19:22 -0500, Mark A. Hershberger wrote:
> Ted Smith <[hidden email]> 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.

_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs

signature.asc (852 bytes) Download Attachment