From f2252093c688b8155efab6b978c752aa04ca08e6 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sat, 3 Jul 2010 09:15:31 +0000 Subject: [PATCH] Some basic UBBCodes implemented --- Builder/IISMainHandler/build.txt | 2 +- Builder/IISUploadHandler/build.txt | 2 +- Common/BBCodes/B.cs | 19 +++++++++ Common/BBCodes/Code.cs | 19 +++++++++ Common/BBCodes/FUrl.cs | 25 +++++++++++ Common/BBCodes/I.cs | 19 +++++++++ Common/BBCodes/Image.cs | 23 +++++++++++ Common/BBCodes/S.cs | 19 +++++++++ Common/BBCodes/U.cs | 19 +++++++++ Common/BBCodes/Url.cs | 25 +++++++++++ Common/BBCodes/helpers/BBCode.cs | 35 ++++++++++++++++ Common/BBCodes/helpers/UrlProcessor.cs | 57 ++++++++++++++++++++++++++ Common/Common.csproj | 14 +++++++ Common/UBBParser.cs | 30 +++++++++++++- 14 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 Common/BBCodes/B.cs create mode 100644 Common/BBCodes/Code.cs create mode 100644 Common/BBCodes/FUrl.cs create mode 100644 Common/BBCodes/I.cs create mode 100644 Common/BBCodes/Image.cs create mode 100644 Common/BBCodes/S.cs create mode 100644 Common/BBCodes/U.cs create mode 100644 Common/BBCodes/Url.cs create mode 100644 Common/BBCodes/helpers/BBCode.cs create mode 100644 Common/BBCodes/helpers/UrlProcessor.cs diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 755ab3c..0316458 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -495 \ No newline at end of file +503 \ No newline at end of file diff --git a/Builder/IISUploadHandler/build.txt b/Builder/IISUploadHandler/build.txt index 565f1b0..34578cc 100644 --- a/Builder/IISUploadHandler/build.txt +++ b/Builder/IISUploadHandler/build.txt @@ -1 +1 @@ -231 \ No newline at end of file +239 \ No newline at end of file diff --git a/Common/BBCodes/B.cs b/Common/BBCodes/B.cs new file mode 100644 index 0000000..5197f1c --- /dev/null +++ b/Common/BBCodes/B.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PJonDevelopment.BBCode; + +namespace FLocal.Common.BBCodes { + class B : BBCode { + + public B() + : base("b") { + } + + public override string Format(ITextFormatter formatter) { + return "" + this.GetInnerHTML(formatter) + ""; + } + + } +} diff --git a/Common/BBCodes/Code.cs b/Common/BBCodes/Code.cs new file mode 100644 index 0000000..83ad886 --- /dev/null +++ b/Common/BBCodes/Code.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PJonDevelopment.BBCode; + +namespace FLocal.Common.BBCodes { + class Code : BBCode { + + public Code() + : base("code") { + } + + public override string Format(ITextFormatter formatter) { + return "
" + this.InnerBBCode + ""; + } + + } +} diff --git a/Common/BBCodes/FUrl.cs b/Common/BBCodes/FUrl.cs new file mode 100644 index 0000000..8f82c6c --- /dev/null +++ b/Common/BBCodes/FUrl.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PJonDevelopment.BBCode; + +namespace FLocal.Common.BBCodes { + class FUrl : BBCode { + + public FUrl() + : base("furl") { + } + + public override string Format(ITextFormatter formatter) { + string rawUrl = this.Default; + if(rawUrl == null) { + // throw new ApplicationException(String.Join("; ", (from kvp in this.Attributes select kvp.Key + "=" + kvp.Value).ToArray())); + rawUrl = this.InnerText; + } + Uri uri = new Uri(rawUrl); + return "" + this.GetInnerHTML(formatter) + ""; + } + + } +} diff --git a/Common/BBCodes/I.cs b/Common/BBCodes/I.cs new file mode 100644 index 0000000..2241b5b --- /dev/null +++ b/Common/BBCodes/I.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PJonDevelopment.BBCode; + +namespace FLocal.Common.BBCodes { + class I : BBCode { + + public I() + : base("i") { + } + + public override string Format(ITextFormatter formatter) { + return "" + this.GetInnerHTML(formatter) + ""; + } + + } +} diff --git a/Common/BBCodes/Image.cs b/Common/BBCodes/Image.cs new file mode 100644 index 0000000..fc0562c --- /dev/null +++ b/Common/BBCodes/Image.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using PJonDevelopment.BBCode; + +namespace FLocal.Common.BBCodes { + class Image : BBCode { + + public Image() : base("image") { + } + + public override string Format(ITextFormatter formatter) { + var urlInfo = UrlProcessor.Process(this.InnerText); + if (urlInfo.isLocal && urlInfo.relativeUrl.StartsWith("/user/upload/")) { + return "