Tag Archives: SVN

WP Codebox Quick fix for WordPress 2.9

This bug has been fixed !

I like to have the latest version of WordPress, this is why I use the SVN version. And recently the CSS of the “WP Codebox” plugin stopped working. Here the explanation and the solution :

It seems that starting with the 2.9 version, you can register the styles in the “wp_print_scripts” action method. So in the wp-codebox.php file, you have to put this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
add_action('wp_print_scripts', 'Codebox_ScriptsAction');
function Codebox_ScriptsAction ()
{
    $cb_path = get_bloginfo('wpurl') . "/wp-content/plugins/wp-codebox"; //URL to the plugin directory
    if (! is_admin()) {
        wp_enqueue_script('jquery');
        wp_enqueue_script('codebox', $cb_path . '/js/codebox.js', array('jquery'), '0.1');
    }
}
 
add_action('wp_print_styles', 'Codebox_StylesAction');
function Codebox_StylesAction() {
        $cb_path = get_bloginfo('wpurl') . "/wp-content/plugins/wp-codebox"; //URL to the plugin directory
        if (! is_admin()) {
                wp_enqueue_style('codebox', $cb_path . '/css/codebox.css', array(), '0.1', 'screen');
        }
}

And it will work…

SVN : Go further

I’m not a huge fan of SVN. It’s crappy for file transfers and it easily locks. But still, it works pretty well for my relatively small needs and it’s super easy to setup. I’d like to talk a little bit about the things you might not know about SVN…

Hooks on the SVN Server
You might not know this but you can add a lot of personalized actions on your repository. You just have to add script files to the “hooks” directory of your repository. For a complete list of hooks file name, look here.
The two most important files you should consider adding are :

  • post-commit : This file is executed each time something is commited. With it you can send the change made during the last commit.
  • pre-revprop-change : This file controls what property you allow to change on your published files. It’s really useful when you want to allow people to edit some already committed logs.

Useful SVN properties on files and directories
SVN properties can be attached to files and directory to define special behaviors on the other clients or on the server. For a complete list of the SVN properties, look here. Here are for me the most important SVN properties :

  • svn:externals : Reference to an external SVN source. This is very useful, you can have the same files copied.
  • svn:needs-lock : This will force you to lock file(s) before committing them. This should be only use for special files like binary file that can’t be merged (Word can merge concurrent versions of the same file).

Quick note : A very bad idea I had was to put my SVN files within my dropbox folder. It creates a lot more locks than SVN normally does.

Insert SVN version and Build number in your C# AssemblyInfo file

Software version number is quite important. It helps you track what versions have your users when they report something. And when it’s linked to an SVN version number, it’s even better.

Well, with MSBuild Community Task, you can easily automatically generate smart version numbers, you have to:

  • Download MSBuildCommunityTasks
  • Make sure your “svn.exe” binary is in C:\program files\subversion\bin
  • Add this at the end of your .csproject file :

2011-07-02 update: As given in Markus comment, this code is a much better option:

1
2
3
4
5
6
7
8
9
10
11
12
13
<!-- Import of the MSBuildCommunityTask targets -->
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
 
  <!-- to AssemblyInfo to include svn revision number -->
<Target Name="BeforeBuild">
	<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(ProgramFiles)\VisualSVN\bin">
	   <Output TaskParameter="Revision" PropertyName="Revision" />
        </SvnVersion>
 
	<FileUpdate Files="Properties\AssemblyInfo.cs"
                Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
                ReplacementText="$1.$2.$3.$(Revision)" />
</Target

You should only have a “</Project>” field left…

Then, you just have to open your project and build your project, it will fail once (missing version.txt file) and then work forever. This will generate your Assembly & AssemblyFile versions like this: Major.Minor.SvnVersion.BuildVersion

In your C# code, to get your version, you just have to add something like that:

1
2
3
4
5
public static String Version {
  get {
    return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  }
}