Пример #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
            }
        }
Пример #2
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
     }
 }
Пример #3
0
        public IBarelyView View(BlogRouteModel route)
        {
            BlogEntryData entry;

            try{
                entry = BlogEntryData.Get(route.Date);
            }catch {
                throw new HttpException(404, "Blog entry not found");
            }
            if (entry == null)
            {
                throw new HttpException(404, "Blog entry not found");
            }
            if (GetUrl(entry) != Request.Url.AbsolutePath)
            {
                PermanentRedirect(GetUrl(entry));
            }
            string text = BetterCache.Get <string>(entry.ID.ToString());

            if (text == null)
            {
                entry.Text = Config.GetMarkdown().Transform(entry.Text);
                BetterCache.Add(entry.ID.ToString(), entry.Text);
            }
            else
            {
                entry.Text = text;
            }
            var v = new BlogEntryView();

            v.Layout.Title = "";
            if (entry.Tags != null)
            {
                v.Layout.Title = entry.Tags[0] + " - ";
            }
            v.Layout.Title += entry.Title + " - Earlz.Net";
#if DEBUG
            v.Layout.Title += "-" + entry.ID.ToString();
#endif
            v.ShowComments = true;
            v.Entry        = entry;
            v.Summary      = false;
            return(v);
        }
Пример #4
0
        public IBarelyView Redirect(BlogRouteModel route)
        {
            var c = Config.GetDB().GetCollection <BlogEntryData>("entries");

            switch (RouteID)
            {
            case "redirect_id":
                BlogEntryData entry;
                try{
                    entry = c.FindOneById(route.ID);
                }catch {
                    throw new HttpException(404, "Blog entry not found");
                }
                if (entry == null)
                {
                    throw new HttpException(404, "Blog entry not found");
                }
                PermanentRedirect(GetUrl(entry));
                break;
            }
            return(null);
        }
Пример #5
0
 public IBarelyView View(BlogRouteModel route)
 {
     BlogEntryData entry;
     try{
         entry=BlogEntryData.Get(route.Date);
     }catch{
         throw new HttpException(404,"Blog entry not found");
     }
     if(entry==null){
         throw new HttpException(404,"Blog entry not found");
     }
     if(GetUrl(entry)!=Request.Url.AbsolutePath)
     {
         PermanentRedirect(GetUrl(entry));
     }
     string text=BetterCache.Get<string>(entry.ID.ToString());
     if(text==null)
     {
         entry.Text=Config.GetMarkdown().Transform(entry.Text);
         BetterCache.Add(entry.ID.ToString(), entry.Text);
     }
     else
     {
         entry.Text=text;
     }
     var v=new BlogEntryView();
     v.Layout.Title="";
     if(entry.Tags!=null)
     {
         v.Layout.Title=entry.Tags[0]+" - ";
     }
     v.Layout.Title+=entry.Title+" - Earlz.Net";
     #if DEBUG
     v.Layout.Title+="-"+entry.ID.ToString();
     #endif
     v.ShowComments=true;
     v.Entry=entry;
     v.Summary=false;
     return v;
 }
Пример #6
0
 public IBarelyView Redirect(BlogRouteModel route)
 {
     var c=Config.GetDB().GetCollection<BlogEntryData>("entries");
     switch(RouteID)
     {
     case "redirect_id":
         BlogEntryData entry;
         try{
             entry=c.FindOneById(route.ID);
         }catch{
             throw new HttpException(404, "Blog entry not found");
         }
         if(entry==null)
         {
             throw new HttpException(404, "Blog entry not found");
         }
         PermanentRedirect(GetUrl(entry));
         break;
     }
     return null;
 }