Skip to content

Commit

Permalink
Add version information to header of diagnostics pages
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaflanagan committed Jan 29, 2010
1 parent f6c298a commit 3a054f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rakefile.rb
Expand Up @@ -34,7 +34,7 @@
rescue
commit = "git unavailable"
end
asm.trademark = "Commit: " + commit
asm.trademark = commit
end

desc "Prepares the working directory for a new build"
Expand Down
17 changes: 14 additions & 3 deletions src/FubuMVC.Core/Diagnostics/BehaviorGraphWriter.cs
Expand Up @@ -3,20 +3,21 @@
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Text;
using FubuMVC.Core.Diagnostics.HtmlWriting;
using FubuMVC.Core.Diagnostics.TextWriting;
using FubuMVC.Core.Registration;
using FubuMVC.Core.Registration.Nodes;
using FubuMVC.Core.Runtime;
using FubuMVC.Core.Urls;
using HtmlTags;
using System.Linq;
using FubuMVC.Core.Util;

namespace FubuMVC.Core.Diagnostics
{
public class BehaviorGraphWriter
{
private const string sourceControlUrlBase = "http://github.com/DarthFubuMVC/fubumvc/";
private const string sourceControlUrlFormat = sourceControlUrlBase + "commit/{0}";
private readonly BehaviorGraph _graph;
private readonly IUrlRegistry _urls;

Expand Down Expand Up @@ -66,7 +67,7 @@ public static HtmlDocument BuildDocument(IUrlRegistry urls, string title, params
document.Title = realTitle;

var mainDiv = new HtmlTag("div").AddClass("main");
mainDiv.Add("h2").Text("FubuMVC Diagnostics");
mainDiv.Add("h2").Text("FubuMVC Diagnostics").Child(buildVersionTag());
var navBar = mainDiv.Add("div").AddClass("homelink");
navBar.AddChildren(new LinkTag("Home", urls.UrlFor<BehaviorGraphWriter>(w => w.Index())));
navBar.Add("span").Text(" > " + title);
Expand All @@ -79,6 +80,16 @@ public static HtmlDocument BuildDocument(IUrlRegistry urls, string title, params
return document;
}

private static HtmlTag buildVersionTag()
{
var fubuAssembly = typeof(BehaviorGraphWriter).Assembly;
var version = fubuAssembly.GetName().Version.ToString();
var commitAttribute = fubuAssembly.GetAttribute<AssemblyTrademarkAttribute>();
var commit = commitAttribute == null ? null : commitAttribute.Trademark;
var versionUrl = commit.IsNotEmpty() ? sourceControlUrlFormat.ToFormat(commit) : sourceControlUrlBase;
return new HtmlTag("span").Id("version-display").Text("version: ").Child(new LinkTag(version, versionUrl).Attr("title", commit));
}

public HtmlDocument Chain(ChainRequest chainRequest)
{
var title = "Chain " + chainRequest.Id;
Expand Down
10 changes: 10 additions & 0 deletions src/FubuMVC.Core/Diagnostics/diagnostics.css
Expand Up @@ -5,6 +5,10 @@
background-color: #ccc;
}

a, a:visited{
color: #111;
}

.main{
-moz-background-clip:border;
-moz-border-radius-topleft:6px;
Expand Down Expand Up @@ -126,4 +130,10 @@ table.details TH

.summary {
margin: 5px 10px;
}

#version-display{
float:right;
font-size:small;
font-weight:normal;
}

0 comments on commit 3a054f1

Please sign in to comment.