Skip to content

Commit

Permalink
Added new MVC2 sample website.
Browse files Browse the repository at this point in the history
  • Loading branch information
troygoode committed Oct 29, 2010
1 parent 4ae3aec commit bc9dcb0
Show file tree
Hide file tree
Showing 60 changed files with 26,545 additions and 30 deletions.
62 changes: 62 additions & 0 deletions src/EngageNet.Mvc/EngageNet.Mvc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{60C8D259-A659-4B11-BAF2-54198F0ECD2C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EngageNet.Mvc</RootNamespace>
<AssemblyName>EngageNet.Mvc</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.Routing" />
</ItemGroup>
<ItemGroup>
<Compile Include="EngageProvider.cs" />
<Compile Include="Html\EngageExtensions.cs" />
<Compile Include="Html\EngageUrlBuilder.cs" />
<Compile Include="Html\EngageWidgetBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EngageNet\EngageNet.csproj">
<Project>{FFEC4881-58C8-43BC-B0C3-D97114725C70}</Project>
<Name>EngageNet</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
13 changes: 13 additions & 0 deletions src/EngageNet.Mvc/EngageProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace EngageNet.Mvc
{
public static class EngageProvider
{
public static string ApplicationDomain { get; set; }
public static IEngageNetSettings Settings { get; set; }

public static IEngageNet Build()
{
return new EngageNet(Settings);
}
}
}
17 changes: 17 additions & 0 deletions src/EngageNet.Mvc/Html/EngageExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Web.Mvc;

namespace EngageNet.Mvc.Html
{
public static class EngageExtensions
{
public static EngageUrlBuilder Engage(this UrlHelper urlHelper)
{
return new EngageUrlBuilder(urlHelper);
}

public static EngageWidgetBuilder Engage(this HtmlHelper htmlHelper)
{
return new EngageWidgetBuilder(htmlHelper);
}
}
}
40 changes: 40 additions & 0 deletions src/EngageNet.Mvc/Html/EngageUrlBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Web;
using System.Web.Mvc;

namespace EngageNet.Mvc.Html
{
public class EngageUrlBuilder
{
private readonly UrlHelper _urlHelper;

public EngageUrlBuilder(UrlHelper urlHelper)
{
_urlHelper = urlHelper;
}

private const string EngageOverlayUrlFormat = "https://{0}/openid/v2/signin?token_url={1}";
private const string EngageEmbedUrlFormat = "https://{0}/openid/embed?token_url={1}";

public string TokenUrl(string action, string controller)
{
return string.Format(
"{0}://{1}{2}",
_urlHelper.RequestContext.HttpContext.Request.ServerVariables["HTTPS"] == "ON" ? "https" : "http",
_urlHelper.RequestContext.HttpContext.Request.ServerVariables["HTTP_HOST"],
VirtualPathUtility.ToAbsolute(_urlHelper.Action(action, controller))
);
}

public string OverlayUrl(string action, string controller)
{
var tokenUrl = TokenUrl(action, controller);
return string.Format(EngageOverlayUrlFormat, EngageProvider.ApplicationDomain, _urlHelper.Encode(tokenUrl));
}

public string EmbedUrl(string action, string controller)
{
var tokenUrl = TokenUrl(action, controller);
return string.Format(EngageEmbedUrlFormat, EngageProvider.ApplicationDomain, _urlHelper.Encode(tokenUrl));
}
}
}
53 changes: 53 additions & 0 deletions src/EngageNet.Mvc/Html/EngageWidgetBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Web.Mvc;

namespace EngageNet.Mvc.Html
{
public class EngageWidgetBuilder
{
private readonly HtmlHelper _htmlHelper;

public EngageWidgetBuilder(HtmlHelper htmlHelper)
{
_htmlHelper = htmlHelper;
}

public MvcHtmlString LogOnLink(string linkText, string action, string controller)
{
var urlHelper = new UrlHelper(_htmlHelper.ViewContext.RequestContext);

var tb = new TagBuilder("a");
tb.AddCssClass("rpxnow");
tb.Attributes.Add("onclick", "return false;");
tb.Attributes.Add("href", urlHelper.Engage().OverlayUrl(action, controller));
tb.SetInnerText(linkText);
return MvcHtmlString.Create(tb.ToString(TagRenderMode.Normal));
}

public MvcHtmlString LogOnLinkScript()
{
return MvcHtmlString.Create(
"<script type=\"text/javascript\">\n" +
"var rpxJsHost = ((\"https:\" == document.location.protocol) ? \"https://\" : \"http://static.\");\n" +
"document.write(unescape(\"%3Cscript src='\" + rpxJsHost + \"rpxnow.com/js/lib/rpx.js' type='text/javascript'%3E%3C/script%3E\"));\n" +
"</script>\n" +
"<script type=\"text/javascript\">\n" +
"RPXNOW.overlay = true;\n" +
"RPXNOW.language_preference = 'en';\n" +
"</script>\n");
}

public MvcHtmlString InlineWidget(string action, string controller)
{
var urlHelper = new UrlHelper(_htmlHelper.ViewContext.RequestContext);

var tb = new TagBuilder("iframe");
tb.AddCssClass("rpxnow-embedded");
tb.Attributes.Add("src", urlHelper.Engage().EmbedUrl(action, controller));
tb.Attributes.Add("scrolling", "no");
tb.Attributes.Add("frameborder", "no");
tb.Attributes.Add("allowtransparency", "true");
tb.Attributes.Add("style", "width:400px;height:240px;");
return MvcHtmlString.Create(tb.ToString(TagRenderMode.Normal));
}
}
}
36 changes: 36 additions & 0 deletions src/EngageNet.Mvc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EngageNet.Mvc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("EngageNet.Mvc")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c635f157-a287-4378-bd4d-d7607dbdad25")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit bc9dcb0

Please sign in to comment.