Quotes skipping implemented when quoting

main
Inga 🏳‍🌈 15 years ago
parent fd1dc5fadb
commit c9bd19b042
  1. 2
      Builder/IISMainHandler/build.txt
  2. 47
      Common/BBCodes/QuoteSkipper.cs
  3. 1
      Common/Common.csproj
  4. 31
      Common/UBBParser.cs
  5. 5
      IISMainHandler/handlers/response/PMReplyHandler.cs
  6. 2
      IISMainHandler/handlers/response/PMReplyToPostHandler.cs
  7. 2
      IISMainHandler/handlers/response/ReplyHandler.cs
  8. 2
      templates/Full/PMReply.xslt

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJonDevelopment.BBCode;
namespace FLocal.Common.BBCodes {
class QuoteSkipper : BBCode {
public QuoteSkipper() : base("quoteskipper") {
}
public override string Format(ITextFormatter formatter) {
if(this.Name.ToLower() == "q" || this.Name.ToLower() == "quote") {
return "";
} else if(this.Name.ToLower() == "code") {
return "[code]" + this.InnerBBCode + "[/code]";
} else {
var sb = new StringBuilder();
sb.Append("[");
sb.Append(this.Name);
if(this.Default != null && this.Default != "") {
sb.Append("='");
sb.Append(this.Default.Replace("'", "''"));
sb.Append("'");
} else {
foreach(var attribute in this.Attributes) {
sb.Append(" ");
sb.Append(attribute.Key);
sb.Append("='");
sb.Append(attribute.Value.Replace("'", "''"));
sb.Append("'");
}
}
sb.Append("]");
if(this.RequireClosingTag) {
sb.Append(this.GetInnerHTML(formatter));
sb.Append("[/");
sb.Append(this.Name);
sb.Append("]");
}
return sb.ToString();
}
}
}
}

@ -71,6 +71,7 @@
<Compile Include="BBCodes\Lurk.cs" />
<Compile Include="BBCodes\Poll.cs" />
<Compile Include="BBCodes\Quote.cs" />
<Compile Include="BBCodes\QuoteSkipper.cs" />
<Compile Include="BBCodes\RuWiki.cs" />
<Compile Include="BBCodes\S.cs" />
<Compile Include="BBCodes\Spoiler.cs" />

@ -13,6 +13,19 @@ namespace FLocal.Common {
private class BBParserGateway {
private class SimpleFormatter : ITextFormatter {
public static readonly SimpleFormatter instance = new SimpleFormatter();
private SimpleFormatter() {
}
public string Format(string source) {
return source;
}
}
private class TextFormatter : ITextFormatter {
public static readonly TextFormatter instance = new TextFormatter();
@ -92,6 +105,9 @@ namespace FLocal.Common {
private BBCodeParser parser;
private ITextFormatter formatter;
private BBCodeParser quotesParser;
private ITextFormatter simpleFormatter;
private BBParserGateway() {
this.parser = new BBCodeParser();
this.parser.ElementTypes.Add("b", typeof(BBCodes.B), true);
@ -118,6 +134,12 @@ namespace FLocal.Common {
this.parser.ElementTypes.Add("wiki", typeof(BBCodes.Wiki), true);
this.parser.ElementTypes.Add("ruwiki", typeof(BBCodes.RuWiki), true);
this.formatter = TextFormatter.instance;
this.quotesParser = new BBCodeParser();
foreach(var elementType in this.parser.ElementTypes) {
this.quotesParser.ElementTypes.Add(elementType.Key, typeof(BBCodes.QuoteSkipper), elementType.Value.RequireClosingTag);
}
this.simpleFormatter = SimpleFormatter.instance;
}
public string Parse(string input) {
@ -126,6 +148,11 @@ namespace FLocal.Common {
return result;
}
public string ParseQuote(string input) {
string result = this.quotesParser.Parse(input).Format(this.simpleFormatter);
return result;
}
}
public static string UBBToIntermediate(string UBB) {
@ -137,5 +164,9 @@ namespace FLocal.Common {
return shaller;
}
public static string StripQuotes(string UBB) {
return BBParserGateway.instance.ParseQuote(UBB);
}
}
}

@ -20,9 +20,10 @@ namespace FLocal.IISHandler.handlers.response {
override protected IEnumerable<XElement> getSpecificNewMessageData(WebContext context) {
PMMessage message = PMMessage.LoadById(int.Parse(context.requestParts[1]));
string quoted = UBBParser.StripQuotes(message.bodyUBB).Trim();
return new XElement[] {
message.exportToXml(context)
message.exportToXml(context),
new XElement("quoted", quoted),
};
}
}

@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response {
if(quoted != null) quoted = quoted.Trim();
if(quoted == null || quoted == "") {
if(post.revision.HasValue) {
quoted = post.latestRevision.body.Trim();
quoted = UBBParser.StripQuotes(post.latestRevision.body).Trim();
}
}

@ -26,7 +26,7 @@ namespace FLocal.IISHandler.handlers.response {
if(quoted != null) quoted = quoted.Trim();
if(quoted == null || quoted == "") {
if(post.revision.HasValue) {
quoted = post.latestRevision.body.Trim();
quoted = UBBParser.StripQuotes(post.latestRevision.body).Trim();
}
}

@ -53,7 +53,7 @@
<xsl:call-template name="textEditor">
<xsl:with-param name="body">
<xsl:text>[q]</xsl:text>
<xsl:value-of select="message/bodyUBB"/>
<xsl:value-of select="quoted"/>
<xsl:text>[/q]
</xsl:text>
</xsl:with-param>

Loading…
Cancel
Save