From 02cb47f36dc02dc94665b6d64377e818d53b4bba Mon Sep 17 00:00:00 2001 From: Mads Kristensen Date: Mon, 11 Sep 2017 09:52:56 -0700 Subject: [PATCH] Added social sharing buttons --- README.md | 1 + src/Pages/Album.cshtml.cs | 13 +++++++------ src/Pages/_Layout.cshtml | 1 + src/Pages/_SocialButtons.cshtml | 24 ++++++++++++++++++++++++ src/Startup.cs | 1 - src/wwwroot/css/site.scss | 10 ++++++++++ src/wwwroot/img/facebook.png | Bin 0 -> 272 bytes src/wwwroot/img/pinterest.png | Bin 0 -> 348 bytes src/wwwroot/img/twitter.png | Bin 0 -> 311 bytes 9 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/Pages/_SocialButtons.cshtml create mode 100644 src/wwwroot/img/facebook.png create mode 100644 src/wwwroot/img/pinterest.png create mode 100644 src/wwwroot/img/twitter.png diff --git a/README.md b/README.md index 83484a9..6f341d8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ A photo gallery site implemented in ASP.NET Core 2.0 Razor Pages. - Elegant masonry layout of images - Easy to manage through simple [admin interface](#admin-interface) - All major browsers fully supported (IE 10+) +- Social media integration (Facebook, Twitter, Pinterest) - Follows best practices for web applications - [See DareBoost report](art/dareboost-report.pdf) diff --git a/src/Pages/Album.cshtml.cs b/src/Pages/Album.cshtml.cs index e74f5ce..559e58c 100644 --- a/src/Pages/Album.cshtml.cs +++ b/src/Pages/Album.cshtml.cs @@ -79,21 +79,22 @@ public async Task OnPostUpload(string name, ICollection _ac.IsImageFile(f.FileName))) { - string path = Path.Combine(_environment.WebRootPath, "albums", album.Name, Path.GetFileName(file.FileName)); + string fileName = Path.GetFileName(file.FileName); + string filePath = Path.Combine(_environment.WebRootPath, "albums", album.Name, Path.GetFileName(fileName)); - if (System.IO.File.Exists(path)) + if (System.IO.File.Exists(filePath)) { - path = Path.ChangeExtension(path, file.GetHashCode() + Path.GetExtension(path)); + filePath = Path.ChangeExtension(filePath, file.GetHashCode() + Path.GetExtension(filePath)); } using (var imageStream = file.OpenReadStream()) - using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)) + using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { - _processor.CreateThumbnails(imageStream, path); + _processor.CreateThumbnails(imageStream, filePath); await file.CopyToAsync(fileStream); } - var photo = new Photo(album, new FileInfo(path)); + var photo = new Photo(album, new FileInfo(filePath)); album.Photos.Insert(0, photo); } diff --git a/src/Pages/_Layout.cshtml b/src/Pages/_Layout.cshtml index 913d84c..d0560ed 100644 --- a/src/Pages/_Layout.cshtml +++ b/src/Pages/_Layout.cshtml @@ -26,6 +26,7 @@
@RenderBody() + @{await Html.RenderPartialAsync("_SocialButtons.cshtml", ViewData["Title"]);}