Compare commits
No commits in common. "8e2fd65b68bd80383cc0e9e29839ab7e57c534d9" and "6b4e52e7cebd612995c88d2bc156647b4d676401" have entirely different histories.
8e2fd65b68
...
6b4e52e7ce
7 changed files with 107 additions and 89 deletions
|
|
@ -10,7 +10,6 @@ using Yavsc.Abstract.Workflow;
|
||||||
using Yavsc.Api.Client;
|
using Yavsc.Api.Client;
|
||||||
using Yavsc.Models.Haircut;
|
using Yavsc.Models.Haircut;
|
||||||
namespace PostIt.ViewModels.Commands;
|
namespace PostIt.ViewModels.Commands;
|
||||||
|
|
||||||
public partial class BrushViewModel : RdvViewModel
|
public partial class BrushViewModel : RdvViewModel
|
||||||
{
|
{
|
||||||
public override string SupportMessage => "Choisissez une prestation coiffure puis postez la commande.";
|
public override string SupportMessage => "Choisissez une prestation coiffure puis postez la commande.";
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.AspNetCore.Localization;
|
using Microsoft.AspNetCore.Localization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|
@ -1283,52 +1282,10 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
||||||
|
|
||||||
app.UseFileServer(Config.AvatarsOptions);
|
app.UseFileServer(Config.AvatarsOptions);
|
||||||
|
|
||||||
app.Use(async (context, next) =>
|
|
||||||
{
|
|
||||||
await next();
|
|
||||||
|
|
||||||
if (context.Response.StatusCode != StatusCodes.Status404NotFound
|
|
||||||
|| context.Response.HasStarted
|
|
||||||
|| !HttpMethods.IsGet(context.Request.Method)
|
|
||||||
|| !context.Request.Path.StartsWithSegments(Constants.AvatarsPath, out var avatarFile))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var webHostEnvironment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
|
|
||||||
var fallbackAsset = ResolveAvatarFallbackAsset(avatarFile);
|
|
||||||
var fallbackFile = webHostEnvironment.WebRootFileProvider.GetFileInfo(fallbackAsset.TrimStart('/'));
|
|
||||||
if (!fallbackFile.Exists)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Response.StatusCode = StatusCodes.Status200OK;
|
|
||||||
context.Response.ContentType = "image/png";
|
|
||||||
await context.Response.SendFileAsync(fallbackFile);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseFileServer(Config.GitOptions);
|
app.UseFileServer(Config.GitOptions);
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ResolveAvatarFallbackAsset(PathString avatarFile)
|
|
||||||
{
|
|
||||||
var fileName = avatarFile.Value ?? string.Empty;
|
|
||||||
|
|
||||||
if (fileName.EndsWith(".xs.png", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return "/images/Users/icon_user.xs.png";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileName.EndsWith(".s.png", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return "/images/Users/icon_user.s.png";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Constants.DefaultAvatar;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
@using System.Security.Claims
|
@using System.Security.Claims
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Manage your account";
|
ViewBag.Title = "Manage your account";
|
||||||
var avatarSrc = string.IsNullOrWhiteSpace(Model.UserName)
|
|
||||||
? Yavsc.Constants.DefaultAvatar
|
|
||||||
: $"{Yavsc.Constants.AvatarsPath}/{Model.UserName}.s.png";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewBag.Title</h2>
|
<h2>@ViewBag.Title</h2>
|
||||||
|
|
@ -89,7 +86,7 @@ Html.DisplayText("Modify");
|
||||||
|
|
||||||
<dt>Avatar:</dt>
|
<dt>Avatar:</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<img src="@avatarSrc" asp-append-version="true" class="smalltofhol" />
|
<img src="/Avatars/@(User.GetUserName()+".s").png" asp-append-version="true" class="smalltofhol" />
|
||||||
[<a asp-controller="Manage" asp-action="SetAvatar">Modify</a>]
|
[<a asp-controller="Manage" asp-action="SetAvatar">Modify</a>]
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
@model PerformerProfile
|
@model PerformerProfile
|
||||||
@{ ViewBag.Title = "Edit your avatar"; }
|
@{ ViewBag.Title = "Edit your avatar"; }
|
||||||
@{
|
|
||||||
var previewAvatarSrc = string.IsNullOrWhiteSpace(User?.Identity?.Name)
|
|
||||||
? Yavsc.Constants.DefaultAvatar
|
|
||||||
: $"{Yavsc.Constants.AvatarsPath}/{User.Identity.Name}.png";
|
|
||||||
}
|
|
||||||
@section header{
|
@section header{
|
||||||
<script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
|
<script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" type="text/css" />
|
<link rel="stylesheet" href="https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" type="text/css" />
|
||||||
|
|
@ -26,7 +21,7 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
<img src="@previewAvatarSrc">
|
<img src="~/avatars/@(User.Identity.Name).png">
|
||||||
|
|
||||||
<form id="postavatar" action="/api/setavatar" class="dropzone" method="post" enctype="multipart/form-data">
|
<form id="postavatar" action="/api/setavatar" class="dropzone" method="post" enctype="multipart/form-data">
|
||||||
<div class="fallback">
|
<div class="fallback">
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,5 @@
|
||||||
@using Yavsc.Abstract.Identity
|
|
||||||
@model ApplicationUser
|
@model ApplicationUser
|
||||||
|
|
||||||
@if (Model != null)
|
@if (Model!=null) {
|
||||||
{
|
<img src="/Avatars/@(Model.UserName+".xs").png" asp-append-version="true" class="smalltofhol" />
|
||||||
var avatarSrc = UserDisplayHelpers.AvatarSrc(Model);
|
|
||||||
if (avatarSrc.EndsWith(".s.png", StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
avatarSrc = avatarSrc.Replace(".s.png", ".xs.png", StringComparison.Ordinal);
|
|
||||||
}
|
|
||||||
|
|
||||||
<img src="@avatarSrc" asp-append-version="true" class="smalltofhol" />
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ if (Model ==null || Model.UserName==null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string avuri = UserDisplayHelpers.AvatarSrc(Model);
|
string avuri = "/Avatars/" + Model.UserName + ".s.png";
|
||||||
|
|
||||||
<div class="userinfo">
|
<div class="userinfo">
|
||||||
<a title="Posts" asp-controller="Blogspot" asp-action="Index" asp-route-id="@Model.UserName" class="btn btn-primary">
|
<a title="Posts" asp-controller="Blogspot" asp-action="Index" asp-route-id="@Model.UserName" class="btn btn-primary">
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,84 @@ namespace Yavsc.Server.Helpers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RequestHelper
|
public class RequestHelper
|
||||||
{
|
{
|
||||||
|
string WRPostMultipart(string url, Dictionary<string, object> parameters, string authorizationHeader = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
string boundary = "---------------------------" + DateTime.UtcNow.Ticks.ToString("x");
|
||||||
|
byte[] boundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
|
||||||
|
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||||
|
request.Method = "POST";
|
||||||
|
request.KeepAlive = true;
|
||||||
|
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
|
||||||
|
if (authorizationHeader != null)
|
||||||
|
request.Headers["Authorization"] = authorizationHeader;
|
||||||
|
if (parameters != null && parameters.Count > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
using (Stream requestStream = request.GetRequestStream())
|
||||||
|
{
|
||||||
|
using (WebResponse response = request.GetResponse())
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, object> pair in parameters)
|
||||||
|
{
|
||||||
|
|
||||||
|
requestStream.Write(boundaryBytes, 0, boundaryBytes.Length);
|
||||||
|
if (pair.Value is FormFile)
|
||||||
|
{
|
||||||
|
FormFile file = pair.Value as FormFile;
|
||||||
|
string header = "Content-Disposition: form-data; name=\"" + pair.Key + "\"; filename=\"" + file.Name + "\"\r\nContent-Type: " + file.ContentType + "\r\n\r\n";
|
||||||
|
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(header);
|
||||||
|
requestStream.Write(bytes, 0, bytes.Length);
|
||||||
|
byte[] buffer = new byte[32768];
|
||||||
|
int bytesRead;
|
||||||
|
if (file.Stream == null)
|
||||||
|
{
|
||||||
|
// upload from file
|
||||||
|
using (FileStream fileStream = File.OpenRead(file.FilePath))
|
||||||
|
{
|
||||||
|
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
|
||||||
|
requestStream.Write(buffer, 0, bytesRead);
|
||||||
|
fileStream.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// upload from given stream
|
||||||
|
while ((bytesRead = file.Stream.Read(buffer, 0, buffer.Length)) != 0)
|
||||||
|
requestStream.Write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string data = "Content-Disposition: form-data; name=\"" + pair.Key + "\"\r\n\r\n" + pair.Value;
|
||||||
|
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data);
|
||||||
|
requestStream.Write(bytes, 0, bytes.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
|
||||||
|
requestStream.Write(trailer, 0, trailer.Length);
|
||||||
|
requestStream.Close();
|
||||||
|
|
||||||
|
using (Stream responseStream = response.GetResponseStream())
|
||||||
|
using (StreamReader reader = new StreamReader(responseStream))
|
||||||
|
{
|
||||||
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
} // end WebResponse response
|
||||||
|
|
||||||
|
} // end using requestStream
|
||||||
|
|
||||||
|
}
|
||||||
|
else throw new ArgumentOutOfRangeException("no parameter found ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> PostMultipart(string url, FormFile[] formFiles, string access_token = null)
|
public static async Task<string> PostMultipart(string url, FormFile[] formFiles, string access_token = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue