diff --git a/NpgsqlContentProvider/ChangeLog b/NpgsqlContentProvider/ChangeLog index cae08936..3a67cf0e 100644 --- a/NpgsqlContentProvider/ChangeLog +++ b/NpgsqlContentProvider/ChangeLog @@ -1,3 +1,8 @@ +2015-09-10 Paul Schneider + + * NpgsqlCircleProvider.cs: * refactoring + * updates the circle + 2015-08-20 Paul Schneider * NpgsqlCircleProvider.cs: circle members are now stored in bd diff --git a/NpgsqlContentProvider/NpgsqlCircleProvider.cs b/NpgsqlContentProvider/NpgsqlCircleProvider.cs index 3d6fc23b..8ed18843 100644 --- a/NpgsqlContentProvider/NpgsqlCircleProvider.cs +++ b/NpgsqlContentProvider/NpgsqlCircleProvider.cs @@ -37,20 +37,122 @@ namespace WorkFlowProvider public class NpgsqlCircleProvider : CircleProvider { #region implemented abstract members of CircleProvider + /// + /// Updates the circle. + /// + /// C. + public override void UpdateCircle (CircleBase c) + { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "update circle " + + "set title = :title, " + + "isprivate = :pv " + + "where _id = :cid "; + cmd.Parameters.AddWithValue ("title", c.Title); + cmd.Parameters.AddWithValue ("pv", c.IsPrivate); + cmd.Parameters.AddWithValue ("cid", c.Id); + cmd.ExecuteNonQuery (); + } + cnx.Close (); + } + } + /// + /// Get the specified circle by id, including all of its members. + /// + /// Identifier. + /// The members. + public override Circle GetMembers (long id) + { + Circle circ = null; + + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "select title, owner, public from circle where _id = :cid"; + cmd.Parameters.AddWithValue ("cid", id); + using (NpgsqlDataReader dr = cmd.ExecuteReader ()) { + if (dr.Read ()) { + circ = new Circle (); + circ.Id = id; + circ.Title = dr.GetString ( + dr.GetOrdinal ("title")); + circ.Owner = dr.GetString ( + dr.GetOrdinal ("owner")); + circ.IsPrivate = !dr.GetBoolean (dr.GetOrdinal ("public")); + + } + dr.Close (); + } + } + + if (circ != null) { + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "select member from circle_members where circle_id = :cid"; + cmd.Parameters.AddWithValue ("cid", id); + cmd.Prepare (); + List members = new List (); + using (NpgsqlDataReader dr = cmd.ExecuteReader ()) { + while (dr.Read ()) + members.Add (dr.GetString (0)); + dr.Close (); + circ.Members = members.ToArray (); + } + } + } + cnx.Close (); + } + return circ; + } + /// + /// Gets the identifier. + /// + /// The identifier. + /// Circle. + /// Username. + public override long GetId (string circle, string username) + { + long cid = 0; + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "select _id from circle where " + + "owner = :uname " + + "and title = :title " + + "and applicationname = :appname"; + + cmd.Parameters.AddWithValue ("uname", username); + cmd.Parameters.AddWithValue ("title", circle); + cmd.Parameters.AddWithValue ("appname", applicationName); + cid = (long)cmd.ExecuteScalar (); + } + cnx.Close (); + } + return cid; + } + /// + /// Removes the membership. + /// + /// Circle identifier. + /// Member. public override void RemoveMembership (long circle_id, string member) { using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "delete from circle_members where circle_id = :cid and username = :uname"; - cmd.Parameters.AddWithValue("cid",circle_id); - cmd.Parameters.AddWithValue("uname",member); + cmd.Parameters.AddWithValue ("cid", circle_id); + cmd.Parameters.AddWithValue ("uname", member); cnx.Open (); cmd.ExecuteNonQuery (); cnx.Close (); } } - + /// + /// Removes the member from all current user circles. + /// + /// Member. public override void RemoveMember (string member) { throw new NotImplementedException (); @@ -72,18 +174,18 @@ namespace WorkFlowProvider /// /// Circle identifiers. /// Member name. - public override bool Matches (long [] circle_ids, string member) + public override bool Matches (long[] circle_ids, string member) { - bool result=false; + bool result = false; using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "select count(*)>0 from circle_members where circle_id = :cid and member = :mbr"; - cmd.Parameters.Add("cid",NpgsqlDbType.Bigint); - cmd.Parameters.AddWithValue("mbr",member); + cmd.Parameters.Add ("cid", NpgsqlDbType.Bigint); + cmd.Parameters.AddWithValue ("mbr", member); cnx.Open (); cmd.Prepare (); foreach (long cid in circle_ids) { - result = (bool) cmd.ExecuteScalar(); + result = (bool)cmd.ExecuteScalar (); if (result) break; } @@ -97,61 +199,38 @@ namespace WorkFlowProvider /// /// circle Identifier. /// User name. - public override void Add (long id, string username) + public override void AddMember (long id, string username) { using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "insert into circle_members (circle_id, member) values (:cid,:uname)"; - cmd.Parameters.AddWithValue("cid",id); - cmd.Parameters.AddWithValue("uname",username); + cmd.Parameters.AddWithValue ("cid", id); + cmd.Parameters.AddWithValue ("uname", username); cnx.Open (); cmd.ExecuteNonQuery (); cnx.Close (); } } - /// - /// Get the specified id. + /// Get the specified circle by id. /// /// Identifier. - public override Circle Get (long id) + public override CircleBase Get (long id) { - Circle circ=null; - + CircleBase circ = null; using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "select title, owner, public from circle where _id = :cid"; + cmd.CommandText = "select title, owner from circle where _id = :cid"; cmd.Parameters.AddWithValue ("cid", id); - using (NpgsqlDataReader dr = cmd.ExecuteReader ()) { - if (dr.Read ()) { - circ = new Circle (); - circ.Id = id; - circ.Title = dr.GetString ( - dr.GetOrdinal ("title")); - circ.Owner = dr.GetString ( - dr.GetOrdinal ("owner")); - circ.IsPrivate = !dr.GetBoolean(dr.GetOrdinal("public")); - - } - dr.Close (); - } - } - - if (circ != null) { - - using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "select member from circle_members where circle_id = :cid"; - cmd.Parameters.AddWithValue ("cid", id); - cmd.Prepare (); - List members = new List (); - using (NpgsqlDataReader dr = cmd.ExecuteReader ()) { - while (dr.Read ()) - members.Add (dr.GetString (0)); - dr.Close (); - circ.Members = members.ToArray (); - } + using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) { + if (rdr.Read ()) { + circ = new CircleBase (); + circ.Id = id; + circ.Owner = rdr.GetString (1); + circ.Title = rdr.GetString (0); + } } } cnx.Close (); @@ -159,6 +238,7 @@ namespace WorkFlowProvider return circ; } + /// /// Add the specified owner, title and users. /// @@ -175,16 +255,16 @@ namespace WorkFlowProvider cmd.Parameters.AddWithValue ("wnr", owner); cmd.Parameters.AddWithValue ("tit", title); cmd.Parameters.AddWithValue ("app", applicationName); - id = (long) cmd.ExecuteScalar (); + id = (long)cmd.ExecuteScalar (); } using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "insert into circle_members (circle_id,member) values (@cid,@mbr)"; cmd.Parameters.AddWithValue ("cid", id); cmd.Parameters.Add ("mbr", NpgsqlDbType.Varchar); cmd.Prepare (); - if (users!=null) + if (users != null) foreach (string user in users) { - cmd.Parameters[1].Value = user; + cmd.Parameters [1].Value = user; cmd.ExecuteNonQuery (); } } @@ -202,7 +282,7 @@ namespace WorkFlowProvider using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "delete from circle where _id = @cid"; - cmd.Parameters.AddWithValue("cid",id); + cmd.Parameters.AddWithValue ("cid", id); cnx.Open (); cmd.ExecuteNonQuery (); cnx.Close (); @@ -213,9 +293,9 @@ namespace WorkFlowProvider /// List user's circles. /// /// User. - public override IEnumerable List (string user) + public override IEnumerable List (string user) { - List cc = new List (); + List cc = new List (); using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "select _id, title from circle where owner = :wnr"; @@ -224,39 +304,18 @@ namespace WorkFlowProvider cmd.Prepare (); using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) { if (rdr.HasRows) { - while (rdr.Read ()) { - string title = null; - int ottl = rdr.GetOrdinal ("title"); - if (!rdr.IsDBNull (ottl)) - title = rdr.GetString (ottl); - long id = (long)rdr.GetInt64 ( - rdr.GetOrdinal ("_id")); - cc.Add (new Circle { Id = id, Title = title }); + CircleBase cb = new CircleBase (); + cb.Id = rdr.GetInt64 (0); + cb.Title = rdr.GetString (1); + cb.Owner = user; + cc.Add (cb); } } rdr.Close (); } } - // select members - using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "select member from circle_members where circle_id = :cid"; - cmd.Parameters.Add("cid",NpgsqlDbType.Bigint); - cmd.Prepare (); - foreach (Circle c in cc) { - cmd.Parameters ["cid"].Value = c.Id; - using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) { - if (rdr.HasRows) { - var res = new List (); - while (rdr.Read ()) { - res.Add (rdr.GetString (0)); - } - c.Members = res.ToArray (); - } - rdr.Close (); - } - } - } + cnx.Close (); } return cc; @@ -266,6 +325,7 @@ namespace WorkFlowProvider string connectionString = null; string applicationName = null; + /// /// Initialize this object using the specified name and config. /// @@ -273,11 +333,11 @@ namespace WorkFlowProvider /// Config. public override void Initialize (string name, NameValueCollection config) { - if ( string.IsNullOrWhiteSpace(config ["connectionStringName"])) + if (string.IsNullOrWhiteSpace (config ["connectionStringName"])) throw new ConfigurationErrorsException ("No name for Npgsql connection string found"); connectionString = ConfigurationManager.ConnectionStrings [config ["connectionStringName"]].ConnectionString; - applicationName = config["applicationName"] ?? "/"; + applicationName = config ["applicationName"] ?? "/"; } } diff --git a/WebControls/ChangeLog b/WebControls/ChangeLog index 3941f85b..71d9d245 100644 --- a/WebControls/ChangeLog +++ b/WebControls/ChangeLog @@ -1,3 +1,9 @@ +2015-09-10 Paul Schneider + + * InputCircle.cs: using the new CircleBase class + + * ResultPages.cs: Using a new "None" attribute + 2015-08-22 Paul Schneider * InputCircle.cs: this class is about to be removed diff --git a/WebControls/InputCircle.cs b/WebControls/InputCircle.cs index 82767fa5..709f7b27 100644 --- a/WebControls/InputCircle.cs +++ b/WebControls/InputCircle.cs @@ -29,6 +29,7 @@ using System.Web.Security; using System.Collections; using System.Collections.Generic; using System.Web.Mvc; +using System.Linq; namespace Yavsc.WebControls { @@ -154,15 +155,15 @@ namespace Yavsc.WebControls } var u = Membership.GetUser (); if (u != null) { - foreach (var ci in CircleManager.DefaultProvider.List(u.UserName)) { - foreach (SelectListItem sli in Value) - if (sli.Value == ci.Id.ToString()) { + var circles = CircleManager.DefaultProvider.List (u.UserName); + foreach (SelectListItem sli in Value) { + if (circles.Any( x=> x.Title == sli.Text)) { writer.AddAttribute ("selected", null); break; } - writer.AddAttribute ("value", ci.Id.ToString() ); + writer.AddAttribute ("value", sli.Value ); writer.RenderBeginTag ("option"); - writer.Write (ci.Title); + writer.Write (sli.Text); writer.RenderEndTag (); } } diff --git a/WebControls/ResultPages.cs b/WebControls/ResultPages.cs index bbf1d893..ed1d3a3d 100644 --- a/WebControls/ResultPages.cs +++ b/WebControls/ResultPages.cs @@ -26,6 +26,7 @@ namespace Yavsc.WebControls /// public ResultPages () { + } @@ -96,6 +97,18 @@ namespace Yavsc.WebControls } } + [Bindable (true)] + [DefaultValue("none")] + public string None { + get { + + string s = (string) ViewState["None"]; + return (s == null) ? String.Empty : s; + } + set { + ViewState["None"] = value; + } + } /// /// Gets or sets the current page. @@ -134,14 +147,11 @@ namespace Yavsc.WebControls writer.Write (" "); } } - writer.Write ("("); if (ResultCount == 0) { - writer.Write ("Pas de resultat"); - } else { - writer.Write (ResultCount.ToString () + " resultat"); - if (ResultCount>1) writer.Write("s"); + writer.Write ("("); + writer.Write (None); + writer.Write (")"); } - writer.Write (")"); } } diff --git a/web/ApiControllers/CircleController.cs b/web/ApiControllers/CircleController.cs index 18490ad8..da7f7092 100644 --- a/web/ApiControllers/CircleController.cs +++ b/web/ApiControllers/CircleController.cs @@ -58,7 +58,7 @@ namespace Yavsc.ApiControllers public void Add(long id, string username) { checkIsOwner (CircleManager.DefaultProvider.Get (id)); - CircleManager.DefaultProvider.Add (id, username); + CircleManager.DefaultProvider.AddMember (id, username); } @@ -70,7 +70,7 @@ namespace Yavsc.ApiControllers AcceptVerbs ("GET")] public void Delete(long id) { - checkIsOwner (CircleManager.DefaultProvider.Get(id)); + checkIsOwner (CircleManager.DefaultProvider.Get (id)); CircleManager.DefaultProvider.Delete (id); } @@ -88,7 +88,7 @@ namespace Yavsc.ApiControllers CircleManager.DefaultProvider.RemoveMembership (id,username); } - private void checkIsOwner(Circle c) + private void checkIsOwner(CircleBase c) { string user = Membership.GetUser ().UserName; if (c.Owner != user) @@ -103,7 +103,7 @@ namespace Yavsc.ApiControllers AcceptVerbs ("GET")] public Circle Get(long id) { - var c = CircleManager.DefaultProvider.Get (id); + var c = CircleManager.DefaultProvider.GetMembers (id); checkIsOwner (c); return c; } @@ -113,11 +113,26 @@ namespace Yavsc.ApiControllers /// [Authorize, AcceptVerbs ("GET")] - public IEnumerable List() + public IEnumerable List() { string user = Membership.GetUser ().UserName; return CircleManager.DefaultProvider.List (user); } + + /// + /// List the circles + /// + [Authorize, + AcceptVerbs ("POST")] + public void Update(CircleBase circle) + { + string user = Membership.GetUser ().UserName; + CircleBase current = CircleManager.DefaultProvider.Get (circle.Id); + if (current.Owner != user) + throw new AuthorizationDenied ("Your not owner of circle at id "+circle.Id); + CircleManager.DefaultProvider.UpdateCircle (circle); + } + } } diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index 0aaba7b5..7fef66a1 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -29,7 +29,6 @@ main { fieldset { background-color: rgba(32,16,16,0.8); border-radius:5px; border: solid 1px #000060; - float:left; } video,img { @@ -69,27 +68,30 @@ footer { border-radius:5px; margin:.5em; padding: .5em; - float:left; } -.bsh { float: right; } -#login { +#appmenu { margin: .5em; padding: .5em; border-radius:10px; + color: #ff8; background-color: rgba(32,16,16,.6); - position: fixed; - top:0; - right:0; - justify-content: space-around; - text-align: center; - max-width:40%; - font-size:75%; } -#login img { max-height:5em; max-width:5em; } +#appmenu img { max-height:2em; max-width:2em; } + +.hint { + display: inline; + font-style: italic; +} +.hint::before { +content: "("; +} +.hint::after { +content: ")"; +} header { background-color:rgba(16,16,0,0.8); top:0; @@ -221,7 +223,10 @@ a.actionlink img { top:4px; } border-radius:25px; font-size: smaller; } +.menuitem { + display: block; +} .onhover { display:none; position: absolute; @@ -241,7 +246,7 @@ a.actionlink img { top:4px; } @media print { body {background-color:white;color:black;} - header,footer,.postcomment,.actionlink,.metablog,#login + header,footer,.postcomment,.actionlink,.metablog,#appmenu { display:none;} } @@ -250,11 +255,24 @@ a.actionlink img { top:4px; } .bsh { display: none; } .c3 { display:initial; } .c3-alt { display:none; } + + + #appmenu {position: fixed; + top:0; + right:0;} } @media all and (max-width: 640px) { - .bshpanel { cursor:zoom-in; } +#appmenu {position:relative;} +.menuitem { + display: inline; +} +.menuitem:not(:last-child):after { + content:' |'; +} +.bshpanel { cursor:zoom-in; } footer { + clear:both; font-size: x-small; } .c2 { display:initial; } diff --git a/web/ChangeLog b/web/ChangeLog index 20d1de39..81ea81e5 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,44 @@ +2015-09-10 Paul Schneider + + * yavsc.js: + * yavsc.circles.js: js refactoring + + * Credits.aspx: A credit about to add + + * CircleController.cs: refactoring : drops the NewCircle class + The `List` method now resterns collection of circlebase + + * style.css: * a new `dirty` css class, could be used to tag + data to validate ala ajax + * removed quite all of the `float` usages + + * AccountController.cs: xml doc + + * BlogsController.cs: Avatar method moved to the Account + controller + + * YavscHelpers.cs: An avatar url + + * App.master: Login div moved up + + * Circles.aspx: a new `private` filed in the `Circle` object, + in order to keep circle names from being published as user's + information, + should be true by default + + * Profile.aspx: removed the tables + + * Index.aspx: Un message plus explicite + + * Web.config: nothing to view + + * Web.csproj: * new page : Credit + * new script: yavsc.circle.js + + + * instdbws.sql: circles are uniques for a given user against a + given app + 2015-08-22 Paul Schneider * yavsc.js: factorize some javascript diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index e2876f3d..429ca3a6 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -14,6 +14,8 @@ using System.Web.Mvc; using Yavsc.Model.Circles; using System.Collections.Specialized; using System.Text; +using System.Net; +using System.Configuration; namespace Yavsc.Controllers { @@ -23,8 +25,40 @@ namespace Yavsc.Controllers public class AccountController : Controller { - string avatarDir = "~/avatars"; + string avatarDir = "~/avatars"; + string defaultAvatar; + string defaultAvatarMimetype; + + /// + /// Avatar the specified user. + /// + /// User. + [AcceptVerbs (HttpVerbs.Get)] + public ActionResult Avatar (string user) + { + ProfileBase pr = ProfileBase.Create (user); + string avpath = (string ) 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); + } + + WebRequest wr = WebRequest.Create (avpath); + FileContentResult res; + using (WebResponse resp = wr.GetResponse ()) { + using (Stream str = resp.GetResponseStream ()) { + byte[] content = new byte[str.Length]; + str.Read (content, 0, (int)str.Length); + res = File (content, resp.ContentType); + wr.Abort (); + return res; + } + } + } /// /// Gets or sets the avatar dir. /// This value is past to Server.MapPath, @@ -69,7 +103,17 @@ namespace Yavsc.Controllers ViewData ["returnUrl"] = returnUrl; return View (model); } - + /// + /// Initializes a new instance of the class. + /// + private void GetAvatarConfig () + { + string[] defaultAvatarSpec = ConfigurationManager.AppSettings.Get ("DefaultAvatar").Split (';'); + if (defaultAvatarSpec.Length != 2) + throw new ConfigurationErrorsException ("the DefaultAvatar spec should be found as ; "); + defaultAvatar = defaultAvatarSpec [0]; + defaultAvatarMimetype = defaultAvatarSpec [1]; + } /// /// Login the specified returnUrl. diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs index c09aad1a..711889d8 100644 --- a/web/Controllers/BlogsController.cs +++ b/web/Controllers/BlogsController.cs @@ -27,7 +27,6 @@ namespace Yavsc.Controllers /// public class BlogsController : Controller { - string defaultAvatarMimetype; private string sitename = WebConfigurationManager.AppSettings ["Name"]; string avatarDir = "~/avatars"; @@ -41,17 +40,7 @@ namespace Yavsc.Controllers set { avatarDir = value; } } - /// - /// Initializes a new instance of the class. - /// - public BlogsController () - { - string[] defaultAvatarSpec = ConfigurationManager.AppSettings.Get ("DefaultAvatar").Split (';'); - if (defaultAvatarSpec.Length != 2) - throw new ConfigurationErrorsException ("the DefaultAvatar spec should be found as ; "); - defaultAvatar = defaultAvatarSpec [0]; - defaultAvatarMimetype = defaultAvatarSpec [1]; - } + /// /// Index the specified user, title, pageIndex and pageSize. @@ -256,7 +245,7 @@ namespace Yavsc.Controllers ViewData ["UserName"] = un; ViewData ["AllowedCircles"] = CircleManager.DefaultProvider.List (Membership.GetUser ().UserName).Select (x => new SelectListItem { Value = x.Id.ToString(), - Text = YavscHelpers.FormatCircle(x).ToHtmlString() + Text = x.Title }); return View ("Edit", new BlogEntry { Title = title }); @@ -325,36 +314,7 @@ namespace Yavsc.Controllers return GetPost (model.PostId); } - string defaultAvatar; - /// - /// Avatar the specified user. - /// - /// User. - [AcceptVerbs (HttpVerbs.Get)] - public ActionResult Avatar (string user) - { - ProfileBase pr = ProfileBase.Create (user); - string avpath = (string)pr.GetPropertyValue ("avatar"); - if (avpath == null) { - FileInfo fia = new FileInfo (Server.MapPath (defaultAvatar)); - return File (fia.OpenRead (), defaultAvatarMimetype); - } - if (avpath.StartsWith ("~/")) { - - } - WebRequest wr = WebRequest.Create (avpath); - FileContentResult res; - using (WebResponse resp = wr.GetResponse ()) { - using (Stream str = resp.GetResponseStream ()) { - byte[] content = new byte[str.Length]; - str.Read (content, 0, (int)str.Length); - res = File (content, resp.ContentType); - wr.Abort (); - return res; - } - } - } /// /// Remove the specified blog entry, by its author and title, diff --git a/web/Helpers/YavscHelpers.cs b/web/Helpers/YavscHelpers.cs index b975bc5e..faa356ff 100644 --- a/web/Helpers/YavscHelpers.cs +++ b/web/Helpers/YavscHelpers.cs @@ -13,6 +13,7 @@ using System.Web.Mvc; using Yavsc.Model.Circles; using System.Web.UI; using System.Linq.Expressions; +using System.Web.Profile; namespace Yavsc.Helpers { @@ -162,6 +163,14 @@ namespace Yavsc.Helpers foreach (MembershipUser u in users) YavscHelpers.SendActivationMessage (u); } + + public static string AvatarUrl (this HtmlHelper helper, string username) { + ProfileBase pr = ProfileBase.Create (username); + string avpath = (string ) pr.GetPropertyValue("avatar") ; + if (avpath != null) + return helper.Encode (avpath); + return "/avatars/" + helper.Encode(username)+".png"; + } } } diff --git a/web/Models/App.master b/web/Models/App.master index e9f130c3..4ee6b45f 100644 --- a/web/Models/App.master +++ b/web/Models/App.master @@ -12,6 +12,9 @@ ViewState["orgtitle"] = Html.Translate(Page.Title); + @@ -32,28 +35,39 @@ ViewState["orgtitle"] = Html.Translate(Page.Title); %>
<%= Html.Encode(ViewData["Message"]) %>
<% } %> + +
+<% if (Membership.GetUser()==null) { %> + +<% } else { %> + + + + + +
-
- "> - <%=Html.Encode(YavscHelpers.SiteName) %>
- Page d'accueil
-<% if (Membership.GetUser()==null) { %> -
<%= Html.ActionLink("Authentification", "Login", "Account", new { returnUrl=Request.Url.PathAndQuery },null) %> - Pourquoi s'authentifier?

-<% } else { %> - Votre Blog
- - <%= Html.ActionLink(HttpContext.Current.User.Identity.Name, "Profile", "Account", new { id = HttpContext.Current.User.Identity.Name }, null) %> - Édition de votre profile
- Poster - Édition d'un nouveau billet
- <%= Html.ActionLink( "Deconnexion", "Logout", "Account", new { returnUrl=Request.Url.PathAndQuery }, null) %> -<% } %>
+