Skip to content

Commit

Permalink
Added a lot of base code to start building up the platform
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyOnePro committed Sep 4, 2020
1 parent 47044b5 commit 2d87e37
Show file tree
Hide file tree
Showing 14 changed files with 475 additions and 18 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,11 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb
healthchecksdb

# User Defined Ignored Routes
NStart/wwwroot/dist
## Ignored Attainable Files
NStart/wwwroot/lib/animatecss/
NStart/wwwroot/lib/jquery/
NStart/wwwroot/lib/material-components/
3 changes: 0 additions & 3 deletions NStart/Extensions/LocalizationSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public static class LocalizationSetup

public static void AddCustomLocalization(this IServiceCollection services)
{
if (services is null)
throw new ArgumentNullException(nameof(services));

services.Configure<RequestLocalizationOptions>(options =>
{
options.DefaultRequestCulture = new RequestCulture(culture: DefaultCulture, uiCulture: DefaultCulture);
Expand Down
9 changes: 9 additions & 0 deletions NStart/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ var jqueryTargetPath = './wwwroot/lib/jquery/dist';
module.exports = function (grunt) {
grunt.initConfig({
clean: [
targetPath + 'animatecss/*',
targetPath + 'material-components/*', targetPath + 'jquery/*',
targetPath + 'jquery-validation/*', targetPath + 'jquery-validation-unobtrusive/*'
],
copy: {
external: {
files: [
// AnimateCSS Library
{
src: nodeRoot + "animate.css/*.css",
dest: targetPath + "animatecss/dist/",
expand: true,
filter: "isFile",
flatten: true
},
// jQuery Library
{
src: nodeRoot + "jquery/dist/*",
Expand Down
1 change: 1 addition & 0 deletions NStart/NStart.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<ItemGroup>
<Folder Include="wwwroot\lib\material-components\" />
<Folder Include="wwwroot\fonts\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion NStart/Pages/Home/HomePage.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page
@page "/"
@model NStart.Pages.Home.HomePageModel
@{
ViewData["Title"] = "HomePage";
Expand Down
29 changes: 29 additions & 0 deletions NStart/Pages/Shared/_CookieConsentPartial.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@using Microsoft.AspNetCore.Http.Features

@{
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
var showBanner = !consentFeature?.CanTrack ?? false;
var cookieString = consentFeature?.CreateConsentCookie();
}

@if (showBanner)
{
<div id="cookieConsent" class="alert alert-info alert-dismissible fade show" role="alert">
<h4>Cookie Consent</h4>
In order to grant you access to our site's basic features, you have to accept cookies from us.
<hr />
Our <a asp-area="" asp-controller="Privacy" asp-action="CookiePolicy">Cookie Policy</a> contains all the information about how we handle cookies on our sites.
<br />
<button type="button" class="accept-policy close" data-dismiss="alert" aria-label="Close" data-cookie-string="@cookieString">
<span aria-hidden="true">Accept</span>
</button>
</div>
<script>
(function () {
var button = document.querySelector("#cookieConsent button[data-cookie-string]");
button.addEventListener("click", function (event) {
document.cookie = button.dataset.cookieString;
}, false);
})();
</script>
}
6 changes: 1 addition & 5 deletions NStart/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<meta name="twitter:url" content="@(ViewData["Twitter:URL"] ?? "https://nstart.net")" />
<meta name="twitter:image" content="@(ViewData["Twitter:Image"] ?? "https://nstart.net/static/defaults/default-twitter-image.png")" />
<meta name="twitter:image:alt" content="@(ViewData["Twitter:ImageAlt"] ?? "Default NStart page Twitter image")" />
<meta name="twitter:site" content="@@pixelystudios" />
<meta name="twitter:site" content="@@dummy-account" />
<meta name="twitter:creator" content="@(ViewData["Twitter:CreatorAccount"] ?? "@dummy-account")" />
@* Language, Charset and Format Information*@
<meta charset="utf-8" />
Expand All @@ -45,7 +45,6 @@
<meta name="description" content="NStart base template" />
<meta name="author" content="Leonardo Antonio González Castro" />
<link rel="canonical" href="https://nstart.com" />
<link rel="manifest" href="~/manifest.json" />
<link rel="shortcut icon" href="~/assets/icons/favicon.ico" type="image/x-icon" sizes="32x32" />
<link rel="shortcut icon" href="~/assets/icons/favicon-64px.ico" type="image/x-icon" sizes="64x64" />
<link rel="fluid-icon" href="~/App_Data/Assets/Icons/fluid_icon.png" title="Pixely Studios" />
Expand Down Expand Up @@ -97,9 +96,6 @@
<a class="navbar-item" asp-area="" asp-page="/Pages/Home/Contact">@Localizer["ProjectsNavbar"]</a>
<a asp-area="" asp-page="/Pages/Privacy/PrivacyIndex">@Localizer["PrivacyNavbar"]</a>
</div>
<div class="navbar-end">
<partial name="_LoginPartial" />
</div>
</div>
</nav>
<partial name="_CookieConsentPartial" />
Expand Down
2 changes: 1 addition & 1 deletion NStart/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace NStart
{
public class Program
public static class Program
{
public static void Main(string[] args)
{
Expand Down
8 changes: 5 additions & 3 deletions NStart/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:2176",
"applicationUrl": "http://localhost:2176/",
"sslPort": 44356
}
},
Expand All @@ -12,14 +12,16 @@
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
}
},
"NStart": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
Expand Down
32 changes: 28 additions & 4 deletions NStart/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using NStart.Extensions;

namespace NStart
{
Expand All @@ -16,7 +19,18 @@ public class Startup
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddRouting();

services.AddApplicationInsightsTelemetry();

services.AddCustomLocalization();

services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.SubFolder)
.AddDataAnnotationsLocalization();

// Singleton Services
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -26,15 +40,25 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}

var localizationOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>().Value;
app.UseRequestLocalization(localizationOptions);

app.UseStaticFiles();

app.UseHttpsRedirection();

app.UseCookiePolicy();

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
endpoints.MapRazorPages();
});
}
}
Expand Down
37 changes: 37 additions & 0 deletions NStart/web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44360" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
</environmentVariables>
</aspNetCore>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
<remove name="Server" />
<add name="X-XSS-Protection" value="1" />
<add name="Service-Worker-Allowed" value="/" />
<add name="X-Content-Type-Option" value="nosniff" />
</customHeaders>
</httpProtocol>
</system.webServer>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<!--
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
-->
</configuration>
Loading

0 comments on commit 2d87e37

Please sign in to comment.