Vote Up!
Vote Down!

Bookmarklet Hack

3 points | submitted by about 3 years ago | 3 comments

I tried to adapt the bookmarklets used for HackerNews / New Mogul.

For the following bookmarket to work...

javascript:window.location=%22http://yoursite.com/submit?u=%22+encodeURIComponent(document.location)+%22&t=%22+encodeURIComponent(document.title)

I added the following code after $type = $ns->form['type']; in form.php

if (isset($_GET['u']))

{

$formfields['content']='';

$formfields['node'] = '';

$formfields['url'] = $_GET['u'];

if (isset($_GET['t']))

$formfields['title'] = $_GET['t'];

}

This works, but the expert may wish to do it more elegantly.

You must be logged in to leave a comment.

Vote Up!
Vote Down!
1 point | submitted by about 3 years ago | Link

Cool :)

Support for bookmarklets (and other remote and related scriptable stuff) will be in the v0.7 release. I'm just testing the most elegant way to handle it in the engine.

Reply
Vote Up!
Vote Down!
1 point | submitted by about 3 years ago | Link

I attempted to indent the code 5 spaces to have it behave like HN, but that didn't work. Most people won't use this for code, so perhaps no worries, but it's also nice for quoting...

Reply
Vote Up!
Vote Down!
1 point | submitted by about 3 years ago | Link

Yeah, there's currently no output or input filtering for comments or submissions. v0.7 will have the necessary interrupts (plugin hooks) to enable that, so things like Markdown and Textile can be plugged in with relative ease.

Reply