diff --git a/web/ApiControllers/Calendar/CalendarController.cs b/web/ApiControllers/Calendar/CalendarController.cs
index 9cf2eacd..2ad7eed2 100644
--- a/web/ApiControllers/Calendar/CalendarController.cs
+++ b/web/ApiControllers/Calendar/CalendarController.cs
@@ -28,6 +28,7 @@ using Yavsc.Model;
using System.Web.Security;
using System.Web.Profile;
using System.Web.Http.ModelBinding;
+using Yavsc.Model.Google;
namespace Yavsc.ApiControllers.Calendar
{
@@ -133,155 +134,10 @@ namespace Yavsc.ApiControllers.Calendar
throw new NotImplementedException();
}
- ///
- /// Notification.
- ///
- public class Notification {
- ///
- /// The title.
- ///
- public string title;
- ///
- /// The body.
- ///
- public string body;
- ///
- /// The icon.
- ///
- public string icon;
- ///
- /// The sound.
- ///
- public string sound;
- ///
- /// The tag.
- ///
- public string tag;
- ///
- /// The color.
- ///
- public string color;
- ///
- /// The click action.
- ///
- public string click_action;
- }
- // https://gcm-http.googleapis.com/gcm/send
- ///
- /// Message with payload.
- ///
- public class MessageWithPayload {
- ///
- /// To.
- ///
- public string to;
- ///
- /// The registration identifiers.
- ///
- public string [] registration_ids;
- ///
- /// The data.
- ///
- public T[] data ;
- ///
- /// The notification.
- ///
- public Notification notification;
- ///
- /// The collapse key.
- ///
- public string collapse_key; // in order to collapse ...
- ///
- /// The priority.
- ///
- public int priority; // between 0 and 10, 10 is the lowest!
- ///
- /// The content available.
- ///
- public bool content_available;
- ///
- /// The delay while idle.
- ///
- public bool delay_while_idle;
- ///
- /// The time to live.
- ///
- public int time_to_live; // seconds
- ///
- /// The name of the restricted package.
- ///
- public string restricted_package_name;
- ///
- /// The dry run.
- ///
- public bool dry_run;
- ///
- /// Validate the specified modelState.
- ///
- /// Model state.
- public void Validate(ModelStateDictionary modelState) {
- if (to==null && registration_ids == null) {
- modelState.AddModelError ("to", "One of \"to\" or \"registration_ids\" parameters must be specified");
- modelState.AddModelError ("registration_ids", "*");
- }
- if (notification == null && data == null) {
- modelState.AddModelError ("notification", "At least one of \"notification\" or \"data\" parameters must be specified");
- modelState.AddModelError ("data", "*");
- }
- if (notification != null) {
- if (notification.icon == null)
- modelState.AddModelError ("notification.icon", "please, specify an icon resoure name");
- if (notification.title == null)
- modelState.AddModelError ("notification.title", "please, specify a title");
- }
- }
- }
- ///
- /// Message with payload response.
- ///
- public class MessageWithPayloadResponse {
- ///
- /// The multicast identifier.
- ///
- public int multicast_id;
- ///
- /// The success count.
- ///
- public int success;
- ///
- /// The failure count.
- ///
- public int failure;
- ///
- /// The canonical identifiers... ?!?
- ///
- public int canonical_ids;
- ///
- /// Detailled result.
- ///
- public class Result {
- ///
- /// The message identifier.
- ///
- public string message_id;
- ///
- /// The registration identifier.
- ///
- public string registration_id;
- ///
- /// The error.
- ///
- public string error;
- }
- ///
- /// The results.
- ///
- public Result [] results;
- }
///
/// GCM register model.
diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs
index 43d6f12a..e57f1c21 100644
--- a/web/Controllers/BlogsController.cs
+++ b/web/Controllers/BlogsController.cs
@@ -199,22 +199,26 @@ namespace Yavsc.Controllers
///
/// User.
/// Title.
- [Authorize]
+ [Authorize,
+ ValidateInput(false)]
public ActionResult Post (string user, string title)
{
ViewData ["SiteName"] = sitename;
string un = Membership.GetUser ().UserName;
if (String.IsNullOrEmpty (user))
user = un;
+ if (String.IsNullOrEmpty (title))
+ title = "";
ViewData ["UserName"] = un;
- return View (new BlogEditEntryModel { Title = title });
+ return View ("Edit", new BlogEditEntryModel { Title = title });
}
///
/// Validates the post.
///
/// The post.
/// Model.
- [Authorize]
+ [Authorize,
+ ValidateInput(false)]
public ActionResult ValidatePost (BlogEditEntryModel model)
{
string username = Membership.GetUser ().UserName;
@@ -233,15 +237,19 @@ namespace Yavsc.Controllers
///
/// The edit.
/// Model.
- [Authorize]
+ [Authorize,
+ ValidateInput(false)]
public ActionResult ValidateEdit (BlogEditEntryModel model)
{
ViewData ["SiteName"] = sitename;
ViewData ["BlogUser"] = Membership.GetUser ().UserName;
if (ModelState.IsValid) {
if (!model.Preview) {
- BlogManager.UpdatePost (model.Id, model.Title, model.Content, model.Visible);
- return UserPost (model);
+ 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);
@@ -250,7 +258,8 @@ namespace Yavsc.Controllers
/// Edit the specified model.
///
/// Model.
- [Authorize]
+ [Authorize,
+ ValidateInput(false)]
public ActionResult Edit (BlogEditEntryModel model)
{
if (model != null) {
@@ -261,16 +270,13 @@ namespace Yavsc.Controllers
ViewData ["UserName"] = user;
if (model.UserName == null) {
model.UserName = user;
- BlogEntry e = BlogManager.GetPost (model.UserName, model.Title);
- if (e == null) {
+ }
+ BlogEntry e = BlogManager.GetPost (model.UserName, model.Title);
+ if (e != null) {
+ if (e.UserName != user) {
return View ("TitleNotFound");
- } else {
- model = new BlogEditEntryModel (e);
- ModelState.Clear ();
- this.TryValidateModel (model);
}
- } else if (model.UserName != user) {
- return View ("TitleNotFound");
+ model = new BlogEditEntryModel(e);
}
}
return View (model);
diff --git a/web/Helpers/MarkdownHelper.cs b/web/Helpers/MarkdownHelper.cs
new file mode 100644
index 00000000..e0839436
--- /dev/null
+++ b/web/Helpers/MarkdownHelper.cs
@@ -0,0 +1,39 @@
+using System.Web;
+using System.Web.Mvc;
+using MarkdownDeep;
+
+namespace Yavsc.Helpers
+{
+ ///
+ /// Helper class for transforming Markdown.
+ ///
+ public static partial class MarkdownHelper
+ {
+ ///
+ /// Transforms a string of Markdown into HTML.
+ ///
+ /// The Markdown that should be transformed.
+ /// The HTML representation of the supplied Markdown.
+ public static IHtmlString Markdown(string text)
+ {
+ // Transform the supplied text (Markdown) into HTML.
+ var markdownTransformer = new Markdown();
+ string html = markdownTransformer.Transform(text);
+
+ // Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :(
+ return new MvcHtmlString(html);
+ }
+
+ ///
+ /// Transforms a string of Markdown into HTML.
+ ///
+ /// HtmlHelper - Not used, but required to make this an extension method.
+ /// The Markdown that should be transformed.
+ /// The HTML representation of the supplied Markdown.
+ public static IHtmlString Markdown(this HtmlHelper helper, string text)
+ {
+ // Just call the other one, to avoid having two copies (we don't use the HtmlHelper).
+ return Markdown(text);
+ }
+ }
+}
diff --git a/web/Models/App.master b/web/Models/App.master
index fbb0fb7c..a00e1d9c 100644
--- a/web/Models/App.master
+++ b/web/Models/App.master
@@ -1,18 +1,17 @@
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
-
-<%
+<%
ViewState["orgtitle"] = T.GetString(Page.Title);
Page.Title = ViewState["orgtitle"] + " - " + YavscHelpers.SiteName;
%>
-
-
-
-
+
+
+
+
-
-
+
+
@@ -83,4 +82,4 @@ $( ".bshd" ).on("click",function(e) {
} });
-