Refactoring Service Links
TheCrow - February 22, 2009 - 19:47
| Project: | Service links |
| Version: | 6.x-2.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | TheCrow |
| Status: | active |
Jump to:
Description
Hi guys im the new co-mantainer of Service Links module and i'll be happy to share my plain for improve the general features with you all.
For now im working in 5.x branch and i already made in my local copy some change (added twitter service and the option for open in new window), but i think can be more useful a new approach for manage the project:
- add the new service must be really easy and fast, so i tought to create a service_links.inc file that contain the associative array of all services and their attributes (url, text, internal name, image name), maybe some of them can be derivate from the others (the image name can be the same of internal name + png extension) and settings hook modify will be automatic too (after some fix);
- the theme api for build the link must be open to the new attributes (b.e. for introduce a class name);
- the render must allow also a supplementary theme way (http://drupal.org/node/265391);
- integration with Share module, through the patch (i hope it will be soon upgraded to 6.x branch);
- add the service image too in the settings page.
These are just few idea's i had, any comment is welcome :))

#1
I didn't yet mentioned it but i found the interestling patch by bdragon at http://drupal.org/node/185642 i wish integrate it...
Instead of service.inc, will have other modules with just the address of services, respecting in this way the Drupal extension philosophy :P
#2
Definitely seems like a good place for DRUPAL-6--2 ;-) .
#3
yes Rob, all these changes are for the new 2.x branch, and plus after your contrib about Yahoo Buzz i tought to speed the work changing the original plan; below all the news:
$links['my_service'] = array('name' => 'MyService',
'description' => t('Bookmark the post on MyService now!'),
'link' => 'http://myservice.com/?q=<encoded-url>&title=<encoded-title>',
'icon' => 'optional_just_if_the_icon_name_is_not_my_service_png.gif',
'javascript' => 'my_javascript.js',
);
...
well the icon field is optional =))
Some details:
Part of these features are already implemented in the 6.x branch available for download;
Thank you to all people partecipated actively or shared their ideas :))
The refactoring process is still open!
#4
We needed a link to the forward module and a 'bookmark this' link
For the forward module it's pretty easy (I copied their icon to the image directory)
$links['forward'] = theme('service_links_build_link', t('Forward'), "/forward?path=node/$node->nid", t('Send to a friend.'), 'images/forward.gif', $nodelink);For the 'bookmark this' it's a bit more complicated, since there's no support for a class on a link (idea: pass a unique identifier to the theme function and a a class like service_link_uniqueid to each link). We ended up doing this
$links['bookmark'] = theme('service_links_build_link', t('Bookmark'), "/", t('Bookmark this page.'), 'images/bookmark.gif', $nodelink);create a servicelink.js file and add it to your theme.info file
$(document).ready(function(){
// only show for FF and IE
if (window.sidebar || window.external) {
$("a:has(img[src=/sites/all/modules/service_links/images/bookmark.gif])").click(function(event){
event.preventDefault();
var url = this.href;
var title = this.title;
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if ( window.external ) {
window.external.AddFavorite( url, title);
}
});
} else {
$("a:has(img[src=/sites/all/modules/service_links/images/bookmark.gif])").remove();
}
});
#5
Great ideas attiks, i'll support both; for the second maybe i'll integrate Bookmark US module just for don't duplicate the efforces :))
Thank you!
#6
Initial Drupal 6 version of Share is available. Docs haven't yet been written for the new API but you can take a look at the share_plugin or sharethis_plugin and link_codes modules for examples of how to use the API. The _plugin modules are used to provide different methods of displaying different ways to share. To add a tab to the share_plugin, look at the link_codes module.
The Share API is not set in stone so any advice or needs please share.
Initial patch for Share version 2 can be found at #413860: Beginning work for implementation of Share hooks
#7
Good idea integrating with bookmark, only 'problem' i see is that their icon is a bit bigger then yours, so it looks a bit weird.
#8
@greenSkin great news, if i understood well your module now allow different profiles and for each tab module different settings can be configurated (as link_codes do)... if that's right ill need more time for integrate the whole system! Anyway thank you for the patch is a good start :)).
@attiks another problem with bookmark_us is the module allow the bookmark only for the current page and not the single post. Ill try to talk with the author for expand some feature otherwise ill bring service links in the hall of shame =))
#9
It would be neat to have an option to mimic the fisheye effect shown here:
http://www.sociofluid.com/
...without having to link an external script like that service requires.
#10
Hello,
I think it would be nice feature if this module kept track of what was being bookmarked.
so you could have a "most bookmarked" block.
great work.
#11
You said this was in DRUPAL-6--2? I don't see it anywhere. I just see DRUPAL-6--1.....
Here is a proposal for a hook_service_links(). Since we don't really know if the service requires additional JavaScript, or CSS, we have a gathering hook and an adding hook that's called when a service is added.
<?php
/**
* Adds external services to the Service Links.
*/
function hook_service_links() {
$services['myservice'] = array(
'name' => 'MyService',
'description' => 'Bookmark the post on MyService now!',
'link' => 'http://myservice.com/?q=!url&title=!title',
'icon' => drupal_get_path('module', 'service_links') . '/images/myservice.png',
);
return $services;
}
/**
* Adding an external service link to the page.
*
* @param $service
* The service that we're adding.
*/
function hook_service_links_add($service) {
if ($service == 'myservice') {
drupal_add_js(drupal_get_path('module', 'service_links') . '/myservice.js');
}
?>
So we end up with hook_service_links() and hook_service_links_add(). We could even easily add a hook_service_links_alter() ;-) .
#12
@lpkb, @loze two pretty ideas i would like to add them as external addons but about the fisheye effect for have something good will need 128x128 icons, so i dont know if is better keep it as an example for theme extension.
@Rob before upload im fixing some detail and reviewing some point... wondering if the render function can accept a theme function as input (so we reuse the standard render function but with another theme job) but too if the render function can be variable and served as option... if we want integrate the bookmarks count i tought on a menu item as service_links/twitter/node-id (and relative callback function)... links will have an url in this path instead of the classic http://twitter.com/... so we can count the link and redirect at the service page after the validation... :))
[EDIT] 6.x-2.x Branch is officially in CVS and available for download in the project page!
#15
I did a bunch of work with Service Links today and hit up a number of things in commit 250904.
Regarding #10 in your todo list , I just made #548960: Use inline popup for Service Links.
#16
I'm a big fan of your module and appreciate the work you all are putting in. Do you have any guesses about when you will release 6.x.2?
#17
Following
#18
following
#19
The 2.x branch of the module *greatly* improves the functionality of the module, great work on it.
I have a few suggestions.
1. Service link should allow the user a choice to select the size of images. [perhaps a "Large Icons: Yes/No" check-box?]
2. Integration with the AddtoAny module.
#20
hello,
i just installed the module and like it very much! i placed the servicelinks block in the right menu pane. when i select icons only it takes only 3 lines, but when you move the mouse over the icons you don´t get a popup which service it is. enabling icon + text makes a list where you must scroll down a long list - not what i want...
feature request: please add a mouseover effect for each icon so the service name is displayed when the cursor is over a icon. this would make it easier for people to find the correct social bookmark link.
thank you very much!
brgds Deas
#21
following