From 2a30ae85a90914ccc62b015afed30f46034ddf10 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Thu, 29 Oct 2015 12:07:07 +0100 Subject: [PATCH] Bug fixes * Index.aspx: Gives this page a title * AdminController.cs: Trying to fix this Index : /Admin ... a 404 * YavscModel.csproj: * Commande.cs: * FileSystemController.cs: * WebFileSystemManager.cs: Refactoring the name of the files manager class * Index.aspx: Fixes the file system access * RemoveRole.aspx: Role removal form, had not a canonical name! * Web.csproj: a page was renamed --- web/ChangeLog | 17 ++++++++++++ web/Controllers/AdminController.cs | 3 ++- web/Controllers/FileSystemController.cs | 4 +-- .../{RemoveRole..aspx => RemoveRole.aspx} | 0 web/Views/FileSystem/Index.aspx | 4 +-- web/Views/Google/Index.aspx | 4 +++ web/Web.csproj | 3 ++- yavscModel/ChangeLog | 7 +++++ ...stemManager.cs => WebFileSystemManager.cs} | 27 ++++++++----------- yavscModel/FrontOffice/Commande.cs | 4 +-- yavscModel/YavscModel.csproj | 2 +- 11 files changed, 50 insertions(+), 25 deletions(-) rename web/Views/Admin/{RemoveRole..aspx => RemoveRole.aspx} (100%) create mode 100644 web/Views/Google/Index.aspx rename yavscModel/FileSystem/{FileSystemManager.cs => WebFileSystemManager.cs} (88%) diff --git a/web/ChangeLog b/web/ChangeLog index 3655d64c..2627d6e8 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,20 @@ +2015-10-29 Paul Schneider + + * Index.aspx: Gives this page a title + + * AdminController.cs: Trying to fix this Index : /Admin ... a + 404 + + * FileSystemController.cs: Refactoring the name of the files + manager class + + * Index.aspx: Fixes the file system access + + * RemoveRole.aspx: Role removal form, had not a canonical + name! + + * Web.csproj: a page was renamed + 2015-10-28 Paul Schneider * yavsc.circles.js: diff --git a/web/Controllers/AdminController.cs b/web/Controllers/AdminController.cs index 97a68641..90e64d75 100644 --- a/web/Controllers/AdminController.cs +++ b/web/Controllers/AdminController.cs @@ -29,7 +29,8 @@ namespace Yavsc.Controllers YavscHelpers.Notify (ViewData, roleName + " " + LocalizedText.role_created); } - return View ("Index"); + + return View (); } /// /// Inits the db. diff --git a/web/Controllers/FileSystemController.cs b/web/Controllers/FileSystemController.cs index cc448601..2dac4b11 100644 --- a/web/Controllers/FileSystemController.cs +++ b/web/Controllers/FileSystemController.cs @@ -33,7 +33,7 @@ namespace Yavsc.Controllers [Authorize] public ActionResult Index (string user, string filename) { - FileSystemManager fsmgr = new FileSystemManager (); + WebFileSystemManager fsmgr = new WebFileSystemManager (); var files = fsmgr.GetFiles (user,filename); return View (files); } @@ -54,7 +54,7 @@ namespace Yavsc.Controllers /// Filename. public ActionResult Details (string user, string filename) { - FileSystemManager fsmgr = new FileSystemManager (); + WebFileSystemManager fsmgr = new WebFileSystemManager (); FileInfo fi = fsmgr.FileInfo (filename); ViewData ["filename"] = filename; diff --git a/web/Views/Admin/RemoveRole..aspx b/web/Views/Admin/RemoveRole.aspx similarity index 100% rename from web/Views/Admin/RemoveRole..aspx rename to web/Views/Admin/RemoveRole.aspx diff --git a/web/Views/FileSystem/Index.aspx b/web/Views/FileSystem/Index.aspx index c0c5557e..05c9aac0 100644 --- a/web/Views/FileSystem/Index.aspx +++ b/web/Views/FileSystem/Index.aspx @@ -1,6 +1,6 @@ -<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %> +<%@ Page Title="Files" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %> -

Index of <%= Model.Owner %>'s files (<%= Html.Encode(Model.Count) %>) +

Index

    <% foreach (System.IO.FileInfo fi in Model) { %> diff --git a/web/Views/Google/Index.aspx b/web/Views/Google/Index.aspx new file mode 100644 index 00000000..93794753 --- /dev/null +++ b/web/Views/Google/Index.aspx @@ -0,0 +1,4 @@ +<%@ Page Title="Google interface" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %> + + + diff --git a/web/Web.csproj b/web/Web.csproj index 6ab4dcb8..930cab8f 100644 --- a/web/Web.csproj +++ b/web/Web.csproj @@ -286,7 +286,6 @@ - @@ -461,6 +460,8 @@ + + diff --git a/yavscModel/ChangeLog b/yavscModel/ChangeLog index 8e5eefb5..5c60f251 100644 --- a/yavscModel/ChangeLog +++ b/yavscModel/ChangeLog @@ -1,3 +1,10 @@ +2015-10-29 Paul Schneider + + * YavscModel.csproj: + * Commande.cs: + * WebFileSystemManager.cs: Refactoring the name of the files + manager class + 2015-10-28 Paul Schneider * ICalendarManager.cs: WIP booking TODO a calendar provider diff --git a/yavscModel/FileSystem/FileSystemManager.cs b/yavscModel/FileSystem/WebFileSystemManager.cs similarity index 88% rename from yavscModel/FileSystem/FileSystemManager.cs rename to yavscModel/FileSystem/WebFileSystemManager.cs index 569eb680..b9d51179 100644 --- a/yavscModel/FileSystem/FileSystemManager.cs +++ b/yavscModel/FileSystem/WebFileSystemManager.cs @@ -38,7 +38,7 @@ namespace Yavsc.Model.FileSystem /// It just provides simple method for a small set of /// files, in a small tree of sub-folders . ///
- public class FileSystemManager + public class WebFileSystemManager { /// /// Gets or sets the size of the max file. @@ -56,23 +56,18 @@ namespace Yavsc.Model.FileSystem /// /// Initializes a new instance of the class. /// - public FileSystemManager (string rootDirectory="~/users/{0}") + public WebFileSystemManager (string rootDirectory="~/users") { + string rootpath = HttpContext.Current.Server.MapPath (rootDirectory); + var rdi = new DirectoryInfo (rootpath); + if (!rdi.Exists) + rdi.Create (); MembershipUser user = Membership.GetUser (); if (user == null) throw new Exception ("Not membership available"); - Prefix = HttpContext.Current.Server.MapPath ( - string.Format (rootDirectory, user.UserName)); + Prefix = Path.Combine(rootpath, user.ProviderUserKey.ToString()); } - /// - /// Initializes a new instance of the class. - /// - public FileSystemManager (string username, string rootDirectory="~/users/{0}") - { - Prefix = HttpContext.Current.Server.MapPath ( - string.Format (rootDirectory, username)); - } string regexFileName = "^[A-Za-z0-9#^!+ _~\\-.]+$"; /// /// Determines if the specified name is OK. @@ -166,7 +161,7 @@ namespace Yavsc.Model.FileSystem return (di.GetFiles ()); } - public IEnumerable GetFiles (string username, string subdir, bool createNonExistent = false) + public FileInfo[] GetFiles (string username, string subdir) { string path = Prefix; if (subdir != null) { @@ -174,9 +169,9 @@ namespace Yavsc.Model.FileSystem path = Path.Combine (Prefix, subdir); } DirectoryInfo di = new DirectoryInfo (path); - if (createNonExistent) - if (!di.Exists) - di.Create (); + + if (!di.Exists) + return new FileInfo[0]; return (di.GetFiles ()); } diff --git a/yavscModel/FrontOffice/Commande.cs b/yavscModel/FrontOffice/Commande.cs index bef3930b..0b77b051 100644 --- a/yavscModel/FrontOffice/Commande.cs +++ b/yavscModel/FrontOffice/Commande.cs @@ -89,8 +89,8 @@ namespace Yavsc.Model.FrontOffice FromPost (collection, files); } - private FileSystemManager GetFSM() { - return new FileSystemManager ("~/commands/{0}"); + private WebFileSystemManager GetFSM() { + return new WebFileSystemManager ("~/commands/{0}"); } } } diff --git a/yavscModel/YavscModel.csproj b/yavscModel/YavscModel.csproj index 7b7caa64..827d687a 100644 --- a/yavscModel/YavscModel.csproj +++ b/yavscModel/YavscModel.csproj @@ -114,7 +114,6 @@ - @@ -179,6 +178,7 @@ +