在编辑文章的时候添加Flash总是把embed等内容过虑了,看了一下帮助原来可以写一个Extension来处理。
/// <summary>
/// sample:[flash:http://smark.nbao.net/ShowEffectSample.swf 600 400]
/// </summary>
[Extension("FlashPlayer", "1.0.0.0", "smark.nbao.net")]
public class FlashPlayer
{
public FlashPlayer()
{
Post.Serving += new EventHandler<ServingEventArgs>(Post_Serving);
}
private void Post_Serving(object sender, ServingEventArgs e)
{
if (!string.IsNullOrEmpty(e.Body))
{
if (e.Location == ServingLocation.PostList || e.Location == ServingLocation.SinglePost)
{
string regex = @"\[flash:(http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*))(\s+)(\d*)(\s+)(\d*)\]";
MatchCollection matches = Regex.Matches(e.Body, regex);
if (matches.Count > 0)
{
string filename, width, height;
Match match = Regex.Match(e.Body, regex);
if (match.Length > 0)
{
filename = match.Groups[1].Value;
width = match.Groups[match.Groups.Count - 3].Value;
height = match.Groups[match.Groups.Count - 1].Value;
string player = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\""
+ "id=\"ShowEffectSample\" width=\"{1}\" height=\"{2}\""
+ "codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab\">"
+ "<param name=\"movie\" value=\"{0}\" />"
+ "<param name=\"quality\" value=\"high\" />"
+ "<param name=\"bgcolor\" value=\"#869ca7\" />"
+ "<param name=\"allowScriptAccess\" value=\"sameDomain\" />"
+ "<embed src=\"{0}\" quality=\"high\""
+ "width=\"{1}\" height=\"{2}\" align=\"middle\""
+ "play=\"true\""
+ "loop=\"false\""
+ "quality=\"high\""
+ "allowScriptAccess=\"sameDomain\""
+ "type=\"application/x-shockwave-flash\""
+ "pluginspage=\"http://www.adobe.com/go/getflashplayer\">"
+ "</embed>"
+ "</object>";
e.Body = e.Body.Replace(match.Value, string.Format(player, filename, width, height));
}
}
}
}
}