refactor + add stuff

* solution-wide renames
* added carousel pic (ms luvz linux)
* created carousel helper
* updated project build configurations
This commit is contained in:
surtur 2020-09-24 13:39:44 +02:00
parent c0c2cfe397
commit f8bb1d5fcc
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
23 changed files with 210 additions and 147 deletions

4
.gitignore vendored
View File

@ -2,4 +2,6 @@ bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
/_ReSharper.Caches/
/node_modules
/wwwroot/node_modules

View File

@ -4,15 +4,19 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using pwa_0x01_2._1.Models;
using pwt_0x01.Models;
namespace pwa_0x01_2._1.Controllers
namespace pwt_0x01.Controllers
{
public class HomeController : Controller
{
private IList<Carousel> Carousels = CarouselHelper.GenerateCarousel();
public IActionResult Index()
{
return View();
CarouselViewModel carousel = new CarouselViewModel();
carousel.Carousels = Carousels;
return View(carousel);
}
public IActionResult About()
@ -37,7 +41,7 @@ namespace pwa_0x01_2._1.Controllers
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
return View(new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier});
}
}
}

View File

@ -1,7 +1,10 @@
namespace pwa_0x01_2._1.Models
namespace pwt_0x01.Models
{
public class Carousel
{
public string DataTarget { get; set; }
public string ImageSrc { get; set; }
public string ImageAlt { get; set; }
public string CarouselContent { get; set; }
}
}
}

View File

@ -1,7 +1,19 @@
namespace pwa_0x01_2._1.Models
using System.Collections.Generic;
namespace pwt_0x01.Models
{
public class CarouselHelper
{
public static IList<Carousel> GenerateCarousel()
{
IList<Carousel> carousel = new List<Carousel>()
{
new Carousel() {DataTarget = "#myCarousel", ImageSrc = "/images/banner1.svg", ImageAlt = "img1", CarouselContent = "Learn how to build ASP.NET apps that can run anywhere. <a class=\"btn btn-default\" href=\"https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409\">Learn More</a>"},
new Carousel() {DataTarget = "#myCarousel", ImageSrc = "/images/banner2.svg", ImageAlt = "img2", CarouselContent = "There are powerful new features in Visual Studio for building modern web apps. <a class=\"btn btn-default\" href=\"https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409\">Learn More</a>"},
new Carousel() {DataTarget = "#myCarousel", ImageSrc = "/images/banner3.svg", ImageAlt = "img3", CarouselContent = "Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.<a class=\"btn btn-default\" href=\"https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409\">Learn More</a>"},
new Carousel() {DataTarget = "#myCarousel", ImageSrc = "/images/ms_loves_linux.jpeg", ImageAlt = "ms loves linux", CarouselContent = "m$ loves linux, reportedly<a class=\"btn btn-default\" href=\"#\">Learn More</a>"}
};
return carousel;
}
}
}
}

View File

@ -1,7 +1,9 @@
namespace pwa_0x01_2._1.Models
using System.Collections.Generic;
namespace pwt_0x01.Models
{
public class CarouselViewModel
{
public IList<Carousel> Carousels { get; set; }
}
}
}

View File

@ -1,6 +1,6 @@
using System;
namespace pwa_0x01_2._1.Models
namespace pwt_0x01.Models
{
public class ErrorViewModel
{
@ -8,4 +8,4 @@ namespace pwa_0x01_2._1.Models
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}
}

View File

@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace pwa_0x01_2._1
namespace pwt_0x01
{
public class Program
{

View File

@ -1,7 +1,7 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28296",
"sslPort": 44327
@ -15,7 +15,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"pwa_0x01_2._1": {
"pwt_0x01": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
@ -24,4 +24,4 @@
}
}
}
}
}

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# pwa-0x01
this repo holds *sawce* for a 0x01 .netcore mvc webapp for PWA lessons

View File

@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace pwa_0x01_2._1
namespace pwt_0x01
{
public class Startup
{

View File

@ -4,4 +4,4 @@
<h2>@ViewData["Title"]</h2>
<h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>

View File

@ -5,13 +5,13 @@
<h3>@ViewData["Message"]</h3>
<address>
One Microsoft Way<br />
Redmond, WA 98052-6399<br />
One Microsoft Way<br/>
Redmond, WA 98052-6399<br/>
<abbr title="Phone">P:</abbr>
425.555.0100
</address>
<address>
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br />
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br/>
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
</address>
</address>

View File

@ -1,47 +1,40 @@
@{
@using Microsoft.AspNetCore.Razor.Language.Intermediate
@model CarouselViewModel
@{
ViewData["Title"] = "Home Page";
}
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
@{
for (int i = 0; i < Model.Carousels.Count; i++)
{
string class_attribute = "";
if (i == 0)
{
class_attribute = "class = \"active\"";
}
<li data-target="@Model.Carousels[i].DataTarget" data-slide-to="@i" @Html.Raw(class_attribute)></li>
}
}
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
Learn how to build ASP.NET apps that can run anywhere.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
<div class="item">
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
There are powerful new features in Visual Studio for building modern web apps.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
<div class="item">
<img src="~/images/banner3.svg" alt="Microsoft Azure" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
@{
for (int i = 0; i < Model.Carousels.Count; i++)
{
string class_div = "item";
if (i == 0)
{
class_div = "item active";
}
<div class="@Html.Raw(class_div)">
<img src="@Model.Carousels[i].ImageSrc" alt="@Model.Carousels[i].ImageAlt" class="img-responsive"/>
<div class="carousel-caption" role="option">
<p>@Html.Raw(Model.Carousels[i].CarouselContent)</p>
</div>
</div>
}
}
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
@ -64,31 +57,61 @@
<div class="col-md-3">
<h2>How to</h2>
<ul>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a>
</li>
</ul>
</div>
<div class="col-md-3">
<h2>Overview</h2>
<ul>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a>
</li>
</ul>
</div>
<div class="col-md-3">
<h2>Run &amp; Deploy</h2>
<ul>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a>
</li>
<li>
<a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a>
</li>
</ul>
</div>
</div>

View File

@ -3,4 +3,4 @@
}
<h2>@ViewData["Title"]</h2>
<p>Use this page to detail your site's privacy policy.</p>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -19,4 +19,4 @@
</p>
<p>
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
</p>
</p>

View File

@ -17,7 +17,9 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></span>
<span class="navbar-brand">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</span>
</div>
<div class="collapse navbar-collapse">
<p class="navbar-text">

View File

@ -1,74 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - pwa_0x01_2._1</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>@ViewData["Title"] - pwt_0x01</title>
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css"/>
<link rel="stylesheet" href="~/css/site.css"/>
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"/>
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true"/>
</environment>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">pwa_0x01_2._1</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li>
</ul>
</div>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">pwa_0x01_2._1</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li>
<a asp-area="" asp-controller="Home" asp-action="About">About</a>
</li>
<li>
<a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a>
</li>
</ul>
</div>
</nav>
<partial name="_CookieConsentPartial" />
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; 2020 - pwa_0x01_2._1</p>
</footer>
</div>
</nav>
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
<partial name="_CookieConsentPartial"/>
@RenderSection("Scripts", required: false)
<div class="container body-content">
@RenderBody()
<hr/>
<footer>
<p>&copy; 2020 - pwt_0x01</p>
</footer>
</div>
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
@RenderSection("Scripts", required: false)
</body>
</html>

View File

@ -15,4 +15,4 @@
crossorigin="anonymous"
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
</script>
</environment>
</environment>

View File

@ -1,3 +1,3 @@
@using pwa_0x01_2._1
@using pwa_0x01_2._1.Models
@using pwt_0x01
@using pwt_0x01.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -1,3 +1,3 @@
@{
Layout = "_Layout";
}
}

View File

@ -2,6 +2,12 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>pwt-0x01</AssemblyName>
<PackageId>pwt-0x01</PackageId>
<Authors>pwt-0x01</Authors>
<Company>pwt-0x01</Company>
<Product>pwt-0x01</Product>
<RootNamespace>pwt-0x01</RootNamespace>
</PropertyGroup>
<ItemGroup>

View File

@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pwa-0x01-2.1", "pwa-0x01-2.1.csproj", "{1868D01F-5327-4413-B7D7-5C62C66788D0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pwt-0x01", "pwt-0x01.csproj", "{D3D29829-31FA-4586-AA46-97D9CDD69AF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -8,9 +8,9 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1868D01F-5327-4413-B7D7-5C62C66788D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1868D01F-5327-4413-B7D7-5C62C66788D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1868D01F-5327-4413-B7D7-5C62C66788D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1868D01F-5327-4413-B7D7-5C62C66788D0}.Release|Any CPU.Build.0 = Release|Any CPU
{D3D29829-31FA-4586-AA46-97D9CDD69AF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3D29829-31FA-4586-AA46-97D9CDD69AF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3D29829-31FA-4586-AA46-97D9CDD69AF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3D29829-31FA-4586-AA46-97D9CDD69AF1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB