Exemple #1
0
 public IBarelyView Edit(BlogRouteModel route, BlogEntryData data)
 {
     var entry=BlogEntryData.Get(route.Date);
     if(Method!=HttpMethod.Post)
     {
         //first diplay the page
         var v=new ModifyBlogView();
         v.Entry=entry;
         v.Layout.Title="Editing '"+entry.Title+"'";
         return v;
     }
     else
     {
         //then receive the form and store it
         data.ID=entry.ID; //set ID so mongodb can find it (and update it instead of create)
         data.Posted=entry.Posted;
         if(!entry.Publish && data.Publish){ //if not previously published, update the time so it's "bumped"
             data.Posted=DateTime.Now; //this shouldn't have any SEO implications unless I unpublish and then republish.
         }
         data.Edited=DateTime.Now;
         BetterCache.Remove<string>(data.ID.ToString());
         data.Save();
         Response.Redirect(GetUrl(data));
         return null; //never actually reaches here
     }
 }
Exemple #2
0
        public static MongoCursor <CommentData> ForEntry(BlogEntryData entry)
        {
            var comments = Collection().FindAs <CommentData>(Query.EQ("EntryID", entry.ID))
                           .SetSortOrder(SortBy.Ascending("Posted"));

            return(comments);
        }
Exemple #3
0
        public static string GetUrl(BlogEntryData entry, string action)
        {
            //return "/view/"+entry.ID.ToString();
            DateTime tmp=entry.Posted.ToUniversalTime();
            string date=tmp.Year+"/"+tmp.Month.ToString().PadLeft(2,'0')+"/"+tmp.Day.ToString().PadLeft(2,'0')+"/"
                + tmp.Hour.ToString().PadLeft(2,'0') + tmp.Minute.ToString().PadLeft(2,'0');

            return "/"+action+"/"+date+"/"+Routing.Slugify(entry.Title);
        }
Exemple #4
0
 public static string GetFullUrl(BlogEntryData entry)
 {
     string host=Config.HostName;
     if(string.IsNullOrEmpty(host))
     {
         host=Request.Url.Host;
     }
     return "http://"+host+GetUrl(entry);
 }
Exemple #5
0
 public static int CountForEntry(BlogEntryData entry)
 {
     return((int)ForEntry(entry).Count());
 }
Exemple #6
0
 public BlogEntryData GetOwner()
 {
     //todo: can cache!
     return(BlogEntryData.Get(EntryID));
 }
Exemple #7
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>");

        }
Exemple #8
0
 public static string GetUrl(BlogEntryData entry)
 {
     return GetUrl(entry, "view");
 }
Exemple #9
0
 public static string GetTweet(BlogEntryData entry)
 {
     return "data-url=\""+HttpUtility.HtmlAttributeEncode(GetFullUrl(entry))+"\" data-text=\""+HttpUtility.HtmlAttributeEncode(entry.Title)+"\" data-via=\"earlzdotnet\"";
 }
Exemple #10
0
 public IBarelyView New(BlogEntryData data)
 {
     if(Method!=HttpMethod.Post)
     {
         var v=new ModifyBlogView();
         v.Layout.Active="home";
         return v;
     }
     else
     {
         data.Posted=DateTime.Now;
         data.Edited=DateTime.Now;
         data.Save();
         Response.Redirect(GetUrl(data));
         return null;
     }
 }