I wish I had intellisense before

, , , 4 Comments »

I was just walking through all the sample web apps in the Spark project converting them from ${H(expr)} and ${expr} to ${expr} and !{expr}. One thing I hate to admit is how frequently I had demo data like product names going out without html encoding - so for me that’s kind of case in point on that particular feature.

The other thing I noticed was when I was working updating a _NavItem.spark partial file in a MonoRail web app. I saw a comparison of a value with a Context.Request.RawUrl and had an idle curiosity about what other properties might have been available.

So I thought, hey! Great time to see if that intellisense thing is working. Ctrl+space and Bam! That property is deprecated.

_ShowNav.spark

But even better than that is how well it informs you of the vast array of properties available at every level. I really wish we’d had this available a few projects ago. I guess you should never underestimate the value of your development tools.
Read the rest of this entry »

Spark build for the new year includes VS integration installer

, , , No Comments »

Happy new year! A new build for Spark has been posted on the download page that includes a SparkVsIntegration.msi file in the root of the zip. That file will deploy needed resources to Program Files\Spark and add registry entries.

Newer versions of the msi will upgrade these without needing to uninstall. To reverse any changes you may uninstall “Spark View Engine” from Control Panel at any time.

There are a few other changes, see release notes on download page for details, but one is based on a thread started by Kevin Dente.

There’s been a bunch of discussion in the blogosphere lately about XSS
and encoding output, with the the general consensus being “always HTML
encode your output”. Yet no view engines seem to do this. Have you
considered making Spark encode output by default (with a way to
escape, of course)? Or at least giving an expression syntax that
encodes by default (e.g #{expr}, ^{expr}, or whatever).

See also The Perfect Storm Botnet. In the end the feature allows you to opt-in to a configuration where you html-encode all ${expr} by default, and the expressions which you explicitly intend to hold raw html would use a !{expr} syntax.

Assuming you have an existing project there’s a migration path if you want to switch over. First go through your entire project and change $ to ! where you want html to come through.

<p>
  Hello ${H(user.Name)}
  ${Html.ActionLink("edit profile", "edit", "account")}
</p>

becomes

<p>
  Hello ${H(user.Name)}
  !{Html.ActionLink("edit profile", "edit", "account")}
</p>

You can verify your site’s still working because $ and ! work identically with automatic html encoding disabled. Then turn on the option with a config switch:

<configuration>
  <spark>
    <pages automaticEncoding="true"/>
  </spark>
</configuration>

You can verify your site is still working at this point because ${H(expr)} will ignore the redundant H(). Finally go through and remove those extra H()’s.

<p>
  Hello ${user.Name}
  !{Html.ActionLink("edit profile", "edit", "account")}
</p>

I have nothing to say

, , No Comments »

I feel like I should post something, but honestly I can’t think of a topic.

Nothing really to say about Spark. Don’t feel like doing a year in review. I try to avoid talking politics (though it has been an interesting year) and all of the current events are too awful.

I guess I could provide a video of Piggy, the Lord of Terror.

Created and uploaded by Alex. :)

Update: Ah - one thing I should mention is the Spark Visual Studio integration package preview 2.

Spark Language Package - Preview 1

, 8 Comments »

This is a very early copy of a msi which installs a Spark language package for Visual Studio 2008. It will put dlls into a Program Files\Spark directory and add just enough registry keys to add color and intellisense to files with a .spark extension.

Download Now Update: This link is obsolete - please visit the download page for the latest release bits.

I’ve tested installing and uninstalling which will remove the files and registry entries.

Eventually there may be a single installer that contains the VSIP files in addition to the things currently in the zip download - but for now they’re entirely separate. The copy of Spark.dll installed by the msi is used used by the language service for parsing and colorizing. It won’t conflict with the Spark.dll in the zip download, and that’s the file you should continue to use as an assembly reference in your projects.

As always feedback is welcomed.

Update: There’s been a report of “no effect” on XP sp2. I should also mention the installer has no user interface, so it’s normal for it for a small dialog box to show a progress bar move back and forth a bit then disappear without confirmation.

Also the spark file will need to be “Open With…” the “Source Code (Text) Editor” in case you’re using the xml or html editor.

Further Update: If you’re adding namespaces in the web.config or as code in global.asax they won’t be seen. Until that’s fixed try adding a Views\Shared\_global.spark file to hold things like:

<use namespace="System.Collections.Generic"/>
<use namespace="System.Linq"/>
<use namespace="System.Web.Mvc.Html"/>
<use namespace="MyApp.Models"/>

Using Spark as a general purpose template engine

, 5 Comments »

There was a question in the discussion group about using Spark as a simple text templating engine for creating email bodies like you can do with Velocity. Maybe they meant NVelocity?

In any case I put together a small console sample to verify the use case that I thought I would share here. It shows a few of the ways you can micro-manage how the Spark engine works by providing a specific base page and replacing the IViewFolder abstraction.

using System;
using Spark;
using Spark.FileSystem;

public class User
{
    public int Id { get; set; }
    public string Name { get; set; }
}

public abstract class EmailView : AbstractSparkView
{
    public User user { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        // following are one-time steps

        // create engine
        var settings = new SparkSettings()
            .SetPageBaseType(typeof(EmailView));

        var templates = new InMemoryViewFolder();
        var engine = new SparkViewEngine(settings)
                     {
                         ViewFolder = templates
                     };

        // add templates
        templates.Add("sample.spark", @"
Dear ${user.Name},

This is an email.

Sincerely,
Spark View Engine

http://constanto.org/unsubscribe/${user.Id}
");

        // following are per-render steps

        // render template
        var descriptor = new SparkViewDescriptor()
            .AddTemplate("sample.spark");

        var view = (EmailView)engine.CreateInstance(descriptor);
        view.user = new User { Id = 655321, Name = "Alex" };
        view.RenderView(Console.Out);
        Console.ReadLine();
    }
}

It’s alive! And it tells me what to do!

, , 17 Comments »

A while ago I took a moment to reflect on the functionality Spark had accumulated. It seems like the discussion group has been pretty quiet lately. I mentioned that to Tim and he reminded me of something I’d said earlier, “a view engine really only needs to do a handful of things - so much of the work is in framework.” So it might have hit that point where it does what it needs to do and you can call it version 1.

On the other hand if you look at the feedback from people who wouldn’t consider it a viable alternative there’s a definite theme surrounding Visual Studio integration in general and Intellisense in particular. So I decided a few weeks ago to muster up my courage and take another pass at the task of making a Visual Studio integration package to provide a Spark language service.

In an earlier post there was a comment from Pablo Blamirez that provided a really interesting lead with a few of the contained language interfaces. Then earlier last week I had some invaluable assistance from Phil Haack in tracking down some reference material on the subject. And I’m delighted to say all of the ingredients have finally come together, at least in a preliminary fashion.
Read the rest of this entry »

I’ve been Haacked

, , No Comments »

I mentioned in an earlier post I’d had a chance to meet Phil Haack when I was at the PDC a little while ago. One of the things that came up at the Asp.Net Mvc special interest table was the subject of third party view engines, and I’m happy he took me up on my request to take a closer look at Spark. It sounds like he liked what he saw and it has shown up in his blog posts about Rendering A Single View Using Multiple ViewEngines and ASP.NET MVC Northwind Demo Using the Spark View Engine.

The feedback in the comments are really great, too. Some people seem to get the benefits behind a simple text- and xml-editor-friendly view engine, while others point to the lack of intellisense or have a general sort of “it ain’t broke” attitude towards the webforms view engine.

Which is perfectly fine of course! The purpose was never to provide a superset of the aspx functionality as a feature-parity replacement. That would be insane. Rather it’s a syntax that’s optimized for a particular style of development and developer: someone that know what’s in their viewdata, knows what their html should look like, and doesn’t want the code to get in the way as the two come together. Plus some tricks to keep the templates nice and clean looking.

Although I suspect you can guess from the last post that the next thing for Spark could be a Visual Studio Integration Package for colorization and intellisense. Tricky! Probably have more on that later.

IVsIntellisenseless

, , , No Comments »

Just dropping in a quick post about what might be coming next… Still hunting down the holy grail of intellisense.

And as far as the Visual Studio SDK goes? You’ll never see a more wretched hive of undocumented interfaces and secret behaviors. I’ve down-shifted all the way to ATL C++ on this one to see eye-to-eye with the components the language service is integrating with, and it’s still a massive undertaking of black-box reverse engineering.

It’s not the VS SDK’s fault really. It’s the nature of the beast when you’re talking COM and OLE integration style. Lots of reasons for that.
Read the rest of this entry »

Things to do overload

, , , , No Comments »

There are far too many things to do! The rate things are being created can be overwhelming sometimes.

After reading Hansleman’s post about Web Platform Installer now supports XP - And the Master Plan continues I downloaded it and was very impressed. I also notices something called Application Request Routing which is added to my things-to-learn list.

If it is what I think it is and works as well as I hope it does it should fill a huge gap in the Microsoft web server platform. Lots of features/scenarios which Apache and Nginx servers have baked in. As much as I enjoy ISA Server and have seen it used successfully as a Layer-7 router for development environments, it’s always been trapped between two things it’s not. It’s not a web server (though it runs Windows) and it isn’t a network appliance, so it’s doesn’t fit traditional network design that won’t expose the Windows operating system to the internet without a firewall and load balancing appliance.

What else… Oh yes, holidays coming up so I’m only able to work one day this week. Hmm… It’s odd when you realize you’ve just typed “only able to work one day this week” as a problem. :)

The other thing to do is install Windows 2008 R2 Server Core and experiment with it’s support for Asp.Net. I’m hoping to check out PowerShell 2.0 while I’m doing that.

Seems like every time you turn around you’re faced with a dozen new things leaving you with that feeling you barely know anything about what the latest tools can do.

I also haven’t had time to blog about is support for IronRuby added to Spark. It’ll be old news I’m sure by the time I get to it.

Update wasted a few hours trying to install 2008 R2 in a virtual guest. Under both VMWare and Virtual PC the Windows setup complained a 64-bit process could not be started. Internet wisdom states a bios settings must be changed to allow hardware assisted virtualization - no such setting exists - tried to update bios - Dell firmware flashing app won’t run on my host o/s which is 64-bit. Do I really need to make a cmd prompt boot disk here? What year is it?

Lights on again

, , 3 Comments »


Based on some mixed feedback Where’s Lou has returned to the light side. I liked the dark theme but after returned to it with fresh eyes it was pretty intense. Plus the amber color palette is kind of “not done” on the internet, so when in Rome…

The theme on deck is Deliciously Blue - so tasty it hurts. :) The two things I was looking for were clean lines and lots of width for the text. Adjusting the css from 760 to 960 overall gave plenty of space in the content area.

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