diff --git a/Yavsc/ApiControllers/FileSystemApiController.cs b/Yavsc/ApiControllers/FileSystemApiController.cs index dde4474e..1c97da77 100644 --- a/Yavsc/ApiControllers/FileSystemApiController.cs +++ b/Yavsc/ApiControllers/FileSystemApiController.cs @@ -6,13 +6,12 @@ using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Mvc; using Yavsc.Helpers; using Yavsc.Models; -using Yavsc.Models.FileSystem; namespace Yavsc.ApiControllers { - + using Yavsc.Exceptions; public class FSQuotaException : Exception { - + } [Authorize,Route("api/fs")] @@ -27,7 +26,7 @@ namespace Yavsc.ApiControllers AuthorizationService = authorizationService; dbContext = context; } - + [HttpGet()] public IActionResult Get() { @@ -46,10 +45,14 @@ namespace Yavsc.ApiControllers [HttpPost] - public IEnumerable Post(string subdir="") + public IEnumerable Post(string subdir="") { - var root = User.InitPostToFileSystem(subdir); - + string root = null; + try { + root = User.InitPostToFileSystem(subdir); + } catch (InvalidPathException) {} + if (root==null) + yield return new BadRequestObjectResult(new { error= "InvalidPathException" }); var user = dbContext.Users.Single( u => u.Id == User.GetUserId() ); @@ -58,8 +61,8 @@ namespace Yavsc.ApiControllers { var item = user.ReceiveUserFile(root, f); dbContext.SaveChanges(User.GetUserId()); - yield return item; + yield return Ok(item); }; } } -} \ No newline at end of file +} diff --git a/Yavsc/Constants.cs b/Yavsc/Constants.cs index 6d340dda..eab9a382 100644 --- a/Yavsc/Constants.cs +++ b/Yavsc/Constants.cs @@ -30,6 +30,7 @@ namespace Yavsc AvatarsPath = "/Avatars", DefaultAvatar = "/images/Users/icon_user.png", AnonAvatar = "/images/Users/icon_anon_user.png"; + public static char[] ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. ".ToCharArray(); public static readonly long DefaultFSQ = 1024*1024*500; public static readonly Scope[] SiteScopes = {  diff --git a/Yavsc/Exceptions/InvalidPathException.cs b/Yavsc/Exceptions/InvalidPathException.cs new file mode 100644 index 00000000..d093d9ab --- /dev/null +++ b/Yavsc/Exceptions/InvalidPathException.cs @@ -0,0 +1,9 @@ +using System; + +namespace Yavsc.Exceptions +{ + public class InvalidPathException: Exception + { + + } +} diff --git a/Yavsc/Helpers/FileSystemHelpers.cs b/Yavsc/Helpers/FileSystemHelpers.cs index 3053b793..a2660ad6 100644 --- a/Yavsc/Helpers/FileSystemHelpers.cs +++ b/Yavsc/Helpers/FileSystemHelpers.cs @@ -9,6 +9,7 @@ using System.Net.Mime; using System.Security.Claims; using System.Web; using Microsoft.AspNet.Http; +using Yavsc.Exceptions; using Yavsc.Models; using Yavsc.Models.FileSystem; using Yavsc.ViewModels; @@ -26,11 +27,11 @@ namespace Yavsc.Helpers return di; } - static char[] ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~. ".ToCharArray(); + public static bool IsValidDirectoryName(this string name) { - return !name.Any(c => !ValidChars.Contains(c)); + return !name.Any(c => !Constants.ValidChars.Contains(c)); } public static bool IsValidPath(this string path) { @@ -49,8 +50,6 @@ namespace Yavsc.Helpers string subpath) { var root = Path.Combine(Startup.UserFilesDirName, user.Identity.Name); - // TOSO secure this path - // if (subdir!=null) root = Path.Combine(root, subdir); var diRoot = new DirectoryInfo(root); if (!diRoot.Exists) diRoot.Create(); if (subpath != null) @@ -60,6 +59,7 @@ namespace Yavsc.Helpers diRoot = new DirectoryInfo(root); if (!diRoot.Exists) diRoot.Create(); } + else throw new InvalidPathException(); return root; } @@ -81,7 +81,7 @@ namespace Yavsc.Helpers byte[] buffer = new byte[1024]; long len = org.Length; if (len > (user.DiskQuota - usage)) { - + return item; } usage += len; @@ -110,7 +110,7 @@ namespace Yavsc.Helpers { var item = new FileRecievedInfo(); item.FileName = user.UserName + ".png"; - + var destFileName = Path.Combine(Startup.SiteSetup.UserFiles.Avatars, item.FileName); var fi = new FileInfo(destFileName); @@ -179,7 +179,7 @@ namespace Yavsc.Helpers SignFileNameFormat = new Func ((signType,estimateId) => $"estimate-{signType}sign-{estimateId}.png"); public static FileRecievedInfo ReceiveProSignature(this ClaimsPrincipal user, long estimateId, IFormFile formFile, string signtype) - { + { var item = new FileRecievedInfo(); item.FileName = SignFileNameFormat("pro",estimateId); var destFileName = Path.Combine(Startup.SiteSetup.UserFiles.Bills, item.FileName); diff --git a/Yavsc/Migrations/20170409004555_haircutCommandTaints.Designer.cs b/Yavsc/Migrations/20170409004555_haircutCommandTaints.Designer.cs index 85caf904..5f6078ff 100644 --- a/Yavsc/Migrations/20170409004555_haircutCommandTaints.Designer.cs +++ b/Yavsc/Migrations/20170409004555_haircutCommandTaints.Designer.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Metadata; using Microsoft.Data.Entity.Migrations; using Yavsc.Models; diff --git a/Yavsc/Migrations/20170409004555_haircutCommandTaints.cs b/Yavsc/Migrations/20170409004555_haircutCommandTaints.cs index d5ddc946..84ff22a5 100644 --- a/Yavsc/Migrations/20170409004555_haircutCommandTaints.cs +++ b/Yavsc/Migrations/20170409004555_haircutCommandTaints.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; + using Microsoft.Data.Entity.Migrations; namespace Yavsc.Migrations diff --git a/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs b/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs index db1c24d1..5cb12629 100644 --- a/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,8 +1,6 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; -using Microsoft.Data.Entity.Metadata; -using Microsoft.Data.Entity.Migrations; using Yavsc.Models; namespace Yavsc.Migrations diff --git a/Yavsc/Startup/Startup.Workflow.cs b/Yavsc/Startup/Startup.Workflow.cs index 77a332d6..de990cc6 100644 --- a/Yavsc/Startup/Startup.Workflow.cs +++ b/Yavsc/Startup/Startup.Workflow.cs @@ -20,7 +20,7 @@ namespace Yavsc public static List UserSettings = new List (); /// - /// Lists available command forms. + /// Lists available command forms. /// This is hard coded. /// public static readonly string [] Forms = new string [] { "Profiles" , "HairCut" }; @@ -29,7 +29,7 @@ namespace Yavsc { return UserSettings.SingleOrDefault(s => s.PropertyType.GenericTypeArguments[0].FullName == settingsClassName ) ; } - + private void ConfigureWorkflow(IApplicationBuilder app, SiteSettings settings, ILogger logger) { System.AppDomain.CurrentDomain.ResourceResolve += OnYavscResourceResolve; @@ -48,14 +48,14 @@ namespace Yavsc // bingo if (typeof(IQueryable).IsAssignableFrom(propinfo.PropertyType)) { - logger.LogInformation($"Paramêtres utilisateur déclaré: {propinfo.Name}"); + logger.LogVerbose($"Paramêtres utilisateur déclaré: {propinfo.Name}"); UserSettings.Add(propinfo); - } else + } else // Design time error { - var msg = + var msg = $@"La propriété {propinfo.Name} du contexte de la -base de donnée porte l'attribut [ActivitySetting], +base de donnée porte l'attribut [ActivitySetting], mais n'implemente pas l'interface IQueryable ({propinfo.MemberType.GetType()})"; logger.LogCritical(msg); @@ -69,7 +69,7 @@ mais n'implemente pas l'interface IQueryable public static System.Reflection.Assembly OnYavscResourceResolve (object sender, ResolveEventArgs ev) { return AppDomain.CurrentDomain.GetAssemblies()[0]; - } + } } - + } diff --git a/Yavsc/Startup/Startup.cs b/Yavsc/Startup/Startup.cs index 7a816c28..adea9ca2 100755 --- a/Yavsc/Startup/Startup.cs +++ b/Yavsc/Startup/Startup.cs @@ -22,13 +22,13 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.OptionsModel; using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Net.Http.Headers; -using Yavsc.Formatters; -using Yavsc.Models; -using Yavsc.Services; -using Yavsc.ViewModels.Auth.Handlers; namespace Yavsc { + using Formatters; + using Models; + using Services; + using ViewModels.Auth.Handlers; public partial class Startup { public static string ConnectionString { get; private set; } @@ -261,7 +261,24 @@ namespace Yavsc if (env.IsDevelopment()) { - loggerFactory.MinimumLevel = LogLevel.Verbose; + var logenvvar = Environment.GetEnvironmentVariable("ASPNET_LOG_LEVEL"); + if (logenvvar!=null) + switch (logenvvar) { + case "info": + loggerFactory.MinimumLevel = LogLevel.Information; + break; + case "warn": + loggerFactory.MinimumLevel = LogLevel.Warning; + break; + case "err": + loggerFactory.MinimumLevel = LogLevel.Error; + break; + default: + loggerFactory.MinimumLevel = LogLevel.Information; + break; + } + + app.UseDeveloperExceptionPage(); app.UseRuntimeInfoPage(); var epo = new ErrorPageOptions(); diff --git a/Yavsc/ViewModels/Haircut/HaircutAdminViewModel.cs b/Yavsc/ViewModels/Haircut/HaircutAdminViewModel.cs new file mode 100644 index 00000000..d91cd8dc --- /dev/null +++ b/Yavsc/ViewModels/Haircut/HaircutAdminViewModel.cs @@ -0,0 +1,7 @@ +namespace Yavsc.ViewModels.Haircut +{ + public class HaircutAdminViewModel + { + + } +} diff --git a/Yavsc/Views/Administration/Haircut.cshtml b/Yavsc/Views/Administration/Haircut.cshtml new file mode 100644 index 00000000..a59ab801 --- /dev/null +++ b/Yavsc/Views/Administration/Haircut.cshtml @@ -0,0 +1,5 @@ +@model HaircutAdminViewModel + + + Gestion des couleurs + \ No newline at end of file diff --git a/Yavsc/Views/Administration/Index.cshtml b/Yavsc/Views/Administration/Index.cshtml index 2c2b4dcb..f8502ef9 100644 --- a/Yavsc/Views/Administration/Index.cshtml +++ b/Yavsc/Views/Administration/Index.cshtml @@ -32,3 +32,8 @@ Nombre
@Model.AdminCount
+

Coiffure

+ + + Gestion des couleurs + \ No newline at end of file diff --git a/Yavsc/Views/Home/About.cshtml b/Yavsc/Views/Home/About.cshtml index e189277e..c4fdd73c 100755 --- a/Yavsc/Views/Home/About.cshtml +++ b/Yavsc/Views/Home/About.cshtml @@ -93,7 +93,14 @@ L'opération est annulable, jusqu'à deux semaines après sa programmation. -C'est mon site pérso. +C'est mon site pérso, une customisation de _Yavsc_ (encore une autre très petite entreprise). + +En voici d'autres: + +* [Coiffure](https://coiffure.pschneider.fr) +* [ZicMoove](https://zicmoove.pschneider.fr) +* [Lua](https://lua.pschneider.fr) +* [Yavsc](https://yavsc.pschneider.fr) -- Paul, @@ -137,9 +144,12 @@ Veuillez excuser l'équipe de développement pour vous avoir fait part de cette La "pré-production" affiche les sites suivants: +* [Coiffure](https://coiffure.pschneider.fr) * [ZicMoove](https://zicmoove.pschneider.fr) * [Yavsc](https://yavsc.pschneider.fr) -* [Lua (le site perso de l'auteur de ce truc)](https://lua.pschneider.fr) +* [Lua](https://lua.pschneider.fr) + + diff --git a/Yavsc/Views/Shared/_Layout.cshtml b/Yavsc/Views/Shared/_Layout.cshtml index b31a8d42..bde839aa 100755 --- a/Yavsc/Views/Shared/_Layout.cshtml +++ b/Yavsc/Views/Shared/_Layout.cshtml @@ -26,13 +26,9 @@ - - diff --git a/Yavsc/contrib/rsync-to-pre.sh b/Yavsc/contrib/rsync-to-pre.sh index c8e1c248..40503b5e 100755 --- a/Yavsc/contrib/rsync-to-pre.sh +++ b/Yavsc/contrib/rsync-to-pre.sh @@ -9,11 +9,11 @@ set -e cd bin/output/ rsync -ravu wwwroot approot root@localhost:$FSPATH -sleep 3 +sleep 5 ssh root@localhost service kestrel restart ) -sleep 10 +sleep 15 echo "Now, go and try " # wait a little, for the processes to become stable sleep 15 diff --git a/Yavsc/contrib/rsync-to-prod.sh b/Yavsc/contrib/rsync-to-prod.sh index d001a174..57dfc45c 100755 --- a/Yavsc/contrib/rsync-to-prod.sh +++ b/Yavsc/contrib/rsync-to-prod.sh @@ -2,17 +2,18 @@ FSPATH=/srv/www/yavsc -ssh root@localhost rm -rf $FSPATH/approot/src + ( -set -e -cd bin/output/ -rsync -ravu wwwroot approot root@localhost:$FSPATH + set -e + ssh root@localhost rm -rf $FSPATH/approot/src + cd bin/output/ + rsync -ravu wwwroot approot root@localhost:$FSPATH -sleep 1 -ssh root@localhost service kestrel restart + sleep 5 + ssh root@localhost service kestrel restart ) # wait a little, for the processes to become stable -sleep 10 +sleep 15 diff --git a/Yavsc/wwwroot/css/main/site.css b/Yavsc/wwwroot/css/main/site.css index 005416d2..12c50525 100644 --- a/Yavsc/wwwroot/css/main/site.css +++ b/Yavsc/wwwroot/css/main/site.css @@ -74,10 +74,16 @@ tr.visiblepost { max-height: 3em; } +tr.visiblepost img { + max-height: 3em; +} tr.hiddenpost { + max-height: 2em; background-color: #888; font-size: smaller; - max-height: 2em; +} +tr.hiddenpost img { + max-height: 3em; } a.bloglink { font-weight: bold; diff --git a/Yavsc/wwwroot/css/main/site.min.css b/Yavsc/wwwroot/css/main/site.min.css index a8a8be28..07c5421c 100644 --- a/Yavsc/wwwroot/css/main/site.min.css +++ b/Yavsc/wwwroot/css/main/site.min.css @@ -1 +1 @@ -.discussion,.notif,.pv{font-family:monospace}.smalltofhol,tr.visiblepost{max-height:3em}.blog a:active,.blog a:hover,a:active,a:hover{outline:0}#discussion,.blogphoto{float:left}.badge img{height:2em}.performer{padding-left:1em;background-repeat:no-repeat;background-image:url(/images/lis.svg);background-attachment:local;background-size:contain}.performer ul{margin-left:2.5em}.smalltofhol{max-width:3em;float:left;margin:.5em}.price,.total{font-weight:700;padding:.2em;margin:.2em}.price{font-size:x-large;border:2px solid #000;border-radius:1em}.total{font-size:xx-large;background-color:#f8f;border:3px solid #000;border-radius:1em}.blog,.panel{padding:1em}.blog a{font-weight:900}.discussion{color:#000}.notif{color:#006}.pv{color:#251;font-style:bold}#targets{display:block}tr.hiddenpost{background-color:#888;font-size:smaller;max-height:2em}a.bloglink{font-weight:700;text-shadow:0 0 8px #000}a{font-weight:900}.panel{display:inline-block;margin:1em;color:#000;background-color:inherit;border:1px solid #000}button,input,select,textarea{background-color:#bbb;color:#000}.jumbotron{padding:.5em}.carousel .item .btn{-webkit-transition:-webkit-transform 2s;transition:transform 2s background-color 1s color 1s;transform:scale3d(0,0,0);-webkit-transform:scale3d(0,0,0)}.carousel .active .btn{-webkit-transform:inherit;transform:inherit}.container{-webkit-transition:background-color 2s color 1s;-moz-transition:background-color 2s color 1s;transition:background-color 2s color 1s}.disabled{color:#999;background-color:#555}.carousel-caption-s p{font-family:jubilat;font-weight:600;font-size:large;line-height:1.1;text-decoration:overline;text-decoration-line:overline;text-shadow:3px 3px 7px #ffc8ff;-webkit-text-shadow:inset 0 3px 5px #ffc8ff;color:#000;margin:.5em;padding:.5em;animation:mymove 3s infinite;background-color:rgba(255,255,255,.6)}.carousel-caption-s{right:3em;top:1em;left:3em;z-index:10;padding-top:20px;padding-bottom:20px;text-align:center;min-height:16em;overflow:auto}.carousel-inner .item{padding-left:15%;padding-right:15%}.carousel-indicators{position:absolute;z-index:15;padding:0;text-align:center;list-style:none;top:.1em;height:1em}main.container{padding-right:1em;padding-left:1em;margin-left:1em;margin-right:1em}@-webkit-keyframes mymove{from,to{text-decoration-color:red}50%{text-decoration-color:#00f}}@keyframes mymove{from,to{text-decoration-color:red}50%{text-decoration-color:#00f}}ul.actiongroup li{display:inline}ul.actiongroup li a:hover{background-color:rgba(200,200,200,.6);color:#400}footer{vertical-align:bottom;padding:1.5em}.display-field{font-kerning:none;display:inline-flex;color:#008}.display-label{font-family:'Lucida Sans','Lucida Sans Regular','Lucida Grande','Lucida Sans Unicode',Geneva,Verdana,sans-serif;font-stretch:condensed;display:inline-flex;color:#ff8;padding:.1em;border-radius:.5em;background-color:#210912}footer{color:grey;font-weight:bolder;font-size:x-small}.meta{color:#444;font-style:italic;font-size:smaller}.activity{font-family:fantasy}.blogtitle{display:inline-block;font-size:x-large}.blogphoto{margin:1em}.dl-horizontal dd{margin-left:20%} \ No newline at end of file +.discussion,.notif,.pv{font-family:monospace}.smalltofhol,tr.visiblepost,tr.visiblepost img{max-height:3em}.blog a:active,.blog a:hover,a:active,a:hover{outline:0}#discussion,.blogphoto{float:left}.badge img{height:2em}.performer{padding-left:1em;background-repeat:no-repeat;background-image:url(/images/lis.svg);background-attachment:local;background-size:contain}.performer ul{margin-left:2.5em}.smalltofhol{max-width:3em;float:left;margin:.5em}.price,.total{font-weight:700;padding:.2em;margin:.2em}.price{font-size:x-large;border:2px solid #000;border-radius:1em}.total{font-size:xx-large;background-color:#f8f;border:3px solid #000;border-radius:1em}.blog,.panel{padding:1em}.blog a{font-weight:900}.discussion{color:#000}.notif{color:#006}.pv{color:#251;font-style:bold}#targets{display:block}tr.hiddenpost{max-height:2em;background-color:#888;font-size:smaller}tr.hiddenpost img{max-height:3em}a.bloglink{font-weight:700;text-shadow:0 0 8px #000}a{font-weight:900}.panel{display:inline-block;margin:1em;color:#000;background-color:inherit;border:1px solid #000}button,input,select,textarea{background-color:#bbb;color:#000}.jumbotron{padding:.5em}.carousel .item .btn{-webkit-transition:-webkit-transform 2s;transition:transform 2s background-color 1s color 1s;transform:scale3d(0,0,0);-webkit-transform:scale3d(0,0,0)}.carousel .active .btn{-webkit-transform:inherit;transform:inherit}.container{-webkit-transition:background-color 2s color 1s;-moz-transition:background-color 2s color 1s;transition:background-color 2s color 1s}.disabled{color:#999;background-color:#555}.carousel-caption-s p{font-family:jubilat;font-weight:600;font-size:large;line-height:1.1;text-decoration:overline;text-decoration-line:overline;text-shadow:3px 3px 7px #ffc8ff;-webkit-text-shadow:inset 0 3px 5px #ffc8ff;color:#000;margin:.5em;padding:.5em;animation:mymove 3s infinite;background-color:rgba(255,255,255,.6)}.carousel-caption-s{right:3em;top:1em;left:3em;z-index:10;padding-top:20px;padding-bottom:20px;text-align:center;min-height:16em;overflow:auto}.carousel-inner .item{padding-left:15%;padding-right:15%}.carousel-indicators{position:absolute;z-index:15;padding:0;text-align:center;list-style:none;top:.1em;height:1em}main.container{padding-right:1em;padding-left:1em;margin-left:1em;margin-right:1em}@-webkit-keyframes mymove{from,to{text-decoration-color:red}50%{text-decoration-color:#00f}}@keyframes mymove{from,to{text-decoration-color:red}50%{text-decoration-color:#00f}}ul.actiongroup li{display:inline}ul.actiongroup li a:hover{background-color:rgba(200,200,200,.6);color:#400}footer{vertical-align:bottom;padding:1.5em}.display-field{font-kerning:none;display:inline-flex;color:#008}.display-label{font-family:'Lucida Sans','Lucida Sans Regular','Lucida Grande','Lucida Sans Unicode',Geneva,Verdana,sans-serif;font-stretch:condensed;display:inline-flex;color:#ff8;padding:.1em;border-radius:.5em;background-color:#210912}footer{color:grey;font-weight:bolder;font-size:x-small}.meta{color:#444;font-style:italic;font-size:smaller}.activity{font-family:fantasy}.blogtitle{display:inline-block;font-size:x-large}.blogphoto{margin:1em}.dl-horizontal dd{margin-left:20%} \ No newline at end of file