Преглед на файлове

Changed blog add/edit posts to use separate pages instead of modal popups. Also added editor helpers.

tags/2.0.3
Teknikode преди 4 години
родител
ревизия
23b6e61efc

+ 18
- 1
Teknik/Areas/Blog/BlogAreaRegistration.cs Целия файл

@@ -26,11 +26,27 @@ namespace Teknik.Areas.Blog
new { controller = "Blog", action = "Blog", username = string.Empty }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog.New", // Route name
new List<string>() { "blog" }, // Subdomains
new List<string>() { config.Host },
"{username}/New", // URL with parameters
new { controller = "Blog", action = "NewPost", username = "" }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog.Edit", // Route name
new List<string>() { "blog" }, // Subdomains
new List<string>() { config.Host },
"{username}/Edit/{id}", // URL with parameters
new { controller = "Blog", action = "EditPost", username = "", id = 0 }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog.Post", // Route name
new List<string>() { "blog" }, // Subdomains
new List<string>() { config.Host },
"{username}/{id}", // URL with parameters
"{username}/p/{id}", // URL with parameters
new { controller = "Blog", action = "Post", username = "", id = 0 }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
@@ -50,6 +66,7 @@ namespace Teknik.Areas.Blog
"~/Areas/Blog/Scripts/Blog.js"));
// Register Style Bundles
BundleTable.Bundles.Add(new StyleBundle("~/Content/blog").Include(
"~/Scripts/mdd_styles.css",
"~/Areas/Blog/Content/Blog.css"));
}
}

+ 143
- 47
Teknik/Areas/Blog/Controllers/BlogController.cs Целия файл

@@ -115,107 +115,203 @@ namespace Teknik.Areas.Blog.Controllers
model.ErrorMessage = "Blog Post does not exist.";
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}

[HttpPost]
[AllowAnonymous]
public ActionResult GetPosts(int blogID, int startPostID, int count)
public ActionResult NewPost(string username)
{
if (string.IsNullOrEmpty(username))
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
BlogViewModel model = new BlogViewModel();
// find the post specified
bool isAuth = User.IsInRole("Admin");
var posts = db.BlogPosts.Where(p => ((p.BlogId == blogID && !p.System) || (p.System && blogID == Config.BlogConfig.ServerBlogId)) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).OrderByDescending(p => p.DatePosted).Skip(startPostID).Take(count).ToList();
List<PostViewModel> postViews = new List<PostViewModel>();
if (posts != null)
var blog = db.Blogs.Where(p => (p.User.Username == username) && (p.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (blog != null)
{
foreach (BlogPost post in posts)
model = new BlogViewModel(blog);
if (blog.User.Username == Constants.SERVERUSER)
{
postViews.Add(new PostViewModel(post));
ViewBag.Title = model.Title + " - " + Config.BlogConfig.Title + " - " + Config.Title;
ViewBag.Description = Config.BlogConfig.Description;
}
else
{
ViewBag.Title = username + "'s Blog - " + Config.Title;
if (!string.IsNullOrEmpty(blog.User.BlogSettings.Title))
{
ViewBag.Title = blog.User.BlogSettings.Title + " - " + ViewBag.Title;
}
ViewBag.Title = model.Title + " - " + ViewBag.Title;
ViewBag.Description = blog.User.BlogSettings.Description;
}
return View("~/Areas/Blog/Views/Blog/NewPost.cshtml", model);
}
return PartialView("~/Areas/Blog/Views/Blog/Posts.cshtml", postViews);
model.Error = true;
model.ErrorMessage = "Blog does not exist.";
return View("~/Areas/Blog/Views/Blog/Blog.cshtml", model);
}

[HttpPost]
[AllowAnonymous]
public ActionResult GetPostTitle(int postID)
public ActionResult EditPost(string username, int id)
{
if (string.IsNullOrEmpty(username))
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
PostViewModel model = new PostViewModel();
// find the post specified
bool isAuth = User.IsInRole("Admin");
BlogPost post = db.BlogPosts.Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
var post = db.BlogPosts.Where(p => (p.Blog.User.Username == username && p.BlogPostId == id) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
return Json(new { result = post.Title });
model = new PostViewModel(post);

if (post.System)
{
ViewBag.Title = model.Title + " - " + Config.BlogConfig.Title + " - " + Config.Title;
ViewBag.Description = Config.BlogConfig.Description;
}
else
{
ViewBag.Title = username + "'s Blog - " + Config.Title;
if (!string.IsNullOrEmpty(post.Blog.User.BlogSettings.Title))
{
ViewBag.Title = post.Blog.User.BlogSettings.Title + " - " + ViewBag.Title;
}
ViewBag.Title = model.Title + " - " + ViewBag.Title;
ViewBag.Description = post.Blog.User.BlogSettings.Description;
}
return View("~/Areas/Blog/Views/Blog/EditPost.cshtml", model);
}
return Json(new { error = "No title found" });
model.Error = true;
model.ErrorMessage = "Blog Post does not exist.";
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}

[HttpPost]
[AllowAnonymous]
public ActionResult GetPostArticle(int postID)
public ActionResult GetPosts(int blogID, int startPostID, int count)
{
bool isAuth = User.IsInRole("Admin");
BlogPost post = db.BlogPosts.Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
var posts = db.BlogPosts.Where(p => ((p.BlogId == blogID && !p.System) || (p.System && blogID == Config.BlogConfig.ServerBlogId)) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).OrderByDescending(p => p.DatePosted).Skip(startPostID).Take(count).ToList();
List<PostViewModel> postViews = new List<PostViewModel>();
if (posts != null)
{
return Json(new { result = post.Article });
foreach (BlogPost post in posts)
{
postViews.Add(new PostViewModel(post));
}
}
return Json(new { error = "No article found" });
return PartialView("~/Areas/Blog/Views/Blog/Posts.cshtml", postViews);
}

[HttpPost]
public ActionResult CreatePost(int blogID, string title, string article)
{
BlogViewModel model = new BlogViewModel();
if (ModelState.IsValid)
{
if (User.IsInRole("Admin") || db.Blogs.Where(b => b.User.Username == User.Identity.Name).FirstOrDefault() != null)
bool isAuth = User.IsInRole("Admin");
var blog = db.Blogs.Where(p => (p.BlogId == blogID) && (p.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (blog != null)
{
bool system = (blogID == Config.BlogConfig.ServerBlogId);
if (system)
if (User.IsInRole("Admin") || db.Blogs.Where(b => b.User.Username == User.Identity.Name).FirstOrDefault() != null)
{
var user = db.Blogs.Where(b => b.User.Username == User.Identity.Name);
if (user != null)
// Validate the fields
if (string.IsNullOrEmpty(title))
{
blogID = user.First().BlogId;
model.Error = true;
model.ErrorMessage = "You must write something for the title";
return View("~/Areas/Blog/Views/Blog/NewPost.cshtml", model);
}
}
BlogPost post = db.BlogPosts.Create();
post.BlogId = blogID;
post.Title = title;
post.Article = article;
post.System = system;
post.DatePosted = DateTime.Now;
post.DatePublished = DateTime.Now;
post.DateEdited = DateTime.Now;

db.BlogPosts.Add(post);
db.SaveChanges();
return Json(new { result = true });
if (string.IsNullOrEmpty(article))
{
model.Error = true;
model.ErrorMessage = "You must write something for the article";
return View("~/Areas/Blog/Views/Blog/NewPost.cshtml", model);
}

bool system = (blogID == Config.BlogConfig.ServerBlogId);
if (system)
{
var user = db.Blogs.Where(b => b.User.Username == User.Identity.Name);
if (user != null)
{
blogID = user.First().BlogId;
}
}
BlogPost post = db.BlogPosts.Create();
post.BlogId = blogID;
post.Title = title;
post.Article = article;
post.System = system;
post.DatePosted = DateTime.Now;
post.DatePublished = DateTime.Now;
post.DateEdited = DateTime.Now;

db.BlogPosts.Add(post);
db.SaveChanges();
return Post(blog.User.Username, post.BlogPostId);
}
model.Error = true;
model.ErrorMessage = "You are not authorized to create a post for this blog";
return View("~/Areas/Blog/Views/Blog/Blog.cshtml", model);
}
return Json(new { error = "You are not authorized to create a post for this blog" });
model.Error = true;
model.ErrorMessage = "Blog does not exist.";
return View("~/Areas/Blog/Views/Blog/Blog.cshtml", model);
}
return Json(new { error = "No post created" });
model.Error = true;
model.ErrorMessage = "No post created";
return View("~/Areas/Blog/Views/Blog/NewPost.cshtml", model);
}

[HttpPost]
public ActionResult EditPost(int postID, string title, string article)
{
PostViewModel model = new PostViewModel();
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
model = new PostViewModel(post);
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
{
// Validate the fields
if (string.IsNullOrEmpty(title))
{
model.Error = true;
model.ErrorMessage = "You must write something for the title";
return View("~/Areas/Blog/Views/Blog/EditPost.cshtml", model);
}

if (string.IsNullOrEmpty(article))
{
model.Error = true;
model.ErrorMessage = "You must write something for the article";
return View("~/Areas/Blog/Views/Blog/EditPost.cshtml", model);
}

post.Title = title;
post.Article = article;
post.DateEdited = DateTime.Now;
db.Entry(post).State = EntityState.Modified;
db.SaveChanges();
return Json(new { result = true });
return Post(post.Blog.User.Username, post.BlogPostId);
}
return Json(new { error = "You are not authorized to edit this post" });
model.Error = true;
model.ErrorMessage = "You are not authorized to edit this post";
return View("~/Areas/Blog/Views/Blog/EditPost.cshtml", model);
}
return Json(new { error = "No post found" });
model.Error = true;
model.ErrorMessage = "Post does not exist.";
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}
return Json(new { error = "Invalid Parameters" });
model.Error = true;
model.ErrorMessage = "Invalid Parameters";
return View("~/Areas/Blog/Views/Blog/EditPost.cshtml", model);
}

[HttpPost]

+ 4
- 68
Teknik/Areas/Blog/Scripts/Blog.js Целия файл

@@ -1,72 +1,8 @@
$(document).ready(function () {
$("#blog_submit").click(function () {
$('#newPost').modal('hide');
blogID = $("#blog_blogid").val();
title = $("#blog_title").val();
post = $("#blog_post").val();
$.ajax({
type: "POST",
url: addPostURL,
data: { blogID: blogID, title: title, article: post },
success: function (html) {
if (html.result) {
window.location.reload();
}
else {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' + html.error + '</div>');
}
}
});
return false;
});

$('#editPost').on('show.bs.modal', function (e) {
$("#edit_blog_post").val("");
postID = $(e.relatedTarget).attr("id");
$("#edit_blog_postid").val(postID);
$.ajax({
type: "POST",
url: getPostTitleURL,
data: { postID: postID },
success: function (html) {
if (html.result) {
$("#edit_blog_title").val(html.result);
}
}
});
$.ajax({
type: "POST",
url: getPostArticleURL,
data: { postID: postID },
success: function (html) {
if (html.result) {
$("#edit_blog_post").val(html.result);
}
}
});
});

$("#edit_submit").click(function () {
$('#editPost').modal('hide');
postID = $("#edit_blog_postid").val();
title = $("#edit_blog_title").val();
post = $("#edit_blog_post").val();
$.ajax({
type: "POST",
url: editPostURL,
data: { postID: postID, title: title, article: post },
success: function (html) {
if (html.result) {
window.location.reload();
}
else {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' + html.error + '</div>');
}
}
});
return false;
$("textarea.mdd_editor").MarkdownDeep({
help_location: helpURL,
disableTabHandling: false,
resizebar: false
});

$("#comment_submit").click(function () {

+ 15
- 0
Teknik/Areas/Blog/ViewModels/BlogViewModel.cs Целия файл

@@ -22,5 +22,20 @@ namespace Teknik.Areas.Blog.ViewModels
public User User { get; set; }

public bool HasPosts { get; set; }

public BlogViewModel()
{

}

public BlogViewModel(Models.Blog blog)
{
BlogId = blog.BlogId;
UserId = blog.UserId;
Title = blog.User.BlogSettings.Title;
Description = blog.User.BlogSettings.Description;
User = blog.User;
HasPosts = false;
}
}
}

+ 1
- 67
Teknik/Areas/Blog/Views/Blog/Blog.cshtml Целия файл

@@ -8,11 +8,7 @@
var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';

var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
var getPostTitleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostTitle" })';
var getPostArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostArticle" })';
var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';
var addPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreatePost" })';
var editPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditPost" })';
var deletePostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeletePost" })';

var getCommentsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetComments" })';
@@ -45,69 +41,7 @@
{
<div class="row">
<div class="col-sm-12 text-center">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newPost">Create Post</button>
</div>
</div>
<div class="modal fade" id="newPost" tabindex="-1" role="dialog" aria-labelledby="newPostLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form" action="##" method="post" id="publishPost">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
<h4 class="modal-title" id="newPostLabel">Create a New Post</h4>
</div>
<div class="modal-body">
<input name="blog_blogid" id="blog_blogid" type="hidden" value="@Model.BlogId" />
<div class="row">
<div class="form-group col-sm-12">
<label for="blog_title"><h4>Title</h4></label>
<input class="form-control" name="blog_title" id="blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="blog_post"><h4>Article</h4></label>
<textarea class="form-control wmd-input" name="blog_post" id="blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="blog_submit">Create</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form" action="##" method="post" id="editPostForm">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
<h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
</div>
<div class="modal-body">
<input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
<div class="row">
<div class="form-group col-sm-12">
<label for="edit_blog_title"><h4>Title</h4></label>
<input class="form-control" name="edit_blog_title" id="edit_blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="edit_blog_post"><h4>Article</h4></label>
<textarea class="form-control" name="edit_blog_post" id="edit_blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit_submit">Save</button>
</div>
</form>
</div>
<a href="@Url.SubRouteUrl("blog", "Blog.New", new { username = Model.User.Username })" role="button" class="btn btn-primary">Create Post</a>
</div>
</div>
}

+ 59
- 0
Teknik/Areas/Blog/Views/Blog/EditPost.cshtml Целия файл

@@ -0,0 +1,59 @@
@model Teknik.Areas.Blog.ViewModels.PostViewModel

@using Teknik.Helpers

<script>
// We need to define the action URLs for the script
var helpURL = '@Url.SubRouteUrl("help", "Help.Markdown")';
</script>

@Styles.Render("~/Content/blog")
@Scripts.Render("~/bundles/blog")

<div class="container">
@if (Model.Error)
{
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<div class="alert alert-danger" role="alert">@Model.ErrorMessage</div>
</div>
</div>
}

<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<h2>Edit Post</h2>
</div>
</div>
<form class="form" action="@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditPost" })" method="post" id="newPost">
<input name="postID" id="postID" type="hidden" value="@Model.PostId" />
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<label for="title"><h4>Title</h4></label>
<input class="form-control" name="title" id="title" placeholder="generic click bait" title="enter a title for your post." type="text" value="@Model.Title" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<label for="article"><h4>Article</h4></label>
<div class="mdd_toolbar"></div>
<textarea class="form-control mdd_editor" name="article" id="article" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10">@Model.Article</textarea>
</div>
</div>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Preview</div>
<div class="panel-body">
<div class="mdd_preview"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<button type="submit" class="btn btn-primary" id="submit">Save</button>
</div>
</div>
</form>
</div>

+ 59
- 0
Teknik/Areas/Blog/Views/Blog/NewPost.cshtml Целия файл

@@ -0,0 +1,59 @@
@model Teknik.Areas.Blog.ViewModels.BlogViewModel

@using Teknik.Helpers

<script>
// We need to define the action URLs for the script
var helpURL = '@Url.SubRouteUrl("help", "Help.Markdown")';
</script>

@Styles.Render("~/Content/blog")
@Scripts.Render("~/bundles/blog")

<div class="container">
@if (Model.Error)
{
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<div class="alert alert-danger" role="alert">@Model.ErrorMessage</div>
</div>
</div>
}

<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<h2>Create a New Post</h2>
</div>
</div>
<form class="form" action="@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreatePost" })" method="post" id="newPost">
<input name="blogID" id="blogID" type="hidden" value="@Model.BlogId" />
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<label for="title"><h4>Title</h4></label>
<input class="form-control" name="title" id="title" placeholder="generic click bait" title="enter a title for your post." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<label for="article"><h4>Article</h4></label>
<div class="mdd_toolbar"></div>
<textarea class="form-control mdd_editor" name="article" id="article" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea>
</div>
</div>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Preview</div>
<div class="panel-body">
<div class="mdd_preview"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-sm-10 col-sm-offset-1">
<button type="submit" class="btn btn-primary" id="submit">Create Post</button>
</div>
</div>
</form>
</div>

+ 1
- 1
Teknik/Areas/Blog/Views/Blog/Post.cshtml Целия файл

@@ -17,7 +17,7 @@
@if (Model.Blog.User.Username == User.Identity.Name || User.IsInRole("Admin"))
{
<br />
<button type="button" class="btn btn-info edit_post" id="@Model.PostId" data-toggle="modal" data-target="#editPost">Edit</button>
<a href="@Url.SubRouteUrl("blog", "Blog.Edit", new { username = Model.Blog.User.Username, id = Model.PostId })" role="button" class="btn btn-primary">Edit</a>
if (Model.Published)
{
<button type="button" class="btn btn-warning unpublish_post" id="@Model.PostId">Unpublish</button>

+ 0
- 40
Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml Целия файл

@@ -8,11 +8,7 @@
var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';

var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
var getPostTitleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostTitle" })';
var getPostArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostArticle" })';
var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';
var addPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreatePost" })';
var editPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditPost" })';
var deletePostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeletePost" })';

var getCommentsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetComments" })';
@@ -28,42 +24,6 @@
<div class="container">
@if (!Model.Error)
{
if (User.IsInRole("Admin") || Model.Blog.User.Username == User.Identity.Name)
{
<div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form" action="##" method="post" id="editPostForm">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
<h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
</div>
<div class="modal-body">
<input name="edit_blog_userid" id="edit_blog_userid" type="hidden" value="@Model.Blog.User.UserId" />
<input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
<div class="row">
<div class="form-group col-sm-12">
<label for="edit_blog_title"><h4>Title</h4></label>
<input class="form-control" name="edit_blog_title" id="edit_blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="edit_blog_post"><h4>Article</h4></label>
<textarea class="form-control" name="edit_blog_post" id="edit_blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="edit_submit">Save</button>
</div>
</form>
</div>
</div>
</div>
}

<ol class="breadcrumb">
<li><a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = (Model.System) ? string.Empty : Model.Blog.User.Username })">@((Model.System) ? Model.Config.BlogConfig.Title : (string.IsNullOrEmpty(Model.Blog.User.BlogSettings.Title) ? string.Format("{0}'s Blog", Model.Blog.User.Username) : Model.Blog.User.BlogSettings.Title))</a></li>
<li class="active"><a href="#">@Model.Title</a></li>

+ 9
- 0
Teknik/Areas/Help/Controllers/HelpController.cs Целия файл

@@ -101,5 +101,14 @@ namespace Teknik.Areas.Help.Controllers
HelpViewModel model = new HelpViewModel();
return View("~/Areas/Help/Views/Help/Upload.cshtml", model);
}

[TrackPageView]
[AllowAnonymous]
public ActionResult Markdown()
{
ViewBag.Title = "Markdown Help - " + Config.Title;
HelpViewModel model = new HelpViewModel();
return View("~/Areas/Help/Views/Help/Markdown.cshtml", model);
}
}
}

+ 8
- 0
Teknik/Areas/Help/HelpAreaRegistration.cs Целия файл

@@ -90,6 +90,14 @@ namespace Teknik.Areas.Help
new { controller = "Help", action = "Upload" }, // Parameter defaults
new[] { typeof(Controllers.HelpController).Namespace }
);
context.MapSubdomainRoute(
"Help.Markdown", // Route name
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"Markdown", // URL with parameters
new { controller = "Help", action = "Markdown" }, // Parameter defaults
new[] { typeof(Controllers.HelpController).Namespace }
);

// Register Style Bundles
BundleTable.Bundles.Add(new StyleBundle("~/Content/help").Include(

+ 2
- 0
Teknik/Areas/Help/Views/Help/Index.cshtml Целия файл

@@ -31,6 +31,8 @@
<dd>The public Mumble server and configuration settings needed.</dd>
<dt><a href="@Url.SubRouteUrl("help", "Help.Upload")">Uploads</a></dt>
<dd>How the Upload service works and special considerations.</dd>
<dt><a href="@Url.SubRouteUrl("help", "Help.Markdown")">Markdown</a></dt>
<dd>Markdown syntax used throughout the site.</dd>
</dl>
</div>
</div>

+ 133
- 0
Teknik/Areas/Help/Views/Help/Markdown.cshtml Целия файл

@@ -0,0 +1,133 @@
@model Teknik.Areas.Help.ViewModels.HelpViewModel

<div class="container">
<div class="row">
<h2>Markdown Formatting</h2>
<p><a href="http://daringfireball.net/projects/markdown/" target="_blank">Markdown</a> turns plain text formatting into fancy HTML formatting.</p>
<h3>Phrase Emphasis</h3>
<pre><code>*italic* **bold**
_italic_ __bold__
</code></pre>
<h3>Links</h3>
<p>Inline:</p>
<pre><code>An [example](http://url.com/ &quot;Title&quot;)
</code></pre>
<p>Reference-style labels (titles are optional):</p>
<pre><code>An [example][id]. Then, anywhere
else in the doc, define the link:
[id]: http://example.com/ &quot;Title&quot;
</code></pre>
<h3>Images</h3>
<p>Inline (titles are optional):</p>
<pre><code>![alt text](/path/img.jpg &quot;Title&quot;)
</code></pre>
<p>Reference-style:</p>
<pre><code>![alt text][id]
[id]: /url/to/img.jpg &quot;Title&quot;
</code></pre>
<h3>Headers</h3>
<p>Setext-style:</p>
<pre><code>Header 1
========
Header 2
--------
</code></pre>
<p>atx-style (closing #'s are optional):</p>
<pre><code># Header 1 #
## Header 2 ##
###### Header 6
</code></pre>
<h3>Lists</h3>
<p>Ordered, without paragraphs:</p>
<pre><code>1. Foo
2. Bar
</code></pre>
<p>Unordered, with paragraphs:</p>
<pre><code>* A list item.
With multiple paragraphs.
* Bar
</code></pre>
<p>You can nest them:</p>
<pre><code>* Abacus
* answer
* Bubbles
1. bunk
2. bupkis
* BELITTLER
3. burper
* Cunning
</code></pre>
<h3>Blockquotes</h3>
<pre><code>&gt; Email-style angle brackets
&gt; are used for blockquotes.
&gt; &gt; And, they can be nested.
&gt; #### Headers in blockquotes
&gt;
&gt; * You can quote a list.
&gt; * Etc.
</code></pre>
<h3>Code Spans</h3>
<pre><code>`&lt;code&gt;` spans are delimited
by backticks.
You can include literal backticks
like `` `this` ``.
</code></pre>
<h3>Preformatted Code Blocks</h3>
<p>Indent every line of a code block by at least 4 spaces or 1 tab.</p>
<pre><code>This is a normal paragraph.
This is a preformatted
code block.
</code></pre>
<h3>Horizontal Rules</h3>
<p>Three or more dashes or asterisks:</p>
<pre><code>---
* * *
- - - -
</code></pre>
<h3>Manual Line Breaks</h3>
<p>End a line with two or more spaces:</p>
<pre><code>Roses are red,
Violets are blue.
</code></pre>
<h2>Extra Mode</h2>
These formatting features are only available when Extra Mode is enabled.

<h3>Markdown In Html</h3>
<p>Enable markdown in HTML block level elements:</p>
<pre><code>&lt;div markdown=&quot;1&quot;&gt;
Markdown **still** works.
&lt;/div&gt;
</code></pre>
<h3>Fenced Code Blocks</h3>
<p>Code blocks delimited by 3 or more tildas:</p>
<pre><code>~~~
This is a preformatted
code block
~~~
</code></pre>
<h3>Header IDs</h3>
<p>Set the id of headings with <code>{#&lt;id&gt;}</code> at end of heading line:</p>
<pre><code>## My Heading {#myheading}
</code></pre>
<h3>Tables</h3>
<pre><code>Fruit |Color
---------|----------
Apples |Red
Pears |Green
Bananas |Yellow</code></pre>
<h3>Definition Lists</h3>
<pre><code>Term 1
: Definition 1
Term 2
: Definition 2</code></pre>
<h3>Footnotes</h3>
<pre><code>Body text with a footnote [^1]
[^1]: Footnote text here
</code></pre>
<h3>Abbreviations</h3>
<pre><code>MDD &lt;- will have title
*[MDD]: MarkdownDeep
</code></pre>
<p>&nbsp;</p>
</div>
</div>

+ 3
- 0
Teknik/Teknik.csproj Целия файл

@@ -559,6 +559,9 @@
<Content Include="Content\bootstrap.css.map" />
<Content Include="Content\bootstrap-theme.min.css.map" />
<Content Include="Content\bootstrap-theme.css.map" />
<Content Include="Areas\Blog\Views\Blog\NewPost.cshtml" />
<Content Include="Areas\Blog\Views\Blog\EditPost.cshtml" />
<Content Include="Areas\Help\Views\Help\Markdown.cshtml" />
<None Include="Properties\PublishProfiles\Teknik Dev.pubxml" />
<None Include="Properties\PublishProfiles\Teknik Production.pubxml" />
<None Include="Scripts\jquery-2.1.4.intellisense.js" />

Loading…
Отказ
Запис