Skip to content

Instantly share code, notes, and snippets.

@bengillies
Created January 28, 2010 13:29
Show Gist options
  • Save bengillies/288739 to your computer and use it in GitHub Desktop.
Save bengillies/288739 to your computer and use it in GitHub Desktop.
modifier: None
created:
modified: 20100127161525
type: text/css
tags: bookmarklet
.TiddlyWikiImportContainer {
position: absolute;
position: fixed !important;
right: 0;
top: 0;
height: 100%;
width: 30%;
background-color: #F88;
/* border-right: 1px solid black;*/
border-left: 1px solid black;
padding-left: 2px;
padding-top: 2px;
z-index: 9999999 !important;
}
.TiddlyWikiImportCloseButton {
display: block !important;
float: left !important;
color: black !important;
border: 1px solid black !important;
text-decoration: none !important;
padding: 1px !important;
margin-bottom: 2px !important;
}
.TiddlyWikiImportIFrame {
height: 95%;
width: 100%;
border-width: 0px;
}
modifier: None
created:
modified: 20100128132014
type: text/javascript
tags: bookmark
//create an iframe and load tiddlywiki into it
var openTiddlyWiki = function(urlBase, path, tiddler) {
var css = document.createElement('link');
css.type = 'text/css';
css.rel = 'stylesheet';
css.href = urlBase + path + '/tiddlers/bookmarklet.css';
document.body.appendChild(css);
var container = document.createElement('div');
container.className = 'TiddlyWikiImportContainer';
document.body.appendChild(container);
var closeButton = document.createElement('a');
closeButton.className = 'TiddlyWikiImportCloseButton';
closeButton.href = 'javascript:;';
closeButton.innerHTML = 'Close';
closeButton.onclick = function() {
//hide, don't remove
document.body.removeChild(css);
document.body.removeChild(container);
};
container.appendChild(closeButton);
var tiddlerLink = (tiddler) ? '#' + tiddler : '';
var iframe = document.createElement('iframe');
iframe.className = 'TiddlyWikiImportIFrame';
iframe.src = urlBase + path + '/tiddlers.wiki' + tiddlerLink;
container.appendChild(iframe);
}
modifier: None
created:
modified: 20100127161718
type: None
tags: systemConfig
/***
|Name|BookmarkletPlugin|
|Version|0.1|
|Author|Ben Gillies|
|Type|plugin|
|Description|Generate a bookmarklet that will pop up your TiddlyWiki inside a different web page|
!Code
***/
//{{{
if(!version.extensions.BookmarkletPlugin)
{ //# ensure that the plugin is only installed once
version.extensions.BookmarkletPlugin = { installed: true }
};
config.macros.bookmarklet ={
handler: function(place, macroName, params, wikifier, paramString, tiddler){
if (!config.defaultCustomFields)
throw 'defaultCustomFields Not Found. This plugin requires TiddlyWeb to work.';
var urlBase = config.defaultCustomFields['server.host'];
var path = escape(config.defaultCustomFields['server.workspace']);
var tiddler = params.length > 0 ? ',%22' + escape(params[0]) + '%22' : '';
var bookmarklet = 'javascript:(function(){'
+ 'var%20u=%22' + urlBase + '%22;var%20p=%22' + path + '%22;'
+ 'var%20s=document.createElement(%22script%22);'
+ 's.type=%22text/javascript%22;'
+ 's.src=u+p+%22/tiddlers/bookmarklet%22;'
+ 'document.body.appendChild(s);'
+ 'var%20lT=setInterval(function(){'
+ 'if(window.openTiddlyWiki){'
+ 'window.openTiddlyWiki(u,p' + tiddler + ');'
+ 'clearTimeout(lT);'
+ '}},100);})();';
console.log(bookmarklet)
jQuery('<a/>')
.attr('href', bookmarklet)
.text(document.title)
.appendTo(place);
}
}
//}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment