uclaradio / uclaradio.com

UCLA Radio Website
http://www.uclaradio.com
GNU Affero General Public License v3.0
31 stars 4 forks source link

Blog Deploy with Loading Icon #338

Closed tanzeelak closed 5 years ago

tanzeelak commented 5 years ago

** Copied and pasted from the original PR. Only difference is that we added a Loading Icon because blog posts were taking time to load.

Types of changes

Purpose

DigiPress wants to move off of Tumblr. We created a blog from within UCLA Radio. Users can make posts from KeystoneJS's Admin UI. Old posts from Tumblr are also compiled into the new blog. They have been categorized via machine learning. The same categories are used in the new Admin UI.

Approach

Mia categorized old tumblr posts using machine learning with app/database/scripts/augment_training_set.py. Her original input came from the JSON object generated by app/database/scripts/addTumblrPosts.js, which fetches all the Tumblr posts and stores them in the database.

When a user goes to /blog (BlogPage.js), the /getBlogPosts (index.js) route is called. This fetches all the Keystone posts from the deployed KeystoneJS API and the stored Tumblr posts which are in MongoDB. We modified all the post objects to include their original platform "KEYSTONE" or "TUMBLR" and to include a category object for filtering. These posts are displayed with some g00d ole styling on /blog.

The filter bar (BlogFilterBar.js) essentially keeps track of an array of toggleable filters. The current state of the array is sent back to BlogPage.js, which filters the fetched blogposts object based on the active filters. The search bar (BlogSearch.js) dynamically searches through all the fetched blogposts, resetting the pagination (Pagination.js) component to 1 each time. Users can add only numerical input to pagination.

Keystone Posts are parsed manually. Admin Users are instructed to include images as <Image#> in the content object. The images are fetched as separate parts of the post object. The post's content object is parsed to replace all <*> with their corresponding image.

Updated the README for new blog development instructions.

Testing

  1. Install package.json: yarn
  2. Run mongod: in one terminal: mongod
  3. Delete the blogposts object from the mongo shell: in a second terminal: mongo use uclaradio db.blogposts.drop() Ctrl+C
  4. Download the NEW categorized-blogposts.json from Google Drive
  5. Import the new file into the database: yarn fill-blog-db
  6. Start the server yarn dev. Navigate to localhost:3000/blog.
  7. Test filters, search, pagination, and blog post pages by clicking around.

Screenshot(s)

Filtering

screen shot 2019-03-06 at 11 46 13 am

Checklist

Link to Issue

#331