Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Bookmarklet 0.2

  1. #1
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,869
    Blog Entries
    88
    Thanks
    481
    Thanked 806 Times in 526 Posts

    Default Bookmarklet 0.2

    Bookmarklet
    Version: 0.2
    Author: Nick Ramsay
    Created: 2009/11/29
    Last Updated:
    2010/06/03
    Tested on: Hotaru 1.0.5 ~ 1.3.0
    Plugins Required: Submit
    Plug & Play: No. One template edit required.
    Supported: Yes

    Description
    A simple plugin that displays a bookmarklet link for users to drag to their toolbar or add to their favorites. They can click that link when browsing other webpages to open a new window at step 2 of the post submission process. In other words, a bookmarklet is a tool for making it easier to use your site.

    Instructions
    1. Upload the "bookmarklet" folder to your plugins folder. Install it from Plugin Management in Admin.
    2. Add the following plugin hook in a template, wherever you want to display the link:

    PHP Code:
    <?php $h->pluginHook('hotaru_bookmarklet'); ?>
    By default, the language used for the link is "Submit to YOUR SITE". You can change that in the language file.

    It's advisable to add instructions around the bookmarklet link in the /templates/bookmarklet.php file so your users can understand how to use it. E.g.

    You can easily submit articles to SITE NAME with the link below. Just bookmark it in your browser and click it whenever you are reading something you want to share!
    Firefox: Drag the link to your Bookmarks Toolbar
    Opera: Right click the link, and choose "Bookmark Link"
    Internet Explorer: Right click the link, and choose "Add to favorites"


    Revision History

    v.0.2 2009/12/28 - Nick - Updated for compatibility with Hotaru 1.0
    v.0.1 2009/11/28 - Nick - Released first version

    Please click "Rate Thread" and give this plugin a rating. Thank you.

    Attached Thumbnails Attached Thumbnails bookmarklet.png  
    Attached Files Attached Files

  2. Thanked by:


  3. #2
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Its important plugin.
    Just i want to say THANKS

  4. #3
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,869
    Blog Entries
    88
    Thanks
    481
    Thanked 806 Times in 526 Posts

    Default Bookmarklet Page

    The bookmarklet plugin is very, very basic. All it does is display a link wherever you put the "hotaru_bookmarklet" plugin hook.

    With that in mind, I made a bookmarklet page which does not use the plugin.

    First, here's what it looks like on my site:

    Click image for larger version. 

Name:	bookmarklet_page&#46.png 
Views:	118 
Size:	28.3 KB 
ID:	560

    Here's how to make it:

    1. Create a new .php file in your theme folder and name it bookmarklet.php
    2. Paste this into it:

    Code:
    <h2><?php echo SITE_NAME; ?> Bookmarklet</h2>
    
    Submit stories on the fly by adding the <?php echo SITE_NAME; ?> bookmarklet to your browser.<br /><br />
    Whenever you find an interesting article that you'd like to share, simply click the bookmarklet in your toolbar or Favorites menu and the <?php echo SITE_NAME; ?> submit form will open with the page's url and title already filled in.
    <br /><br />
    
    <p style="text-align: center;">
        <img src="<?php echo BASEURL; ?>content/themes/<?php echo THEME; ?>images/EXAMPLE_IMAGE.png" />
    </p>
    <br /><br />
    
    <?php if ($h->currentUser->loggedIn) { ?>
    
        <h2>Instructions</h2>
            <ul>
                <li><b>Internet Explorer:</b> Right click "Submit it!" and choose "Add to favorites"</li> 
                <li><b>Firefox:</b> Drag "Submit it!" to your Bookmarks Toolbar</li> 
                <li><b>Opera:</b> Right click "Submit it!" and choose "Bookmark Link"</li>
            </il>
        
        <p style="font-size: 20pt; font-weight: bold; text-align: center;">
            <a class="bookmarklet" href="javascript:q=(document.location.href);void(open('<?php echo BASEURL; ?>index.php?page=submit&url='+escape(q),'','resizable,location,scrollbars,menubar,toolbar,status'));">Submit it!</a>
        </p>
    
    <?php } else {?>
        You'll need to <a href="<?php echo $h->url(array('page'=>'login')); ?>">log in</a> to get the bookmarklet.
    <?php } ?>
    3. Link to that page in one of your other templates using this:

    Code:
    <a href="<?php echo $h->url(array('page'=>'bookmarklet')); ?>">Get our bookmarklet!</a>

  5. #4
    Senior Member baadier's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town, South Africa
    Posts
    263
    Thanks
    80
    Thanked 14 Times in 10 Posts

    Default

    Is there any way to attach an image to the bookmarklet on the toolbar?

  6. #5
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    379
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    no.............
    Edit: srry for the short answer i needed to go, euhm it cant be done because normal bookmarks use the favicon (icon) of the page they are pointing to, bookmarklets dont point a website, hell they dont even use the http uri scheme, they use the javascript uri scheme (javascript:) to run one (possibly really long) line of code
    this is generated by the plugin
    Code:
    javascript:q=(document.location.href);void(open('<?php echo BASEURL; ?>index.php?page=submit&url='+escape(q),'','resizable,location,scrollbars,menubar,toolbar,status'));
    So the image cant be fetched from the uri
    Last edited by ties; 04-22-2010 at 06:16 PM.
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  7. #6
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    268
    Thanks
    34
    Thanked 37 Times in 25 Posts

    Default

    The selected text feature caught my attention, this would be a welcome addition to this plugin.

    http://friendfeed.com/share/bookmarklet

  8. #7
    Member
    Join Date
    Jul 2010
    Location
    dhaka
    Posts
    42
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default

    When I click in the bookmarklet in my browser it bookmarks only the link and the heading but no description. is there any way to take the description from the link?

  9. #8
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,869
    Blog Entries
    88
    Thanks
    481
    Thanked 806 Times in 526 Posts

    Default

    Not with the current plugins. If you enjoy programming, you could extend the Submit plugin to fetch descriptions from the meta description tags.

  10. #9
    Junior Member
    Join Date
    Oct 2010
    Location
    London, England.
    Posts
    16
    Thanks
    5
    Thanked 5 Times in 3 Posts

    Default Important addition / fix:

    With both the bookmarklet plugin, as well as the page method, users get an error message if they click the bookmarklet when not logged in.

    I've managed to get the submit page to redirect to the login page if a user isn't logged in (as it should) - including the referring url to send them back to the submit page by making the following modification:

    Replace the following in Submit.php (in the submit plugin folder)

    Code:
          // check user has permission to post. Exit if not.
            $h->vars['posting_denied'] = false;
            if ($h->currentUser->getPermission('can_submit') == 'no') {
                // No permission to submit
                $h->messages[$h->lang['submit_no_post_permission']] = "red";
                $h->vars['posting_denied'] = true;
                $h->vars['can_edit'] = false;
                $h->vars['post_deleted'] = false;
                return false;
            }
    With the following:

    Code:
            // check user has permission to post. Exit if not.
            $h->vars['posting_denied'] = false;
            if ($h->currentUser->getPermission('can_submit') == 'no' && $h->currentUser->loggedIn) {
                // No permission to submit
                $h->messages[$h->lang['submit_no_post_permission']] = "red";
                $h->vars['posting_denied'] = true;
                $h->vars['can_edit'] = false;
                $h->vars['post_deleted'] = false;
                return false;
            }

    Don't know if this is the most elegant solution, but it works. Hope it helps anyone wrestling with the problem and brings the issue to the attention of anyone who hasn't tried the bookmarklet when logged out. Cheers, Mark.
    Last edited by mystermarque; 10-26-2010 at 11:10 AM.

  11. Thanked by:


  12. #10
    Junior Member
    Join Date
    Oct 2010
    Location
    London, England.
    Posts
    16
    Thanks
    5
    Thanked 5 Times in 3 Posts

    Default Extract a link's description and keywords from meta tags

    @anika039

    I also need the link's description - as well as the keywords - and I just worked out how to do it.

    Copy submit2.php (in the submit plugin folder) to your theme folder and paste the following at the top (below the license):

    Code:
    <?php
    $tags = get_meta_tags($h->vars['submit_orig_url']);
    $h->vars['submit_content'] = $tags['description'];
    $h->vars['submit_tags'] = $tags['keywords'];
    ?>
    Note: You can remove the keywords line if you don't need them - but if you use the code as is, you might want to increase the plugin's tag character limit setting in admin to 1000 rather than 100. Otherwise you'll likely get a "too many tags" error message upon submission.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •