Пример #1
0
 /// <summary>
 /// デシリアライズ時に呼ばれるコンストラクタ
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 public BoardInfo(SerializationInfo info, StreamingContext context)
 {
     this.bbs    = (BbsType)info.GetValue("Bbs", typeof(BbsType));
     this.name   = HtmlTextUtility.RemoveTag(info.GetString("Name"));
     this.path   = info.GetString("Path");
     this.server = info.GetString("Server");
 }
Пример #2
0
 /// <summary>
 /// BoardInfoクラスのインスタンスを初期化
 /// </summary>
 /// <param name="server">サーバーアドレス</param>
 /// <param name="path">板へのパス</param>
 /// <param name="name">板名</param>
 public BoardInfo(string server, string path, string name)
     : this()
 {
     this.server = server;
     this.path   = path;
     this.name   = HtmlTextUtility.RemoveTag(name);
     this.bbs    = Parse(server);
 }
Пример #3
0
        /// <summary>
        /// 指定したResSetを
        /// 設定されているスキンを使用して文字列形式に変換
        /// </summary>
        /// <param name="resSet"></param>
        /// <returns></returns>
        protected virtual string Convert(string skinhtml, ResSet resSet)
        {
            StringBuilder sb = new StringBuilder(2048);
            string        name;
            string        mailname;
            string        dateonly, dateString;
            string        body;

            #region  前の作成
            sb.Append("<b>");
            sb.Append(resSet.Name);
            sb.Append("</b>");
            name = sb.ToString();
            sb.Remove(0, sb.Length);
            #endregion

            #region Email付き名前の作成
            if (resSet.Email != String.Empty)
            {
                sb.Append("<a href=\"mailto:");
                sb.Append(resSet.Email);
                sb.Append("\">");
                sb.Append(name);
                sb.Append("</a>");
                mailname = sb.ToString();
                sb.Remove(0, sb.Length);
            }
            else
            {
                mailname = name;
            }
            #endregion

            #region 日付とIDを作成
            dateString = resSet.DateString;
            dateonly   = resSet.DateString;
            Match m = Regex.Match(resSet.DateString, "( ID:)|(\\[)");

            if (m.Success)
            {
                dateonly = resSet.DateString.Substring(0, m.Index);
            }
            #endregion

            #region Be2chIDのリンクを貼る
            // BE:0123456-# または <BE:0123456:0> 形式の二つあるみたい
            dateString =
                Regex.Replace(dateString, @"BE:(?<id>\d+)\-(?<rank>.+)",
                              "<a href=\"http://be.2ch.net/test/p.php?i=${id}\" target=\"_blank\">?${rank}</a>", RegexOptions.IgnoreCase);

            dateString =            // 面白ネタnews形式
                         Regex.Replace(dateString, @"<BE:(?<id>\d+):(?<rank>.+)>",
                                       "<a href=\"http://be.2ch.net/test/p.php?i=${id}\" target=\"_blank\">Lv.${rank}</a>", RegexOptions.IgnoreCase);
            #endregion

            #region 本分を作成
            body = HtmlTextUtility.RemoveTag(resSet.Body, "a");
            body = HtmlTextUtility.Linking(body);
            #endregion

            #region レス参照を作成
            body = HtmlTextUtility.RefRegex.Replace(body, "<a href=\"" + baseUri + "${num}\" target=\"_blank\">${ref}</a>");
            body = HtmlTextUtility.ExRefRegex.Replace(body, "<a href=\"" + baseUri + "${num}\" target=\"_blank\">${num}</a>");
            #endregion

            sb.Remove(0, sb.Length);
            sb.Append(skinhtml);
            sb.Replace("<PLAINNUMBER/>", resSet.Index.ToString());
            sb.Replace("<NUMBER/>", resSet.Index.ToString());
            sb.Replace("<MAILNAME/>", mailname);
            sb.Replace("<ID/>", resSet.ID);
            sb.Replace("<BE/>", resSet.BeLink);
            sb.Replace("<NAME/>", name);
            sb.Replace("<MAIL/>", resSet.Email);
            sb.Replace("<DATE/>", dateString);
            sb.Replace("<DATEONLY/>", dateonly);
            sb.Replace("<MESSAGE/>", body);
            sb.Replace("<SKINPATH/>", skinPath);

            skinhtml = sb.ToString();

            return(skinhtml);
        }
Пример #4
0
        /// <summary>
        /// 指定したResSetを
        /// 設定されているスキンを使用して文字列形式に変換
        /// </summary>
        /// <param name="resSet"></param>
        /// <returns></returns>
        public override string Convert(ResSet resSet)
        {
            if (!resSet.Visible)
            {
                return(String.Empty);
            }

            if (resSet.DateString == "透明あぼーん")
            {
                return(String.Empty);
            }

            /*
             * if (resSet.IsABone) {
             *      resSet = ResSet.ABone(resSet, ABoneType.NG, "");
             *      resSet.Email = String.Empty;
             * }*/

            // 使用するスキン
            string skinhtml = resSet.IsNew ? newResSkin : resSkin;
            string dateonly, body;

            // 本分からtagを取り除く
            body = resSet.Body;
            body = Regex.Replace(body, "<a[^>]+>(?<uri>[^<]*)</a>", "${uri}", RegexOptions.IgnoreCase);
            body = Regex.Replace(body, "<(?!br|hr)[^>]+>", "");

            buffer.Append(body);
            buffer.Replace("<br>", "\r\n");
            buffer.Replace("<hr>", "\r\n ————————————————————\r\n");
            buffer.Replace("&gt;", ">");
            buffer.Replace("&lt;", "<");
            body = buffer.ToString();
            buffer.Remove(0, buffer.Length);

            #region 日付とIDを作成
            dateonly = resSet.DateString;
            Match m = Regex.Match(resSet.DateString, "( ID:)|(\\[)");

            if (m.Success)
            {
                dateonly = resSet.DateString.Substring(0, m.Index);
            }
            #endregion

#if REGEX_REPLACE
            skinhtml = PlainNumberRegex.Replace(skinhtml, resSet.Index.ToString());
            skinhtml = IDRegex.Replace(skinhtml, resSet.ID);
            skinhtml = NameRegex.Replace(skinhtml, resSet.Name);
            skinhtml = EmailRegex.Replace(skinhtml, resSet.Email);
            skinhtml = DateRegex.Replace(skinhtml, resSet.DateString);
            skinhtml = DateOnlyRegex.Replace(skinhtml, dateonly);
            skinhtml = BodyRegex.Replace(skinhtml, body);
#else
            buffer.Append(skinhtml);
            buffer.Replace("<PLAINNUMBER/>", resSet.Index.ToString());
            buffer.Replace("<ID/>", resSet.ID);
            buffer.Replace("<NAME/>", HtmlTextUtility.RemoveTag(resSet.Name));
            buffer.Replace("<MAIL/>", resSet.Email);
            buffer.Replace("<DATE/>", resSet.DateString);
            buffer.Replace("<DATEONLY/>", dateonly);
            buffer.Replace("<MESSAGE/>", body);
            skinhtml = buffer.ToString();
            buffer.Remove(0, buffer.Length);
#endif

            return(skinhtml);
        }
Пример #5
0
        private StringBuilder CreateHtml(string skinhtml, ResSet resSet)
        {
            StringBuilder sb = new StringBuilder(2048);
            string        number;
            string        name;
            string        mailname;
            string        dateonly, dateString;
            string        body;

            #region メニュー付き番号の作成
            int iPos = -1;

            sb.Append("<a href=\"menu:");
            sb.Append(resSet.Index);
            sb.Append("\" name=\"");
            sb.Append(resSet.Index);
            sb.Append("\" target=\"_blank\">");
            iPos = sb.Length;
            sb.Append(resSet.Index);

            if (resSet.IsServerAboned)
            {
                sb.Insert(iPos, "<font color=lime><i>");
                sb.Append("</i></font>");
            }

            sb.Append("</a>");

            number = sb.ToString();
            sb.Remove(0, sb.Length);
            #endregion

            #region  前の作成
            sb.Append("<b>");
            sb.Append(resSet.Name);
            sb.Append("</b>");
            name = sb.ToString();
            sb.Remove(0, sb.Length);
            #endregion

            #region  前欄ポップアップ
            string _resName = String.Empty;
            if (!String.IsNullOrEmpty(resSet.Name))
            {
                if (namePopup && Char.IsDigit(resSet.Name[resSet.Name.Length - 1]))
                {
                    _resName = Regex.Replace(resSet.Name, ">|>|&gt;", String.Empty);
                }
            }

            // 名前欄が数字ならリンクを貼る
            if (namePopup && HtmlTextUtility.IsDigit(_resName))             // 最後の文字が数字のときのみ処理する
            {
                sb.Append("<a href=\"");
                sb.Append(baseUri);
                sb.Append(HtmlTextUtility.ZenToHan(_resName));
                sb.Append("\" target=\"_blank\">");
                sb.Append(name);
                sb.Append("</a>");
                name     = sb.ToString();
                mailname = name;
                sb.Remove(0, sb.Length);
            }
            #endregion

            #region Email付き名前の作成
            else if (resSet.Email != String.Empty)
            {
                sb.Append("<a href=\"mailto:");
                sb.Append(resSet.Email);
                sb.Append("\">");
                sb.Append(name);
                sb.Append("</a>");
                mailname = sb.ToString();
                sb.Remove(0, sb.Length);
            }
            else
            {
                mailname = name;
            }
            #endregion

            #region 日付とIDを作成
            dateString = resSet.DateString;
            dateonly   = resSet.DateString;
            Match m = Regex.Match(resSet.DateString, @"\d{2,4}/\d{2}/\d{2}(\(\w\))?\s\d{2}:\d{2}(:\d{2}.\d{2}|:\d{2})?(\s[0-9a-zA-GJ-Z])?");

            if (m.Success)
            {
                dateonly = m.Value;
            }
            #endregion

            #region Be2chIDのリンクを貼る
            // BE:0123456-# または <BE:0123456:0> 形式の二つあるみたい
            dateString =
                Regex.Replace(dateString, @"BE:(?<id>\d+)\-(?<rank>.+)",
                              "<a href=\"http://be.2ch.net/test/p.php?i=${id}\" target=\"_blank\">?${rank}</a>", RegexOptions.IgnoreCase);

            dateString =            // 面白ネタnews形式
                         Regex.Replace(dateString, @"<BE:(?<id>\d+):(?<rank>.+)>",
                                       "<a href=\"http://be.2ch.net/test/p.php?i=${id}\" target=\"_blank\">Lv.${rank}</a>", RegexOptions.IgnoreCase);
            #endregion

            #region 本分を作成
            body = HtmlTextUtility.RemoveTag(resSet.Body, "a|font");
            body = rexBRSpace.Replace(body, "<BR>");
            body = HtmlTextUtility.Linking(body);
            #endregion

            #region レス参照を作成
            body = HtmlTextUtility.RefRegex.Replace(body, "<a href=\"" + baseUri + "${num}\" target=\"_blank\" name=\"res" + resSet.Index + "_ref${num}\">${ref}</a>");
            // body = HtmlTextUtility.ExRefRegex.Replace(body, "<a href=\"" + baseUri + "${num}\" target=\"_blank\">${num}</a>");  // 2011.12.16 水玉さん
            #endregion

            #region そのほかの置き換え処理
            sb.Remove(0, sb.Length);
            sb.Append(skinhtml);
            sb.Replace("<PLAINNUMBER/>", resSet.Index.ToString());
            sb.Replace("<MAILNAME/>", mailname);
            sb.Replace("<NUMBER/>", number);
            sb.Replace("<ID/>", resSet.ID);
            sb.Replace("<BE/>", resSet.BeLink);
            sb.Replace("<NAME/>", name);
            sb.Replace("<MAIL/>", resSet.Email);
            sb.Replace("<DATE/>", dateString);
            sb.Replace("<DATEONLY/>", dateonly);
            sb.Replace("<MESSAGE/>", body);
            sb.Replace("<SKINPATH/>", skinPath);
            sb.Replace("<HOST/>", resSet.Host);
            #endregion

            return(sb);
        }