karthik25 / sblog.net

sBlog.Net is a minimalistic blog engine created using the ASP.Net MVC 4 framework
http://sblogproject.net
BSD 3-Clause "New" or "Revised" License
117 stars 61 forks source link

more robust post entity #7

Open nmolzach opened 10 years ago

nmolzach commented 10 years ago

hello, just a suggestion as i am going to try my hand at implementing this myself. but i think a more robust post entity would be nice and allow alternate layouts depending on what sort of stuff was attached to the post. i.e. specifically, a table for files associated with the post.

with that, you could create downloadable assets associated with the post, add banner graphics to a post, and also have an easy way to embed videos associated with the post.

Something like the following:

on the post:


public List<AttachmentEntity> Attachments { get; set; }

namespace sBlog.Net.Domain.Entities
{
    [Table(Name = "Attachments")]
    public class AttachmentEntity
    {
        [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
        public int AttachmentId { get; set; }
        [Column] 
        public int PostID { get; set; }
        [Column] 
        public string AttachmentName { get; set; }
        [Column]
        public string AttachmentType { get; set; }
        [Column]
        public string AttachmentPath { get; set; }
        [Column]
        public PostContextType PostContext { get; set; } 
    }

    public enum PostContextType //context of the post, is this for a banner?  a main content video?  downloadable asset?
    {
        Video,
        Banner,
        Downloadable
    }
}

Also, you could store the entire file in the db as a byte array and decode the context on the other side for secured files...

nmolzach commented 10 years ago

also, if this is not the place for this stuff, i'll post where it should be if you let me know where :)

karthik25 commented 10 years ago

Hello Zach,

This is an excellent idea!!! Feel free to give a pull request and I will check and merge it w/ the master branch (if you're interested)! Initially when I was designing the attachments part I thought about this, but since one attachment could be used across multiple posts I wanted to avoid that complexity, I ignored this at that point, to get the project released :). But this would definitely be a value add now! If you're interested let me know!