bug fixes
* Makefile: my deploy config * NpgsqlMembershipProvider.cs: Fixes a Bug introduced by Npgsql driver upgrade * ResultPages.cs: . * style.css: other colors * BlogsController.cs: code cleaning * GoogleController.cs: refactoring * ErrorHtmlFormatter.cs: MarkdownDeep calls now come from yavscModel * YavscHelpers.cs: xmldoc * Index.aspx: code formatting * UserPosts.aspx: nothing to note * Web.csproj: MarkdownHelper has gone to the yavscModel project * MarkdownHelper.cs: * BlogEntryCollection.cs: refactoring + extract an intro from Markdown for PostInfo* * YavscModel.csproj: MarkdownHelper integration
This commit is contained in:
parent
bdae927f67
commit
ce1689df7b
19 changed files with 193 additions and 129 deletions
|
|
@ -1,82 +0,0 @@
|
|||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using MarkdownDeep;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class for transforming Markdown.
|
||||
/// </summary>
|
||||
public static partial class MarkdownHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Transforms a string of Markdown into HTML.
|
||||
/// </summary>
|
||||
/// <param name="text">The Markdown that should be transformed.</param>
|
||||
/// <returns>The HTML representation of the supplied Markdown.</returns>
|
||||
public static IHtmlString Markdown(string text)
|
||||
{
|
||||
// Transform the supplied text (Markdown) into HTML.
|
||||
var markdownTransformer = new Markdown();
|
||||
markdownTransformer.ExtraMode = true;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a string of Markdown into HTML.
|
||||
/// </summary>
|
||||
/// <param name="helper">HtmlHelper - Not used, but required to make this an extension method.</param>
|
||||
/// <param name="text">The Markdown that should be transformed.</param>
|
||||
/// <param name="urlBaseLocation">The url Base Location.</param>
|
||||
/// <returns>The HTML representation of the supplied Markdown.</returns>
|
||||
public static IHtmlString Markdown(this HtmlHelper helper, string text, string urlBaseLocation="")
|
||||
{
|
||||
// Transform the supplied text (Markdown) into HTML.
|
||||
var markdownTransformer = new Markdown();
|
||||
markdownTransformer.ExtraMode = true;
|
||||
markdownTransformer.UrlBaseLocation = urlBaseLocation;
|
||||
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);
|
||||
}
|
||||
|
||||
public static IHtmlString MarkdownToHtmlIntro(this HtmlHelper helper, out bool truncated, string text, string urlBaseLocation="")
|
||||
{
|
||||
int maxLen = 250;
|
||||
// Transform the supplied text (Markdown) into HTML.
|
||||
var markdownTransformer = new Markdown();
|
||||
markdownTransformer.ExtraMode = true;
|
||||
markdownTransformer.UrlBaseLocation = urlBaseLocation;
|
||||
if (text.Length < maxLen) {
|
||||
truncated = false;
|
||||
return new MvcHtmlString(markdownTransformer.Transform(text));
|
||||
}
|
||||
string intro = text.Remove (maxLen);
|
||||
truncated = true;
|
||||
int inl = intro.LastIndexOf ("\n");
|
||||
if (inl > 20)
|
||||
intro = intro.Remove (inl);
|
||||
intro += " ...";
|
||||
|
||||
string html = markdownTransformer.Transform(intro);
|
||||
// Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :(
|
||||
return new MvcHtmlString(html);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a string of Markdown into HTML.
|
||||
/// </summary>
|
||||
/// <param name="helper">HtmlHelper - Not used, but required to make this an extension method.</param>
|
||||
/// <param name="text">The Markdown that should be transformed.</param>
|
||||
/// <returns>The HTML representation of the supplied Markdown.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -163,13 +163,17 @@ namespace Yavsc.Helpers
|
|||
foreach (MembershipUser u in users)
|
||||
YavscHelpers.SendActivationMessage (u);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avatars the URL.
|
||||
/// </summary>
|
||||
/// <returns>The URL.</returns>
|
||||
/// <param name="helper">Helper.</param>
|
||||
/// <param name="username">Username.</param>
|
||||
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";
|
||||
var a = pr.GetPropertyValue("Avatar") ;
|
||||
if (a == null || a is DBNull) return "/avatars/" + helper.Encode(username)+".png";
|
||||
return helper.Encode ((string)a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue