Zooomr

Topic: BBCode: AppleScript for this missing feature

wrote Posted 2 months, 1 week ago
My favorite billboard has a photo thread, in wich I put BBCode for Zooomr-hosted images — formerly by hand, now with this nice AppleScript.
Note that it only checks for “.jpg” since one should only reference previews or your admin will… ;-)

You need, of course, an Apple computer with OS X and Safari.
Copy the code in Script Editor and safe it nicely named in ~/Library/Scripts/Applications/Safari/ (create the folder if not exists).
Usage: Copy the HTML code provided with any image size (Apple+C), run the script from the script menu, insert into your forum post. Preview and have fun!

CODE:
(* BlogHTML to BBCode (Clipboard)

© 2008 www.thorix.de

4.5.2008
Provides a feature missed in Zooomr:
the code for referencing an image’s representation like
<a href="image—detail—view" title="Photo Sharing"><img alt="image-title" height="683" src="image—url" width="1024" /></a>
— copied to the clipboard — will replaced by
[URL=image—detail—view][IMG]image—url[/IMG][/URL]
— still in the clipboard — to be copied in a forum post.

Installation: put me in ~/Library/Scripts/Applications/Safari/ (even if I do nothing with it)
*)

property URL_TAG : "URL"
property IMG_TAG : "IMG"

tell application "Safari"
set html to (the clipboard as text)
set oldDelimiters to AppleScript's text item delimiters
-- Brute force parsing
set AppleScript's text item delimiters to "\""
set htmlElements to html's text items
repeat with element in htmlElements
if element begins with "http://" then
-- I’ve got something real
if element ends with ".jpg" then
set pictureHref to element
else
set siteHref to element
end if
end if
end repeat
set AppleScript's text item delimiters to oldDelimiters

set the clipboard to "[" & URL_TAG & "=" & siteHref & "][" & IMG_TAG & "]" & pictureHref & "[/" & IMG_TAG & "][/" & URL_TAG & "]"
end tell
wrote Posted on May 4, 2008 (permalink)
§$%&/ where’s the edit feature? Preview didn’t work so I’m shocked by the test images… but copy&paste works in Script Editor even with the images :-}
<edit>Edit was thrown out of view by the images, finally found :-) Everything is fine.</edit>
wrote Posted on May 4, 2008 (permalink)
If you learn HTML, you don't have to learn meta-HTML (e.g. BBCode).

I never did understand why BBCode and other metalanguages were invented. That's what toolbars / quick buttons are for.
wrote Posted on May 5, 2008 (permalink)
If you learn HTML, you don't have to learn meta-HTML (e.g. BBCode).

I never did understand why BBCode and other metalanguages were invented. That's what toolbars / quick buttons are for.


Metacode ist the safest way for a PHP driven site (insert your favorite engine here ;-) to avoid side-effects like display of images in comments (discussed in a thread nearby) or serious security issues.

With metacode your site controls whatever is displayed, with HTML the client's browser and the potentially malevolent poster takes over…

You are right in the toolbar/quickbutton question: I would prefer a wysiwyg-editor without visible metacode in billboards.
But will there be a quickbutton for "my image @ Zooomr" then?
wrote Posted on May 15, 2008 (permalink)
There’s another one, now for offering a “View Large” link in your photo’s description field. Of course this ist nearly the same like the one above ;-)

CODE:

(* Make Zooomr “View Large” Link (Clipboard)

© 2008 www.thorix.de

14.5.2008
Provided you opened an images detail page in Zooomr…
You might want to include for others a “View Large” link to show your image at 1024- or original resolution.
The code for referencing an image’s representation like
<a href="image—detail—view" title="Photo Sharing"><img src="image—url" width="1024" height="683" alt="image-title" /></a>
— copied to the clipboard — will replaced by
<a href="image—url">LINK_TEXT—property</a>
— still in the clipboard — to be copied in the image’s description.

Installation: put me in ~/Library/Scripts/Applications/Safari/ (even if I do nothing with it)
*)

property LINK_TEXT : "Großes Bild · View Large"

tell application "Safari"
set html to (the clipboard as text)
set oldDelimiters to AppleScript's text item delimiters
-- Brute force parsing
set AppleScript's text item delimiters to "\""
set htmlElements to html's text items
set currentTag to ""
repeat with element in htmlElements
if currentTag is "src" then
set pictureHref to element
else
if currentTag is "alt" then
set pictureName to element
else
if currentTag is "width" then
set pictureWidth to element
else
if currentTag is "height" then
set pictureHeight to element
end if
end if
end if
end if
if currentTag is not "" then set currentTag to ""
if element ends with "src=" then
set currentTag to "src"
else
if element ends with "alt=" then
set currentTag to "alt"
else
if element ends with "width=" then
set currentTag to "width"
else
if element ends with "height=" then
set currentTag to "height"
else
set currentTag to ""
end if
end if
end if
end if
end repeat
set AppleScript's text item delimiters to oldDelimiters

set the clipboard to "<a href=\"" & pictureHref & "\" title=\"" & pictureName & " (" & pictureWidth & "x" & pictureHeight & ")" & "\">" & LINK_TEXT & "</a>"
end tell


Want to post a reply?

Please Sign-In OR Sign-Up
< Previous 1 Next >
( 4 Posts )
Quantcast