* Logs moins verbeux, + support config env var  ASPNET_LOG_LEVEL
* [REFACT/FS] Valid chars + [FIX] inclut maintenant le tiret (`-`) et `=`
* scripts de déployement : timings des `sleep`  plus sûrs
* [HAIRCUT] les commandes de teintes (de la part du client)
* index admin des coiffeurs
* Maj de ma Home page
* Mise en forme
* [FIX] suppression de la reference externe aux scripts de ajax.aspnetcdn.com, pour un chargement sans Internet des pages.
vnext
Paul Schneider 8 years ago
parent 4143b1a75e
commit 7355a249cb
18 changed files with 109 additions and 53 deletions

@ -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<FileRecievedInfo> Post(string subdir="")
public IEnumerable<IActionResult> 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);
};
}
}
}
}

@ -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 = { 

@ -0,0 +1,9 @@
using System;
namespace Yavsc.Exceptions
{
public class InvalidPathException: Exception
{
}
}

@ -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<string,long,string> ((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);

@ -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;

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
namespace Yavsc.Migrations

@ -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

@ -20,7 +20,7 @@ namespace Yavsc
public static List<PropertyInfo> UserSettings = new List<PropertyInfo> ();
/// <summary>
/// Lists available command forms.
/// Lists available command forms.
/// This is hard coded.
/// </summary>
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<ISpecializationSettings>).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<ISpecializationSettings>
({propinfo.MemberType.GetType()})";
logger.LogCritical(msg);
@ -69,7 +69,7 @@ mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
public static System.Reflection.Assembly OnYavscResourceResolve (object sender, ResolveEventArgs ev)
{
return AppDomain.CurrentDomain.GetAssemblies()[0];
}
}
}
}

@ -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();

@ -0,0 +1,7 @@
namespace Yavsc.ViewModels.Haircut
{
public class HaircutAdminViewModel
{
}
}

@ -0,0 +1,5 @@
@model HaircutAdminViewModel
<a asp-controller="HairTaints" class="btn btn-primary">
Gestion des couleurs
</a>

@ -32,3 +32,8 @@ Nombre </dt><dd> @Model.AdminCount</dd>
</dd>
</dl>
<h3>Coiffure</h3>
<a asp-controller="HairTaints" class="btn btn-primary">
Gestion des couleurs
</a>

@ -93,7 +93,14 @@ L'opération est annulable, jusqu'à deux semaines après sa programmation.
<environment names="Lua">
<markdown>
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)
</markdown>
</environment>

@ -26,13 +26,9 @@
<link rel="alternate stylesheet" title="Dark" href="~/css/dark/site.min.css" asp-append-version="true" />
<link rel="alternate stylesheet" title="Clear" href="~/css/clear/site.min.css" asp-append-version="true" />
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
asp-fallback-src="~/jquery.min.js"
asp-fallback-test="window.jQuery" >
<script src="~/js/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js"
asp-fallback-src="~/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
<script src="~/js/bootstrap.min.js">
</script>
<script src="~/js/jquery-ui.min.js" asp-append-version="true"></script>
<script src="~/js/jquery.signalR-2.2.1.min.js" asp-append-version="true"></script>

@ -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 <https://yavscpre.pschneider.fr>"
# wait a little, for the processes to become stable
sleep 15

@ -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

@ -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;

@ -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%}
.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%}
Loading…