Starting with Spark in ten minutes

, , , No Comments »

Earlier today Donn Felker blogged about his new DimeCast episode:

# 113 – Saying Hello to the Spark View Engine

In this episode we are going to start a series where we take an indepth look at the Spark View Engine.

Spark is a view engine for Asp.Net Mvc and Castle Project MonoRail frameworks. The idea is to allow the html to dominate the flow and the code to fit seamlessly.

Very cool. Can’t wait to see it on a pc with audio.

It also reminds me I need to revamp the front page of the project site. I’d like for it to start with something like a quick article about creating a spark app instead of a bunch of random links.

Spark Macro for Uploadify, Take One-B

, , 10 Comments »

Matt recently wrote in ASP.NET MVC HtmlHelper for Uploadify, Take One about a fairly common problem in the shades of gray where html and code concerns overlap. It’s a game of trying to get the least of both evils mixed in with the other.

Matt makes a particularly insightful remark in a comment, “what I dislike is how the balance of language in the helpers tends to shift from C# to JavaScript or HTML.”

I’d agree with that. On the one hand you’re trying to avoid excessive code in your template, but in doing so you’re dragging markup into your code. It’s actually a great example of a primary use-case for a macro in the Spark language, which lets you declare a helper method in the template language.

Here is the HtmlHelper extension exactly as it appeared on Matt’s post:

/// <summary>
/// Renders JavaScript to turn the specified file input control into an
/// Uploadify upload control.
/// </summary>
/// <param name="helper"></param>
/// <param name="name"></param>
/// <param name="options"></param>
/// <returns></returns>
public static string Uploadify(this HtmlHelper helper, string name, UploadifyOptions options)
{
    string scriptPath = helper.ResolveUrl("~/Content/jqueryPlugins/uploadify/");

    StringBuilder sb = new StringBuilder();
    //Include the JS file.
    sb.Append(helper.ScriptInclude("~/Content/jqueryPlugins/uploadify/jquery.uploadify.js"));
    sb.Append(helper.ScriptInclude("~/Content/jqueryPlugins/uploadify/jquery.uploadify.init.js"));

    //Dump the script to initialze Uploadify
    sb.AppendLine("<script type=\"text/javascript\">");
    sb.AppendLine("$(document).ready(function() {");
    sb.AppendFormat("initUploadify($('#{0}'),'{1}','{2}','{3}','{4}','{5}',{6},{7});",
                    name, options.UploadUrl,
                    scriptPath, options.FileExtensions,
                    options.FileDescription, options.AuthenticationToken,
                    options.ErrorFunction ?? "null",
                    options.CompleteFunction ?? "null");
    sb.AppendLine();
    sb.AppendLine("});");
    sb.AppendLine("</script");

    return sb.ToString();
}

And here’s the same helper implemented as a macro:

<macro name="Uploadify" name="string" options="UploadifyOptions">

  <var scriptPath="Html.ResolveUrl('~/Content/jqueryPlugins/uploadify/')"/>

  !{Html.ScriptInclude("~/Content/jqueryPlugins/uploadify/jquery.uploadify.js")}
  !{Html.ScriptInclude("~/Content/jqueryPlugins/uploadify/jquery.uploadify.init.js")}

  <script type="text/javascript">
    $(document).ready(function() {
      initUploadify($('#!{name}'), '!{options.UploadUrl}',
        '!{scriptPath}', '!{options.FileExtensions}',
        '!{options.FileDescription}', '!{options.AuthenticationToken}',
        !{options.ErrorFunction ?? "null"},
        !{options.CompleteFunction ?? "null"});
    });
  </script>

</macro>

The usage of the helper remains nearly identical. It’s a method on the view now instead of an Html extension method… So:

<%= Html.Uploadify("fileInput", new UploadifyOptions { ... }) %>

becomes:

<%= Uploadify("fileInput", new UploadifyOptions { ... }) %>

or rather:

!{Uploadify("fileInput", new UploadifyOptions { ... })}

Server upgraded – brief service interruption

, , , No Comments »

The host this runs on was upgraded just now. Runtime for the VM Ubuntu host was 399 days. Hats off to slidehost for that quality of service!

Upgrade went well – some config files showed up as modified so there were some keep/replace prompts. But in general pretty smooth.

Did lose the php-fastcgi daemon in the upgrade though. So that was a bit of a rough moment after the reboot when both http://whereslou.com and http://sparkviewengine.com were toast.

Fortunately a quick Google search turned up this blog post from Elderec which got me up and running again.

Spark in the field – MarketWatch 5.0

, , 3 Comments »

The MarketWatch site has recently recently been the target of a massive renovation project. A highlight of some new features from an editorial perspective can be found at the Site tour, but I wanted to take some time to talk about it from a technology point of view.

The initial work for engineering began some time last year, approximately December, we began to create systems known to be necessary for the functionality that would be eventually required. The middle of the first quarter saw the completion of the joint efforts of the design agency and business stakeholders in the form of new IA/UX and design. With an ultimate target date of May 12th I’m sure you can appreciate the fact a huge number of things about the implementation needed to go very well.

Many people on several teams were involved in it’s creation. I can’t possibly name everyone involved but I wanted to recognize a few people who acted in a technical leadership capacity.
Read the rest of this entry »

Recipe for Spark build/dev machine on Virtual PC

, , , 4 Comments »

I had a Virtual PC instance die recently. Oddest thing – it wouldn’t accept network traffic anymore. If it wasn’t virtual I’d have assumed it was a hardware problem.

I need to create an RC2 build of Spark, so I need to recreate a suitable platform. To kill two birds with one stone I thought I would keep track of the software I installed to be able to run the Spark distribution build.
Read the rest of this entry »

Design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in