public static HtmlString MetaTags() { StringBuilder sb = new StringBuilder(); if (CmsPage.TheSite.BlockIndex || CmsPage.ThePage.BlockIndex) { sb.AppendLine(CarrotWeb.MetaTag("robots", "noindex,nofollow,noarchive").ToString()); sb.AppendLine(String.Empty); } if (!String.IsNullOrEmpty(CmsPage.ThePage.MetaKeyword)) { sb.AppendLine(CarrotWeb.MetaTag("keywords", CmsPage.ThePage.MetaKeyword).ToString()); sb.AppendLine(String.Empty); } if (!String.IsNullOrEmpty(CmsPage.ThePage.MetaDescription)) { sb.AppendLine(CarrotWeb.MetaTag("description", CmsPage.ThePage.MetaDescription).ToString()); sb.AppendLine(String.Empty); } sb.AppendLine(CarrotWeb.MetaTag("generator", SiteData.CarrotCakeCMSVersion).ToString()); sb.AppendLine(String.Empty); return(new HtmlString(sb.ToString())); }
public ActionResult GetCarrotHelp(string id) { var context = System.Web.HttpContext.Current; context.Response.Cache.VaryByParams["ts"] = true; DoCacheMagic(context, 10); string sBody = CarrotWeb.GetManifestResourceStream("Carrotware.Web.UI.Components.carrotHelp.js"); DateTime timeAM = DateTime.Now.Date.AddHours(6); // 6AM DateTime timePM = DateTime.Now.Date.AddHours(12); // 6PM sBody = sBody.Replace("[[TIMESTAMP]]", DateTime.UtcNow.ToString("u")); sBody = sBody.Replace("[[SHORTDATEPATTERN]]", CarrotWeb.ShortDatePattern); sBody = sBody.Replace("[[SHORTTIMEPATTERN]]", CarrotWeb.ShortTimePattern); sBody = sBody.Replace("[[SHORTDATEFORMATPATTERN]]", CarrotWeb.ShortDateFormatPattern); sBody = sBody.Replace("[[SHORTDATETIMEFORMATPATTERN]]", CarrotWeb.ShortDateTimeFormatPattern); sBody = sBody.Replace("[[AM_TIMEPATTERN]]", timeAM.ToString("tt")); sBody = sBody.Replace("[[PM_TIMEPATTERN]]", timePM.ToString("tt")); var byteArray = Encoding.UTF8.GetBytes(sBody); stream = new MemoryStream(byteArray); return(File(stream, "text/javascript")); }
public string ToHtmlString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(String.Empty); try { if (this.CmsPage != null) { if (!String.IsNullOrEmpty(this.CmsPage.ThePage.MetaDescription)) { sb.AppendLine(CarrotWeb.MetaTag("og:description", this.CmsPage.ThePage.MetaDescription).ToString()); } sb.AppendLine(CarrotWeb.MetaTag("og:url", this.CmsPage.TheSite.DefaultCanonicalURL).ToString()); string contType = OpenGraphTypeDef.Default.ToString(); if (this.OpenGraphType == OpenGraphTypeDef.Default) { if (this.CmsPage.ThePage.ContentType == ContentPageType.PageType.BlogEntry) { contType = OpenGraphTypeDef.Blog.ToString().ToLower(); } else { contType = OpenGraphTypeDef.Article.ToString().ToLower(); } if (this.CmsPage.TheSite.Blog_Root_ContentID.HasValue && this.CmsPage.ThePage.Root_ContentID == this.CmsPage.TheSite.Blog_Root_ContentID) { contType = OpenGraphTypeDef.Website.ToString().ToLower(); } } else { contType = this.OpenGraphType.ToString().ToLower(); } sb.AppendLine(CarrotWeb.MetaTag("og:type", contType).ToString()); if (!String.IsNullOrEmpty(this.CmsPage.ThePage.TitleBar)) { sb.AppendLine(CarrotWeb.MetaTag("og:title", this.CmsPage.ThePage.TitleBar).ToString()); } if (!String.IsNullOrEmpty(this.CmsPage.ThePage.Thumbnail)) { sb.AppendLine(CarrotWeb.MetaTag("og:image", String.Format("{0}/{1}", this.CmsPage.TheSite.MainCanonicalURL, this.CmsPage.ThePage.Thumbnail).Replace(@"//", @"/").Replace(@"//", @"/").Replace(@":/", @"://")).ToString()); } if (!String.IsNullOrEmpty(this.CmsPage.TheSite.SiteName)) { sb.AppendLine(CarrotWeb.MetaTag("og:site_name", this.CmsPage.TheSite.SiteName).ToString()); } sb.AppendLine(CarrotWeb.MetaTag("article:published_time", this.CmsPage.TheSite.ConvertSiteTimeToISO8601(this.CmsPage.ThePage.GoLiveDate)).ToString()); sb.AppendLine(CarrotWeb.MetaTag("article:modified_time", this.CmsPage.TheSite.ConvertSiteTimeToISO8601(this.CmsPage.ThePage.EditDate)).ToString()); if (this.ShowExpirationDate) { sb.AppendLine(CarrotWeb.MetaTag("article:expiration_time", this.CmsPage.TheSite.ConvertSiteTimeToISO8601(this.CmsPage.ThePage.RetireDate)).ToString()); } } } catch (Exception ex) { } return(sb.ToString()); }