Page 1 of 1

POPFetcher

Posted: Wed Apr 21, 2010 6:40 am
by golfsailor
Could you help me with this one. If it's a bug ? probably not but everything seem to work except one thing. The text just disappear. Images goes where is expected.

I can see in the log that the moderate_comment is truncated when inserted into the db but I think the article should go there anyway. Maybe it doesn't ?

is there any way of setting more options like tagging the email. Could think of some options like

draft / publish
language then it will be possible to send even more than one language in one e-mail.
title
moderation
comments
author
category
publish date

some version in the future ?

now running 1.5.2
apache 2.2.8
windows XP

/Rolf

Re: POPFetcher

Posted: Wed Apr 21, 2010 11:49 am
by garvinhicking
Hi!

If text disappears, that can be related to how your mail is formatted, which attachment types are added, and if the text is plaintext or some kind of encoded attachment. The popfetcher plugin has several options to deal with text attachments, how is your configuration set currently?

Tagging inside the plugin is currently not existing, because we would need some kind of parsing or whatever to indicate which are tags. That's a conceptual thing which needs some thinking, and it's also not so easy to implement - but I agree, this would be nice!

Regards,
Garvin

Re: POPFetcher

Posted: Wed Apr 21, 2010 3:35 pm
by golfsailor
I changed the moderation flag and put the article as a draft and then it works, so I guess there is a bug !

please consider the tagging, especially the language tag would be nice .....

My best
Rolf

Re: POPFetcher

Posted: Wed Apr 21, 2010 5:00 pm
by garvinhicking
Hi!

Are you using MYSQL, or which database?
please consider the tagging, especially the language tag would be nice .....
How would you propse to add support for this, how would you add tags to entries that got sent by mail?

Regards,
Garvin

Re: POPFetcher

Posted: Thu Apr 22, 2010 12:25 am
by golfsailor
Hi Garvin,

why don't use the same technic as there is already, you may have some better idea

{{article}}
{{moderation=on}}
{{comments=on / off}}
{{author=name}}
{{category=category name}}
{{date=yyyy-mm-dd}}
{{draft=on}}(also means {{publish=off}})
{{publish=on}} (also means {{draft=off}})
{{imagedirectory=imagepath}}
{{language=en}}{{title}}a title{{--}}{{body}}some english text{{extension}}more text{{--}}
{{language=sv}}{{title}}a title{{--}}{{body}}swedish text{{extension}}more text{{--}}
{{language=sv}}{{title}}a title{{body}}swedish text{{extension}}more text{{--}}
{{image1=filename}}(attachment 1)
{{image3=filename}}(attachment 3)
{{article}} Next article ....

Images handled as now just insert into all languages that have a language tag.
Then I could email my computer, start the popfetcher with a scheduler every day ... bingo !

For perfection, insert image3 into text at position tagged
{{image3, class=left/right/center, height=xxx, width=xxx}}

Just an idea. This is already a good system ! by the way, yes I use mysql

Rolf

Re: POPFetcher

Posted: Thu Apr 22, 2010 8:32 pm
by garvinhicking
Hi!

Hm, maybe for tags something like {{....}} would work. The other options are IMHO a tad bloated...where's the benefit in writing such mails? Why not use the client directly?

Are you aware of API tools for xmlrpc like windows live writer or wbloggar? Those also support tags...

Regards,
Garvin

Re: POPFetcher

Posted: Fri Apr 23, 2010 8:36 am
by golfsailor
Hi Garvin,

when travelling, there is usually a lot of time I spend with my notebook. Then it's
more efficient just to send the e-mails, using the client limits the time and places,
though it's possible to cut and paste or using other options as you suggest. Just
that option puts limitations in a way the email don't. (Maybe I am wrong here ?)
Next year I will cross the Atlantic (sailing) and just have a satelite phone then it's
not an option working online.

I have never used windows live writer or wbloggar. (Will look).

What's your idea's, what is the best way ?

If you consider tagging, tags for {{Meta-Description=, Meta-Keywords=, HTML_page_title=}} is not a bad idea.

Rolf

Re: POPFetcher

Posted: Mon Apr 26, 2010 10:55 am
by garvinhicking
Hi!

For your situation, I would really opt to go for the windows live writer method, it's much more straight-forward and for you maybe better to use. Have a try and tell me what you think of that variant :)

Regards,
Garvin

Re: POPFetcher

Posted: Wed Apr 28, 2010 6:34 pm
by golfsailor
Hi Garvin,

works, but don't solve the language problem as far as I can see. Any solution ?

Rolf

Re: POPFetcher

Posted: Wed Apr 28, 2010 10:36 pm
by garvinhicking
Hi!

Hm, for the translation that'S true, WLW won't help with that. Adding the parsing to the popfetcher plugin should be doable, but I'm pretty swamped with work right now, so I don't know when I can find the time to write a parser for it.

The parser would need to insert the appropriate parsed language versions and insert them to the "body_en", "body_de" etc. entryproperties database table. Any volunteers who'd like to dive into an s9y plugin for this instance? :)

I'll also add this specific language parsing to my list!

Best regards,
Garvin

Re: POPFetcher

Posted: Thu Apr 29, 2010 8:49 pm
by golfsailor
Hi Garvin,

I wish I was familiar with php then I could help :-) but I have never tried any script language, and
don't have the setup either. Maybe you might give me some hint, then I could be of some more help in the future. (Have been programming for 40 years, so I am not a beginner).

Rolf

Re: POPFetcher

Posted: Fri Apr 30, 2010 10:57 am
by garvinhicking
Hi!

Okay, the basic idea is this. The main file to edit is plugins/serendipity_event_popfetcher/serendipity_event_popfetcher.php

You can do that with any text editor, so you don't really need a setup for this.

Inside that file there's a function called "workEntry":

Code: Select all

    function workEntry($subject, &$msgbody, $authorid, &$postex, &$cid, &$s) {
        global $serendipity;

        $striptagsflag = serendipity_db_bool($this->get_config('striptagsflag'));
...

        $entry['title']    = $subject;
        $entry['body']     = $msgbody;
This function does all the parsing work to convert what the plugin gathered through a mail to put it into a large $entry array, which is later converted into a serendipity entry:

Code: Select all

            $id = serendipity_updertEntry($entry);
            $this->out('<br />' . MF_MSG15 . ': ' . $id);
Now, around this place is where we would to some extended parsing. To do that, I'd create a new function like "meta_parser()":

Code: Select all

function meta_parser(&$entry) {
  // Match all multi-language parts of 'Body'
  preg_match_all('/\{\{language=(.+)\}\}(.+)\{\{/language\}\}/imsU', $entry['body'], $bodylang);
  // Match all multi-language parts of 'Extended'
  preg_match_all('/\{\{language=(.+)\}\}(.+)\{\{/language\}\}/imsU', $entry['extended'], $extendedlang);

  // {{language=XX}}...{{/language}} parts are all equivalent, so deal with them the same way
  $languages = array();
  $this->meta_parser_helper($bodylang, $languages);
  $this->meta_parser_helper($extendedlang, $languages);

  // We don't want those parts in our normal entry, so let's replace them out:
  $entry['body'] = preg_replace('/\{\{language.+\{\{/language\}\}/imsU', '', $entry['body']);
  $entry['extended'] = preg_replace('/\{\{language.+\{\{/language\}\}/imsU', '', $entry['extended']);
  
  // $languages is our parsed return. We need that one later on:
  return $languages;
}

function meta_parser_helper($regex, &$storage) {
  // Now we need to store each language into a proper variable
  foreach($bodylang[0] AS $idx => $cont) {
    $langkey  = $bodylang[1][$idx];
    $langcont = $bodylang[2][$idx];
    
    // $langkey is the en/de/fr language key
    // $langcont is the content of it. This might contain other specific markup like {{title}} {{body}} {{extended}}, so let's get them
    preg_match('@\{\{title\}\}(.+)\{\{/title\}\}@imsU', $langcont, $title);
    preg_match('@\{\{body\}\}(.+)\{\{/body\}\}@imsU', $langcont, $body);
    preg_match('@\{\{extended\}\}(.+)\{\{/extended\}\}@imsU', $langcont, $extended);

    // Note how we already call the columns like they need to be called in the serendipity_entryproperties db table
    $storage[$langkey] = array(
        'multilingual_' . $langkey . '_title'    => $title[1],
        'multilingual_' . $langkey . '_body'     => $body[1],
        'multilingual_' . $langkey . '_extended' => $extended[1]
    );
  }

}
So now we need to call that inside the main routine:

Code: Select all

            $languages = $this->meta_parser($entry);
            $id = serendipity_updertEntry($entry);
            $this->out('<br />' . MF_MSG15 . ': ' . $id);

           // After the entry id is received, we can go and store our multilingual versions:
           foreach($languages as $langkey => $langvals) {
               foreach($langvals AS $langcolkey => $langcolval) {
                   // Store the proper fields in the DB table column names 'entryid', 'property', 'value'
                   $ep_insert = array('entryid' => $id, 'property' => $langcolkey, 'value' => $langcolval);
                   serendipity_db_insert('entryproperties', $ep_insert);
                }
           }
This is all untested, but if you know some basic RegExp stuff, and are willing to try, this should be a good way to start...?

Best regards,
Garvin

Re: POPFetcher

Posted: Wed May 05, 2010 9:12 pm
by golfsailor
OK, Garvin
I will take a good look at this. Let you know.
Rolf