Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I currently use PressThis 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 post. The output PressThis gives is mainly just the title twice; once as the title and the second this as the source.

So basically I want PressThis 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 pressThis that is used as a bookmarklet.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
+1 Thanks for the hack , unfortunately I am talking about a wordpress.com account. I updated the question with the javascript that is used for the PressThis bookmark.So is this method possible to use without going in the admin code ? –  phwd Jul 16 '10 at 10:31
    
Unless there is something obscure that I don't know about, you can't do this kind of thing on WordPress.com. Time to get yourself a self-hosted WordPress? –  MikeSchinkel Aug 12 '10 at 21:14
    
Yeah I do have a self-hosted as well. Trying to push the limits of the wordpress.com one. Right now it involves lengthy chats with customer support. Thanks again. –  phwd Aug 22 '10 at 11:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.