Fixes the avatar Url from the menu
This commit is contained in:
4
Makefile
4
Makefile
@ -1,7 +1,7 @@
|
||||
|
||||
VERSION=1.1
|
||||
CONFIG=Debug
|
||||
LDYDESTDIR=build/web/$(CONFIG)
|
||||
LDYDESTDIR=dist/web/$(CONFIG)
|
||||
COPYUNCHANGED="false"
|
||||
|
||||
HOST_rsync_yavsc=lua.pschneider.fr
|
||||
@ -37,7 +37,7 @@ rsync_% : DESTDIR = $(DESTDIR_$@)
|
||||
|
||||
rsync_% : deploy
|
||||
echo "!Deploying to $(HOST)!"
|
||||
$(RSYNCCMD) build/web/$(CONFIG)/ root@$(HOST):$(DESTDIR)
|
||||
$(RSYNCCMD) dist/web/$(CONFIG)/ root@$(HOST):$(DESTDIR)
|
||||
|
||||
build:
|
||||
xbuild /p:Configuration=$(CONFIG) /t:Build Yavsc.sln
|
||||
|
@ -40,7 +40,7 @@ namespace Yavsc.Admin
|
||||
*/
|
||||
Exec ("pg_dump", string.Format (
|
||||
"-f {0} -Ft -h {1} -U {2} -p {3} {4}",
|
||||
fileName, da.Host, da.Dbuser, da.Port, da.Dbname ),e);
|
||||
fileName, da.Host, da.DbUser, da.Port, da.DbName ),e);
|
||||
return e;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ namespace Yavsc.Admin
|
||||
var t = new TaskOutput ();
|
||||
Exec ("pg_restore", (dataOnly?"-a ":"")+string.Format (
|
||||
"-1 -Ft -O -h {0} -U {1} -p {2} -d {3} {4}",
|
||||
da.Host, da.Dbuser, da.Port, da.Dbname, fileName ),t);
|
||||
da.Host, da.DbUser, da.Port, da.DbName, fileName ),t);
|
||||
/*
|
||||
Exec ("pg_restore", (dataOnly?"-a ":"")+string.Format (
|
||||
"-1 -w -Fd -O -h {0} -U {1} -p {2} -d {3} {4}",
|
||||
@ -149,7 +149,7 @@ namespace Yavsc.Admin
|
||||
var t = new TaskOutput ();
|
||||
Exec ("pg_restore", string.Format (
|
||||
"-a -w -Fd -O -h {0} -U {1} -p {2} -d {3} {4}",
|
||||
da.Host, da.Dbuser, da.Port, da.Dbname, fileName ),t);
|
||||
da.Host, da.DbUser, da.Port, da.DbName, fileName ),t);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Yavsc.Admin
|
||||
namespace Yavsc.Model.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Export.
|
||||
@ -9,7 +9,7 @@ namespace Yavsc.Admin
|
||||
public class Export: TaskOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.Admin.Export"/> class.
|
||||
/// Initializes a new instance of the <see cref="Yavsc.Model.Admin.Export"/> class.
|
||||
/// </summary>
|
||||
public Export ()
|
||||
{
|
||||
|
@ -146,18 +146,30 @@ namespace Yavsc.ApiControllers
|
||||
try
|
||||
{
|
||||
// Read the form data.
|
||||
await Request.Content.ReadAsMultipartAsync(provider) ;
|
||||
IEnumerable<HttpContent> data = await Request.Content.ReadAsMultipartAsync(provider) ;
|
||||
|
||||
var invalidChars = Path.GetInvalidFileNameChars();
|
||||
List<string> bodies = new List<string>();
|
||||
List<string> parts = new List<string>();
|
||||
List<string> text = new List<string>();
|
||||
|
||||
foreach (string fkey in provider.BodyPartFileNames.Keys)
|
||||
// filter files on their mime type
|
||||
foreach ( var httpAudioContent in data
|
||||
) {
|
||||
string [] mimetype = httpAudioContent.Headers.ContentType.MediaType.Split('/');
|
||||
switch (mimetype[0]) {
|
||||
case "application": break;
|
||||
case "text": break;
|
||||
case "image": break;
|
||||
case "audio": break;
|
||||
case "video": break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string fkey in text)
|
||||
{
|
||||
string filename = provider.BodyPartFileNames[fkey];
|
||||
|
||||
|
||||
string nicename=fkey;
|
||||
if (fkey.StartsWith("\"") && fkey.EndsWith("\"") && fkey.Length > 2)
|
||||
nicename = fkey.Substring(1,fkey.Length-2);
|
||||
var filtered = new string (nicename.Where( x=> !invalidChars.Contains(x)).ToArray());
|
||||
|
||||
FileInfo fi = new FileInfo(filtered);
|
||||
@ -165,6 +177,10 @@ namespace Yavsc.ApiControllers
|
||||
FileInfo fp = new FileInfo (Path.Combine(root,filename));
|
||||
if (fi.Exists) fi.Delete();
|
||||
fp.MoveTo(fi.FullName);
|
||||
// Get the mime type
|
||||
|
||||
|
||||
|
||||
using (Process p = new Process ()) {
|
||||
p.StartInfo.WorkingDirectory = root;
|
||||
p.StartInfo = new ProcessStartInfo ();
|
||||
@ -187,14 +203,14 @@ namespace Yavsc.ApiControllers
|
||||
);
|
||||
}
|
||||
}
|
||||
bodies.Add(fo.OpenText().ReadToEnd());
|
||||
parts.Add(fo.OpenText().ReadToEnd());
|
||||
|
||||
|
||||
fi.Delete();
|
||||
fo.Delete();
|
||||
}
|
||||
|
||||
return Request.CreateResponse(HttpStatusCode.OK,string.Join("---\n",bodies),new SimpleFormatter("text/plain"));
|
||||
return Request.CreateResponse(HttpStatusCode.OK,string.Join("---\n",parts),new SimpleFormatter("text/plain"));
|
||||
|
||||
}
|
||||
catch (System.Exception e)
|
||||
|
@ -33,21 +33,25 @@ namespace Yavsc.Controllers
|
||||
/// <summary>
|
||||
/// Avatar the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">User.</param>
|
||||
/// <param name="id">User.</param>
|
||||
[AcceptVerbs (HttpVerbs.Get)]
|
||||
public ActionResult Avatar (string user)
|
||||
public ActionResult Avatar (string id)
|
||||
{
|
||||
ProfileBase pr = ProfileBase.Create (user);
|
||||
string avpath = (string ) pr.GetPropertyValue("Avatar") ;
|
||||
if (id == null)
|
||||
return new EmptyResult ();
|
||||
|
||||
ProfileBase pr = ProfileBase.Create (id);
|
||||
var avpath = pr.GetPropertyValue("Avatar");
|
||||
if (avpath == null) {
|
||||
FileInfo fia = new FileInfo (Server.MapPath (defaultAvatar));
|
||||
return File (fia.OpenRead (), defaultAvatarMimetype);
|
||||
}
|
||||
if (avpath.StartsWith ("~/")) {
|
||||
avpath = Server.MapPath (avpath);
|
||||
string avatarLocation = avpath as string;
|
||||
if (avatarLocation.StartsWith ("~/")) {
|
||||
avatarLocation = Server.MapPath (avatarLocation);
|
||||
}
|
||||
|
||||
WebRequest wr = WebRequest.Create (avpath);
|
||||
WebRequest wr = WebRequest.Create (avatarLocation);
|
||||
FileContentResult res;
|
||||
using (WebResponse resp = wr.GetResponse ()) {
|
||||
using (Stream str = resp.GetResponseStream ()) {
|
||||
@ -303,6 +307,8 @@ namespace Yavsc.Controllers
|
||||
// ASSERT("Membership.GetUser ().UserName is made of simple characters, no slash nor backslash"
|
||||
|
||||
string logdu = Membership.GetUser ().UserName;
|
||||
if (string.IsNullOrWhiteSpace (id))
|
||||
id = logdu;
|
||||
ViewData ["UserName"] = id;
|
||||
bool editsMyName = (string.Compare(id,logdu)==0);
|
||||
if (!editsMyName)
|
||||
@ -310,15 +316,17 @@ namespace Yavsc.Controllers
|
||||
if (!Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("Your are not authorized to modify this profile");
|
||||
|
||||
|
||||
if (AvatarFile != null) {
|
||||
// if said valid, move as avatar file
|
||||
// else invalidate the model
|
||||
if (AvatarFile.ContentType == "image/png") {
|
||||
string avdir = Server.MapPath (AvatarDir);
|
||||
var di = new DirectoryInfo (avdir);
|
||||
if (!di.Exists)
|
||||
di.Create ();
|
||||
string avpath = Path.Combine (avdir, id + ".png");
|
||||
AvatarFile.SaveAs (avpath);
|
||||
model.avatar = Request.Url.Scheme + "://" + Request.Url.Authority + AvatarDir.Substring (1) + "/" + id + ".png";
|
||||
model.avatar = Url.Content( AvatarDir + "/" + id + ".png");
|
||||
} else
|
||||
ModelState.AddModelError ("Avatar",
|
||||
string.Format ("Image type {0} is not supported (suported formats : {1})",
|
||||
@ -336,7 +344,9 @@ namespace Yavsc.Controllers
|
||||
if (AvatarFile != null) {
|
||||
prf.SetPropertyValue ("Avatar", model.avatar);
|
||||
} else {
|
||||
model.avatar = (string) prf.GetPropertyValue ("Avatar");
|
||||
var av = prf.GetPropertyValue ("Avatar");
|
||||
if (av != null)
|
||||
model.avatar = av as string;
|
||||
}
|
||||
prf.SetPropertyValue ("Address", model.Address);
|
||||
prf.SetPropertyValue ("CityAndState", model.CityAndState);
|
||||
|
@ -42,6 +42,10 @@ namespace Yavsc.Controllers
|
||||
datac.BackupPrefix = Server.MapPath (datac.BackupPrefix);
|
||||
DataManager mgr = new DataManager (datac);
|
||||
TaskOutput tcdb = mgr.CreateDb ();
|
||||
ViewData ["DbName"] = datac.DbName;
|
||||
ViewData ["DbUser"] = datac.DbUser;
|
||||
ViewData ["Host"] = datac.Host;
|
||||
ViewData ["Port"] = datac.Port;
|
||||
return View ("Created", tcdb);
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ namespace Yavsc.Helpers
|
||||
/// <returns>The URL.</returns>
|
||||
/// <param name="helper">Helper.</param>
|
||||
/// <param name="username">Username.</param>
|
||||
public static string AvatarUrl (this System.Web.WebPages.Html.HtmlHelper helper, string username) {
|
||||
public static string AvatarUrl (this System.Web.Mvc.UrlHelper helper, string username) {
|
||||
ProfileBase pr = ProfileBase.Create (username);
|
||||
var a = pr.GetPropertyValue("Avatar") ;
|
||||
if (a == null || a is DBNull) return "/avatars/" + helper.Encode(username)+".png";
|
||||
|
14
web/Views/Blogs/ChooseMedia.aspx
Normal file
14
web/Views/Blogs/ChooseMedia.aspx
Normal file
@ -0,0 +1,14 @@
|
||||
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %>
|
||||
<asp:Content ID="initContent" ContentPlaceHolderID="init" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="overHeaderOneContent" ContentPlaceHolderID="overHeaderOne" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="headerContent" ContentPlaceHolderID="header" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
kjgftkgt
|
||||
</asp:Content>
|
||||
<asp:Content ID="MASContentContent" ContentPlaceHolderID="MASContent" runat="server">
|
||||
</asp:Content>
|
BIN
web/fonts/fontawesome-webfont.woff2
Normal file
BIN
web/fonts/fontawesome-webfont.woff2
Normal file
Binary file not shown.
Reference in New Issue
Block a user