Exemplo n.º 1
0
        public S1Post GetData()
        {
            var data = raw.Parse<ThreadVariables>();
            if (S1Resource.FormHashUpdater != null)
                S1Resource.FormHashUpdater.UpdateFormHash(data.Formhash);

            var thread = new S1Post();
            thread.Title = S1Resource.HttpUtility.HtmlDecode(data.Thread.Subject);
            thread.TotalPage = (data.Thread.Replies + DZParserFactory.PostsPerPage)/DZParserFactory.PostsPerPage;
            thread.Items = new List<S1PostItem>();
            thread.ReplyLink = string.Format("?module=sendreply&replysubmit=yes&fid={0}&tid={1}", data.Thread.Fid, data.Thread.Tid);

            foreach (var post in data.Postlist)
            {
                var item = new S1PostItem();
                if (thread.CurrentPage == 0)
                    thread.CurrentPage = post.Number/DZParserFactory.PostsPerPage + 1;
                item.No = post.Number;
                item.Author = S1Resource.HttpUtility.HtmlDecode(post.Author);
                item.Date = S1Resource.HttpUtility.HtmlDecode(post.Dateline);

                BuildContent(post, item);
                thread.Items.Add(item);
            }
            return thread;
        }
Exemplo n.º 2
0
        protected virtual S1PostItem ParseThreadItem(HtmlElement item)
        {
            if (null == (item = item.FindFirst("table")))
            {
                return(null);
            }

            var trs = item.Descendants("tr");

            if (trs.Count() < 2)
            {
                return(null);
            }
            var head = trs.First();

            if (head.Attributes["class"] != "head")
            {
                return(null);
            }

            var threadItem = new S1PostItem();

            threadItem.Author = head.Element().PlainText();
            threadItem.Date   = head.Descendants().Last().PlainText();

            var content = trs.ElementAt(1).Element("td");

            if (content != null)
            {
                threadItem.AddRange(ReGroupContent(content));
            }
            return(threadItem);
        }
Exemplo n.º 3
0
        public S1Post GetData()
        {
            var data = raw.Parse <ThreadVariables>();

            if (S1Resource.FormHashUpdater != null)
            {
                S1Resource.FormHashUpdater.UpdateFormHash(data.Formhash);
            }

            var thread = new S1Post();

            thread.Title     = S1Resource.HttpUtility.HtmlDecode(data.Thread.Subject);
            thread.TotalPage = (data.Thread.Replies + DZParserFactory.PostsPerPage) / DZParserFactory.PostsPerPage;
            thread.Items     = new List <S1PostItem>();
            thread.ReplyLink = string.Format("?module=sendreply&replysubmit=yes&fid={0}&tid={1}", data.Thread.Fid, data.Thread.Tid);

            foreach (var post in data.Postlist)
            {
                var item = new S1PostItem();
                if (thread.CurrentPage == 0)
                {
                    thread.CurrentPage = post.Number / DZParserFactory.PostsPerPage + 1;
                }
                item.No     = post.Number;
                item.Author = S1Resource.HttpUtility.HtmlDecode(post.Author);
                item.Date   = S1Resource.HttpUtility.HtmlDecode(post.Dateline);

                BuildContent(post, item);
                thread.Items.Add(item);
            }
            return(thread);
        }
Exemplo n.º 4
0
        private void BuildContent(PostItem post, S1PostItem item)
        {
            post.Message = post.Message ?? "";

            //work around
            post.Message = post.Message.Replace("<imgwidth=", "<img width=").Replace("\n", "");

            FillAttachment(post);

            var content =
                new HtmlDoc(string.Format("<div>{0}</div>", S1Resource.HttpUtility.HtmlDecode(post.Message)))
                    .RootElement;

            if (content != null)
                item.AddRange(SimpleParser.SimpleThreadParser.ReGroupContent(content));
        }
Exemplo n.º 5
0
        private void BuildContent(PostItem post, S1PostItem item)
        {
            post.Message = post.Message ?? "";

            //work around
            post.Message = post.Message.Replace("<imgwidth=", "<img width=").Replace("\n", "");

            FillAttachment(post);

            var content =
                new HtmlDoc(string.Format("<div>{0}</div>", S1Resource.HttpUtility.HtmlDecode(post.Message)))
                .RootElement;

            if (content != null)
            {
                item.AddRange(SimpleParser.SimpleThreadParser.ReGroupContent(content));
            }
        }