Project Directory Structure

The project is organized into the following directory structure:

Image ./: Contains the base application files and supporting folders. This is the project root.

Image ../node_modules: Created when the NPMs listed above are installed in the system.

Image ./controllers: Contains the Express route controllers that provide the interaction between routes and changes to the MongoDB database.

Image ./models: Contains the Mongoose model definitions for objects in the database.

Image ./static: Contains any static files that need to be sent, such as CSS and AngularJS code.

Image ./views: Contains the HTML templates that will be rendered by EJS.


Note

This is just one method of organizing your code. You do not have to follow this directory structure, but keep in mind that directory structure should be part of the overall design of your projects so that you can easily find the code you are looking for.


In addition to the directory structure, the following code files are included. This list is intended to give you an idea of the functionality of each file:

Image ./comment_init.js: Provides standalone initialization code for this example. It adds the initial page object and several photos to the MongoDB database to initialize the project.

Image ./comment_server.js: Loads the necessary libraries, creates a connection to MongoDB, and starts the Express server. This is the main application file.

Image ./comment_routes.js: Defines the routes for the Express server. This file handles functionality that does not apply to the database.

Image ./controllers/comments_controller.js: Defines the functionality for the routes that require interaction with the MongoDB database to get and update comments.

Image ./controllers/pages_controller.js: Defines the functionality for the routes that require interaction with the MongoDB database to get the page objects.

Image ./controllers/photos_controller.js: Defines the functionality for the routes that require interaction with the MongoDB database to get one or all of the photo objects.

Image ./models/comments_model.js: Defines the comment object model.

Image ./models/page_model.js: Defines the comment page model.

Image ./models/photo_model.js: Defines the comment photo model.

Image ./views/photos.html: Provides the main photo page for the application that will allow users to select photos and add comments to the page or to an individual photo.

Image ./static/comment.html: Allows nested comments to be displayed, using the ng-repeat directive. This is an AngularJS partial template.

Image ./static/comment_thread.html: Provides the framework for adding a comment thread to different locations on the webpage. This is an AngularJS partial template.

Image ./static/js/comment_app.js: Provides the AngularJS module and controller definitions to handle getting the page, photo, and comment objects from the servers as well as saving new comments.

Image ./static/css/comment_styles.css: Provides the CSS styling for the AngularJS HTML pages.

Image ../images: A folder that contains images used in this example. This folder is a peer to the chapter folder in the book’s code archive.

Image ../lib: A folder that contains the necessary AngularJS library files used in this example. This folder is a peer to the chapter folder in the book’s code archive.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.29.105