From c86aa2f318de9f8710cd7e2960531e415fcc1752 Mon Sep 17 00:00:00 2001 From: Dario Solera Date: Wed, 27 Jan 2010 13:01:09 +0000 Subject: [PATCH] Fixed #468: Formatter and ReverseFormatter now process inter-namespace links correctly. --- AssemblyVersion.cs | 4 ++-- Core/Formatter.cs | 3 ++- Core/ReverseFormatter.cs | 2 +- WebApplication/PopupWYSIWYG.aspx.cs | 18 ++++++++++-------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index ef3e5fa..76facc7 100644 --- a/AssemblyVersion.cs +++ b/AssemblyVersion.cs @@ -16,5 +16,5 @@ using System.Reflection; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.1.462")] -[assembly: AssemblyFileVersion("3.0.1.462")] +[assembly: AssemblyVersion("3.0.1.463")] +[assembly: AssemblyFileVersion("3.0.1.463")] diff --git a/Core/Formatter.cs b/Core/Formatter.cs index 11b43c7..800687d 100644 --- a/Core/Formatter.cs +++ b/Core/Formatter.cs @@ -1761,7 +1761,8 @@ namespace ScrewTurn.Wiki { } else { targetUrl += Settings.PageExtension; - targetUrl = Tools.UrlEncode(targetUrl); + // #468: Preserve ++ for ReverseFormatter + targetUrl = (bareBones && explicitNamespace ? "++" : "") + Tools.UrlEncode(targetUrl); } string fullName = ""; diff --git a/Core/ReverseFormatter.cs b/Core/ReverseFormatter.cs index 426061c..cc69923 100644 --- a/Core/ReverseFormatter.cs +++ b/Core/ReverseFormatter.cs @@ -234,7 +234,7 @@ namespace ScrewTurn.Wiki { string insertion = "["; if(match.Groups[2].Value == @"target=""_blank"" ") insertion += "^"; string decoded = UrlDecode(match.Groups[3].Value); - insertion += decoded; + insertion += (decoded.StartsWith(" ") ? "++" : "") + decoded.Trim(); if(match.Groups[6].Value != decoded) insertion += "|" + match.Groups[6].Value; insertion += "]"; buffer.Insert(match.Index, insertion); diff --git a/WebApplication/PopupWYSIWYG.aspx.cs b/WebApplication/PopupWYSIWYG.aspx.cs index 4b7aa4f..3234392 100644 --- a/WebApplication/PopupWYSIWYG.aspx.cs +++ b/WebApplication/PopupWYSIWYG.aspx.cs @@ -150,13 +150,16 @@ namespace ScrewTurn.Wiki { protected List ctPages_Populate(object sender, PopulateEventArgs e) { List result = new List(100); - foreach(PageInfo pi in Pages.GetPages(Pages.FindNamespace(lstNamespace.SelectedValue))) { + + NamespaceInfo selectedNamespace = Pages.FindNamespace(lstNamespace.SelectedValue); + NamespaceInfo currentNamespace = DetectNamespaceInfo(); + + foreach(PageInfo pi in Pages.GetPages(selectedNamespace)) { PageContent cont = Content.GetPageContent(pi, true); string formattedTitle = FormattingPipeline.PrepareTitle(cont.Title, false, FormattingContext.Other, pi); string onClickJavascript = "javascript:"; // Populate the page title box if the title is different to the page name - if (pi.FullName != cont.Title) - { + if (pi.FullName != cont.Title) { // Supply the page title to the Javascript that sets the page title on the page // We can safely escape the \ character, but the " character is interpreted by the browser even if it is escaped to Javascript, so we can't allow it. // The non-wysiwyg version escapes ' and replaces " with escaped ', but ' breaks the html insertion, so remove it altogether @@ -164,13 +167,12 @@ namespace ScrewTurn.Wiki { // breaking the drop-down. onClickJavascript += "SetValue('txtPageTitle', '" + cont.Title.Replace("\\", "\\\\").Replace("'", "").Replace("\"", "").Replace("<", "") + "');"; } - else - { + else { onClickJavascript += "SetValue('txtPageTitle', '');"; } - // Populate the page name - onClickJavascript += "return SetValue('txtPageName', '" + pi.FullName + "');"; - TreeElement item = new TreeElement(pi.FullName, formattedTitle, onClickJavascript); + // Populate the page name (#468: add ++ to all ReverseFormatter to work) + onClickJavascript += "return SetValue('txtPageName', '" + (selectedNamespace != currentNamespace ? "++" : "") + pi.FullName + "');"; + TreeElement item = new TreeElement((selectedNamespace != currentNamespace ? "++" : "") + pi.FullName, formattedTitle, onClickJavascript); result.Add(item); } return result;