Created
June 15, 2011 20:42
-
-
Save tommorris/1028054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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