mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
Roles! and other amends
This commit is contained in:
parent
c36de9cdc1
commit
79c96c933e
|
@ -3,16 +3,32 @@
|
|||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace BuildFeed.Areas.admin.Controllers
|
||||
{
|
||||
[Authorize(Users = "hounsell")]
|
||||
public class baseController : Controller
|
||||
{
|
||||
[Authorize(Roles = "Administrators")]
|
||||
// GET: admin/base
|
||||
public ActionResult index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[Authorize(Users = "hounsell")]
|
||||
public ActionResult setup()
|
||||
{
|
||||
if (!Roles.RoleExists("Administrators"))
|
||||
{
|
||||
Roles.CreateRole("Administrators");
|
||||
}
|
||||
if (!Roles.IsUserInRole("hounsell", "Administrators"))
|
||||
{
|
||||
Roles.AddUserToRole("hounsell", "Administrators");
|
||||
}
|
||||
|
||||
return RedirectToAction("index");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace BuildFeed.Areas.admin.Controllers
|
||||
{
|
||||
[Authorize(Users = "hounsell")]
|
||||
[Authorize(Roles = "Administrators")]
|
||||
public class usersController : Controller
|
||||
{
|
||||
// GET: admin/users
|
||||
|
@ -17,6 +17,29 @@ public ActionResult index()
|
|||
return View(Membership.GetAllUsers().Cast<MembershipUser>().OrderByDescending(m => m.IsApproved).ThenBy(m => m.UserName));
|
||||
}
|
||||
|
||||
public ActionResult admins()
|
||||
{
|
||||
List<MembershipUser> admins = new List<MembershipUser>();
|
||||
foreach(var m in Roles.GetUsersInRole("Administrators"))
|
||||
{
|
||||
admins.Add(Membership.GetUser(m));
|
||||
}
|
||||
|
||||
return View(admins.OrderByDescending(m => m.UserName));
|
||||
}
|
||||
|
||||
public ActionResult promote(string id)
|
||||
{
|
||||
Roles.AddUserToRole(id, "Administrators");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult demote(string id)
|
||||
{
|
||||
Roles.RemoveUserFromRole(id, "Administrators");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult approve(Guid id)
|
||||
{
|
||||
var provider = (Membership.Provider as RedisMembershipProvider);
|
||||
|
|
|
@ -7,5 +7,9 @@
|
|||
|
||||
<ul>
|
||||
<li>@Html.ActionLink("Manage users", "index", "users")</li>
|
||||
@if (User.Identity.Name == "hounsell")
|
||||
{
|
||||
<li>@Html.ActionLink("Initial setup", "setup")</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
|
|
42
Areas/admin/Views/users/admins.cshtml
Normal file
42
Areas/admin/Views/users/admins.cshtml
Normal file
|
@ -0,0 +1,42 @@
|
|||
@model IEnumerable<System.Web.Security.MembershipUser>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Administrators | BuildFeed";
|
||||
}
|
||||
|
||||
<h2>Administrators</h2>
|
||||
|
||||
<ul>
|
||||
<li>@Html.ActionLink("User Administration", "index")</li>
|
||||
<li>@Html.ActionLink("Return to Admin Panel", "index", "base")</li>
|
||||
</ul>
|
||||
|
||||
<table class="table table-striped table-bordered table-admin">
|
||||
<tr>
|
||||
<th>
|
||||
Username
|
||||
</th>
|
||||
<th>
|
||||
Email Address
|
||||
</th>
|
||||
<td>
|
||||
Last Login Time
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@foreach (MembershipUser mu in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => mu.UserName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => mu.Email)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => mu.LastLoginDate)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
<h2>User Administration</h2>
|
||||
|
||||
<ul>
|
||||
<li>@Html.ActionLink("View Administrators", "admins")</li>
|
||||
<li>@Html.ActionLink("Return to Admin Panel", "index", "base")</li>
|
||||
</ul>
|
||||
|
||||
<table class="table table-striped table-bordered table-admin">
|
||||
<tr>
|
||||
<th>
|
||||
|
|
244
Auth/RedisRoleProvider.cs
Normal file
244
Auth/RedisRoleProvider.cs
Normal file
|
@ -0,0 +1,244 @@
|
|||
using NServiceKit.DataAnnotations;
|
||||
using NServiceKit.DesignPatterns.Model;
|
||||
using NServiceKit.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web.Security;
|
||||
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
|
||||
|
||||
namespace BuildFeed.Auth
|
||||
{
|
||||
public class RedisRoleProvider : RoleProvider
|
||||
{
|
||||
public override string ApplicationName
|
||||
{
|
||||
get { return ""; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
var uClient = rClient.As<RedisMember>();
|
||||
|
||||
List<RedisRole> roles = new List<RedisRole>();
|
||||
roles.AddRange(from r in client.GetAll()
|
||||
where roleNames.Any(n => n == r.RoleName)
|
||||
select r);
|
||||
|
||||
List<RedisMember> users = new List<RedisMember>();
|
||||
users.AddRange(from u in uClient.GetAll()
|
||||
where usernames.Any(n => n == u.UserName)
|
||||
select u);
|
||||
|
||||
for (int i = 0; i < roles.Count; i++)
|
||||
{
|
||||
List<Guid> newUsers = new List<Guid>();
|
||||
|
||||
if(roles[i].Users != null)
|
||||
{
|
||||
var usersToAdd = from u in users
|
||||
where !roles[i].Users.Any(v => v == u.Id)
|
||||
select u.Id;
|
||||
|
||||
newUsers.AddRange(roles[i].Users);
|
||||
|
||||
newUsers.AddRange(usersToAdd);
|
||||
}
|
||||
|
||||
roles[i].Users = newUsers.ToArray();
|
||||
}
|
||||
|
||||
client.StoreAll(roles);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CreateRole(string roleName)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
|
||||
RedisRole rr = new RedisRole()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
RoleName = roleName
|
||||
};
|
||||
|
||||
client.Store(rr);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
|
||||
var role = client.GetAll().SingleOrDefault(r => r.RoleName == roleName);
|
||||
|
||||
if (role.Users.Length > 0 && throwOnPopulatedRole)
|
||||
{
|
||||
throw new Exception("This role still has users");
|
||||
}
|
||||
|
||||
client.DeleteById(role.Id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
var uClient = rClient.As<RedisMember>();
|
||||
|
||||
var userIds = from r in client.GetAll()
|
||||
where r.RoleName == roleName
|
||||
from u in r.Users
|
||||
select u;
|
||||
|
||||
var users = uClient.GetByIds(userIds);
|
||||
|
||||
return (from u in users
|
||||
where u.UserName.Contains(usernameToMatch)
|
||||
select u.UserName).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] GetAllRoles()
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
|
||||
return (from r in client.GetAll()
|
||||
select r.RoleName).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] GetRolesForUser(string username)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
var uClient = rClient.As<RedisMember>();
|
||||
|
||||
var user = uClient.GetAll().SingleOrDefault(u => u.UserName == username);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("Username does not exist");
|
||||
}
|
||||
|
||||
return (from r in client.GetAll()
|
||||
where r.Users != null
|
||||
where r.Users.Any(u => u == user.Id)
|
||||
select r.RoleName).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] GetUsersInRole(string roleName)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
var uClient = rClient.As<RedisMember>();
|
||||
|
||||
var userIds = from r in client.GetAll()
|
||||
where r.RoleName == roleName
|
||||
from u in r.Users
|
||||
select u;
|
||||
|
||||
var users = uClient.GetByIds(userIds);
|
||||
|
||||
return (from u in users
|
||||
select u.UserName).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsUserInRole(string username, string roleName)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
var uClient = rClient.As<RedisMember>();
|
||||
|
||||
var user = uClient.GetAll().SingleOrDefault(u => u.UserName == username);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
var role = client.GetAll().SingleOrDefault(r => r.RoleName == roleName);
|
||||
|
||||
if(role.Users == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return role.Users.Any(u => u == user.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
var uClient = rClient.As<RedisMember>();
|
||||
|
||||
List<RedisRole> roles = new List<RedisRole>();
|
||||
roles.AddRange(from r in client.GetAll()
|
||||
where roleNames.Any(n => n == r.RoleName)
|
||||
select r);
|
||||
|
||||
List<RedisMember> users = new List<RedisMember>();
|
||||
users.AddRange(from u in uClient.GetAll()
|
||||
where usernames.Any(n => n == u.UserName)
|
||||
select u);
|
||||
|
||||
for (int i = 0; i < roles.Count; i++)
|
||||
{
|
||||
roles[i].Users = (from u in roles[i].Users
|
||||
where !users.Any(v => v.Id == u)
|
||||
select u).ToArray();
|
||||
}
|
||||
|
||||
client.StoreAll(roles);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RoleExists(string roleName)
|
||||
{
|
||||
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
||||
{
|
||||
var client = rClient.As<RedisRole>();
|
||||
|
||||
return client.GetAll().Any(r => r.RoleName == roleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataObject]
|
||||
public class RedisRole : IHasId<Guid>
|
||||
{
|
||||
[Key]
|
||||
[Index]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[@Required]
|
||||
[DisplayName("Role name")]
|
||||
[Key]
|
||||
public string RoleName { get; set; }
|
||||
|
||||
public Guid[] Users { get; set; }
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<ApplicationInsightsResourceId>/subscriptions/4af45631-0e5c-4253-9e38-d0c47f9c5b32/resourcegroups/Default-ApplicationInsights-CentralUS/providers/microsoft.insights/components/BuildFeed</ApplicationInsightsResourceId>
|
||||
<NuGetPackageImportStamp>a0e53051</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>8ba59b7f</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -66,9 +66,9 @@
|
|||
<Reference Include="Microsoft.Diagnostics.Instrumentation.Extensions.Intercept">
|
||||
<HintPath>..\packages\Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.0.12.0-build02810\lib\net40\Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=1.1.13.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=1.1.14.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.13-beta\lib\net40\Microsoft.Diagnostics.Tracing.EventSource.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.14-beta\lib\net45\Microsoft.Diagnostics.Tracing.EventSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Threading.Tasks">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
|
||||
|
@ -174,6 +174,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Areas\admin\Controllers\baseController.cs" />
|
||||
<Compile Include="Auth\RedisRoleProvider.cs" />
|
||||
<Compile Include="Code\BuildDateTimeModelBinder.cs" />
|
||||
<Compile Include="Code\DisplayHelpers.cs" />
|
||||
<Compile Include="App_Start\BundleConfig.cs" />
|
||||
|
@ -192,6 +193,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Models\ApiModel\SearchResult.cs" />
|
||||
<Compile Include="Models\Build.cs" />
|
||||
<Compile Include="Models\LabMeta.cs" />
|
||||
<Compile Include="Models\ViewModel\LoginUser.cs" />
|
||||
<Compile Include="Models\ViewModel\ChangePassword.cs" />
|
||||
<Compile Include="Models\ViewModel\RegistrationUser.cs" />
|
||||
|
@ -210,6 +212,7 @@
|
|||
<Content Include="content\Web.config" />
|
||||
<Content Include="Areas\admin\Views\base\index.cshtml" />
|
||||
<Content Include="ApplicationInsights.config" />
|
||||
<Content Include="Areas\admin\Views\users\admins.cshtml" />
|
||||
<None Include="Properties\PublishProfiles\Milestone 1 FTP.pubxml" />
|
||||
<None Include="Scripts\jquery-2.1.1.intellisense.js" />
|
||||
<Content Include="googleacffc6da14c53e15.html" />
|
||||
|
@ -287,6 +290,7 @@
|
|||
<Content Include="Views\support\rss.cshtml" />
|
||||
<Content Include="Views\support\sitemap.cshtml" />
|
||||
<Content Include="Scripts\jsrender.min.js.map" />
|
||||
<Content Include="Views\build\lab.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
@ -335,8 +339,10 @@
|
|||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.0.12.0-build02810\build\Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.0.12.0-build02810\build\Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.14-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.14-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
|
||||
<Import Project="..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.14-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.targets" Condition="Exists('..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.14-beta\build\portable-net45+win8+wpa81\Microsoft.Diagnostics.Tracing.EventSource.Redist.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">
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using BuildFeed.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace BuildFeed.Controllers
|
||||
|
@ -152,7 +149,7 @@ public ActionResult edit(long id, Build build)
|
|||
}
|
||||
}
|
||||
|
||||
[Authorize(Users = "hounsell")]
|
||||
[Authorize(Roles = "Administrators")]
|
||||
public ActionResult delete(long id)
|
||||
{
|
||||
Build.DeleteById(id);
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
using System;
|
||||
using BuildFeed.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.ServiceModel.Syndication;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Mvc;
|
||||
using BuildFeed.Models;
|
||||
using X.Web.RSS;
|
||||
using X.Web.RSS.Enumerators;
|
||||
using X.Web.RSS.Structure;
|
||||
|
@ -70,7 +67,7 @@ public async Task<ActionResult> added()
|
|||
Title = build.FullBuildString,
|
||||
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id }))),
|
||||
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("info", new { controller = "Build", id = build.Id })) },
|
||||
// PubDate = build.Added - MUST FIX TO USE CORRECT FORMAT BEFORE RE-ENABLING
|
||||
InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
|
||||
}).ToList()
|
||||
}
|
||||
};
|
||||
|
|
|
@ -226,28 +226,30 @@ orderby bv.Key
|
|||
|
||||
public ActionResult xmlsitemap()
|
||||
{
|
||||
XNamespace xn = XNamespace.Get("http://www.sitemaps.org/schemas/sitemap/0.9");
|
||||
List<XElement> xlist = new List<XElement>();
|
||||
|
||||
// home page
|
||||
XElement home = new XElement("url");
|
||||
home.Add(new XElement("loc", Request.Url.GetLeftPart(UriPartial.Authority) + "/"));
|
||||
home.Add(new XElement("changefreq", "daily"));
|
||||
XElement home = new XElement(xn + "url");
|
||||
home.Add(new XElement(xn + "loc", Request.Url.GetLeftPart(UriPartial.Authority) + "/"));
|
||||
home.Add(new XElement(xn + "changefreq", "daily"));
|
||||
xlist.Add(home);
|
||||
|
||||
foreach(var b in Build.Select())
|
||||
{
|
||||
XElement url = new XElement("url");
|
||||
url.Add(new XElement("loc", Request.Url.GetLeftPart(UriPartial.Authority) + Url.Action("info", "build", new { id = b.Id })));
|
||||
XElement url = new XElement(xn + "url");
|
||||
url.Add(new XElement(xn + "loc", Request.Url.GetLeftPart(UriPartial.Authority) + Url.Action("info", "build", new { id = b.Id })));
|
||||
if(b.Modified != DateTime.MinValue)
|
||||
{
|
||||
url.Add(new XElement("lastmod", b.Modified.ToString("yyyy-MM-dd")));
|
||||
url.Add(new XElement(xn + "lastmod", b.Modified.ToString("yyyy-MM-dd")));
|
||||
}
|
||||
xlist.Add(url);
|
||||
}
|
||||
|
||||
XElement root = new XElement("urlset", xlist);
|
||||
XDeclaration decl = new XDeclaration("1.0", "utf-8", "");
|
||||
XElement root = new XElement(xn + "urlset", xlist);
|
||||
|
||||
XDocument xdoc = new XDocument(root);
|
||||
XDocument xdoc = new XDocument(decl, root);
|
||||
|
||||
Response.ContentType = "application/xml";
|
||||
xdoc.Save(Response.OutputStream);
|
||||
|
|
29
Models/LabMeta.cs
Normal file
29
Models/LabMeta.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using NServiceKit.DataAnnotations;
|
||||
using NServiceKit.DesignPatterns.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
|
||||
|
||||
namespace BuildFeed.Models
|
||||
{
|
||||
[DataObject]
|
||||
public class LabMeta : IHasId<string>
|
||||
{
|
||||
[Key]
|
||||
[Index]
|
||||
[@Required]
|
||||
public string Id { get; set; }
|
||||
|
||||
[DisplayName("Page Content")]
|
||||
[AllowHtml]
|
||||
public string PageContent { get; set; }
|
||||
|
||||
[DisplayName("Meta Description")]
|
||||
public string MetaDescription { get; set; }
|
||||
}
|
||||
}
|
|
@ -65,7 +65,7 @@
|
|||
{
|
||||
@Html.ActionLink("Edit", "edit", new { id = item.Id }, new { @class = "btn btn-default btn-xs" })
|
||||
}
|
||||
@if (User.Identity.Name == "hounsell")
|
||||
@if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
@Html.ActionLink("Delete", "delete", new { id = item.Id }, new { @class = "btn btn-danger btn-xs" })
|
||||
}
|
||||
|
@ -117,7 +117,7 @@
|
|||
<div class="list-group">
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
if (User.Identity.Name == "hounsell")
|
||||
if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
@Html.ActionLink("Administration", "index", new { controller = "base", area = "admin" }, new { @class = "list-group-item" })
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<p class="form-control-static">
|
||||
@Html.ActionLink("Edit", "edit", new { id = Model.Id }, new { @class = "btn btn-default btn-xs" })
|
||||
|
||||
@if (User.Identity.Name == "hounsell")
|
||||
@if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
@Html.ActionLink("Delete", "delete", new { id = Model.Id }, new { @class = "btn btn-danger btn-xs" })
|
||||
}
|
||||
|
|
140
Views/build/lab.cshtml
Normal file
140
Views/build/lab.cshtml
Normal file
|
@ -0,0 +1,140 @@
|
|||
@model IEnumerable<BuildFeed.Models.Build>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "BuildFeed";
|
||||
|
||||
|
||||
if (ViewBag.PageNumber > 1)
|
||||
{
|
||||
ViewBag.Title = string.Format("Page {1} | {0}", ViewBag.Title, ViewBag.PageNumber);
|
||||
}
|
||||
|
||||
ViewBag.ItemId = ViewContext.Controller.ValueProvider.GetValue("lab").RawValue;
|
||||
ViewBag.Title = string.Format("Builds from {1} | {0}", ViewBag.Title, ViewBag.ItemId);
|
||||
}
|
||||
|
||||
@section head
|
||||
{
|
||||
<meta name="description" content="Check out all the known builds to come out of the Windows development lab @ViewBag.ItemId through BuildFeed, a collaborative Windows build list" />
|
||||
<meta property="og:description" content="Check out all the known builds to come out of the Windows development lab @ViewBag.ItemId through BuildFeed, a collaborative Windows build list" />
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-9">
|
||||
<ul class="list-unstyled">
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<li>
|
||||
<div class="build-head">
|
||||
@Html.ActionLink("Info", "info", new { id = item.Id }, new { @class = "btn btn-info btn-xs" })
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
@Html.ActionLink("Edit", "edit", new { id = item.Id }, new { @class = "btn btn-default btn-xs" })
|
||||
}
|
||||
@if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
@Html.ActionLink("Delete", "delete", new { id = item.Id }, new { @class = "btn btn-danger btn-xs" })
|
||||
}
|
||||
<h3>@Html.DisplayFor(modelItem => item.FullBuildString)</h3>
|
||||
</div>
|
||||
<div class="build-foot">
|
||||
<span class="badge">@Html.DisplayFor(TypeOfSource => item.SourceType, "Enumeration")</span>
|
||||
@if (item.FlightLevel != BuildFeed.Models.LevelOfFlight.None)
|
||||
{
|
||||
<span class="badge">Flight Level: @Html.DisplayFor(TypeOfSource => item.FlightLevel, "Enumeration")</span>
|
||||
}
|
||||
@if (item.BetaWikiUri != null)
|
||||
{
|
||||
<a href="@item.BetaWikiServerUri" target="_blank" class="badge"><i class="fa fa-sm fa-link"></i> BetaWiki (Client)</a>
|
||||
}
|
||||
@if (item.BetaWikiServerUri != null)
|
||||
{
|
||||
<a href="@item.BetaWikiServerUri" target="_blank" class="badge"><i class="fa fa-sm fa-link"></i> BetaWiki (Server)</a>
|
||||
}
|
||||
@if (item.WinWorldPCUri != null)
|
||||
{
|
||||
<a href="@item.WinWorldPCUri" target="_blank" class="badge"><i class="fa fa-sm fa-link"></i> WinWorldPC</a>
|
||||
}
|
||||
@if (item.BetaArchiveUri != null)
|
||||
{
|
||||
<a href="@item.BetaArchiveUri" target="_blank" class="badge"><i class="fa fa-sm fa-link"></i> BetaArchive Wiki</a>
|
||||
}
|
||||
@if (item.LonghornMsUri != null)
|
||||
{
|
||||
<a href="@item.LonghornMsUri" target="_blank" class="badge"><i class="fa fa-sm fa-link"></i> Longhorn.ms</a>
|
||||
}
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="panel panel-default panel-search">
|
||||
<div class="panel-body">
|
||||
@Html.TextBox("search-input", "", new { @class = "form-control" })
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
@Html.ActionLink("Return to full listing", "index", new { controller = "build", area = "", page = 1 }, new { @class = "list-group-item" })
|
||||
</div>
|
||||
<div class="list-group">
|
||||
@if (User.Identity.IsAuthenticated)
|
||||
{
|
||||
if (Roles.IsUserInRole("Administrators"))
|
||||
{
|
||||
@Html.ActionLink("Administration", "index", new { controller = "base", area = "admin" }, new { @class = "list-group-item" })
|
||||
}
|
||||
@Html.ActionLink("Add a build", "create", new { controller = "build" }, new { @class = "list-group-item" })
|
||||
@Html.ActionLink("Change your password", "password", new { controller = "support" }, new { @class = "list-group-item" })
|
||||
@Html.ActionLink("Log out", "logout", new { controller = "support" }, new { @class = "list-group-item" })
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.ActionLink("Log in", "login", new { controller = "support" }, new { @class = "list-group-item" })
|
||||
@Html.ActionLink("Register", "register", new { controller = "support" }, new { @class = "list-group-item" })
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (ViewBag.PageCount > 1)
|
||||
{
|
||||
<ul class="pagination">
|
||||
@if (ViewBag.PageNumber > 1)
|
||||
{
|
||||
<li>@Html.ActionLink(HttpUtility.HtmlDecode("«"), ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(), new { page = ViewBag.PageNumber - 1 })</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="disabled"><span>«</span></li>
|
||||
}
|
||||
|
||||
|
||||
@for (int i = 1; i <= ViewBag.PageCount; i++)
|
||||
{
|
||||
<li @((i == ViewBag.PageNumber) ? "class=active" : "")>@Html.ActionLink(i.ToString(), ViewBag.Action as string, new { page = i })</li>
|
||||
}
|
||||
|
||||
|
||||
@if (ViewBag.PageNumber < ViewBag.PageCount)
|
||||
{
|
||||
<li>@Html.ActionLink(HttpUtility.HtmlDecode("»"), ViewBag.Action as string, new { page = ViewBag.PageNumber + 1 })</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="disabled"><span>»</span></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@section scripts
|
||||
{
|
||||
@Scripts.Render("~/bundles/jsrender")
|
||||
<script type="text/javascript" src="~/Scripts/bfs.js"></script>
|
||||
<script id="result-template" type="text/x-jsrender">
|
||||
<a href="{{:Url}}" class="list-group-item" title="{{:Title}}">
|
||||
<h4 class="list-group-item-heading">{{:Label}}</h4>
|
||||
<p class="list-group-item-text">{{:Group}}</p>
|
||||
</a>
|
||||
</script>
|
||||
}
|
|
@ -30,6 +30,12 @@
|
|||
<add name="BuildFeedMemberProvider" type="BuildFeed.Auth.RedisMembershipProvider"/>
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager defaultProvider="BuildFeedRoleProvider" enabled="true">
|
||||
<providers>
|
||||
<clear/>
|
||||
<add name="BuildFeedRoleProvider" type="BuildFeed.Auth.RedisRoleProvider"/>
|
||||
</providers>
|
||||
</roleManager>
|
||||
<httpModules>
|
||||
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web"/>
|
||||
</httpModules>
|
||||
|
@ -38,7 +44,7 @@
|
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Diagnostics.Tracing.EventSource" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.13.0" newVersion="1.1.13.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.14.0" newVersion="1.1.14.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
|
||||
<package id="Microsoft.Diagnostics.Instrumentation.Extensions.Intercept" version="0.12.0-build02810" targetFramework="net45" />
|
||||
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.13-beta" targetFramework="net45" />
|
||||
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.14-beta" targetFramework="net45" />
|
||||
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.2" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user