Ejemplo n.º 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)
        {
            StringBuilderTextileFormatter s = new StringBuilderTextileFormatter();
            TextileFormatter f = new TextileFormatter(s);

            f.Format(input);
            return(s.GetFormattedText());
        }
Ejemplo n.º 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)
        {
            StringBuilderOutputter output    = new StringBuilderOutputter();
            TextileFormatter       formatter = new TextileFormatter(output);

            formatter.Format(input);
            return(output.GetFormattedText());
        }
Ejemplo n.º 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());
 }
Ejemplo n.º 4
0
        public DressingRoom()
        {
            InitializeComponent();

            m_textileOutput    = new Textile.StringBuilderOutputter();
            m_textileFormatter = new Textile.TextileFormatter(m_textileOutput);

            System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly();
            var    absolutePathToCustomCss     = Path.ChangeExtension(Application.ExecutablePath, ".css");
            Stream css;

            if (File.Exists(absolutePathToCustomCss))
            {
                css = new FileStream(absolutePathToCustomCss, FileMode.Open, FileAccess.Read, FileShare.Read);
            }
            else
            {
                css = thisExe.GetManifestResourceStream("DressingRoom.Default.css");
            }
            string styleContent;

            using (css)
            {
                using (StreamReader rdr = new StreamReader(css))
                {
                    styleContent = rdr.ReadToEnd();
                }
            }

            m_webBrowser.DocumentText = String.Format(@"<html>
	<head>
		<base id='base' />
		<style>
			{0}
		</style>
	</head>
	<body id='body'>
	</body>
</html>", styleContent);

            var ni = m_textInput.NativeInterface;

            ni.SetCaretLineBack(Colour(0xdc, 0xff, 0xff));
            ni.SetCaretLineVisible(true);
            m_textInput.Selection.ForeColor          = Color.Transparent;
            m_textInput.Selection.ForeColorUnfocused = Color.Transparent;
            m_textInput.Selection.BackColor          = Color.FromArgb(224, 224, 224);
            m_textInput.Selection.BackColorUnfocused = Color.FromArgb(240, 240, 240);
            ni.SetWrapMode((int)WrapMode.Word);
            SetWrapAwareHomeEndKeys();
            // disable links, since we operate on the assumption we can simply substitute the contents of <body>
            m_webBrowser.AllowNavigation = false;
            UpdateWindowTitle();
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="f">The parent formatter.</param>
 public FormatterState(TextileFormatter formatter)
 {
     m_formatter = formatter;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Public constructor.
 /// </summary>
 /// <param name="f">The parent formatter.</param>
 public FormatterState(TextileFormatter formatter)
 {
     m_formatter = formatter;
 }
 internal static string GetConsumedInput(List<Type> disabledFormatterStates, string input, TextileFormatter instance)
 {
     for (int i = 0; i < s_registeredStates.Count; i++)
     {
         Type type = s_registeredStates[i];
         if (!disabledFormatterStates.Contains(type))
         {
             FormatterStateAttribute att = s_registeredStatesAttributes[i];
             Match m = Regex.Match(input, att.Pattern);
             if (m.Success)
             {
                 FormatterState formatterState = (FormatterState) Activator.CreateInstance(type, instance);
                 return formatterState.Consume(input, m);
             }
         }
     }
     return null;
 }
 /// <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();
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 public WikiRenderer()
 {
     output = new StringBuilderTextileFormatter();
     formatter = new TextileFormatter(output);
 }
Ejemplo n.º 13
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);
            }
        }
 internal static string GetConsumedInput(List <Type> disabledFormatterStates, string input, TextileFormatter instance)
 {
     for (int i = 0; i < s_registeredStates.Count; i++)
     {
         Type type = s_registeredStates[i];
         if (!disabledFormatterStates.Contains(type))
         {
             FormatterStateAttribute att = s_registeredStatesAttributes[i];
             Match m = Regex.Match(input, att.Pattern);
             if (m.Success)
             {
                 FormatterState formatterState = (FormatterState)Activator.CreateInstance(type, instance);
                 return(formatterState.Consume(input, m));
             }
         }
     }
     return(null);
 }