* BlogsController.cs: cleans unused code

and drops the server side "Preview" notion, made obsolete by client side
  MarkdownDeep js

* Edit.aspx: no more server side preview action

* YavscModel.csproj: no more server side preview action

* BlogEditEntryModel.cs: made osolete by MarkDown js

* BlogEditCommentModel.cs: made osolete by MarkDown js
vnext
Paul Schneider 9 years ago
parent 282b750d53
commit a7f5f399ed
7 changed files with 28 additions and 90 deletions

@ -1,3 +1,11 @@
2015-06-09 Paul Schneider <paul@pschneider.fr>
* BlogsController.cs: - cleans unused code
- drops the server side "Preview" notion, made obsolete by
client side MarkdownDeep js
* Edit.aspx: no more server side preview action
2015-06-09 Paul Schneider <paul@pschneider.fr>
* CircleController.cs: adds a Circle controller

@ -190,7 +190,6 @@ namespace Yavsc.Controllers
return UserPost (BlogManager.GetPost (postid));
}
}
string prevstr = LocalizedText.Preview;
return UserPost (BlogManager.GetPost (user, title));
}
/// <summary>
@ -209,7 +208,7 @@ namespace Yavsc.Controllers
if (String.IsNullOrEmpty (title))
title = "";
ViewData ["UserName"] = un;
return View ("Edit", new BlogEditEntryModel { Title = title });
return View ("Edit", new BlogEntry { Title = title });
}
/// <summary>
/// Validates the post.
@ -218,16 +217,14 @@ namespace Yavsc.Controllers
/// <param name="model">Model.</param>
[Authorize,
ValidateInput(false)]
public ActionResult ValidatePost (BlogEditEntryModel model)
public ActionResult ValidatePost (BlogEntry model)
{
string username = Membership.GetUser ().UserName;
ViewData ["SiteName"] = sitename;
ViewData ["BlogUser"] = username;
if (ModelState.IsValid) {
if (!model.Preview) {
BlogManager.Post (username, model.Title, model.Content, model.Visible);
return UserPost (username, model.Title);
}
}
return View ("Post", model);
}
@ -238,18 +235,16 @@ namespace Yavsc.Controllers
/// <param name="model">Model.</param>
[Authorize,
ValidateInput(false)]
public ActionResult ValidateEdit (BlogEditEntryModel model)
public ActionResult ValidateEdit (BlogEntry model)
{
ViewData ["SiteName"] = sitename;
ViewData ["BlogUser"] = Membership.GetUser ().UserName;
if (ModelState.IsValid) {
if (!model.Preview) {
if (model.Id != 0)
BlogManager.UpdatePost (model.Id, model.Title, model.Content, model.Visible);
else
BlogManager.Post (model.UserName, model.Title, model.Content, model.Visible);
return UserPost(model.UserName, model.Title);
}
}
return View ("Edit", model);
}
@ -259,7 +254,7 @@ namespace Yavsc.Controllers
/// <param name="model">Model.</param>
[Authorize,
ValidateInput(false)]
public ActionResult Edit (BlogEditEntryModel model)
public ActionResult Edit (BlogEntry model)
{
if (model != null) {
string user = Membership.GetUser ().UserName;
@ -275,7 +270,9 @@ namespace Yavsc.Controllers
if (e.UserName != user) {
return View ("TitleNotFound");
}
model = new BlogEditEntryModel(e);
model = e;
ModelState.Clear ();
TryValidateModel (model);
}
}
return View (model);
@ -286,14 +283,12 @@ namespace Yavsc.Controllers
/// </summary>
/// <param name="model">Model.</param>
[Authorize]
public ActionResult Comment (BlogEditCommentModel model) {
public ActionResult Comment (Comment model) {
string username = Membership.GetUser ().UserName;
ViewData ["SiteName"] = sitename;
if (ModelState.IsValid) {
if (!model.Preview) {
BlogManager.Comment(username, model.PostId, model.CommentText, model.Visible);
return UserPost (model.PostId);
}
}
return UserPost (model.PostId);
}

@ -1,4 +1,4 @@
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEditEntryModel>" MasterPageFile="~/Models/App.master" %>
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntry>" MasterPageFile="~/Models/App.master" %>
<asp:Content ContentPlaceHolderID="head" ID="HeadContent1" runat="server">
<link rel="stylesheet" href="<%=Url.Content("~/Theme/mdd_styles.css")%>">
<script type="text/javascript" src="<%=Url.Content("~/Scripts/MarkdownDeepLib.min.js")%>">
@ -8,9 +8,7 @@
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<% if (Model != null ) if (Model.Content != null ) { %>
<%= Html.ActionLink(Model.Title,"UserPost",new{user=Model.UserName,title=Model.Title}) %>
<div class="blogpost">
<%= Html.Markdown(Model.Content) %>
</div>
<% } %>
<%= Html.ValidationSummary("Edition du billet") %>
@ -23,17 +21,12 @@
<%= Html.LabelFor(model => model.Content) %>:<br/>
<div class="mdd_toolbar"></div>
<%= Html.TextArea( "Content" , new { @class="mdd_editor"}) %>
<div class="mdd_resizer"></div>
<div class="mdd_preview"></div>
<%= Html.ValidationMessage("Content", "*") %>
<br/>
<%= Html.CheckBox( "Visible" ) %>
<%= Html.LabelFor(model => model.Visible) %>
<%= Html.ValidationMessage("Visible", "*") %>
<br/>
<%= Html.CheckBox( "Preview" ) %>
<%= Html.LabelFor(model => model.Preview) %>
<%= Html.ValidationMessage("Preview", "*") %>
<%= Html.Hidden("Id") %>
<%= Html.Hidden("UserName") %>
@ -58,4 +51,7 @@
</div>
</asp:Content>
<asp:Content ContentPlaceHolderID="MASContent" ID="masContent1" runat="server">
<div class="mdd_preview"></div>
</asp:Content>

@ -1,22 +0,0 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Model.Blogs
{
/// <summary>
/// Blog edit comment model.
/// </summary>
public class BlogEditCommentModel:Comment
{
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogEditCommentModel"/> is preview.
/// </summary>
/// <value><c>true</c> if preview; otherwise, <c>false</c>.</value>
[DisplayName("Prévisualiser")]
[Required]
public bool Preview { get; set; }
}
}

@ -1,43 +0,0 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Model.Blogs
{
/// <summary>
/// Blog edit entry model.
/// </summary>
public class BlogEditEntryModel:BlogEntry
{
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogEditEntryModel"/> is preview.
/// </summary>
/// <value><c>true</c> if preview; otherwise, <c>false</c>.</value>
[DisplayName("Prévisualiser")]
[Required]
public bool Preview { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.Blogs.BlogEditEntryModel"/> class.
/// </summary>
public BlogEditEntryModel ()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.Blogs.BlogEditEntryModel"/> class.
/// </summary>
/// <param name="be">Be.</param>
public BlogEditEntryModel(BlogEntry be) {
this.Preview = true;
this.Content = be.Content;
this.Title = be.Title;
this.Posted = be.Posted;
this.Modified = be.Modified;
this.Visible = be.Visible;
this.UserName = be.UserName;
this.Id = be.Id;
}
}
}

@ -0,0 +1,6 @@
2015-06-09 Paul Schneider <paul@pschneider.fr>
* YavscModel.csproj:
* BlogEditEntryModel.cs:
* BlogEditCommentModel.cs:

@ -49,11 +49,9 @@
<Compile Include="RolesAndMemebers\NewAdminModel.cs" />
<Compile Include="RolesAndMemebers\NewRoleModel.cs" />
<Compile Include="RolesAndMemebers\RegisterViewModel.cs" />
<Compile Include="Blogs\BlogEditEntryModel.cs" />
<Compile Include="Admin\RestoreQuery.cs" />
<Compile Include="Admin\DataAccess.cs" />
<Compile Include="RolesAndMemebers\Profile.cs" />
<Compile Include="Blogs\BlogEditCommentModel.cs" />
<Compile Include="FileSystem\FileInfoCollection.cs" />
<Compile Include="WorkFlow\Writting.cs" />
<Compile Include="WorkFlow\Estimate.cs" />

Loading…