Recently I was working on a WordPress site that contains a large number of external links both in the content and in the sidebars. One of the requirements for the external links is that they be designated by an icon, such as is common on many sites. I wanted to achieve two things with my solution:
- Create something simple so that the users don’t have to add CSS classes to links or fiddle with positioning images manually
- Prevent a developer from needing to constantly modify or tweak site styles whenever a user needs to add additional content
jQuery’s robust selectors work perfectly for this. Since TinyMCE (WordPress’ default Rich Text Editor) allows users to toggle a link so that it opens in a new window using the classic “target=_blank” attribute, I decided that I’d leverage this mechanism. The script for accomplishing this is short and sweet, a single line of jQuery and a couple lines of CSS styling. The script is here, with some formatting for readability:
<script type=”text/javascript”>jQuery(‘a[target="_blank"]‘).attr({title: “Opens in a new window”}).append(‘<span class=”external_link”> </span>’);</script>
What this script does is search the DOM for any <a> tag that has the “target=_blank” attribute and add a span tag with the class “external_link”. With that in place, it’s a simple CSS class to handle the positioning and appearance of the external link image. This is what mine looks like:
.external_link{width: 14px;height: 14px;margin-left: 5px;padding: 0px 5px;background: url(images/external-blue.png);background-repeat: no-repeat;}
jQuery(‘a[@href^="http://"]‘);
I’ve been working on a social networking app called What’s Shakin’ (www.whatshakin.net). The desktop version of the app runs in AIR and I’ve developed it with Flex.
For some third-party API calls, I needed to use OAuth. I found this Actionscript implementation of OAuth by Dan Petitt: http://www.coderanger.com/blog/?p=59
However, I ran into one problem, which other commenters on the blog also had. If any of your POST fields have certain special characters in them (for example, apostrophes or parentheses), the library will fail.
The problem is that the library uses encodeURIComponent to encode the parameters. Unforunately, this function does not quite meet the requirements for oAuth encoding.
Per the oAuth specs (http://oauth.net/core/1.0a/), in addition to letters and numbers these are the only characters that don’t need to be encoded:
- . _ ~
Unfortunately, Actionscript’s encodeURIComponent function also does not encode these characters:
! * ‘ ( )
So any of these characters will cause an error when you try to use the library.
To solve this, I wrote my own methods, oAuthURIEncode, and oAuthURIDecode and included them as package functions. I then replaced every call to encodeURIComponent or decodeURIComponent in OAuthManager.as, Parameter.as, and QueryString.as with calls to my new function. Problem solved!
Here’s the source code, with my changes added:
For anyone constantly creating/managing Add, Deploy, Delete, Upgrade STSADM bat file scripts for each SharePoint project they do, I just came up with the following WSP agnostic scripts:
http://blog.bluesphereinc.com/wp-content/uploads/2012/01/STSADM_Scripts.zip
I do a lot of SharePoint development, creating new WSPs, constant tweaking, testing, and deployment to multiple environments. I like to use BAT scripts for the ease of copying WSPs to a server and just double clicking Upgrade, or whatever other deployment commands that are needed. However, this involved creating the entire set of BAT scripts over again for each specific WSP I intruduced. On some projects, I was managing up to 10 or more seperate WSPs. That made for a lot of scripts.
Twitter Feed
- Blog: Using jQuery to Add an Icon to External Links See how... http://t.co/HecawJWI
- Press Release : Address Change : http://t.co/Xr4olhpY
- OAuth with Flex and Actionscript? See how... http://t.co/UlsUWmhZ
- RT @SeeWhatsShakin: We are putting the finishing touches on beta, register now to try out early adopter -- http://t.co/td2G1Y5g