Пример #1
0
        /// <summary>
        /// Utility method for quickly formatting a text without having
        /// to create a TextileFormatter with an IOutputter.
        /// </summary>
        /// <param name="input">The string to format</param>
        /// <returns>The formatted version of the string</returns>
        public static string FormatString(string input)
        {
            StringBuilderOutputter output    = new StringBuilderOutputter();
            TextileFormatter       formatter = new TextileFormatter(output);

            formatter.Format(input);
            return(output.GetFormattedText());
        }
Пример #2
0
        /// <summary>
        /// Utility method for quickly formatting a text without having
        /// to create a TextileFormatter with an IOutputter.
        /// </summary>
        /// <param name="input">The string to format</param>
        /// <returns>The formatted version of the string</returns>
        public static string FormatString(string input)
        {
            StringBuilderTextileFormatter s = new StringBuilderTextileFormatter();
            TextileFormatter f = new TextileFormatter(s);

            f.Format(input);
            return(s.GetFormattedText());
        }
Пример #3
0
 public void ApplyFormating(NoticeMessage message)
 {
     var output = new StringBuilderTextileFormatter();
     var formatter = new TextileFormatter(output);
     message.Subject = VelocityArguments.Replace(message.Subject, argMatchReplace);
     formatter.Format(message.Body);
     message.Body = Master.Replace("%CONTENT%", output.GetFormattedText());
 }
Пример #4
0
        public void ApplyFormating(NoticeMessage message)
        {
            var output = new StringBuilderTextileFormatter();
            var formatter = new TextileFormatter(output);

            if (!string.IsNullOrEmpty(message.Subject))
            {
                message.Subject = VelocityArguments.Replace(message.Subject, m => m.Result("${arg}"));
            }

            if (!string.IsNullOrEmpty(message.Body))
            {
                formatter.Format(message.Body);

                var logoMail = ConfigurationManager.AppSettings["web.logo.mail"];
                var logo = string.IsNullOrEmpty(logoMail) ? "http://cdn.teamlab.com/media/newsletters/images/header_04.jpg" : logoMail;
                message.Body = Resources.TemplateResource.HtmlMaster.Replace("%CONTENT%", output.GetFormattedText()).Replace("%LOGO%", logo);

                var footer = message.GetArgument("WithPhoto");
                var partner = message.GetArgument("Partner");
                var res = String.Empty;

                if (partner != null) {
                    res = partner.Value.ToString();
                }
                if (String.IsNullOrEmpty(res) && footer != null)
                {
                    switch ((string)footer.Value)
                    {
                        case "photo":
                            res = Resources.TemplateResource.FooterWithPhoto;
                            break;
                        case "links":
                            res = Resources.TemplateResource.FooterWithLinks;
                            break;
                        default:
                            res = String.Empty;
                            break;
                    }
                }
                message.Body = message.Body.Replace("%FOOTER%", res);

                var mail = message.Recipient.Addresses.FirstOrDefault(r => r.Contains("@"));
                var domain = ConfigurationManager.AppSettings["web.teamlab-site"];
                var site = string.IsNullOrEmpty(domain) ? "http://www.teamlab.com" : domain;
                var link = site + string.Format("/Unsubscribe.aspx?id={0}", HttpServerUtility.UrlTokenEncode(Security.Cryptography.InstanceCrypto.Encrypt(Encoding.UTF8.GetBytes(mail.ToLowerInvariant()))));
                var text = string.Format(Resources.TemplateResource.TextForFooter, link, DateTime.UtcNow.Year);

                message.Body = message.Body.Replace("%TEXTFOOTER%", text);
            }
        }
Пример #5
0
 private void DoTextileToHtml()
 {
     m_textileFormatter.Format(m_textInput.Text);
     m_cachedHtml = m_textileOutput.GetFormattedText();
     if (m_bodyElement == null)
     {
         m_bodyElement = m_webBrowser.Document.GetElementById("body");
         if (m_bodyElement == null)
         {
             // the browser was not ready for us yet
             m_webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(m_webBrowser_DocumentCompleted);
         }
         else
         {
             m_bodyElement.InnerHtml = m_cachedHtml;
         }
     }
     else
     {
         m_bodyElement.InnerHtml = m_cachedHtml;
     }
 }
 /// <summary>
 /// Utility method for formatting a text with a given outputter.
 /// </summary>
 /// <param name="input">The string to format</param>
 /// <param name="outputter">The IOutputter to use</param>
 public static void FormatString(string input, IOutputter outputter)
 {
     TextileFormatter f = new TextileFormatter(outputter);
     f.Format(input);
 }
 /// <summary>
 /// Utility method for quickly formatting a text without having
 /// to create a TextileFormatter with an IOutputter.
 /// </summary>
 /// <param name="input">The string to format</param>
 /// <returns>The formatted version of the string</returns>
 public static string FormatString(string input)
 {
     StringBuilderTextileFormatter s = new StringBuilderTextileFormatter();
     TextileFormatter f = new TextileFormatter(s);
     f.Format(input);
     return s.GetFormattedText();
 }
Пример #8
0
        /// <summary>
        /// Utility method for formatting a text with a given outputter.
        /// </summary>
        /// <param name="input">The string to format</param>
        /// <param name="outputter">The IOutputter to use</param>
        public static void FormatString(string input, IOutputter outputter)
        {
            TextileFormatter f = new TextileFormatter(outputter);

            f.Format(input);
        }
Пример #9
0
        public void ApplyFormating(NoticeMessage message)
        {
            bool isPromoTmpl = false;
            var output = new StringBuilderTextileFormatter();
            var formatter = new TextileFormatter(output);

            if (!string.IsNullOrEmpty(message.Subject))
            {
                message.Subject = VelocityArguments.Replace(message.Subject, m => m.Result("${arg}"));
            }

            if (!string.IsNullOrEmpty(message.Body))
            {
                formatter.Format(message.Body);

                var isPromo = message.GetArgument("isPromoLetter");
                if (isPromo != null && (string)isPromo.Value == "true")
                {
                    isPromoTmpl = true;
                }

                var logoImg = "";
                if (isPromoTmpl) {
                    logoImg = "http://cdn.teamlab.com/media/newsletters/images/logo.png";
                } else {
                   logoImg = ConfigurationManager.AppSettings["web.logo.mail"];
                    if (String.IsNullOrEmpty(logoImg))
                    {
                        var logo = message.GetArgument("LetterLogo");
                        if (logo != null && (string)logo.Value != "")
                        {
                            logoImg = (string)logo.Value;
                        }
                        else
                        {
                            logoImg = "http://cdn.teamlab.com/media/newsletters/images/header_08.png";
                        }
                    }
                }


                var template = isPromoTmpl ? Resources.TemplateResource.HtmlMasterPromo : Resources.TemplateResource.HtmlMaster;
                message.Body = template.Replace("%CONTENT%", output.GetFormattedText()).Replace("%LOGO%", logoImg);

                var footer = message.GetArgument("WithPhoto");
                var partner = message.GetArgument("Partner");
                var res = String.Empty;

                if (partner != null) {
                    res = partner.Value.ToString();
                }


                if (String.IsNullOrEmpty(res) && footer != null)
                {
                    switch ((string)footer.Value)
                    {
                        case "photo":
                            res = Resources.TemplateResource.FooterWithPhoto;
                            break;
                        case "links":
                            res = Resources.TemplateResource.FooterWithLinks;
                            break;
                        case "personal":
                            res = Resources.TemplateResource.FooterPersonal;
                            break;
                        default:
                            res = String.Empty;
                            break;
                    }
                }
                message.Body = message.Body.Replace("%FOOTER%", res);


                var text = "";

                var noUnsubscribeLink = message.GetArgument("noUnsubscribeLink");
                if (noUnsubscribeLink == null || (string)noUnsubscribeLink.Value == "false")
                {
                    var isHosted = ConfigurationManager.AppSettings["core.payment-partners-hosted"];
                    if (String.IsNullOrEmpty(isHosted) || isHosted == "false")
                    {
                        var mail = message.Recipient.Addresses.FirstOrDefault(r => r.Contains("@"));
                        var domain = ConfigurationManager.AppSettings["web.teamlab-site"];
                        var site = string.IsNullOrEmpty(domain) ? "http://www.onlyoffice.com" : domain;
                        var link = site + string.Format("/Unsubscribe.aspx?id={0}", HttpServerUtility.UrlTokenEncode(Security.Cryptography.InstanceCrypto.Encrypt(Encoding.UTF8.GetBytes(mail.ToLowerInvariant()))));

                        text = string.Format(Resources.TemplateResource.TextForFooterWithUnsubscribe, link);
                    }
                }

                text += string.Format(Resources.TemplateResource.TextForFooter, DateTime.UtcNow.Year, string.Empty);
                message.Body = message.Body.Replace("%TEXTFOOTER%", text);
            }
        }