Fixes the avatar Url from the menu
This commit is contained in:
@ -24,7 +24,7 @@ namespace Yavsc.Controllers
|
||||
/// </summary>
|
||||
public class AccountController : Controller
|
||||
{
|
||||
|
||||
|
||||
string avatarDir = "~/avatars";
|
||||
string defaultAvatar;
|
||||
string defaultAvatarMimetype;
|
||||
@ -37,20 +37,7 @@ namespace Yavsc.Controllers
|
||||
[AcceptVerbs (HttpVerbs.Get)]
|
||||
public ActionResult Avatar (string id)
|
||||
{
|
||||
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);
|
||||
}
|
||||
string avatarLocation = avpath as string;
|
||||
if (avatarLocation.StartsWith ("~/")) {
|
||||
avatarLocation = Server.MapPath (avatarLocation);
|
||||
}
|
||||
|
||||
string avatarLocation = Url.AvatarUrl (id);
|
||||
WebRequest wr = WebRequest.Create (avatarLocation);
|
||||
FileContentResult res;
|
||||
using (WebResponse resp = wr.GetResponse ()) {
|
||||
|
@ -151,10 +151,18 @@ namespace Yavsc.Helpers
|
||||
/// <param name="helper">Helper.</param>
|
||||
/// <param name="username">Username.</param>
|
||||
public static string AvatarUrl (this System.Web.Mvc.UrlHelper helper, string username) {
|
||||
if (username == null)
|
||||
return null;
|
||||
ProfileBase pr = ProfileBase.Create (username);
|
||||
var a = pr.GetPropertyValue("Avatar") ;
|
||||
if (a == null || a is DBNull) return "/avatars/" + helper.Encode(username)+".png";
|
||||
return helper.Encode ((string)a);
|
||||
object avpath = null;
|
||||
if (pr != null) avpath = pr.GetPropertyValue("Avatar");
|
||||
if (avpath == null) return "/bfiles/"+username+".png";
|
||||
string avatarLocation = avpath as string;
|
||||
if (avatarLocation.StartsWith ("~/")) {
|
||||
avatarLocation = helper.RequestContext.HttpContext.Server.MapPath(avatarLocation);
|
||||
}
|
||||
return avatarLocation;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,15 +80,12 @@ $(document).ready(function(){
|
||||
|
||||
<asp:ContentPlaceHolder ID="overHeaderOne" runat="server">
|
||||
|
||||
<h1><a href="<%= Html.Encode(Request.Url.AbsoluteUri.ToString()) %>"> <%=ViewState["orgtitle"]%> </a>
|
||||
<span> -
|
||||
<a href="<%= Url.Content("~/") %>"><%= YavscHelpers.SiteName %></a>
|
||||
</span></h1>
|
||||
<h1><a href="<%= Url.Content("~/") %>"> <%=ViewState["orgtitle"]%> </a></h1>
|
||||
|
||||
</asp:ContentPlaceHolder>
|
||||
</asp:ContentPlaceHolder>
|
||||
|
||||
|
||||
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
|
||||
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
|
||||
<div id="error"><%= (ViewData["Error"]!=null)? Html.Encode(ViewData["Error"]) : "" %></div>
|
||||
<div id="message"><%= Html.Encode(ViewData["Message"]) %></div>
|
||||
|
||||
@ -104,7 +101,7 @@ $(document).ready(function(){
|
||||
</a>
|
||||
<% } else { %>
|
||||
<a href="/Blog/<%= HttpContext.Current.User.Identity.Name%>" accesskey = "B" class="menuitem">
|
||||
<img src="<%=Html.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
|
||||
<img src="<%=Url.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
|
||||
<div class="hint">Vos billets</div>
|
||||
</a>
|
||||
<a href="<%= Url.Content("~/Account/Profile/" + HttpContext.Current.User.Identity.Name) %>" accesskey="L" class="menuitem">
|
||||
|
Reference in New Issue
Block a user