Ejemplo n.º 1
0
        /// <summary>
        /// Writes out the empty pages for the post. Also handles the redirect pages
        /// </summary>
        public void WritePages()
        {
            PageTemplateToolboxContext templateContext = new PageTemplateToolboxContext();

            templateContext.Put("PostId", Id);
            templateContext.Put("CategoryId", CategoryId);
            templateContext.Put("PostName", Name);
            templateContext.Put("Name", Name);
            templateContext.Put("CategoryName", Category.LinkName);
            templateContext.Put("MetaDescription",
                                !string.IsNullOrEmpty(MetaDescription)
                                    ? MetaDescription
                                    : HttpUtility.HtmlEncode(Util.RemoveHtml(PostBody, 255) ?? string.Empty));

            templateContext.Put("MetaKeywords",
                                !string.IsNullOrEmpty(MetaKeywords)
                                    ? MetaKeywords
                                    : TagList);


            string pageName = null;

            if (CategoryController.UnCategorizedId != CategoryId)
            {
                pageName = categories.GetCachedCategory(CategoryId, false).LinkName + "/";
            }

            pageName = "~/" + pageName + Name + "/" + Util.DEFAULT_PAGE;

            PageWriter.Write("post.view", pageName, templateContext);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Writes empty pages to disk.
        /// </summary>
        public void WritePages()
        {
            PageTemplateToolboxContext templateContext = new PageTemplateToolboxContext();

            templateContext.Put("CategoryId", Id);
            templateContext.Put("CategoryName", LinkName);
            templateContext.Put("MetaDescription",
                                !string.IsNullOrEmpty(MetaDescription)
                                                                        ? MetaDescription
                                                                        : HttpUtility.HtmlEncode(Util.RemoveHtml(Body, 255) ?? string.Empty));

            templateContext.Put("MetaKeywords",
                                !string.IsNullOrEmpty(MetaKeywords)
                                                                        ? MetaKeywords
                                                                        : Name);


            if (!IsUncategorized)
            {
                PageWriter.Write("category.view", "~/" + LinkName + "/" + Util.DEFAULT_PAGE, templateContext);
                PageWriter.Write("categoryrss.view", "~/" + LinkName + "/feed/" + Util.DEFAULT_PAGE, templateContext);
            }

            if (__initialCategoryName != null && __initialCategoryName != LinkName)
            {
                PostCollection pc        = new PostCollection();
                Query          postQuery = Post.CreateQuery();
                postQuery.AndWhere(Post.Columns.CategoryId, Id);
                pc.LoadAndCloseReader(postQuery.ExecuteReader());
                foreach (Post p in pc)
                {
                    p.Save();
                }
            }
        }
Ejemplo n.º 3
0
        public static bool Send(string templateFile, string emailTo, string subject, PageTemplateToolboxContext cntxt)
        {
            string fileText =
                Util.GetFileText(HttpContext.Current.Server.MapPath("~/__utility/emails/" + templateFile));

            fileText = TemplateEngine.Evaluate(fileText, cntxt);

            SiteSettings settings = SiteSettings.Get();

            using (MailMessage mm = new MailMessage(settings.EmailFrom, emailTo))
            {
                mm.Subject = subject;
                mm.IsBodyHtml = true;
                mm.Body = fileText;

                SmtpClient client = new SmtpClient();
                client.Host = settings.EmailServer;

                if(settings.EmailServerRequiresAuthentication)
                    client.Credentials = new System.Net.NetworkCredential(settings.EmailUser, settings.EmailPassword);

                if (settings.EmailRequiresSSL)
                    client.EnableSsl = true;

                if (settings.EmailPort > 0)
                    client.Port = settings.EmailPort;

                client.Send(mm);
            }

            return true;
        }
Ejemplo n.º 4
0
        public static void WritePage(string name)
        {
            PageTemplateToolboxContext templateContext = new PageTemplateToolboxContext();
            templateContext.Put("tag", name);
            templateContext.Put("MetaDescription", "Posts and articles tagged as " + name);
            templateContext.Put("MetaKeywords", name);

            PageWriter.Write("tag.view", "~/tags/" + name + "/" + Util.DEFAULT_PAGE, templateContext);
            PageWriter.Write("tagrss.view", "~/tags/" + name + "/feed/" + Util.DEFAULT_PAGE, templateContext);
        }
Ejemplo n.º 5
0
        public static void WritePage(string name)
        {
            PageTemplateToolboxContext templateContext = new PageTemplateToolboxContext();

            templateContext.Put("tag", name);
            templateContext.Put("MetaDescription", "Posts and articles tagged as " + name);
            templateContext.Put("MetaKeywords", name);


            PageWriter.Write("tag.view", "~/tags/" + name + "/" + Util.DEFAULT_PAGE, templateContext);
            PageWriter.Write("tagrss.view", "~/tags/" + name + "/feed/" + Util.DEFAULT_PAGE, templateContext);
        }
Ejemplo n.º 6
0
        public static bool Send(string templateFile, string emailTo, string subject, PageTemplateToolboxContext cntxt)
        {
            string fileText =
                Util.GetFileText(HttpContext.Current.Server.MapPath("~/__utility/emails/" + templateFile));

            fileText = TemplateEngine.Evaluate(fileText, cntxt);

            SiteSettings settings = SiteSettings.Get();

            using (MailMessage mm = new MailMessage(settings.EmailFrom, emailTo))
            {
                mm.Subject    = subject;
                mm.IsBodyHtml = true;
                mm.Body       = fileText;

                SmtpClient client = new SmtpClient();
                client.Host = settings.EmailServer;

                if (settings.EmailServerRequiresAuthentication)
                {
                    client.Credentials = new NetworkCredential(settings.EmailUser, settings.EmailPassword);
                }

                if (settings.EmailRequiresSSL)
                {
                    client.EnableSsl = true;
                }

                if (settings.EmailPort > 0)
                {
                    client.Port = settings.EmailPort;
                }

                client.Send(mm);
            }

            return(true);
        }
Ejemplo n.º 7
0
        public static void Write(string pageTemplateFile, string virtualPath, PageTemplateToolboxContext cntxt)
        {
            if (SiteSettings.Get().GenerateFolders)
            {
                string fileText =
                    Util.GetFileText(HttpContext.Current.Server.MapPath("~/__utility/pages/" + pageTemplateFile));
                //fileText = string.Format(fileText, list.ToArray());

                fileText = TemplateEngine.Evaluate(fileText, cntxt);

                string   absPath = HttpContext.Current.Server.MapPath(virtualPath);
                FileInfo fi      = new FileInfo(absPath);
                if (!fi.Directory.Exists)
                {
                    fi.Directory.Create();
                }

                using (StreamWriter sw = new StreamWriter(absPath, false))
                {
                    sw.WriteLine(fileText);
                    sw.Close();
                }
            }
        }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context,"settings");

        ClientScript.RegisterStartupScript(this.GetType(), "set-fields", "toggleServerAuthFields()", true);
        if (!IsPostBack)
        {
            SiteSettings settings = SiteSettings.Get();
            txtServerName.Text = settings.EmailServer;
            txtFrom.Text = settings.EmailFrom;
            RequiresAuthentication.Checked = settings.EmailServerRequiresAuthentication;
            UseSSL.Checked = settings.EmailRequiresSSL;
            txtPort.Text = settings.EmailPort.ToString();

            if (RequiresAuthentication.Checked)
            {
                txtUser.Text = settings.EmailUser;
                txtPassword.Text = settings.EmailPassword;
            }

            PageTemplateToolboxContext ptc = new PageTemplateToolboxContext();
            ptc.Put("comment", this);
        }
    }
Ejemplo n.º 9
0
        public static void Write(string pageTemplateFile, string virtualPath, PageTemplateToolboxContext cntxt)
        {
            if (SiteSettings.Get().GenerateFolders)
            {
                string fileText =
                    Util.GetFileText(HttpContext.Current.Server.MapPath("~/__utility/pages/" + pageTemplateFile));
                //fileText = string.Format(fileText, list.ToArray());

                fileText = TemplateEngine.Evaluate(fileText, cntxt);

                string absPath = HttpContext.Current.Server.MapPath(virtualPath);
                FileInfo fi = new FileInfo(absPath);
                if (!fi.Directory.Exists)
                {
                    fi.Directory.Create();
                }

                using (StreamWriter sw = new StreamWriter(absPath, false))
                {
                    sw.WriteLine(fileText);
                    sw.Close();
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Writes out the empty pages for the post. Also handles the redirect pages
        /// </summary>
        public void WritePages()
        {
            PageTemplateToolboxContext templateContext = new PageTemplateToolboxContext();
            templateContext.Put("PostId", Id);
            templateContext.Put("CategoryId", CategoryId);
            templateContext.Put("PostName", Name);
            templateContext.Put("Name", Name);
            templateContext.Put("CategoryName", Category.LinkName);
            templateContext.Put("MetaDescription",
                                !string.IsNullOrEmpty(MetaDescription)
                                    ? MetaDescription
                                    : HttpUtility.HtmlEncode(Util.RemoveHtml(PostBody,255) ?? string.Empty));

            templateContext.Put("MetaKeywords",
                                !string.IsNullOrEmpty(MetaKeywords)
                                    ? MetaKeywords
                                    : TagList);

            string pageName = null;

            if(CategoryController.UnCategorizedId != CategoryId)
                     pageName =  categories.GetCachedCategory(CategoryId, false).LinkName + "/";

            pageName = "~/" + pageName + Name + "/" + Util.DEFAULT_PAGE;

            PageWriter.Write("post.view", pageName, templateContext);
        }