Exemple #1
0
        public IBarelyView New(string entryid, CommentData post)
        {
            if (Form["Link"] != "")
            {
                return(null);
            }
            post.Name      = post.Name.Substring(0, Math.Min(post.Name.Length, 32));
            post.Text      = post.Text.Substring(0, Math.Min(post.Text.Length, 1024));
            post.IPAddress = Request.UserHostAddress;
            post.UserAgent = Request.UserAgent;
            post.Text      = CheckLines(post.Text);
            if (post.Text == "OOONNNNYYYYTTTTIIIII")
            {
                throw new HttpException(500, "F**k you.");
            }
            BlogEntryData entry = BlogEntryData.Get(entryid);

            if (entry == null)
            {
                throw new HttpException(404, "Blog entry not found");
            }
            post.EntryID = entry.ID;
            post.Posted  = DateTime.Now;
            post.Save();
            BlogEntryData.RecalculateComments(entry.ID);
            Response.Redirect(BlogHandler.GetUrl(entry));
            return(null);
        }
Exemple #2
0
        void BuildOutput()
        {
            __Write(@"");
            __Write(@"");
            __Write(@"
");
            __Write(@"

<div class=""entry"">
<h2><a href=""");
            {
                object __v;


                __v = BlogHandler.GetUrl(Entry);

                __OutputVariable(__v);
            }
            __Write(@""">");
            {
                object __v;


                __v = Entry.Title;

                __OutputVariable(__v);
            }
            __Write(@"</a></h2>
<div>");
            {
                object __v;


                __v = Entry.Text;

                __OutputVariable(__v);
            }
            __Write(@"</div>

<div id=""post-info"">
	<div class=""tags"">Tags: 
	"    );
            foreach (var tag in Entry.Tags)
            {
                __Write(@"
		<a href=""/tags/"        );
                {
                    object __v;


                    __v = tag;

                    __OutputVariable(__v);
                }
                __Write(@""">");
                {
                    object __v;


                    __v = tag;

                    __OutputVariable(__v);
                }
                __Write(@"</a>
	"    );
            }
            __Write(@"
	</div>
	<div class=""timestamp"">Posted: "    );
            {
                object __v;


                __v = Entry.Posted;

                __OutputVariable(__v);
            }
            __Write(@"</div>
	<div class=""twittershare"">
		<a href=""https://twitter.com/share"" "        );
            {
                object __v;


                __v = BlogHandler.GetTweet(Entry);

                __OutputVariable(__v);
            }
            __Write(@" class=""twitter-share-button"">Tweet</a>
	</div>
	"    );
            if (!ShowComments)
            {
                __Write(@"
		<div class=""comment-link""><a href="""        );
                {
                    object __v;


                    __v = BlogHandler.GetUrl(Entry);

                    __OutputVariable(__v);
                }
                __Write(@"#comments"">");
                {
                    object __v;


                    __v = Entry.CommentCount.ToString();

                    __OutputVariable(__v);
                }
                __Write(@" Comments</a></div>
	"    );
            }
            __Write(@"
	</div>
</div>
");
            if (ShowComments)
            {
                __Write(@"	
<div id=""the-comments"">	
<div class=""comments"">
	<h2><a name=""comments"">Comments</a></h2>		
	<div class=""comment-list"">
		"        );
                foreach (var comment in Entry.GetComments())
                {
                    __Write(@"
			<div class=""comment"">
			<div class=""comment-name"">
			"            );
                    {
                        object __v;


                        __v = HttpUtility.HtmlEncode(comment.Name);

                        __OutputVariable(__v);
                    }
                    __Write(@"
			</div>
			<div class=""comment-text"">
				
					"                    );
                    {
                        object __v;


                        __v = "<pre>" + HttpUtility.HtmlEncode(comment.Text) + "</pre>";

                        __OutputVariable(__v);
                    }
                    __Write(@" <!--workaround for a bug in my view generator. Otherwise puts out tabs and extra linefeeds -->
				
			</div>
			<div class=""comment-timestamp"">
			"            );
                    {
                        object __v;


                        __v = HttpUtility.HtmlEncode(comment.Posted.ToString());

                        __OutputVariable(__v);
                    }
                    __Write(@"
			</div>
			"            );
                    if (FSCAuth.ProbablyLoggedIn)
                    {
                        __Write(@"
			<div class=""delete-comment"">
				<form method=""post"" action=""/comment/delete/"                );
                        {
                            object __v;


                            __v = comment.ID.ToString();

                            __OutputVariable(__v);
                        }
                        __Write(@""">
					<input type=""submit"" value=""delete""  />
				</form>
			</div>
			"            );
                    }
                    __Write(@"
			</div>
		"        );
                }
                __Write(@"

		<div class=""comment-form"">	
			"            );
                if (Config.CommentsEnabled)
                {
                    __Write(@"
			<h2>Add a comment</h2>
		<form method=""post"" action=""/comment/"        );
                    {
                        object __v;


                        __v = Entry.ID;

                        __OutputVariable(__v);
                    }
                    __Write(@"/new"">
			<div><label for=""Name"">Name:</label> <input type=""text"" name=""Name"" maxlength=""32"" value=""Anonymous"" /></div>
			<div><label for=""Text""> Comment: </label> <textarea rows=""6"" cols=""92"" name=""Text""></textarea></div>
			<div class=""comment-restrictions"">Everything will be HTML encoded. Only 1024 characters. No more than 20 line breaks </div>
			<span class=""x12"">Honeys: <input type=""text"" name=""Link"" value="""" /></span> <!-- cakes and pies -->
			<span class=""x12"">Fill this in if you're a robot: <input type=""text"" name=""FullName"" value="""" /></span>
			<input type=""submit"" value=""Add Comment"" />
		</form>
			"            );
                }
                else
                {
                    __Write(@"
			<h2>Posting comments is currently disabled(probably due to spam)</h2>
			"            );
                }
                __Write(@"
		</div>
	</div>


</div>
</div>			
");
            }
            __Write(@"			");
        }
Exemple #3
0
        void BuildOutput()
        {
            __Write(@"<!DOCTYPE HTML>
");
            __Write(@"
<html>
	<head>
		<title></title>
	</head>
	<body style=""max-width: 700px"">
		"        );
            foreach (var comment in Comments)
            {
                __Write(@"
			<div>
				</div>By "                );
                {
                    object __v;


                    __v = HttpUtility.HtmlEncode(comment.Name);

                    __OutputVariable(__v);
                }
                __Write(@"</div>
				"                );
                {
                    object __v;


                    __v = "<pre>" + HttpUtility.HtmlEncode(comment.Text) + "</pre>";

                    __OutputVariable(__v);
                }
                __Write(@"
				<div>posted at "                );
                {
                    object __v;


                    __v = HttpUtility.HtmlEncode(comment.Posted.ToString());

                    __OutputVariable(__v);
                }
                __Write(@"
				"                );
                if (FSCAuth.IsAuthenticated())
                {
                    __Write(@"
				<div>IP: "                );
                    {
                        object __v;


                        __v = comment.IPAddress;

                        __OutputVariable(__v);
                    }
                    __Write(@"</div>
				<div>Agent: "                );
                    {
                        object __v;


                        __v = HttpUtility.HtmlEncode(comment.UserAgent);

                        __OutputVariable(__v);
                    }
                    __Write(@"</div>
				"                );
                }
                __Write(@"
				<div><a href="""                );
                {
                    object __v;


                    __v = BlogHandler.GetUrl(comment.GetOwner());

                    __OutputVariable(__v);
                }
                __Write(@""">Go to Comment</a></div>
			</div>
		"        );
            }
            __Write(@"
	</body>
</html>
");
        }
Exemple #4
0
        void BuildOutput()
        {
            __Write(@"");
            __Write(@"");
            __Write(@"
");
            __Write(@"
<div class=""entry"">
");
            if (Entry == null)
            {
                __Write(@"	
<form method=""post"" action=""/new"">
");
            }
            else
            {
                __Write(@"
<form method=""post"" action=""");
                {
                    object __v;


                    __v = BlogHandler.GetUrl(Entry, "edit");

                    __OutputVariable(__v);
                }
                __Write(@""">
");
            }
            __Write(@"

");
            if (Entry == null)
            {
                Entry = new BlogEntryData();
            }
            __Write(@"		
Title: <input type=""text"" name=""Title"" value=""");
            {
                object __v;


                __v = Entry.Title;

                __OutputVariable(__v);
            }
            __Write(@""" /> <br />
Text: <textarea rows=""10"" cols=""80"" name=""Text"">");
            {
                object __v;


                __v = Entry.Text;

                __OutputVariable(__v);
            }
            __Write(@"</textarea><br />
Publish To Index?: <input type=""checkbox"" name=""Publish"" checked=""");
            {
                object __v;


                __v = Entry.Publish ? "yes" : "no";

                __OutputVariable(__v);
            }
            __Write(@""" value=""true"" /><br />
Tags: 
");
            if (Entry.Tags != null)
            {
                __Write(@"
	<input type=""text"" name=""Tags"" value="""    );
                foreach (var tag in Entry.Tags)
                {
                    __Write(@"");
                    {
                        object __v;


                        __v = tag;

                        __OutputVariable(__v);
                    }
                    __Write(@" ");
                }
                __Write(@""" />
");
            }
            else
            {
                __Write(@"
	<input type=""text"" name=""Tags"" value="""" />
");
            }
            __Write(@"
<br />
<input type=""submit"" value=""Submit"" />
</form>
</div>");
        }