Fixed base URL for submissions

dfgfdgdfgdfg - July 25, 2008 - 12:01
Project:AddThis Button
Version:6.x-2.0
Component:Code
Category:feature request
Priority:normal
Assigned:wesku
Status:postponed
Description

We are currently using the Digg This Drupal module on the Coccinella website but we want to move to the Add This module. There is only one missing feature that we really need and that is a way to configure a fixed base URL. Let me explain.

Coccinella's website has 2 official URLs that both point to the same website ( http://coccinella.im/ and http://thecoccinella.org/ ). The reason we don't want redirection is because we want a backup in case of DNS problems on one domain. For instance, if thecoccinella.org would point to coccinella.im and the later is down, it will not work. By pointing to the server instead of to another domain, people can still access the website in case of DNS problems with one domain.

Another reason for doing no redirection is to reduce the risk of malicious people stealing our domain name. Both domains have a similar page ranking. This makes it less interesting to steal any of our domains.

Anyway, the Digg This module also does not have a feature to set a fixed base URL, but we made an ugly patch:

  // always use coccinella.im for Digging
  $url2 = preg_replace("/^http:\\/\\/thecoccinella.org\\//", "http://coccinella.im/", $url);
  $url3 = preg_replace("/^http:\\/\\/www\\.thecoccinella\\.org\\//", "http://coccinella.im/", $url2);
...
digg_url = '$url3';

You can see that the Digg button always points to "coccinella.im" when visiting both http://thecoccinella.org/synchronized-releases and http://coccinella.im/synchronized-releases

So, a feature for Add This to have a field in the admin interface to enter optionally a custom fixed base URL would be a really feature!

#1

wesku - August 12, 2008 - 16:44
Version:6.x-2.0-beta3» 6.x-2.0
Assigned to:Anonymous» wesku
Status:active» postponed

This seems like a very special feature to me. The module is easy to patch to add this kind of functionality, but I am not willing to add more configuration options for special use cases. I would like to keep the module administration as simple as possible.

If you want to use a fixed base url you can replace line 213 in addthis.module. Current version (2.0) of the line:

$teaser ? url('node/'.$node->nid, array('absolute' => 1) ) : '[URL]',

Has to be replaced with:
preg_replace('/^https?:\/\/[^/]+/', 'http://coccinella.im', url('node/'.$node->nid, array('absolute' => 1))),

This would always replace your url with a fixed domain name. Unfortunately you need to redo this when updating the module.

#2

wesku - August 12, 2008 - 16:51

Whoops.. there was one backslash missing from my code. This one actually works:

preg_replace('/^https?:\/\/[^\/]+/', 'http://coccinella.im', url('node/'.$node->nid, array('absolute' => 1))),

 
 

Drupal is a registered trademark of Dries Buytaert.