Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created June 15, 2011 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommorris/1028054 to your computer and use it in GitHub Desktop.
Save tommorris/1028054 to your computer and use it in GitHub Desktop.
// This function was custom written as a plugin to AutoWikiBrowser
// It does DEFAULTSORT-ing on the ORG Wiki of MPs names.
// Copyright (C) Tom Morris 2011. Released under the GNU General Public License.
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "";
string DefaultSortOut = "";
string SummaryOut = "";
if (Regex.Match(ArticleTitle, @"^\w+ \w+ MP$").Success) {
// they are an MP
if (Regex.Match(ArticleText, @"{{DEFAULTSORT:").Success) {
Skip = true;
} else {
// they don't have an existing DEFAULTSORT set
Match match = Regex.Match(ArticleTitle, @"^(\w+) (\w+) MP$");
if (match.Success) {
String FirstName = match.Groups[1].Value;
String LastName = match.Groups[2].Value;
DefaultSortOut += LastName + ", " + FirstName;
ArticleText = ArticleText + "\r\n\r\n{{DEFAULTSORT:" + DefaultSortOut + "}}\n";
Summary = Summary + "adding DEFAULTSORT for MP";
}
}
} else {
Skip = true;
}
return ArticleText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment