DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Tumblr: Turn Twitter Posts Into Quotes
Stick the following code in your Tumblr custom template to turn the posts from your Twitter feed into quotes.
YMMV. I use the Litewire theme and import my Twitter feed as Regular posts without titles.
I used to use this on <a href="http://timmorgan.org">timmorgan.org</a>, but I don't any more. In fact, Tumblr has changed so much since I wrote this, I'm not sure it still works.
<script type="text/javascript">
onload = function() {
var divs = document.getElementsByTagName('div');
for(var i=0; i<divs.length; i++) {
if(divs[i].className == 'regular' && divs[i].innerHTML.match(/\(via.*Twitter\s\//)) {
divs[i].className = 'quote';
var q = divs[i].innerHTML;
var t = q.replace(/^\s*.*?:/, '').replace(/\(via [^\)]+\)/, '');
size = (t.length > 75) ? 'medium' : 'short';
try {
divs[i].innerHTML = '<div class="quote_text"><span class="' + size + '">' + t + '</span></div><div class="source">' + q.match(/\((via [^\)]+)\)/)[1] + '</div>';
} catch(e) {}
}
}
}
</script>





