Open in Edmund bookmarklet to support custom domains

Many of the sites at Wikidot that I use have a custom domain, yet currently the bookmarklet doesn't support these sites. I'm adding this wish so that it's entered into the tracker for future reference.

Potential ways for this to be implemented:

Option 1: Wikidot adds the wiki subdomain to the HTML header, in the same way that other information is added. I assume that this could then be easily detected using a "bookmarklet"?

Option 2: Register your own site beforehand somewhere else, posting the custom domain and the actual Wikidot URL. The bookmarklet would then check this list so that it knows which site to access with the API.


If it ends up being Option 2, I would hope that the site is generic enough to be used by other applications (e.g. STE). An "Open in STE" bookmarklet for that application has been a long-standing wish, but hasn't been possible until recently.

Discussion - 2 comments

Anonymousbcammo 21 Jul 2011 00:15

I'm not sure if option 2 is possible with a bookmarklet. I'll have to look into it. In the meantime, I've worked out a way to manually add support for custom domains - you'll just need to add your domains to the bookmarklet. Below, replace roaringapps.com with your custom domain, and osx with the corresponding wikidot site name. Additional sites can be added in the 'else if' blocks. Then copy the code to the source of the 'Open in Edmund' bookmarklet.

javascript: domain = WIKIREQUEST.info.domain.match(/^(.*?)\.wikidot\.com$/);
if (window.location.host == 'roaringapps.com') {
     domain = ['','osx'];  
}
else if (window.location.host = 'shane-smith.com') {
     domain = ['','shane'];   
}
if (domain) {
    unix = WIKIREQUEST.info.pageUnixName;
    window.location = 'https://css3.wdfiles.com/edmund/code/1#?site=' + domain[1] + '&page=' + unix;
} else {
    alert('Custom domains are not yet supported.');
}

Edit

Anonymousleiger 21 Jul 2011 00:25

Ah, good solution - thanks!

Edit

Add a new comment