Showing posts with label Codename 'DiscMaster'. Show all posts
Showing posts with label Codename 'DiscMaster'. Show all posts

Tuesday, October 27, 2009

Codename 'DiscMaster' - Implementing a custom DataTypeAttribute

In MVC the default validation is provided by DataAnnotations (this is, of course, replaceable) and is fantastic if you ask me. Being able to define the validation principles at the scope of the Model instead of UI makes a much more friendly architecture and enables the controller to present it's data to any view imaginable while still holding together beneath it all.

The DataTypeAttributes available are great, but sometimes you might want to create your own, and so i hope you'll be pleased to learn it's actually really simple to do so:

The example code below is for a custom MaxLength attribute for a text property:

Usage:

  [MaxLength(Length=2, ErrorMessage="Text is to long")]
  public string sample { get; set; }

Code:

namespace DiscMaster.Web.Models.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
    public class MaxLengthAttribute : DataTypeAttribute
    {
        public int Length { get; set; }
        public MaxLengthAttribute() : base(DataType.Text)
        {
        }

        public override bool IsValid(object value)
       {
            string str = Convert.ToString(value, CultureInfo.CurrentCulture);
            if (string.IsNullOrEmpty(str))
                return true;

            if (str.Length > Length)
            {
                return false;
            }
            return true;
        }
    }
}

As always, Codename 'DiscMaster' can be found at: http://discmaster.codeplex.com/

Best regards,

P.

Codename 'DiscMaster' - Implementing custom HtmlHelpers

ASP.NET MVC has great support for writing your own HtmlHelpers, here's an example I wrote that takes a model of a player and outputs the profile picture (if any).

So now outputting the profile picture is trivial and from one source:
<%= Html.ProfileImage(Model, "", null, "70", new {style="float: left; padding-right: 10px; padding-bottom: 10px;"})  %>

The code below is the entire code that generates my helper. it's actually a extension method on the HtmlHelper class that uses a TagBuilder. diving further into that you could write class-specific helpers simply by adding the type to the param, like HtmlHelper<Player>..

using DiscMaster.Web.Models;
using DiscMaster.Web.Extensions;

namespace DiscMaster.Web.Helpers
{
    public static class ProfileImageHelper
    {
        public static string ProfileImage(this HtmlHelper helper, Models.Player player, string alternateText, string width, string height)
        {
            return ProfileImage(helper, player, alternateText, width, height, null);
        }

        public static string ProfileImage(this HtmlHelper helper, Models.Player player, string alternateText, string width, string height, object htmlAttributes)
        {
            // Create tag builder
            var builder = new TagBuilder("img");

            // Create valid id
            builder.GenerateId(player.UserName);

            // Add attributes
            string format = "{0}/{1}";
            if (!string.IsNullOrEmpty(width))
            {
                format = format + "&width={2}";
            }
            if (!string.IsNullOrEmpty(height))
            {
                format = format + "&height={3}";
            }

            builder.MergeAttribute("src", string.Format(format,"/Image.ashx?src=/Content/Media/Images/Players/",player.PlayerDetail.profilepicture.IfEmptyThen("noprofilepicture.png"),width,height));
            builder.MergeAttribute("alt", alternateText.IfEmptyThen(player.UserName));
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));

            // Render tag
            return builder.ToString(TagRenderMode.SelfClosing);
        }
    }
}

As always, the url to Codename 'DiscMaster': http://discmaster.codeplex.com/


Regards,

P.

Sunday, October 18, 2009

Codename ‘DiscMaster’ – Implementing MVC’s AJAX functionality

Seeing that i didn’t really finish the site 100% i figured i might as well go ahead and implement some additional features.

One of those features on top of my agenda was to implement some of the built-in Ajax features available in ASP.NET MVC.

So, now sporting a fresh new approach, the weather forecast from yr.no (read this post for history) is now AJAX enabled and more ‘MVC’-ish:

mvcajax-final This tutorial covers 8 steps:

1: creating a forecast model 2: moving the forecast fetch routine to the repository 3: extending the courses model 4: adding a Forecast action to the CoursesController 5: adding a Forecast partial view 6: enabling Ajax 7: updating the course details view to use AJAX calls 8: adding some fancy jQueryUI functionality

step 1: creating a forecast model

the model for our Forecast object is simple and easy, only thing to note are the three properties in the end that we’ll later use for navigational purposes.

public class Forecast
{
    public string DateFrom { get; set; }
    public string DateTo { get; set; }
    public string SymbolNumber { get; set; }
    public string Conditions { get; set; }
    public string Temperature { get; set; }
    public string Precipitation { get; set; }
    public string Wind { get; set; }
    public string WindSpeed { get; set; }
    public string WindDirection { get; set; }
    public int ForecastsCount { get; set; }
    public int ForecastIndex { get; set; }
    public int NextForecastIndex { get; set; }
}

step 2: moving the forecast fetch routine to the repository

If you’ve followed the previous posts you’ll have seen that earlier we wrote a fetch routine in the partial view that did pretty much everything.. now we’re going to update it, give it some additional features and make it more available throughout the site. The following methods go in the repository layer:

public Forecast GetForecast(Guid courseid, int forecastindex)
{
    return GetForecast(courseid.ToString(), forecastindex);
}
public Forecast GetForecast(string courseid, int forecastindex)
{
    List<Forecast> forecasts = GetForecasts(courseid);

    if (forecasts!=null)
    {
        return forecasts[forecastindex];
    }

    return null;
}
public List<Forecast> GetForecasts(string courseid)
{
    var course = GetCourse(courseid);

    if (!String.IsNullOrEmpty(course.CourseDetail.yr_weather))
    {
        List<Forecast> forecasts = null;

        // determine if the forecast is already stored in the cache..
        if (System.Web.HttpContext.Current.Cache[System.Web.HttpContext.Current.Server.UrlPathEncode(course.CourseDetail.yr_weather)] != null)
        {
            // .. if so, fetch it
            forecasts = (List<Forecast>)System.Web.HttpContext.Current.Cache[System.Web.HttpContext.Current.Server.UrlPathEncode(course.CourseDetail.yr_weather)];
        }
        else
        {
            // .. and if not, try to consume the source using a reader..
            try
            {

                // used to read the forecast xml
                System.Xml.XmlDocument doc = new XmlDocument();
                // our soon-to-be forecast node collection
                System.Xml.XmlNodeList nodelist = null;

                System.Xml.XmlTextReader reader = new XmlTextReader(System.Web.HttpContext.Current.Server.UrlPathEncode(course.CourseDetail.yr_weather));
                doc.Load(reader);

                // if all is loaded ok and data is there, simple xpath query to get the forecast data..
                if (doc != null)
                {
                    if (doc.HasChildNodes)
                    {
                        nodelist = doc.SelectNodes("/weatherdata/forecast/tabular/time");
                    }
                }

                if (nodelist != null)
                {
                    if (nodelist.Count > 0)
                    {
                        // iterate each forecast in the current group (day)

                        var forecastscol = from node in nodelist.OfType<XmlNode>()
                                    select new Forecast
                                    {
                                        DateFrom = DateTime.Parse(node.Attributes["from"].Value).ToString("yyyy-MM-dd HH:MM"),
                                        DateTo = DateTime.Parse(node.Attributes["to"].Value).ToString("yyyy-MM-dd HH:MM"),
                                        Conditions = node["symbol"].Attributes["name"].Value,
                                        SymbolNumber = node["symbol"].Attributes["number"].Value.PadLeft(2, '0'),
                                        Precipitation = node["precipitation"].Attributes["value"].Value,
                                        Temperature = node["temperature"].Attributes["value"].Value,
                                        Wind = node["windSpeed"].Attributes["name"].Value,
                                        WindDirection = node["windDirection"].Attributes["code"].Value,
                                        WindSpeed = node["windSpeed"].Attributes["mps"].Value
                                    };
                        forecasts = forecastscol.ToList();

                        foreach (Forecast forecast in forecasts)
                        {
                            forecast.ForecastsCount = forecasts.Count();
                            forecast.ForecastIndex = forecasts.IndexOf(forecast);
                            if (forecast.ForecastIndex == forecast.ForecastsCount-1)
                            {
                                forecast.NextForecastIndex = 0;
                            }
                            else
                            {
                                forecast.NextForecastIndex = forecast.ForecastIndex + 1;
                            }
                        }

                        // add entry to cache
                        System.Web.HttpContext.Current.Cache.Add(System.Web.HttpContext.Current.Server.UrlPathEncode(course.CourseDetail.yr_weather), forecasts, null, DateTime.Now.AddMinutes(60), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
                    }
                }
            }
            catch (Exception ex)
            {
                // just in case something went wrong we allow this to be blank for now..
            }
        }
        if (forecasts != null)
        {
            return forecasts;
        }
    }
    return null;
}

step 3: extending the Course model

Now we’ll add a simple method to our Course model that takes care of fetching the Forecasts no matter where we are calling it from:

public List<Forecast> Forecasts
{
    get
    {
        return new DiscMasterRepository().GetForecasts(this.courseid.ToString());
    }
}

step 4: adding a Forecast action to the CoursesController

Now it’s time to add the action method that we’ll use in our AJAX-enabled forecast routine:

//
// GET: /Courses/Forecast/5

public ActionResult Forecast(string courseid, int forecastindex)
{
    var forecast = repository.GetForecast(courseid, forecastindex);
    if (forecast!=null)
    {
        return PartialView("Forecast", forecast);
    }
    else
    {
        return PartialView("ForecastNotFound");
    }
}

step 5: adding a Forecast partial view

Now we’ll add a new Forecast.ascx partial view. Compared to the previous version (weather.ascx) this one is more clean and strongly typed to our Forecast model, thus enabling a much more controlled design:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DiscMaster.Web.Models.Forecast>" %>
<div id="forecast">
     <p>
        <strong><%= DateTime.Parse(Model.DateFrom).ToString("dddd, dd MMM hh:mm") %> - <%= DateTime.Parse(Model.DateTo).ToString("dddd, dd MMM hh:mm")%></strong>
        <br />
        <img alt='<%= Model.Conditions %>' style="float: left;" src='<%= String.Format("/Image.ashx?src=/Content/Media/Icons/Weather/{0}.png&width=64", Model.SymbolNumber) %>' />
        conditions: <%= Model.Conditions%>
        <br />
        temperature: <%= Model.Temperature%><sup>o</sup>C
        <br />
        precipitation: <%= Model.Precipitation%>
        <br />
        wind: <%= Model.Wind%> - <%= Model.WindSpeed%> mps <%= Model.WindDirection%>
       <%= Html.Hidden("newforecastindex", Model.NextForecastIndex) %>
    </p>
    <p>
    <em>viewing forecast <%= Model.ForecastIndex+1 %> of <%= Model.ForecastsCount %></em>
    </p>
</div>
<div class="forecastfooter">
    <small>
        Weather forecast from <a href="http://www.yr.no" target="_blank">yr.no</a> delivered by<br />the Norwegian Meteorological Institute and the NRK
    </small>
</div>

step 6: enabling AJAX

Enabling AJAX in the project is really easy – all we have to do is to add the following two lines in the site.Master file:

<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>

step 7: updating the course details view to use AJAX calls

Making an AJAX call from our ASP.NET MVC view (the built-in way) we’ll be using Ajax.BeginForm:

<% using (Ajax.BeginForm("Forecast", new AjaxOptions() {
                   UpdateTargetId = "forecastContainer",
                   LoadingElementId = "forecastLoading",
                   OnSuccess="forecastLoaded",
                   InsertionMode = InsertionMode.Replace
               })){ %>
Below is the entire code part that handles the forecast rendering. The code for our updated Details view now holds the AJAX wrapped request, and a function we’re calling in the end to update forecast index:
<script type="text/javascript">
    function forecastLoaded() {
        $("#forecastindex").get(0).value = $("#newforecastindex").get(0).value;
    }
</script>
    <h2><%= Model.CourseDetail.city %>, <%= Model.CourseDetail.country %></h2>
    <% if (!String.IsNullOrEmpty(Model.CourseDetail.yr_weather)) {
           %>
        <% using (Ajax.BeginForm("Forecast", new AjaxOptions() {
               UpdateTargetId = "forecastContainer",
               LoadingElementId = "forecastLoading",
               OnSuccess="forecastLoaded",
               InsertionMode = InsertionMode.Replace
           })){ %>
           <%= Html.Hidden("courseid", Model.courseid) %>
           <%= Html.Hidden("forecastindex", 1) %>
                <h3>Weather forecast</h3><input type="image" title="next forecast" src="/Image.ashx?src=/Content/Media/Icons/24x24/next.png&width=32" />
        <% } %>
        <div id="forecastContainer">
            <% Html.RenderPartial("~/Areas/Courses/Views/Courses/Forecast.ascx", Model.Forecasts[0]); %>
        </div>
        <div id="forecastLoading" style="display: none;"><img src="/Content/Media/Icons/load.gif" alt="loading.." /></div>
       <%} %>

step 8: adding some fancy jQueryUI functionality

At jQueryUI you can generate a custom file with the contents you wish to implement, i went with some of their effects since i think it’s a great library and the implementation is superb.

In the site.Master we’ll now need to add another line to the script includes:

<script src="/Scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
Now we’ll update the Details view with some animations – i chose the .hide and .show effects in a horizontal mode. The code below is the complete code for the forecast part of our course details view:
<script type="text/javascript">
    function forecastOnLoad() {
        $("div#forecastContainer").hide("slide", { direction: "horizontal" }, 1000);
    }
    function forecastLoaded() {
        $("#forecastindex").get(0).value = $("#newforecastindex").get(0).value;
        $("div#forecastContainer").show("slide", { direction: "horizontal" }, 1000);
    }
</script>
    <h2><%= Model.CourseDetail.city %>, <%= Model.CourseDetail.country %></h2>
    <% if (!String.IsNullOrEmpty(Model.CourseDetail.yr_weather)) {
           %>
        <% using (Ajax.BeginForm("Forecast", new AjaxOptions() {
               UpdateTargetId = "forecastContainer",
               LoadingElementId = "forecastLoading",
               OnBegin="forecastOnLoad",
               OnSuccess="forecastLoaded",
               InsertionMode = InsertionMode.Replace
           })){ %>
           <%= Html.Hidden("courseid", Model.courseid) %>
           <%= Html.Hidden("forecastindex", 1) %>
                <h3>Weather forecast</h3><input type="image" title="next forecast" src="/Image.ashx?src=/Content/Media/Icons/24x24/next.png&width=32" />
        <% } %>
        <div id="forecastContainer">
            <% Html.RenderPartial("~/Areas/Courses/Views/Courses/Forecast.ascx", Model.Forecasts[0]); %>
        </div>
        <div id="forecastLoading" style="display: none;"><img src="/Content/Media/Icons/load.gif" alt="loading.." /></div>
       <%} %>

and now the finished update will be Ajax enabled, fetching one forecast at a time using the built-in AJAX functionality available in ASP.NET MVC with some pretty jQueryUI effects:

mvcajax-final2 As always, the source code for the entire project can be downloaded at http://discmaster.codeplex.com

Take care,

P.

Tuesday, October 13, 2009

Codename 'DiscMaster' - now on CodePlex

I've published the project on CodePlex: http://discmaster.codeplex.com/ As of right now it's not in a stable, nor up to date, release. First scheduled publish of the current sourcecode is set to Thursday, 15th of October 2009. If you want to grab it it's there in it's current (somewhat fragile) state, but i suggest you wait until thursday before trying to run it locally since many changes will be uploaded on that day :) Regards, P.

Tuesday, October 06, 2009

Codename ‘DiscMaster’ – MVC 2 migration and more maps!

After following the upgrade instructions in the release notes (see previous post) i’ve now updated the sourcecode so it’s now based on MVC 2 Preview 2.

First thing to try was the new support for Areas:

areas You’ll find pretty much all the information you need on MSDN and blog articles when it comes to defining your areas and creating the initial code.

I’m convinced the areas addition is one of the key features when it comes to using ASP.NET MVC in the enterprise scope. Scoping your application thru the use of Areas is great when you consider large-scale projects where x number of developers could be working on x number of things, it not only helps the developer but also even branching strategies could benefit from this approach.

After that i had some time to wire up another map, this time it’s a map showing all the registered courses:

courses

i've decided to release the entire code on codeplex once i'm done at the project space i've recently set up (discmaster.codeplex.com), figured that's the only decent thing to do to keep it alive since i'm right now without a hosting environment so hopefully someone will pick it up and (ab)use it when it's released :)

until the next post, take care..

P.

Monday, October 05, 2009

Integrating weather from yr.no

UPDATED: there's a new implementation post here that uses MVC's built-in AJAX functionality.

a lot of places sell data, and often quite pricy too.. there are however a few that actually gives it away, i like that.

yr.no (the Norwegian Meteorological Institute and the NRK) exposes their weather data in xml format, both in norwegian as well as in english. I figured it was about time i tried it out since i really wanted to have some weather data on the discgolf site.

first, the basics:

the code i’m demonstrating is written in ASP.NET MVC, but it’s not anywhere near MVC-specific so you can easily take it all and run in your own solution.

for this example we’re gonna be using the following url:

http://www.yr.no/place/Sweden/Stockholm/J%c3%a4rva/forecast.xml

at yr.no it’s pretty easy to grab the url to the city of your choice (as long as they hold data for that city): just find it on their site and add forecast.xml in the end of the url.

so, after creating a partial view and setting some initial code up we get to consume the data from yr.no and output it to our site:

code:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DiscMaster.Web.Models.Course>" %>
<%@ Import Namespace="System.Xml" %>
<%
    System.Xml.XmlDocument doc = new XmlDocument();

    if (Cache[Server.UrlPathEncode(Model.CourseDetail.yr_weather)]!=null)
    {
        doc = (XmlDocument)Cache[Server.UrlPathEncode(Model.CourseDetail.yr_weather)];
    }
    else
    {
        try
        {
            System.Xml.XmlTextReader reader = new XmlTextReader(Server.UrlPathEncode(Model.CourseDetail.yr_weather));
            doc.Load(reader);
            Cache.Add(Server.UrlPathEncode(Model.CourseDetail.yr_weather), doc, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
        }
        catch (Exception ex)
        {
        
            throw;
        }
    }

    System.Xml.XmlNodeList nodelist = doc.SelectNodes("/weatherdata/forecast/tabular/time");
    for (int i = 0; i < 4; i++)
    {
     %>
     <p>
        <strong><%= DateTime.Parse(nodelist[i].Attributes["from"].Value).ToString("yyyy-mm-dd HH:MM") %> - <%= DateTime.Parse(nodelist[i].Attributes["to"].Value).ToString("HH:MM")%></strong>
        <br />
        <img src='<%= String.Format("/Image.ashx?src=/Content/Media/Icons/Weather/{0}.png&width=32", nodelist[i]["symbol"].Attributes["number"].Value.PadLeft(2,'0')) %>' />
        conditions: <%= nodelist[i]["symbol"].Attributes["name"].Value%>
        <br />
        temperature: <%= nodelist[i]["temperature"].Attributes["value"].Value%><sup>o</sup>C
        <br />
        precipitation: <%= nodelist[i]["precipitation"].Attributes["value"].Value%>
        <br />
        wind: <%= nodelist[i]["windSpeed"].Attributes["name"].Value%> - <%= nodelist[i]["windSpeed"].Attributes["mps"].Value%> mps <%= nodelist[i]["windDirection"].Attributes["code"].Value%>
    </p>
<%    }
     %>
<small>
    Weather forecast from <a href="http://www.yr.no" target="_blank">yr.no</a> delivered by the Norwegian Meteorological Institute and the NRK
</small>

view:

first nothing major really in that code.. the green-highlighted text in the example code is where the actual url to the xml data is entered.

a few minutes more and the code is more optimized to handle errors, linq and in the end i even had the time to throw in a little jQuery i found over at DynamicDrive called Featured Content Glider that i thought would do nicely for what i wanted this forecast to appear as..

so, now the final code:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DiscMaster.Web.Models.Course>" %>
<%@ Import Namespace="System.Xml" %>
<script type="text/javascript" src="/scripts/featuredcontentglider.js">
    /***********************************************
    * Featured Content Glider script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
</script>
<script type="text/javascript">

    featuredcontentglider.init({
        gliderid: "forecast", //ID of main glider container
        contentclass: "glidecontent", //Shared CSS class name of each glider content
        togglerid: "p-select", //ID of toggler container
        remotecontent: "", //Get gliding contents from external file on server? "filename" or "" to disable
        selected: 0, //Default selected content index (0=1st)
        persiststate: false, //Remember last content shown within browser session (true/false)?
        speed: 500, //Glide animation duration (in milliseconds)
        direction: "downup", //set direction of glide: "updown", "downup", "leftright", or "rightleft"
        autorotate: true, //Auto rotate contents (true/false)?
        autorotateconfig: [5000, 2] //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]
    })

</script>
<div id="forecast" class="glidecontentwrapper">
<%
    // used to read the forecast xml
    System.Xml.XmlDocument doc = new XmlDocument();
    // our soon-to-be forecast node collection
    System.Xml.XmlNodeList nodelist = null;

    // determine if the forecast is already stored in the cache..
    if (Cache[Server.UrlPathEncode(Model.CourseDetail.yr_weather)]!=null)
    {
        // .. if so, fetch it
        doc = (XmlDocument)Cache[Server.UrlPathEncode(Model.CourseDetail.yr_weather)];
    }
    else
    {
        // .. and if not, try to consume the source using a reader..
        try
        {
            System.Xml.XmlTextReader reader = new XmlTextReader(Server.UrlPathEncode(Model.CourseDetail.yr_weather));
            doc.Load(reader);
            // add entry to cache
            Cache.Add(Server.UrlPathEncode(Model.CourseDetail.yr_weather), doc, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
        }
        catch (Exception ex)
        {
            // just in case something went wrong we allow this to be blank for now..
            throw;
        }
    }

    // if all is loaded ok and data is there, simple xpath query to get the forecast data..
    if (doc!=null)
    {
        if (doc.HasChildNodes)
        {
             nodelist = doc.SelectNodes("/weatherdata/forecast/tabular/time");
        }
    }

    if (nodelist!=null)
    {
        if (nodelist.Count>0)
        {
            // restruct the nodelist to a queryable list, then group by the day of the forecast, and iterate 'em..
            foreach (var day in nodelist.OfType<XmlNode>().GroupBy(n => DateTime.Parse(n.Attributes["from"].Value).ToString("yyyy-MM-dd")))
            {
                // iterate each forecast in the current group (day)
                foreach (XmlNode node in day)
                {
             %>
             <div class="glidecontent">
                 <p>
                    <strong><%= DateTime.Parse(node.Attributes["from"].Value).ToString("yyyy-MM-dd HH:MM") %> - <%= DateTime.Parse(node.Attributes["to"].Value).ToString("HH:MM")%></strong>
                    <br />
                    <img style="float: left;" src='<%= String.Format("/Image.ashx?src=/Content/Media/Icons/Weather/{0}.png&width=64", node["symbol"].Attributes["number"].Value.PadLeft(2,'0')) %>' />
                    conditions: <%= node["symbol"].Attributes["name"].Value%>
                    <br />
                    temperature: <%= node["temperature"].Attributes["value"].Value%><sup>o</sup>C
                    <br />
                    precipitation: <%= node["precipitation"].Attributes["value"].Value%>
                    <br />
                    wind: <%= node["windSpeed"].Attributes["name"].Value%> - <%= node["windSpeed"].Attributes["mps"].Value%> mps <%= node["windDirection"].Attributes["code"].Value%>
                </p>
             </div>
        <%    }
            }
        }
    }
             %>
</div>
<div id="p-select" class="glidecontenttoggler">
<a href="#" class="prev"><img border="0" title="previous forecast" src="/Image.ashx?src=/Content/Media/Icons/24x24/previous.png&width=32" /></a><br /><a href="#" class="next"><img border="0" title="next forecast" src="/Image.ashx?src=/Content/Media/Icons/24x24/next.png&width=32" /></a>
</div>
<div class="forecastfooter">
    <small>
        Weather forecast from <a href="http://www.yr.no" target="_blank">yr.no</a> delivered by<br />the Norwegian Meteorological Institute and the NRK
    </small>
</div>

and the final view:

final

that’s really all there is to it.. some tweaking of the css and jQuery part to be more what i wanted it to be, but none the less it’s a fairly simple example and could hopefully give you some ideas or lend you some help.

external sources to this article:

Regards,

P.

Thursday, October 01, 2009

Codename 'DiscMaster' - weather and maps

the project keeps moving forward, and as stated earlier the project now has some initial integration with both maps (via Bing and some help from the great code in NerdDinner) and weather (via yr.no), here are some screenshots:

future enhancements will continue to be applied, but right now the next step is migrating the solution to ASP.NET MVC 2 Preview 2 that just came out.

example code and tutorials are coming too, as well as most of the source code.

stay tuned for further updates..

regards,

P.

Previous articles on CodeName 'DiscMaster':

Wednesday, September 16, 2009

Codename 'DiscMaster'

I get one specific question a lot: what would you develop on your own time if you could choose? That question raised has always left me hanging without an answer.. there's too much stuff to try, create, reengineer and analyze. For once i thought i'd actually go ahead and make sense of one of those ideas and turn it into something real. So, say hello to codename 'DiscMaster'! Codename 'DiscMaster' is a website/community for those of us that enjoy discgolfing (yes, i'm one of those people that throw a disc/frisbee around on a pseudo-golfcourse and call it fun). It's built on ASP.NET MVC, LINQ (including LINQ to SQL), Dynamic Data, Entity Framework and custom providers for Repository and Membership - to name but a few. Right now registration is per invitation only on a non-disclosed url and will continue that way while in development - this means that each member that is invited and registers can invite up to three more people to join. Right now registered users can:
  • view courses
  • manage courses
  • manage course layouts
  • manage their own profile
  • manage matches
  • view personal statistics
  • view match statistics
  • view players
  • generate reports
  • and much, much more!
Below are some screenshots showing (still in a standardized mvc layout) some of the features - names and personal details are crossed-out (ok, ok, i know i missed a spot) for privacy reasons but i'm sure you'll get the general idea.
Future updates to this project include:
  • Weather service integration
  • Maps service integration
  • Interactive graphs based on Silverlight
  • OpenID integration
  • Social Networks integration
Also, on a sidetrack, there's development in progress for an iPhone app with score synchronization..
More details, screenshots and thoughts regarding this project will come in later posts..
Regards,
P.