Skip to content

Commit

Permalink
Updated packages
Browse files Browse the repository at this point in the history
  • Loading branch information
madskristensen committed Aug 28, 2017
1 parent 51b6548 commit 52a3a5c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 31 deletions.
15 changes: 11 additions & 4 deletions src/Pages/Album.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ public AlbumsModel(AlbumCollection ac, IHostingEnvironment environment, ImagePro

public Album Album { get; private set; }

public void OnGet(string name)
public IActionResult OnGet(string name)
{
Album = _ac.Albums.FirstOrDefault(a => a.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

if (Album == null)
{
return NotFound();
}

return Page();
}

[Authorize]
Expand All @@ -48,7 +55,7 @@ public IActionResult OnPostDelete(string name)
_ac.Albums.Remove(album);
}

return new RedirectResult("~/?cache=1");
return new RedirectResult("~/");
}

[Authorize]
Expand All @@ -60,7 +67,7 @@ public IActionResult OnPostCreate(string name)
var album = new Album(path, _ac);
_ac.Albums.Insert(0, album);

return new RedirectResult($"~/album/{name}/?cache=1");
return new RedirectResult($"~/album/{name}/");
}

[Authorize]
Expand All @@ -87,7 +94,7 @@ public async Task<IActionResult> OnPostUpload(string name, ICollection<IFormFile
album.Photos.Insert(0, photo);
}

return new RedirectResult($"~/album/{name}/?cache=1");
return new RedirectResult($"~/album/{name}/");
}
}
}
4 changes: 2 additions & 2 deletions src/Pages/Login.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task OnPost(string username, string password)
var principle = new ClaimsPrincipal(identity);
await HttpContext.SignInAsync(principle);

RedirectFromLogin("?cache=1");
RedirectFromLogin();
}
}

Expand All @@ -52,7 +52,7 @@ private void RedirectFromLogin(string query = "")
}
else
{
HttpContext.Response.Redirect("/?" + query);
HttpContext.Response.Redirect("/");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Photo.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public IActionResult OnPostRename(string albumName, string photoName)
System.IO.File.Move(file, newThumbnail);
}

return new RedirectResult($"~/photo/{albumName}/{newPhoto.DisplayName}/?cache=1");
return new RedirectResult($"~/photo/{albumName}/{newPhoto.DisplayName}/");

}

Expand All @@ -74,7 +74,7 @@ public IActionResult OnPostDelete(string albumName, string photoName)
}
}

return new RedirectResult($"~/album/{albumName}/?cache=1");
return new RedirectResult($"~/album/{albumName}/");
}
}
}
6 changes: 0 additions & 6 deletions src/Pages/_ViewStart.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
if (!User.Identity.IsAuthenticated)
{
Context.Response.Headers.TryAdd("Cache-Control", "public,max-age=3600");

var responseCachingFeature = Context.Features.Get<Microsoft.AspNetCore.ResponseCaching.IResponseCachingFeature>();
if (responseCachingFeature != null)
{
responseCachingFeature.VaryByQueryKeys = new[] { "cache" };
}
}

// Setting security HTTP headers
Expand Down
2 changes: 1 addition & 1 deletion src/PhotoGallery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.ImageOptimizer.WebJob" Version="1.0.0.23" />
<PackageReference Include="Azure.ImageOptimizer" Version="1.0.0.37" />
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="1.0.158-beta" />
<PackageReference Include="LigerShark.WebOptimizer.Sass" Version="1.0.32-beta" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
Expand Down
8 changes: 2 additions & 6 deletions src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static IWebHost BuildWebHost(string[] args) =>
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddResponseCaching();
services.AddSingleton<AlbumCollection>();
services.AddSingleton<ImageProcessor>();
services.AddAuthentication(options =>
Expand All @@ -55,14 +54,14 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
//app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}

app.UseStatusCodePages("text/plain", "Status code page, status code: {0}");
app.UseAuthentication();
app.UseWebOptimizer();

Expand All @@ -78,9 +77,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}
});

app.UseResponseCaching();
app.UseETagger();

app.UseMvc(routes =>
{
routes.MapRoute(
Expand Down
14 changes: 14 additions & 0 deletions src/imageoptimizer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"optimizations": [
{
"includes": [ "wwwroot/albums/*/thumbnail/*.*" ],
"lossy": true
},
{
"includes": [ "wwwroot/albums/*/*.*" ],
"lossy": false
}
],

"warmupTime": 0
}
10 changes: 0 additions & 10 deletions src/wwwroot/js/admin.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
(function () {

// Add cache busting querystring to all internal links
var links = document.querySelectorAll("a:not([href~='//'])");

for (var i = 0; i < links.length; i++) {
var a = links[i];
var href = a.getAttribute("href");
var sep = href.indexOf("?") === -1 ? "?" : "&";
a.setAttribute("href", href + sep + "cache=1");
}

// Button click
var form = document.querySelector("form");

Expand Down

0 comments on commit 52a3a5c

Please sign in to comment.