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…

GD Star Rating
loading...

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.

GD Star Rating
loading...
Posted in English. Tags: , . No Comments »

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 :
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
32
33
34
35
36
37
38
39
40
41
42
43
<!-- Import of the MSBuildCommunityTask targets -->
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
 
<!-- to manage version number -->
<Target Name="Version">
  <Version VersionFile="version.txt" RevisionType="Increment">
    <Output TaskParameter="Major" PropertyName="Major" />
    <Output TaskParameter="Minor" PropertyName="Minor" />
    <Output TaskParameter="Build" PropertyName="Build" />
    <Output TaskParameter="Revision" PropertyName="Revision" />
  </Version>
</Target>
 
  <!-- to generate our personnal version info -->
  <Target Name="AssemblyInfo">
 
  <SvnVersion LocalPath="$(MSBuildProjectDirectory)">
    <Output TaskParameter="Revision" PropertyName="Build" />
  </SvnVersion>
 
  <AssemblyInfo
    CodeLanguage="CS"
    OutputFile="Properties\AssemblyInfo.cs"
    AssemblyTitle="Title"
    AssemblyDescription="Description"
    AssemblyCompany="Company"
    AssemblyProduct="product"
    AssemblyCopyright="Copyright © 2009"
    ComVisible="false"
    Guid="88812638-9547-4480-9bf4-4fe25103b35c"
    AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
    AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
    Condition="$(Revision) != '0' "/>
</Target>
 
<!-- We launch these two targets -->
<Target Name="BeforeBuild">
    <CallTarget Targets="Version" />
    <CallTarget Targets="AssemblyInfo" />
</Target>
 
<Target Name="AfterBuild">
</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();
  }
}
GD Star Rating
loading...
Posted in English. Tags: , . 9 Comments »