1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Fixed invalid CORs.

Fixed invalid HTML head elements.
Fixed invalid html elements.
This commit is contained in:
Uncled1023 2016-10-26 22:11:03 -07:00
parent e8eea8404e
commit d8044a9b8e
11 changed files with 110 additions and 122 deletions

View File

@ -65,11 +65,6 @@ namespace Teknik.Areas.Home
// Register Style Bundles // Register Style Bundles
BundleTable.Bundles.Add(new CdnStyleBundle("~/Content/home", config.CdnHost).Include( BundleTable.Bundles.Add(new CdnStyleBundle("~/Content/home", config.CdnHost).Include(
"~/Areas/Home/Content/Home.css")); "~/Areas/Home/Content/Home.css"));
// Register Script Bundles
BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/home", config.CdnHost).Include(
"~/Scripts/PageDown/Markdown.Converter.js",
"~/Scripts/PageDown/Markdown.Sanitizer.js"));
} }
} }
} }

View File

@ -18,13 +18,10 @@
} }
@Styles.Render("~/Content/home") @Styles.Render("~/Content/home")
@Scripts.Render("~/bundles/home")
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<center> <img src="@logoPath" class="img-responsive center-block" alt="Teknik">
<img src="@logoPath" class="img-responsive" alt="Teknik">
</center>
</div> </div>
<br /> <br />
<div class="row text-center"> <div class="row text-center">
@ -137,47 +134,38 @@
<h3 class="panel-title text-center">Recent News</h3> <h3 class="panel-title text-center">Recent News</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<p> <ul class="list-group">
<ul class="list-group"> @if (Model.SitePosts.Any())
@if (Model.SitePosts.Any()) {
{ foreach (BlogPost post in Model.SitePosts)
foreach (BlogPost post in Model.SitePosts)
{
<script>
var converter = new Markdown.getSanitizingConverter();
// Title Conversion
var old_post = $("#title_@post.BlogPostId").text();
var new_post = converter.makeHtml(old_post);
$("#title_@post.BlogPostId").html(new_post);
</script>
<li class="list-group-item">
<div class="row">
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left">
<a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.BlogPostId })" id="title_@post.BlogPostId">@post.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@post.DatePosted.ToString("o")">@post.DatePosted.ToString("MMMM dd, yyyy")</time>
</p>
</div>
</div>
</div>
</li>
}
}
else
{ {
<li class="list-group-item"> <li class="list-group-item">
<div class="row"> <div class="row">
<div class="col-sm-12 text-center"> <div class="col-sm-12">
<h4>No News Available</h4> <div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left">
<a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.BlogPostId })" id="title_@post.BlogPostId">@Html.Markdown(post.Title)</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@post.DatePosted.ToString("o")">@post.DatePosted.ToString("MMMM dd, yyyy")</time>
</p>
</div>
</div> </div>
</div> </div>
</li> </li>
} }
</ul> }
</p> else
{
<li class="list-group-item">
<div class="row">
<div class="col-sm-12 text-center">
<h4>No News Available</h4>
</div>
</div>
</li>
}
</ul>
</div> </div>
</div> </div>
</div> </div>
@ -188,47 +176,38 @@
<h3 class="panel-title text-center">Recent Podcasts</h3> <h3 class="panel-title text-center">Recent Podcasts</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<p> <ul class="list-group">
<ul class="list-group"> @if (Model.Podcasts.Any())
@if (Model.Podcasts.Any()) {
{ foreach (Podcast podcast in Model.Podcasts)
foreach (Podcast podcast in Model.Podcasts)
{
<script>
var converter = new Markdown.getSanitizingConverter();
// Title Conversion
var old_post = $("#title_@podcast.PodcastId").text();
var new_post = converter.makeHtml(old_post);
$("#title_@podcast.PodcastId").html(new_post);
</script>
<li class="list-group-item">
<div class="row">
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left">
<a href="@Url.SubRouteUrl("podcast", "Podcast.View", new { episode = podcast.Episode })" id="title_@podcast.PodcastId">@podcast.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@podcast.DatePosted.ToString("o")">@podcast.DatePosted.ToString("MMMM dd, yyyy")</time>
</p>
</div>
</div>
</div>
</li>
}
}
else
{ {
<li class="list-group-item"> <li class="list-group-item">
<div class="row"> <div class="row">
<div class="col-sm-12 text-center"> <div class="col-sm-12">
<h4>No Podcasts Available</h4> <div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left">
<a href="@Url.SubRouteUrl("podcast", "Podcast.View", new { episode = podcast.Episode })" id="title_@podcast.PodcastId">@Html.Markdown(podcast.Title)</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@podcast.DatePosted.ToString("o")">@podcast.DatePosted.ToString("MMMM dd, yyyy")</time>
</p>
</div>
</div> </div>
</div> </div>
</li> </li>
} }
</ul> }
</p> else
{
<li class="list-group-item">
<div class="row">
<div class="col-sm-12 text-center">
<h4>No Podcasts Available</h4>
</div>
</div>
</li>
}
</ul>
</div> </div>
</div> </div>
</div> </div>
@ -239,46 +218,37 @@
<h3 class="panel-title text-center">Recent Blog Posts</h3> <h3 class="panel-title text-center">Recent Blog Posts</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<p> <ul class="list-group">
<ul class="list-group"> @if (Model.BlogPosts.Any())
@if (Model.BlogPosts.Any()) {
{ foreach (BlogPost post in Model.BlogPosts)
foreach (BlogPost post in Model.BlogPosts)
{
<script>
var converter = new Markdown.getSanitizingConverter();
// Title Conversion
var old_post = $("#title_@post.BlogPostId").text();
var new_post = converter.makeHtml(old_post);
$("#title_@post.BlogPostId").html(new_post);
</script>
<li class="list-group-item">
<div class="row">
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left"><a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.BlogPostId })" id="title_@post.BlogPostId">@post.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@post.DatePosted.ToString("o")">@post.DatePosted.ToString("MMMM dd, yyyy")</time> by <a href="@Url.SubRouteUrl("user", "User.Index", new { username = post.Blog.User.Username })">@post.Blog.User.Username</a>
</p>
</div>
</div>
</div>
</li>
}
}
else
{ {
<li class="list-group-item"> <li class="list-group-item">
<div class="row"> <div class="row">
<div class="col-sm-12 text-center"> <div class="col-sm-12">
<h4>No Posts Available</h4> <div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left"><a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.BlogPostId })" id="title_@post.BlogPostId">@Html.Markdown(post.Title)</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@post.DatePosted.ToString("o")">@post.DatePosted.ToString("MMMM dd, yyyy")</time> by <a href="@Url.SubRouteUrl("user", "User.Index", new { username = post.Blog.User.Username })">@post.Blog.User.Username</a>
</p>
</div>
</div> </div>
</div> </div>
</li> </li>
} }
</ul> }
</p> else
{
<li class="list-group-item">
<div class="row">
<div class="col-sm-12 text-center">
<h4>No Posts Available</h4>
</div>
</div>
</li>
}
</ul>
</div> </div>
</div> </div>
</div> </div>

View File

@ -51,7 +51,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<label for="serverSideEncrypt">Encrypt Server Side</label> <label for="serverSideEncrypt">Encrypt Server Side</label>
<input type="checkbox" name="serverSideEncrypt" id="serverSideEncrypt" @(Model.ServerSideEncrypt ? "checked" : string.Empty) ; /> <input type="checkbox" name="serverSideEncrypt" id="serverSideEncrypt" @(Model.ServerSideEncrypt ? "checked" : string.Empty) />
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
</div> </div>
</div> </div>
</div> </div>
<form role="form" id="loginForm" action="@Url.SubRouteUrl("user", "User.Login")" method="post" accept-charset="UTF-8"> <form id="loginForm" action="@Url.SubRouteUrl("user", "User.Login")" method="post" accept-charset="UTF-8">
<input name="Login.ReturnUrl" id="loginReturnUrl" type="hidden" value="@Model.ReturnUrl" /> <input name="Login.ReturnUrl" id="loginReturnUrl" type="hidden" value="@Model.ReturnUrl" />
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" id="loginUsername" value="" placeholder="Username" name="Login.Username" data-val-required="The Username field is required." data-val="true" /> <input type="text" class="form-control" id="loginUsername" value="" placeholder="Username" name="Login.Username" data-val-required="The Username field is required." data-val="true" />

View File

@ -12,7 +12,7 @@
</div> </div>
</div> </div>
</div> </div>
<form role="form" id="registrationForm" action="@Url.SubRouteUrl("user", "User.Register")" method="post" accept-charset="UTF-8"> <form id="registrationForm" action="@Url.SubRouteUrl("user", "User.Register")" method="post" accept-charset="UTF-8">
<input name="Register.ReturnUrl" id="registerReturnUrl" type="hidden" value="@Model.ReturnUrl" /> <input name="Register.ReturnUrl" id="registerReturnUrl" type="hidden" value="@Model.ReturnUrl" />
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" id="registerUsername" value="" placeholder="Username" name="Register.Username" data-val-required="The Username field is required." data-val="true"/> <input type="text" class="form-control" id="registerUsername" value="" placeholder="Username" name="Register.Username" data-val-required="The Username field is required." data-val="true"/>

View File

@ -15,6 +15,7 @@ using Teknik.ViewModels;
namespace Teknik.Controllers namespace Teknik.Controllers
{ {
[CORSActionFilter]
public class DefaultController : Controller public class DefaultController : Controller
{ {
private Config _config; private Config _config;

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Teknik.Filters
{
public class CORSActionFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.HttpContext.Request.HttpMethod == "OPTIONS")
{
// do nothing let IIS deal with reply!
filterContext.Result = new EmptyResult();
}
else
{
base.OnActionExecuting(filterContext);
}
}
}
}

View File

@ -43,8 +43,6 @@ namespace Teknik
protected void Application_BeginRequest(object sender, EventArgs e) protected void Application_BeginRequest(object sender, EventArgs e)
{ {
HttpContext context = HttpContext.Current;
// Start the generation time stopwatcher // Start the generation time stopwatcher
var stopwatch = new Stopwatch(); var stopwatch = new Stopwatch();
HttpContext.Current.Items["Stopwatch"] = stopwatch; HttpContext.Current.Items["Stopwatch"] = stopwatch;

View File

@ -236,6 +236,7 @@
<Compile Include="Areas\User\Models\TrustedDevice.cs" /> <Compile Include="Areas\User\Models\TrustedDevice.cs" />
<Compile Include="Areas\User\ViewModels\TwoFactorViewModel.cs" /> <Compile Include="Areas\User\ViewModels\TwoFactorViewModel.cs" />
<Compile Include="Attributes\TeknikAuthorizeAttribute.cs" /> <Compile Include="Attributes\TeknikAuthorizeAttribute.cs" />
<Compile Include="Filters\CORSActionFilter.cs" />
<Compile Include="Helpers\BundleExtensions.cs" /> <Compile Include="Helpers\BundleExtensions.cs" />
<Compile Include="Models\TransferTypes.cs" /> <Compile Include="Models\TransferTypes.cs" />
<Compile Include="Areas\User\Models\UploadSettings.cs" /> <Compile Include="Areas\User\Models\UploadSettings.cs" />

View File

@ -3,16 +3,15 @@
@using Teknik.Helpers @using Teknik.Helpers
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<!-- Required Meta --> <!-- Character Set -->
<meta charset="utf-8" /> <meta charset="UTF-8">
<!-- Compatability -->
<meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- What is the page's content type -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Website Info --> <!-- Website Info -->
<meta name="description" content="@ViewBag.Description" /> <meta name="description" content="@ViewBag.Description" />
<meta name="author" content="@Model.Config.Author" /> <meta name="author" content="@Model.Config.Author" />

View File

@ -64,7 +64,7 @@
<customHeaders> <customHeaders>
<add name="Access-Control-Allow-Credentials" value="true" /> <add name="Access-Control-Allow-Credentials" value="true" />
<add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, OPTIONS" /> <add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Accept, Content-Type, X-Requested-With" /> <add name="Access-Control-Allow-Headers" value="Accept, Origin, Content-Type, X-Requested-With" />
<add name="strict-transport-security" value="max-age=31536000; includeSubdomains" /> <add name="strict-transport-security" value="max-age=31536000; includeSubdomains" />
</customHeaders> </customHeaders>
</httpProtocol> </httpProtocol>