Wed 5th Oct 2005
Posted in the evening, filed under
Blogging ,
JavaScript.
Last update for tonight:
<a class='button' onclick='javascript:document.getElementById("the_id").rows+=10;'> Make Text Box Bigger </a>
And similar for Make Text Boxes Smaller.
It’s working on my comment box as we speak. Try it out.
(Thanks to Dunstan).
Wed 5th Oct 2005
Posted in the evening, filed under
Blogsome.
Following on from the previous post, I’ve also shamelessly poached another idea from Dunstan: human-readable timestamps.
Just pop this into your post.html file, where you want the ‘time’ to appear.
(more…)
Wed 5th Oct 2005
Posted early evening, filed under
Blogsome ,
Languages.
I had noticed lots of blogs had a nice little Posted x hours, y minutes after the fact tag attached to Comments. I thought this was pretty cool, and had a very short attempt at this some time ago.
Then, over on Binary Bonsai, Michael mentioned how the plugin was broken, and how it needs fixing.
Well, I didn’t fix the PHP version, but I did write a pure Smarty version!
(more…)
Wed 5th Oct 2005
Posted late afternoon, filed under
Blogsome ,
JavaScript.
I recalled at some stage there was a Smarty Modifier called escape. I think it was when I was looking for one called rot13.
Anyways, you can use this and the JavaScript function unescape() to obfuscate the email address.
You’ll need this code early in your template: I stick it at the start just after <html>
<script type="text/javascript"
src="http://schinckel.blogsome.com/images/md5.jpg">
</script>
This fragment will insert the Gravatar Image:
{capture name=reader}{comment_author_email}{/capture}
<script type="text/javascript">
document.write(’<div class="right">’);
document.write(’<img src="http://www.gravatar.com/avatar.php?gravatar_id=’);
document.write(hex_md5(unescape("{$smarty.capture.reader|escape:"hex"}")));
document.write(’&size=40" alt="" />’);
document.write(’</div>’);
</script>
This seems to more reliably display the Gravatars, so I’d suggest you use it instead. Either that, or Gravatar just fixed up their servers…
Wed 5th Oct 2005
Posted mid-afternoon, filed under
Blogging ,
Languages.
There’s a little one-liner I’ve just learned for showing or hiding the contents of a particular <div> tag. (May also work for other types of tag).
The stuff you want to show or hide needs to have an id attribute. I use it to hide some stuff if there are no Comments or Trackbacks, since I’ve seperated them, and this was the best way to hide the title.
(more…)
Wed 5th Oct 2005
Posted early afternoon, filed under
AppleScript.
I wrote my own script to convert the selection (or whole front document) in Script Editor to XHTML. It uses the same CSS tags as Jonathon’s program, but does not add the style data in, unless a property is set.
I’ve also got the Source Code for his program, so it will be interesting to see similarities.
(more…)
Wed 5th Oct 2005
Posted in the wee hours, filed under
Humour.
Got this one from Boing Boing:

Wed 5th Oct 2005
Posted in the wee hours, filed under
AppleScript ,
Blogging.
Since I need to replace all ” in the generated XHTML with ‘, I use the replace function from the previous post.
(**)
–
tell application "SubEthaEdit"
activate
tell application "System Events" to keystroke "C" using {command down}
end tell
set theStart to (the clipboard)
set the clipboard to (my replace(theStart, "\"", "’"))
beep
–
–
on replace(theText, find, replace)
set OldDelims to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to find
set newText to text items of theText
set AppleScript’s text item delimiters to replace
set theResult to newText as text
set AppleScript’s text item delimiters to OldDelims
return theResult
end replace
–
to replaceText from theText to replace instead of find
set OldDelims to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to find
set theText to text items of theText
set AppleScript’s text item delimiters to replace
set theText to theText as text
set AppleScript’s text item delimiters to OldDelims
theText
end replaceText
Wed 5th Oct 2005
Posted in the wee hours, filed under
AppleScript ,
Blogging.
I like to present styled code for my readers, but I’m not totally happy with my methods of getting it: SubEthaEdit’s Export as XHTML is very cool, but I still have to tweak it so it looks nice. And I’ve got a great program for getting the XHTML version of the code Script Editor (AppleScript) is currently displaying.
But, I’d like more flexibility. I want the code to be tagged with classes, like it’s possible to do with the Script Editor add-on, rather than using inline styles. I’ve already done this for the Script Editor code, but I just need to remember to remove the inline stylesheet from the start of the generated code. Unfortunately the Script has been saved as a Run Only.
I’d love to know a way to decompile one of these Scripts…apparently there isn’t. I’ll have to write my own. Or see if Jon is nice enough to give the Source Code.
As for the SubEthaEdit part: I should be able to do it. I’ve learned a couple of tricks that will help.
Wed 5th Oct 2005
Posted in the wee hours, filed under
AppleScript.
I used to use ecto to paste all of my entries on my blog, but with Blogsome’s XMLRPC issue, I have to use a browser. But it would be nice to automatically get the name and information about my currently playing iTunes track, just like ecto used to do.
I wrote an AppleScript that does this, and, inserts the data in at the insertion point for you.
Because it’s intended to be run from the Script Menu, and everything run from there runs as “System Events”, I had to hard code in the browser name. If you use another browser, just replace the second line with whatever your browser is called.
(more…)