Tag Archives: JavaScript

Easy Edit Links – My New WordPress Plugin

So I’m making a new WordPress plugin that I’m calling Kalin’s Easy Edit Links, though I may change that before release. It’s just a little box that shows up in your page/post edit page that has a list of all pages, posts, categories, tags and links, with links to both the actual page and to the edit page.

Kalin's Edit Links Screenshot 1
Showing a list of posts with links and edit buttons

I figure this solves two hassles I have in making posts with WordPress. First, if I’m doing more than one post in a sitting, I want to be able to switch to the edit screen of the next post without waiting to load, then search through, the posts page. Second, I found myself constantly going back to my live site to find the link to a particular page so I could reference it. With this, I have it right there, ready to copy into my post. Google Chrome and Safari users can even drag and drop the link right into the post and it’s all ready to go. Firefox, for some reason converts the link into a relative link, which then breaks when it goes live 🙁 Imagine that, for once Safari does something better than FireFox. If anyone knows how to fix this in FireFox, please let me know. Internet Explorer can’t drag links at all, but at least you can copy and paste.

It seems like this plugin would be a processor hog since it needs to compile five different, potentially long lists, and needs to hit the database at least five times. However, I’ve built in a caching feature (see the debug output “not cached” in the image) that simply saves all it’s HTML to a WordPress option and loads it next time, giving you a little refresh button in the corner. When I write the settings page I might give the option for an automatic refresh on a timer, but I’m not sure if that’s even necessary.

Kalin's Edit Links Screenshot 1
Showing Categories

I should be releasing this plugin within a week or two, after I finish the settings menu.

I may even add a shortcode so you can add this little box into a post or into a sidebar… or perhaps I will simply copy this code and make a user-facing widget into a separate plugin.

I’m finding the WordPress platform quite enjoyable to work with and might just be switching my development focus away from Flash ActionScript toward PHP, HTML, CSS, JavaScript, jQuery and WordPress. An anarchist should be working with open-source technology.

Code is poetry.

Batch File Actions – a sample Appcelerator/Titanium app with source code

Warning: Nerd Alert!

I’ve been playing around with the Appcelerator/Titanium development platform lately, finally developing an app I’ve wanted to write for years: Batch File Actions. (I think in a previous post I called it Batch Rename.) Appcelerator is a sytem similar to Adobe AIR to allow people to use web technologies like HTML, CSS JavaScript and PHP to build applications that are packaged with the Appcelerator runtime which works on Linux, Windows or Mac, and with a few tweaks, can work on iPhone/iPad, Android and BlackBerry support coming soon.

The app I’m putting together is a tool that allows you to parse through folders and files and commit an action (move, delete, copy, rename) on any file and/or folder that matches certain criteria. At this point, the app is functional and seems to work just fine. However, I still haven’t added all the features I need to ensure both safety and usability. For example, you can enter a regular expression (regex) into the “name contains” field to place extremely complex rules on which files to select. The only issue is that only my fellow coders will even know what a regular expression is. I want to add a utility to build those regexes based on choices and selection boxes and whatnot, but that’ll be a bit of an undertaking.

I also need to add a “parse recursively” checkbox so users can pound through sub-folders and add an unzip option since I think I’ve actually been in situations where I wanted to parse through folders and programatically unzip multiple zip files…

…a little bug testing would be nice too considering that a few mistakes in my code could potentially do serious damage to someone’s data.

So here is the source code that I have written so far. You will of course, need to get the Appcelerator development environment and copy the files into your app’s directory in order to actually compile the app.

And here is the actual Batch File Actions app. I hesitate to actually put up this link because I fear someone will trust me too much. My point of this is more to provide example source code for others getting started in Appcelerator. So please DO NOT actually use this unless you are certain you have everything backed up on a drive not connected to your computer. I’m not aware of any serious issues, but I do not have any kind of Quality Assurance team in my apartment.

One funny bug I did find happened when I selected a folder, left the ‘name contains’ field blank so it caught all files, then I set it to copy those files and folders into a sub-folder of the folder I had selected. This appeared to copy all the files recursively into the folder an infinite number of times. I clicked on each subfolder and on each level there was just another copy of all the files and folders. I kept clicking and clicking until I had gone down 20 or 30 levels and still couldn’t find an end to the copied files. How that didn’t cause anything to crash, I don’t know. It must have given up after 256 levels or something.

Oh, yeah, the other cool thing about this app is that it prints all your options out in a JSON string (originally I wanted to create my own SQL-esque language, but I think JSON makes more sense). Right now this is kind of useless, but eventually I want to allow people to save the string to a file so it can be re-run again simply by opening the file or pasting the string into the textfield. Unfortunately, that stupid regex escape character (\) gets converted whenever I try to print a regex to the textfield.

Anyway, hope someone gets some use out of this–or at least takes my code for use in something else. Whatever you do, don’t accidentally delete all your porn.