Archive for the 'wiki/cms' Category
Saturday, January 2nd, 2010
Wordpress 2.9 has several new image enhancements. One of the biggest features is some basic image editing functionality. Another one is that you can now specify different alt text from the “caption” field. The “caption” field places a caption under the image. The “alt” text is used to describe the picture to non-seeing users (including search engines). This is a nice addition. However, I usually like my caption, alt text, and title text to be all the same, and I don’t like to have to enter it all manually or copy and paste. By default, wordpress will use an IPTC caption as its “description” field, which shows up in the title attribute of the image. This is nice, since I can add a caption in my image editing program of choice (Picasa) and then I don’t have to enter it again. Except for those pesky alt and caption fields, which are blank by default.
This is particularly important if I am uploading many pictures. So I wrote a little sql which will set the “caption” and “alt text” fields to be the same as the description. I already had this working for the “caption” field for quite some time, but getting it to work for the different alt text handling in 2.9 was a bit tricky, since I discovered that the alt text is not stored in wp_posts like the other fields. Instead it is stored in the wp_postmeta table, which is new in 2.9. Although it took me awhile to figure this out, the new table is a welcome addition. Now for each image you upload, wordpress stores meta information in this table, including the width and height, different sized versions of the file, the IPTC caption, some EXIF info and a few other goodies. This means that if you like to include EXIF info about your pictures, that doing so requires only a simple database lookup, instead of having to read the headers from the image, which should be considerably faster I would imagine.
Now for my little SQL which sets the “caption” and “alt text” to be the same as the description. I run this on my server after uploading pictures. It would be even better if I could figure out how to do this as a wordpress plugin.
-- First we set the image caption (post_excerpt) to be the same as the
-- description (post_content)
UPDATE wp_posts SET post_excerpt=post_content WHERE post_type='attachment' AND
date(post_date)=curdate();
-- Next we set the alternative text to be the same as the post_excerpt
INSERT INTO wp_postmeta (wp_postmeta.post_id, wp_postmeta.meta_value) SELECT
DISTINCT wp_posts.ID, wp_posts.post_excerpt FROM wp_posts, wp_postmeta WHERE
wp_posts.ID=wp_postmeta.post_id AND post_type='attachment' AND
date(post_date)=curdate();
-- This line sets the correct meta_key for the previous line, which doesn't
-- seem possible otherwise
UPDATE wp_postmeta SET meta_key='_wp_attachment_image_alt' WHERE meta_key IS
NULL;
Posted in sql, wiki/cms, wordpress | No Comments »
Tuesday, August 18th, 2009
The first question on reader’s mind must be — why use LaTeX to blog?
Well, I have a pretty specific instance in mind, but I can imagine that others might be interested as well. This fall I am teaching a course on computational corpus linguistics at CU Boulder. I like to have some materials online for the students, such as the syllabus, course notes, etc. I thought about setting up a simple webpage, but then I decided instead to use wordpress, because it would give me extra functionality, such as auto-generating rss feeds, and with some plugins, would allow me to notify students via e-mail when I post lecture notes or slides, or homework tips. The one drawback I could see is that it would be hard to update the syllabus throughout the semester, as I tend to change the calendar some throughout the semester. Then I thought that maybe I could hack up a quick xml-rpc solution to the problem, and about an hour later, I had it done. All I needed was the Wordpress::API perl module from CPAN.
Now I have a handy little publish script which first compiles my syllabus as pdf, then compiles it as html using plasTeX. Then I run it through tidy for formatting and hack in a few more things. Then I update the syllabus page on the course blog via xml-rpc. Finally, I rsync the pdf to the server. And with the post-notification plugin for wordpress, students will get an e-mail when the syllabus is updated.
Here are the scripts:
publish
#!/bin/bash
# this script compiles a pdf version, an html version, and then copies it to my
# webserver
# compile as pdf
pdflatex syllabus && pdflatex syllabus
# compile as html
plastex -c syllabus.cfg syllabus
# clean up code a bit
tidy --show-body-only true --ascii-chars true -asxhtml --input-encoding utf8 --output-encoding ascii -wrap 0 -indent --tab-size 4 syllabus/index.html > syllabus/syllabus.tmp
# add in link to pdf version in the html version
cat pdflink syllabus/syllabus.tmp > syllabus/syllabus.html
# update the syllabus page via xml-rpc
./updateSyllabusPage.pl
# upload the newest version of the pdf
rsync -avzu syllabus.pdf robfelty.com:/var/www/html/robfelty/teaching/ling5200Fall2009/ling5200Fall2009-syllabus.pdf
updateSyllabusPage.pl
#!/usr/bin/perl -w
use WordPress::API;
# get new syllabus content
my $contentFile = 'syllabus/syllabus.html';
open(CONTENT, $contentFile);
# slurp in content
$content = do {local ( $/ ); <CONTENT> };
my $w = WordPress::API->new({
proxy => 'http://robfelty.com/teaching/ling5200Fall2009/xmlrpc.php',
username => 'myusername',
password => 'mypassword',
});
my $page = $w->page(3);
$page->description($content);
$page->save;
Finally, if you want to see how I customize content for pdf and html separately, you can check out the LaTeX source file
Tags: blog, plastex, xmlrpc
Posted in (x)html, latex, wiki/cms, wordpress | 2 Comments »
Friday, June 5th, 2009
Thanks to all the users who helped me test out the 1.3.testing version of postie, the wordpress plugin which allows you to post by e-mail. I now feel that it is stable enough to call it 1.3.alpha. There are probably still some bugs, but I think that the new features probably warrant giving it a try for most users. Here is a summary of the new features and fixes:
- Now using default wordpress image and upload handling, which means:
- No more creating special directories for postie
- No more confusion about imagemagick
- Can now use the gallery feature of wordpress
- Attachments are now connected to posts in the database
- All image resizing uses wordpress’s default settings (under media)
- Configuration, settings and documentation improvements
- Completely redesigned settings page (mostly thanks to Rainman)
- Reset configuration no longer deletes mailserver settings
- Now including help files and faq directly in settings page
- More media features
- Automatically turn links to youtube into an embedded player
- Added option to embed audio files with custom templates
- Video options are now template based
- Image options are now solely template based, with several new default
templates
- Bug fixes
- Uploading images from vodafone phones should now work
- Correctly handling Windows-1252 encoding
- Correctly handling non-ascii characters in subject line
I still need your help! As I mentioned there are bound to be some bugs, and I would appreciate if you give me feedback in the postie forum. Several people have also provided localizations. That is a big help. Some of the current localizations now need some updating. If you are familiar with that, I would be grateful. A .pot file is included with the postie distribution.
I have mostly stopped development on the 1.2 branch of postie. I will be adding new updates to postie in the development version.
Below is a screenshot of the new options page for postie.

Screenshot of the new postie options page, showing the video and audio templates
Tags: postie
Posted in (x)html, css, javascript, wiki/cms, wordpress | No Comments »
Monday, August 25th, 2008
I am happy to announce the release of my fourth collapsing X plugin for Wordpress. This one is Collapsing Links, which was requested by several users of my other plugins. With the development of this plugin, I finally added the ability to have multiple instances of the widget. This took some careful study of some of the default wordpress plugins, and forced me to completely re-design how the plugin options are handled. In addition to the ability to have multiple instances of the plugin, the re-design also reduced the number of database queries, since now all the options for the plugin are stored in one row in the database. For more details, look at the Collapsing Links page.
Now that I have figured out these details, I plan on re-working the remaining plugins to allow multiple instances of the widgets as well. Expect to see these updates over the next few weeks.
There is one downside to having multiple instances of the widgets. In the current versions of Collapsing Archives, Categories, and Pages, you can use the plugin either as a widget or standalone. In future versions of the plugin, it will only work as a widget. When I originally wrote these plugins, widgets were new, and not standard for wordpress. Now they seem pretty ubiquitous, so hopefully this shouldn’t pose too much of a problem.
I hope that other people find the plugin useful. I must say that I enjoy developing wordpress plugins, since it a great way to utilize many different languages all at once — xhtml, css, javascript, php, and sql.
Tags: plugin, widget
Posted in (x)html, css, javascript, php, wiki/cms, wordpress | No Comments »
Thursday, February 14th, 2008
I am now trying out the scribefire Firefox extension for xml-rpc blogging, since I have discovered that QTM does not support image uploading, and it seems that scribefire does. It allows one to resize images, but it does not seem to create thumbnails. I will probably stick to posting the old-fashioned way, but it is nice to know that there are some other options.

Posted in wiki/cms, wordpress | 1 Comment »