コード例 #1
0
 public static string MatchEval(Match match)
 {
     if (match.Groups["term"].Success)
     {
         var url = WikiUrlConfig.PrepareUrl(new JGN_Wiki()
         {
             term = match.Groups["term"].Value.Trim().ToLower()
         });
         return("<a href=\"" + url + "\" title=\"" + match.Groups["term"].Value.ToString().Trim() + "\">" + match.Groups["term"].Value.ToString() + "</a>");
     }
     else
     {
         // no match
         return(match.Groups["hrefurl"].Value);
     }
 }
コード例 #2
0
        /// <summary>
        ///  Generate dynamic wiki posts sitemap for search engine submissions
        /// </summary>
        public static async Task <string> BuildGoogleSiteMapUrls(ApplicationDbContext context)
        {
            var str = new StringBuilder();

            str.AppendLine("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"  xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">");
            // start sitemap url
            var _items = await LoadItems(context, new WikiEntity()
            {
                pagesize = 50000
            });

            foreach (var item in _items)
            {
                str.AppendLine("<url>");
                str.AppendLine("<loc>" + WikiUrlConfig.PrepareUrl(item) + "</loc>");
                str.AppendLine("</url>");
            }
            // close sitemap url
            str.AppendLine("</urlset>");

            return(str.ToString());
        }