mardi 5 mai 2015

How to store data for my complex web app, similar to JS Fiddle

I'm designing a web app and I'd like to make sure that my data model will work and can grow. If anyone knows any resources or standards I should follow, I'd appreciate that too. Basically, it's a complex note application with the following pieces:

I have things called chapters, the user can only see one chapter at a time. A chapter consists of 2 parts : pages and comments.

The left half of the window houses the pages (there can be multiple pages). For sake of simplicity, a page is just a string of text.

The right half will contain the comments. In other words, when a user selects a certain sentence in a page, a comment will pop up.

I'd like to have as many of these chapters as necessary, and I haven't come up with a navigational structure but I suspect I'll need to be able to group chapters together.

Right now, how I was thinking about it was having an array for each chapter so it looks like this:

[
    {
        "page": "asd",
        "comments": another array
    },
    {
        "page": "random string, will include html elements"
        "comments": another array
    }
]

I'm using angular JS and using ng-repeat to loop through this array and display all the pages. Then depending on which comment the user clicks on, the selected comment will show up on the right side.

So I don't have a unique id for each chapter- is there a standard way? I also think I need some kind of id for comments, since there can be many comments per page. I was looking into guid's but I've never used them before.

I was thinking of having this comments array:

"comments": [ {"id": "guid", "comment":"asfasfd"}, {"id": "guid", "comment":"asfasfd"}]

I also wanted to assign a guid for each chapter. For testing, I was going to keep all the chapters in one json file.

What is generally done for stuff like this? For example, how does JS Fiddle store it's data? I assume there are chunks for the html, the JS and the CSS, along with metadata, but I'm not sure how their data model actually looks like.

Aucun commentaire:

Enregistrer un commentaire