public ActionResult SiteMapXml() { string domain = Request.Url.Host; Sitemap sitemap = new Sitemap(); using (ContentRepository content_repository = new ContentRepository()) { long totals; foreach (var item in content_repository.GetActive((string[])null, null, null, null, 1, Int64.MaxValue, out totals, "content_in_sitemap = true", null, domain)) { sitemap.Add(new Location() { Url = string.Format("http://{0}{1}", Request.Url.Host, item.content_url) }); } } XmlSerializer xs = new XmlSerializer(typeof(Sitemap)); MemoryStream ms = new MemoryStream(); XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); xs.Serialize(xw, sitemap); ms.Position = 0; return(File(ms, "text/xml")); }
private static IcbcodeCollection <IcbcodeContent> Get(long[] content_root, string[] block_name, string[] template_name, string order_fields, long page, long size, string query, dynamic where, string domain) { IcbcodeCollection <IcbcodeContent> items = new IcbcodeCollection <IcbcodeContent>(); long totals; using (ContentRepository content_repository = new ContentRepository()) { List <dynamic> contents = content_repository.GetActive(block_name, content_root, template_name, order_fields, page, size, out totals, query, where, domain); items.TotalPages = totals; items.CurrentPage = page; items.PageSize = size; for (int index = 0; index < contents.Count; index++) { items.Add(IcbcodeContent.Convert(contents[index], index + 1, contents.Count)); } } return(items); }
public IcbcodeCollection <IcbcodeContent> Childs(string[] template_name = null, string order_fields = null, long page = 1, long size = Int64.MaxValue, string query = null, dynamic where = null, string domain = null) { IcbcodeCollection <IcbcodeContent> items = new IcbcodeCollection <IcbcodeContent>(); long totals; using (ContentRepository content_repository = new ContentRepository()) { List <dynamic> contents = content_repository.GetActive(null, new long[] { ID }, template_name, order_fields, page, size, out totals, query, where, domain); items.TotalPages = totals; items.CurrentPage = page; items.PageSize = size; for (int index = 0; index < contents.Count; index++) { items.Add(IcbcodeContent.Convert(contents[index], index + 1, contents.Count)); } } return(items); }
public ActionResult Index() { string domain = Request.Url.Host; string url = Request.Url.LocalPath; dynamic content = null; using (ContentRepository content_repository = new ContentRepository()) { content = url == "/" ? content_repository.GetActiveMain(domain) : content_repository.GetActiveByUrl(url.TrimEnd('/'), domain); } if (content == null) { throw new HttpException(404, "Not found"); } else { string redirect_url = string.IsNullOrWhiteSpace(content.content_redirect_url) ? Url.Content("~/") : content.content_redirect_url; string view_path = content.view_path; if (content.content_allow_redirect) { return(content.content_redirect_permanent ? RedirectPermanent(redirect_url) : Redirect(redirect_url)); } else if (content.content_export_rss) { var feed = new SyndicationFeed { Title = new TextSyndicationContent(content.content_export_rss_title), Description = new TextSyndicationContent(content.content_export_rss_title), BaseUri = new Uri(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, content.content_url)), Id = Transliterator.Translite(content.content_export_rss_title, '_'), LastUpdatedTime = DateTime.Now, Items = new List <SyndicationItem>() }; List <SyndicationItem> items = new List <SyndicationItem>(); using (ContentRepository content_repository = new ContentRepository()) { long totals; foreach (var item in content_repository.GetActive(null, ModelUtility.GetLongArray(content.content_export_rss_ids), null, "content_last_update desc", 1, 30, out totals, null, null, domain)) { var syndItem = new SyndicationItem { Title = new TextSyndicationContent(item.content_link ?? item.content_h1), Content = new TextSyndicationContent(IcbcodeUtility.GetPlainText(item.content_short_text)), Id = item.content_id.ToString(), LastUpdatedTime = item.content_publish ?? item.content_last_update }; syndItem.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, item.content_url)))); items.Add(syndItem); } } feed.Items = items; return(new RssActionResult() { Feed = feed }); } else { if (string.IsNullOrWhiteSpace(view_path)) { throw new HttpException(404, "Not found"); } return(View(view_path, IcbcodeContent.Convert(content, 1, 1))); } } }