Introduction

Every time I have to deal with svn:externals in SVN, I forget the command line syntax. Every single damn time. Normally, I use SVN GUI clients, such as SmartSVN, which make it very simple to add an svn:externals property. But for command line, it always takes looking at 25 different sites on google, which are all incredibly unhelpful for this question for some reason. Trying "svn help propset" on the command line was bloated and equally useless.

So this time I needed to write it down and make sure everyone who needed help with svn:externals would find exactly what they need here. I hope this page will soon come up on top of all the unhelpful results on google for "propset svn:externals" and other related queries.

The Problem

I want to set a simple svn:externals property in one of my project's directories, lets say 'plugins' (talking about Wordpress here). The outcome would be a directory called 'akismet' within 'plugins' that points to a remote svn url.

Various combinations of trying to do it produced pathetic results, like

svn propset svn:externals akismet http://plugins.svn.wordpress.org/akismet/trunk
svn: Setting property on non-local target 'http://plugins.svn.wordpress.org/akismet/trunk' needs a base revision
svn propset svn:externals . akismet http://plugins.svn.wordpress.org/akismet/trunk
svn: Error parsing svn:externals property on 'akismet': '.'
svn propset svn:externals akismet http://plugins.svn.wordpress.org/akismet/trunk akismet
svn: Setting property on non-local target 'http://plugins.svn.wordpress.org/akismet/trunk' needs a base revision

The Solution

Finally, thanks to this post, I found the right command:

svn propset svn:externals 'akismet http://plugins.svn.wordpress.org/akismet/trunk' .
property 'svn:externals' set on '.'

Note that dot at the end of the command and the quotes around the directory name and url.

Now commit via

svn commit

and then

svn up
Fetching external item into 'akismet' 
A    akismet/akismet.gif 
A    akismet/akismet.php 
A    akismet/readme.txt 
Updated external to revision 127962.
 
Updated to revision 16.

There, was it that hard, forum gurus and blog fiends?

Edit: in order to set multiple directory/url pairs in a single svn:externals property, you should put the individual dir/url pairs into a file (let's call it 'svn.externals'), like so

akismet http://svn.wp-plugins.org/akismet/trunk
all-in-one-seo-pack http://svn.wp-plugins.org/all-in-one-seo-pack/trunk

and then apply the property using

svn propset svn:externals -F svn.externals .

You should also just check in 'svn.externals' to easily keep track of it.

 
  • Share/Save/Bookmark

Updated: June 10th, 2009

* Lightning Fast is a blatant exaggeration. Got you to look though, didn't it?

Introduction

Whether you are a web developer or a self-hosting business owner, the only excuse for not activating compression capabilities of your web server can be that you didn't know about it. And now that you are reading this, there is no excuse left at all.

Here is how big a single page of this blog was before compression was enabled on CSS and Javascript files (computed by YSlow):

image

And here it is after compression:

image

As you see, the difference is quite substantial - almost 30% savings.

Compressing your HTML, XML, Javascript, CSS, etc pages will mean less data transferred between the server and the client which:

  • reduces the bandwidth usage.
  • provides faster page rendering which in turn leads to less user frustration, higher conversion rates, lower bounce rate, etc etc etc.

Compression is especially important for users with slow connections as every kilobyte of your code is that much more painful to them.

Compression can be very effective - you can easily shrink your text, code (HTML, XML, Javascript, CSS, etc) to 10% of the original size (of course, your mileage may vary). 100KB page that needs only 10KB to transfer? Sign me up!

So, before I talk about the solution, let me describe what exactly happens when compression is turned on and how it affects older browsers that don't support it.

image Are you using jQuery?

Did you know that a minified jQuery file is 55KB? In order to achieve the advertised 19KB, you would still need to compress the .js file using the methods listed here.

Compression Mechanism Explained

In order for compression to work in the first place, the web server (Apache in my example) needs to support it. This is achieved by enabling one of Apache modules called mod_deflate. The server will then be able to compress the data to the DEFLATE standard using either the zlib (also known as deflate) or gzip implementations. Yeah, DEFLATE is both the standard the one of its implementations, for those confused. I know I was. This is best described in this Wikipedia article.

The following mechanism is used:

  • the server with a compression extension enabled is able to serve either compressed (smaller) or uncompressed (larger) pages, depending on what the client supports.
  • the client (that is, your browser) sends a special header called "Accept-Encoding" listing the DEFLATE implementations it's capable of decompressing. For example "gzip,deflate".
  • the server picks the best compression supported by the client (if any), compresses the files, and sends them over to the client.
  • the client receives the compressed files and decompresses them.

Are you using a load blancer?

If you are using a load balancer, it may already be configured to compress pages that pass through it. In that case, there is no need to separately configure compression on your web servers. In fact, it should be off to save CPU.

Are Your Pages Already Compressed? Test Them!

If you are not sure whether you are already serving compressed pages or not, test them! My favorite way is by using Charles HTTP Debugger. Another option is by downloading Firebug for Firefox and installing Yahoo's YSlow or Google's Page Speed. Just look at the response headers to see if compression is on (look for the Content-Encoding header). Here are some before and after examples:

Theme CSS

image

Before:

image

After:

image

jQuery

image

Before:

image

After:

image

Solution

Create a .htaccess file in the top directory of your site with the following contents:

1
2
3
4
5
6
7
8
# DEFLATE by type - html, text, css, xml
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml
 
# DEFLATE by type - javascript
AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/x-js text/x-javascript
 
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml

Alternatively, you could put these lines into your Apache config within the Directory directive.

The AddOutputFilterByType directive adds DEFLATE filters to certain MIME types. I tried to assemble some of the common ones but feel free to add more, as each server may be configured differently and give out MIME types different from mine.

You can find your own server's MIME type definitions in the file that the TypesConfig directive is pointing to (mine is /etc/mime.types).

The AddOutputFilter directive binds the DEFLATE filter to specific file extensions, just in case they are not served with a proper MIME type. Feel free to add to this list as well.

Caveats

1. In order to use this whole compression/deflate/gzip business, your Apache server must first have mod_deflate enabled. Without it, you will get the HTTP 500 error (Internal Server error). You can check which mods you already have enabled by checking with the output of phpinfo() function.

image

In order to enable mod_deflate, uncomment the line with "deflate_module" in your Apache config file. The location of this config file is highly dependant on your system. Some examples include

  • /etc/apache2/httpd.conf
  • /etc/httpd/conf/httpd.conf
  • c:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf
  • some other place where your system stores Apache config files (read the special note below for OpenSUSE).

Here's what you should have:

LoadModule deflate_module modules/mod_deflate.so

On OpenSUSE, you actually enable modules a bit differently. Go to /etc/sysconfig/apache2 and look for APACHE_MODULES=. Then add "deflate" to the list, if it's not already there.

Now, restart Apache and check the output of phpinfo() again.

2. Adding AddOutputFilter and AddOutputFilterByType to .htaccess requires such overrides to be authorized by the main Apache configuration for that directory, otherwise it will return error 500 as well. The option you are looking for is called "AllowOverride" and mine was set to "AllowOverride AuthConfig" which wasn't enough. Changing it to

AllowOverride AuthConfig FileInfo

or just

AllowOverride All

fixes the problem. You can find more info about AllowOverride here.

3. In Wordpress, if you are using Google Gears (Turbo mode) for caching some core Wordpress files, they will not show up compressed. That is because they're not served by the remote server but rather reside locally (think of it as permanent cache). I was very confused at first when I didn't see jQuery.js in the HTTP log and YSlow reported it uncompressed.

Are you a Wordpress user?

If you are a Wordpress user, don't assume Wordpress is going to automatically compress your pages. In fact, as you install more and more plugins, the payload becomes larger and larger with those additional CSS and Javascript files.

You owe it to yourself and to your users to immediately enable compression on your blog.

Here is what happened after I enabled compression on this blog.

Before:

image

After:

image

Bonus - WP Minify

For even better results, I suggest you have a look at my good friend and talented Wordpress master Thaya's plugin called WP Minify. It preprocesses and aggregates all or most of your CSS and Javascript into just 2 files, thus saving on the number of HTTP requests. It also minifies content to achieve smaller size.

My blog before WP Minify:

image

After WP Minify:

image

 

That's all folks. Let me know if something was unclear and I'll be glad to clarify it.

A few references that pointed me in the right direction and allowed me to provide a more complete solution:

 
  • Share/Save/Bookmark

IntenseDebate Introduces Plugins

Thursday, March 5th, 2009

image IntenseDebate, a popular Wordpress comment enhancer recently acquired by Automattic (the creator of WP), just announced plugin support. It’s a nice touch to the already useful commenting system that allows threading, easier comment moderation, reputation, voting, etc.

Let’s have a look at some of the announced plugins. Here’s what the comment block looks like with plugins enabled:

image

PollDaddy

This plugins allows you to add a poll to your comment. By the way, PollDaddy is also an Automattic brand.

image

Seesmic

Seesmic enables video comments that you can record right off your webcam.

image 

YouTube

I think this one is self-explanatory – you can easily insert youtube videos into your comments.

image

Smileys

Adds smiley support.

image

You can activate the plugins by going to the IntenseDebate dashboard and clicking the new Plugins tab.

In conclusion, here’s a nice WP hosted video that explains the new features:

 
  • Share/Save/Bookmark

If you're like me, most of your Wordpress plugins are checked out into your plugins directory from the official Wordpress SVN repository or some other one. I haven't updated any of mine for about a month and wanted to sync up everything quickly (including SVN externals). Here's a short command I ran to achieve that:

1
2
cd YOUR_BLOG_ROOT/wp-content/plugins;
find . -maxdepth 1 -type d -exec svn up {} \;

What this command does is finds the top level directories in your Wordpress plugins directory, then applies the "svn update" command to each, one by one.

The result is something like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Fetching external item into 'akismet'
A    akismet/readme.txt
Updated external to revision 50666.
 
Updated to revision 8094.
At revision 8094.
U    share-this/sharethis.php
Updated to revision 50666.
D    wp-postratings/postratings-admin-js.php
D    wp-postratings/postratings-usage.php
D    wp-postratings/postratings-js.php
A    wp-postratings/postratings-js-packed.js
U    wp-postratings/wp-postratings.php
A    wp-postratings/postratings-admin-js.js
U    wp-postratings/postratings-css.css
U    wp-postratings/postratings-options.php
A    wp-postratings/postratings-templates.php
U    wp-postratings/postratings-stats.php
U    wp-postratings/readme.html
A    wp-postratings/postratings-js.js
U    wp-postratings/wp-postratings.pot
U    wp-postratings/wp-postratings-widget.php
U    wp-postratings/postratings-uninstall.php
U    wp-postratings/postratings-admin-ajax.php
U    wp-postratings/wp-postratings.mo
U    wp-postratings/readme.txt
U    wp-postratings/postratings-manager.php
A    wp-postratings/postratings-admin-js-packed.js
Updated to revision 50666.
At revision 8094.
...

With such mass updating, of course, an incompatibility in one of the updates can break the whole blog. In my case, it happened to be the latest version of wp-sticky. I identified it by disabling wp-super-cache first, then disabling each updated plugin one by one. Once identified, I did the following:

1
2
cd wp-sticky
svn log | head

That showed me the latest commits by the author as well as the SVN revision numbers. I then used this information to revert one revision back by doing:

1
svn up -r 50489

The following command showed a diff of what exactly changed in that revision and broke everything:

1
svn diff -r50489:50490

Once everything was stable, I emailed the plugin author to tell him about the bug (heya, Lester). Be careful not to run 'svn up' on this directory again until the bug is fixed as it'll persistently update to the latest version.

 
  • Share/Save/Bookmark

Beer Planet Upgraded To Wordpress 2.5

Saturday, March 29th, 2008

Updated: June 16th, 2008

1
svn sw http://svn.automattic.com/wordpress/tags/2.5

and Beer Planet is on 2.5. There were no problems with the upgrade itself or any of the plugins. Great work on the new clean interface and multi-file upload, Wordpress!

Info here: http://codex.wordpress.org/Version_2.5 (short) and http://wordpress.org/development/2008/03/wordpress-25-brecker/ (more detailed)

 
  • Share/Save/Bookmark