Customizing Press This/ Quick posting for WordPress

Wordpress

I currently use Press This to reblog posts from mainly Vimeo but other times I just want to quote pieces of articles that I can add my own words to. The output Press This gives is mainly just the title twice; once as the title and the second this as the source.

So basically I want Press This to insert the [vimeo] short tag instead of <object> tags.
And for selecting text, it would be great if I could find a way to use quotation marks for the sourced paragraph.

So like this for a TechCrunch post : Facebook Preparing To Announce 500 Million Users


Facebook is about to announce that
they’ve hit 500 million users — a
milestone that cements (as if it
hadn’t already) the site’s status as
one of the web’s biggest successes
ever. Of course, at Facebook’s growth
trajectory it hasn’t been a matter of
if the social network would be hitting
500 million, but when it would (in
fact, the movie poster for the
upcoming movie The Social Network uses
the 500 million stat in its tagline).
Still, it’s finally about to become
official. So how do we know?

via TechCrunch


This is a wordpress.com account, I apologize for not stating this earlier.

Retaining format/links would be a plus.

Here is the Press This that is used as a bookmarklet.

Best Answer

I addressed your Vimeo question and will let you or someone else cover the quotation marks questions (since I didn't understand that part of your question.)

PressThis uses Javascript to capture the information about the Vimeo video. In order to modify it you need to hook WordPress in one of the few places you can hook it in PressThis and insert your own Javascript code, and I chose to hook the "admin_print_footer_scripts" action.

In the Javascript code generated by the hook I set a timer and continued to check the #embed-code textarea every 100 milliseconds until it had a non-null value, and then I disabled the timer (I might have been able to do it without a time but I couldn't figure it out.)

One I had a valid value to operate on I used a regular expressions to extract the clip ID. I coded it so that you can select multiple videos and it will copy all of them (assuming that PressThis even supports it.) The looping on i+=2 allows the code to grab the clip_id for the tag and ignore the tag. The height and width are hardcoded; you can easily change them in the code if you like.

That's about it. Here's the code to copy into your WordPress theme's function file, or use it to create a plugin (you can also find the code here: http://gist.github.com/478078):

add_action('admin_print_footer_scripts','greatjakes_admin_print_footer_scripts');
function greatjakes_admin_print_footer_scripts() {
    if ($_SERVER['PHP_SELF']=='/wp-admin/press-this.php') {
        $script=<<<SCRIPT
<script type="text/javascript">     
    var intervalId;
    var embedCode;
    function monitorEmbedCode() {
        embedCode = jQuery("#embed-code").val();
        if (embedCode!=null) {
            window.clearInterval(intervalId);
            var matches = embedCode.match(/clip_id=([0-9]+)&/g);
            var output = '';
            var clipId = 0;
            for (var i=0; i<matches.length; i+=2 ) {
                clipId = parseInt(matches[i].replace(/(.+=)([0-9]+)(&)/,'$2'));
                output += '[vimeo clip_id="' + clipId + '" width="400" height="225"]\\n';
            }
            jQuery("#embed-code").val(output);
        }
    }
    intervalId = window.setInterval(monitorEmbedCode,100);
</script>
SCRIPT;
        echo $script;
    }
}

Hope this helps.