Contents tagged with Wikis

  • Wiki feature set: highlight proposed changes to current document

    One thing I'm playing with at the moment is a test module that will work with the ASP.NET page model's OnTextCnanged event, to displayed changed content in subsequent versions of a wiki web page.  So for instance, in a document I wrote yesterday, I edit the content and post the update to the server. 

    Upon looking at the changed content, a small Label control (or other visual device) shows the precise area(s) that were changed between versions, and highlights them as such.

    Read more...

  • Creating Wikipedia-like links in your wiki

    One of the things that bugs me about wikis these days isn't that the majority of them rely on some sort of standard string pattern (often CamelCasing) to identify internal links that point to destinations within the wiki containing content on that subject - it's that the links are quite often presented as CamelCasedLinkTextWhichCanGetHardToReadAndIsUgly.  Get it?

    Providing normal-looking links in a large wiki application is something WikiPedia does extremely well.  Considering the literal millions of content areas it features, it renders links as real words, not garbled text.  In my opinion, this is a user experience towards which we should all aspire.

    I believe in form as well as function, so below is code I developed for a wiki parser component that allows text entered into a TextBox to accept camel-cased syntax for automatic link assignment, but then displays the link-worthy hypertext as normal dialogue, without words bunched together.

    <%@ Page Language="C#" %>
    <%@ import Namespace="System.Text.RegularExpressions" %>
    <script runat="server">

    private string camelCase = @"[A-Z]\w*[a-z]\w*[A-Z]\w*(?=\b)";
    private RegexOptions options = RegexOptions.Compiled;

    private void btnSubmit_Click(Object sender, EventArgs e)
    {
    // parses the text and return custom-formatted HTML
    lblParsed.Text = Regex.Replace(txtFirst.Text.Trim(),camelCase,new MatchEvaluator(this.FormatWikiText),options);
    lblParsed.Text = lblParsed.Text.Replace(System.Environment.NewLine,"\n\t<br/>");
    }

    private string FormatWikiText(Match m)
    {
    return "<a onmouseover=\"this.style.backgroundColor='#6699CC';\"
    onmouseout=\"this.style.backgroundColor='#ffffff';\" href=\"/content/" + m.Value + ".aspx\">"
    + BreakCamelCasing(m) + "</a>";
    }

    private string BreakCamelCasing(Match m)
    {
    // add a blank space in between each uppercase letter within the camel-cased word
    string s = m.Value;

    if((s == null) || (s.Length == 0))
    return string.Empty;

    StringBuilder sb = new StringBuilder();
    sb.Append(s[0]); // ignore the first character in the word

    for(int i=1;i<s.Length;i++) // count from the second character on
    {
    char c = s[i];
    if(char.IsUpper(c))
    sb.Append(" ");

    sb.Append(c);
    }

    return sb.ToString();
    }

    </script>
    <html>
    <head>
    </head>
    <body>
    <form runat="server">
    <h3>Sample Wiki text parser
    </h3>
    <hr />
    <p align="text">
    <asp:TextBox id="txtFirst" runat="server" Width="693px" Height="237px" TextMode="MultiLine"/>
    </p>
    <p>
    <asp:Button id="btnSubmit" onclick="btnSubmit_Click" runat="server" Text="Parse this text for the wiki"/>
    </p>
    <p>
    <asp:Label id="lblParsed" runat="server"/>
    </p>
    </form>
    </body>
    </html>
    Thanks to Dave Wanta from 123ASPX.com and AspNetEmail for his contributions.

    Read more...