use container, and jsonp
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
namespace UntappedWidgetGenerator.Web
|
using Nancy.Bootstrapper;
|
||||||
|
using Nancy.Routing;
|
||||||
|
using Nancy.TinyIoc;
|
||||||
|
using UntappedWidgetGenerator.Interface;
|
||||||
|
|
||||||
|
namespace UntappedWidgetGenerator.Web
|
||||||
{
|
{
|
||||||
using Nancy;
|
using Nancy;
|
||||||
|
|
||||||
public class Bootstrapper : DefaultNancyBootstrapper
|
public class Bootstrapper : DefaultNancyBootstrapper
|
||||||
{
|
{
|
||||||
// The bootstrapper enables you to reconfigure the composition of the framework,
|
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
|
||||||
// by overriding the various methods and properties.
|
{
|
||||||
// For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper
|
base.ConfigureApplicationContainer(container);
|
||||||
|
container.Register<IUntappedRepository, UntappedRepository>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,20 @@
|
|||||||
using System.Collections.Generic;
|
using Nancy;
|
||||||
using UntappedWidgetGenerator.Model;
|
using UntappedWidgetGenerator.Interface;
|
||||||
|
|
||||||
namespace UntappedWidgetGenerator.Web
|
namespace UntappedWidgetGenerator.Web
|
||||||
{
|
{
|
||||||
using Nancy;
|
|
||||||
|
|
||||||
public class IndexModule : NancyModule
|
public class IndexModule : NancyModule
|
||||||
{
|
{
|
||||||
public IndexModule()
|
public IndexModule(IUntappedRepository repository )
|
||||||
{
|
{
|
||||||
Get["/"] = x => View["Views/Index/Index.cshtml", "tparnell"];
|
Get["/"] = x => View["Views/Index/Index.cshtml", "tparnell"];
|
||||||
Get["/{username}/browse"] = x => View["Views/Index/Index.cshtml", (string)x.username];
|
Get["/{username}/browse"] = x => View["Views/Index/Index.cshtml", (string)x.username];
|
||||||
Get["/{username}/html"] = parameters =>
|
Get["/{username}/html"] = parameters =>
|
||||||
{
|
{
|
||||||
var info = new UntappedRepository().Get(parameters.username);
|
var info = repository.Get(parameters.username);
|
||||||
return View["Profile", info];
|
return View["Profile", info];
|
||||||
};
|
};
|
||||||
Get["/{username}"] = parameters => Response.AsJson(new UntappedRepository().Get((string)parameters.username));
|
Get["/{username}"] = parameters => Response.AsJson(repository.Get((string)parameters.username));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,7 @@
|
|||||||
$.fn.untappd = function (username) {
|
$.fn.untappd = function (username) {
|
||||||
this.each(function () {
|
this.each(function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
$.get("http://untappdwidget.azurewebsites.net/" + username)
|
$.get("http://untappdwidget.azurewebsites.net/" + username, function(data) { $(that).html(buildProfileTemplate(data, buildBadges(data))); }, "jsonp");
|
||||||
.success(function (data) {
|
|
||||||
$(that).html(buildProfileTemplate(data,buildBadges(data)));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using UntappedWidgetGenerator.Model;
|
||||||
|
|
||||||
|
namespace UntappedWidgetGenerator.Interface
|
||||||
|
{
|
||||||
|
public interface IUntappedRepository
|
||||||
|
{
|
||||||
|
WidgetViewModel Get(string username);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using CsQuery;
|
using CsQuery;
|
||||||
|
using UntappedWidgetGenerator.Interface;
|
||||||
using UntappedWidgetGenerator.Model;
|
using UntappedWidgetGenerator.Model;
|
||||||
|
|
||||||
namespace UntappedWidgetGenerator
|
namespace UntappedWidgetGenerator
|
||||||
{
|
{
|
||||||
public class UntappedRepository
|
public class UntappedRepository : IUntappedRepository
|
||||||
{
|
{
|
||||||
public WidgetViewModel Get(string username)
|
public WidgetViewModel Get(string username)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Interface\IUntappedRepository.cs" />
|
||||||
<Compile Include="Model\Badge.cs" />
|
<Compile Include="Model\Badge.cs" />
|
||||||
<Compile Include="Model\WidgetViewModel.cs" />
|
<Compile Include="Model\WidgetViewModel.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user