Skip to content

a3-Beatrimo-Sizhe Li #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
USER="sizheli"
PASS="a89IblxEVumqBScl"
HOST="cluster0.wmbk7c6.mongodb.net"
PORT=3000
GITHUB_ID="216e302e6a21aba13aaa"
GITHUB_SECRET="89a0bb89fd2eda0289b8734cf47da54de9d99fcc"
1 change: 1 addition & 0 deletions .glitchdotcom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"appType":"node","buildDirectory":null}
Empty file added .node-gyp
Empty file.
138 changes: 36 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,50 @@
Assignment 3 - Persistence: Two-tier Web Application with Database, Express server, and CSS template
===
# Assignment 3 - Persistence: Two-tier Web Application with Database, Express server, and CSS template

Due: September 22nd, by 11:59 AM.
## Project Link

This assignnment continues where we left off, extending it to use the most popular Node.js server framework (express),
a database (mongodb), and a CSS application framework / template of your choice (Boostrap, Material Design, Semantic UI, Pure etc.)
Link: [https://a3-sizheli-persistence.glitch.me](https://a3-sizheli-persistence.glitch.me)

Baseline Requirements
---
Test account: tester

Your application is required to implement the following functionalities:

- a `Server`, created using Express (no alternatives will be accepted for this assignment)
- a `Results` functionality which shows all data associated with a logged in user (except passwords)
- a `Form/Entry` functionality which allows users to add, modify, and delete data items (must be all three!) associated with their user name / account.
- Use of at least five [Express middleware packages](https://expressjs.com/en/resources/middleware.html). Explore! One of these five middleware
can be a custom function that you write yourself; if you choose to do this, make sure to describe what this function is in your README.
- Persistent data storage in between server sessions using [mongodb](https://www.mongodb.com/cloud/atlas)
- Use of a [CSS framework or template](https://github.com/troxler/awesome-css-frameworks).
This should do the bulk of your styling/CSS for you and be appropriate to your application.
For example, don't use [NES.css](https://nostalgic-css.github.io/NES.css/) (which is awesome!) unless you're creating a game or some type of retro 80s site.

Your application is required to demonstrate the use of the following concepts:

HTML:
- HTML input tags and form fields of various flavors (`<textarea>`, `<input>`, checkboxes, radio buttons etc.)
- HTML that can display all data *for a particular authenticated user*. Note that this is different from the last assignnment, which required the display of all data in memory on the server.

Note that it might make sense to have two pages for this assignment, one that handles login / authentication, and one that contains the rest of your application.
For example, when visiting the home page for the assignment, users could be presented with a login form. After submitting the login form, if the login is
successful, they are taken to the main application. If they fail, they are sent back to the login to try again. For this assignment, it is acceptable to simply create
new user accounts upon login if none exist, however, you must alert your users to this fact.

CSS:
- CSS styling should primarily be provided by your chosen template/framework.
Oftentimes a great deal of care has been put into designing CSS templates;
don't override their stylesheets unless you are extremely confident in your graphic design capabilities.
The idea is to use CSS templates that give you a professional looking design aesthetic without requiring you to be a graphic designer yourself.

JavaScript:
- At minimum, a small amount of front-end JavaScript to get / fetch data from the server.
See the [previous assignment](https://github.com/cs4241-19a/a2-shortstack) for reference.

Node.js:
- A server using Express, at least five pieces of Express middleware, and a persistent database (mongodb).

General:
- Your site should achieve at least 90% on the `Performance`, `Best Practices`, `Accessibility`, and `SEO` tests
using Google [Lighthouse](https://developers.google.com/web/tools/lighthouse) (don't worry about the PWA test, and don't worry about scores for mobile devices).
Test early and often so that fixing problems doesn't lead to suffering at the end of the assignment.

Deliverables
---
Test password: 12345

Do the following to complete this assignment:
This app is a website for sharing user reviews of any video game played. Users can manually enter relevant information to enter a game review, and the system will generate corresponding recommendations based on the player's score. Players can browse existing reviews directly by clicking on "see reviews" in the center of the screen. Users can also delete or edit their own published reviews.

1. Implement your project with the above requirements. A good potential starting point is to use the "hello-express" project template inside of Glitch; this appears as an option when you hit the "New Project" button. Use the work you did in the last assignment as a reference to implement functionality.
2. If you developed your project locally, deploy your project to Glitch (unless completing the alternative server technical acheivement described below), and fill in the appropriate fields in your package.json file.
3. Test your project to make sure that when someone goes to your main page on Glitch, it displays correctly.
4. Ensure that your project has the proper naming scheme `a3-yourfirstname-yourlastname` so we can find it.
5. Fork this repository and modify the README to the specifications below.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a3-firstname-lastname`.
I use a lot of CSS positioning techniques, including but not limited to: padding, margin, margin-left/right/top/bottom, display:flex,align-itms,height,weight,justify-content, text-align, vertical-align.
CSS framework I used was bootstrap 5.1.1.

Acheivements
---
Middleware used:

Below are suggested technical and design achievements. You can use these to help boost your grade up to an A and customize the
assignment to your personal interests, for a maximum twenty additional points and a maximum grade of a 100%.
These are recommended acheivements, but feel free to create/implement your own... just make sure you thoroughly describe what you did in your README,
why it was challenging, and how many points you think the achievement should be worth.
ALL ACHIEVEMENTS MUST BE DESCRIBED IN YOUR README IN ORDER TO GET CREDIT FOR THEM.
- serve-static to display login page on default
- express-session, to make sure a user doesn't have to log in every time
- cookie-seesion
- body-parser, to provide JSON flexibility for HTTP requests
- mongoose, to provide wrapper for accessing Mongo with a schema for survey response
- passport

*Technical*
- (10 points) Implement OAuth authentication, perhaps with a library like [passport.js](http://www.passportjs.org/).
*You must either use Github authenticaion or provide a username/password to access a dummy account*.
Course staff cannot be expected, for example, to have a personal Facebook, Google, or Twitter account to use when grading this assignment.
Please contact the course staff if you have any questions about this. THIS IS THE HARDEST ACHEIVEMENT OFFERED IN WEBWARE. You have been warned!
- (5 points) Instead of Glitch, host your site on a different service like [Heroku](https://www.heroku.com) or [Digital Ocean](https://www.digitalocean.com). Make sure to describe this a bit in your README. What was better about using the service you chose as compared to Glitch? What (if anything) was worse?
- (5 points) Get 100% (not 98%, not 99%, but 100%) in all four lighthouse tests required for this assignment.

*Design/UX*
- (10 points) Make your site accessible using the [resources and hints available from the W3C](https://www.w3.org/WAI/), Implement/follow twelve tips from their [tips for writing](https://www.w3.org/WAI/tips/writing/), [tips for designing](https://www.w3.org/WAI/tips/designing/), and [tips for development](https://www.w3.org/WAI/tips/developing/). *Note that all twelve must require active work on your part*.
For example, even though your page will most likely not have a captcha, you don't get this as one of your twelve tips to follow because you're effectively
getting it "for free" without having to actively change anything about your site.
Contact the course staff if you have any questions about what qualifies and doesn't qualify in this regard.
List each tip that you followed and describe what you did to follow it in your site.
- (5 points) Describe how your site uses the CRAP principles in the Non-Designer's Design Book readings.
Which element received the most emphasis (contrast) on each page?
How did you use proximity to organize the visual information on your page?
What design elements (colors, fonts, layouts, etc.) did you use repeatedly throughout your site?
How did you use alignment to organize information and/or increase contrast for particular elements.
Write a paragraph of at least 125 words *for each of four principles* (four paragraphs, 500 words in total).

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your glitch (or alternative server) link e.g. http://a3-charlie-roberts.glitch.me

Include a very brief summary of your project here. Images are encouraged, along with concise, high-level text. Be sure to include:

- the goal of the application
- challenges you faced in realizing the application
- what authentication strategy you chose to use and why (choosing one because it seemed the easiest to implement is perfectly acceptable)
- what CSS framework you used and why
- include any modifications to the CSS framework you made via custom CSS you authored
- the five Express middleware packages you used and a short (one sentence) summary of what each one does. If you use a custom function for *one* (and one alone) middleware please
add a little more detail about what it does.
- Persistent data storage in between server sessions using [mongodb](https://www.mongodb.com/cloud/atlas)

## Technical Achievements
- **Tech Achievement 1**: I used OAuth authentication via the GitHub strategy

- **Tech Achievement 1** (10 points):
I used OAuth authentication via the GitHub strategy.
I also used OAuth authentication via providing a dummy account (your can register your own account.)
- **Tech Achievement 3** (5 points): Here are the lighthouse scores:

### Design/Evaluation Achievements
- **Design Achievement 1**: I followed the following tips from the W3C Web Accessibility Initiative...

- **Design Achievement 1**:

1. Provided sufficient contrast between foreground text and background colors so user can read.
2. Provided clear and consistent navigation options for users to add/edit/delete responses
3. Associated a label with every form control for response entry and edit
4. Kept content clear and concise, when adding response, only add form shows up; same for editing
5. Provided easily identifiable feedback: when user does not enter all fields, warning window pops up
6. Provide informative, unique page titles - my pages have title associated with the content, such as login, response table, edit table
7. Ensure that all interactive elements are keyboard accessible - You may use tab and enter to navigate the website
8. Ensure that form elements include clearly associated labels - The labels and placeholders to the all input fields clearly tell you what you should input
9. Ensure that interactive elements are easy to identify - in login and register page, the sign-in and create buttons really stand out with a green color on a frosted glass. Same for the edit page.
10. Use headings to convey meaning and structure:Use short headings to group related paragraphs and clearly describe the sections, include separate response area and response table on edit page; login and register section on login page
11. Write meaningful text alternatives for images
12. Associate a label with every form control-The labels used in the website basically follow this principle
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "a3-sizhe-li",
"version": "1.0",
"description": "",
"author": "Sizhe Li",
"scripts": {
"start": "node server.improved.js"
},
"engines": {
"node": ">=12.0.0"
},
"dependencies": {
"body-parser": "^1.19.0",
"connect-timeout": "^1.9.0",
"cookie-parser": "^1.4.5",
"cookie-session": "^1.4.0",
"dotenv": "^10.0.0",
"envkey": "^1.3.1",
"express": "^4.17.1",
"mime": "^2.4.4",
"mongodb": "^4.1.2",
"mongoose": "^6.0.7",
"node": "^16.10.0",
"passport": "^0.5.0",
"passport-github2": "^0.1.12",
"request": "^2.88.2",
"serve-static": "^1.14.1",
"text-encoder": "^0.0.4"
}
}
193 changes: 193 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
/*Style your own assignment! This is fun! */

body{padding: 4.5rem;
margin: 0;
background: #edc0bf;

background: linear-gradient(217deg, rgba(255,0,0,.8), rgba(255,0,0,0) 70.71%),
linear-gradient(127deg, rgba(0,255,0,.8), rgba(0,255,0,0) 70.71%),
linear-gradient(336deg, rgba(0,0,255,.8), rgba(0,0,255,0) 70.71%);
background-position: center center;
background-repeat: no-repeat;
background-attachment:fixed;
background-size: cover;
font-family: 'Inter', sans-serif;}


table {
border-collapse: collapse;
border: 2px solid black;
letter-spacing: 1px;
width: 90%;
}

th, td {
border: 1px solid;
padding: 20px;
}


#blogText {
margin-left: 100px;
margin-right: 100px;
padding: 10px;
line-height: 1.6;
text-indent:2em;
}

#buttons {
display: flex;
background-color: #f49097;
color: #083d77;
font-weight: bold;
text-decoration: none;

align-items: center;
padding: 10px;
height: 30px;
display: flex;
justify-content: center;
margin-top: 20px;
background: rgba(255, 255, 255, .7);
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
text-align: center;
border-radius: 1rem;
margin-left: 30px;
margin-right: 30px;
margin-top: 30px;
margin-bottom: 30px;
}

#mainTitle {
text-align: center;
vertical-align:top;
display: flex;
flex-direction: column;
justify-content: flex-start;
font-family: 'Silkscreen', cursive;
font-size: 2em;
color: #f4a83a;
text-shadow: 0 4px 0 #333333;
background: url("../images/title.png") no-repeat fixed;
background-position: center;
background-repeat: no-repeat;
background-attachment:fixed;
background-size: cover;
height: 230px;
margin-top: -80px;
}

#review{
padding: 2rem;
font-family: 'Silkscreen', cursive;
}
#resultTable {
margin-left: 30px;
margin-right:30px;
margin-top: 30px;
margin-bottom: 30px;
background: rgba(255, 255, 255, .7);
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
border-radius: 1rem;
}
#textboxid
{
height:200px;
font-size:14pt;
}

.autoMargin {
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
}

.centerText {
text-align: center;
margin-top: 10px;
justify-content: space-around;
}


.card {
height: auto;
padding: 2rem;
border-radius: 1rem;
margin-top: 10px;
/* other styles */
background: rgba(255, 255, 255, .7);
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
margin-left: 30px;
margin-right: 30px;
margin-top: 30px;
margin-bottom: 30px;
}

.card-title {
margin-top: 0;
margin-bottom: .5rem;
font-size: 1.2rem;
font-family: 'Silkscreen', cursive;
}

.deleteButton {
text-decoration: none;
border: none;
padding: 12px 40px;
font-size: 16px;
background: rgba(255, 255, 255, .7);


}.deleteButton:active {
transform: scale(0.98);
/* Scaling button to 0.98 to its original size */
box-shadow: 3px 2px 22px 1px rgba(0, 0, 0, 0.24);
/* Lowering the shadow */
}
.submitButton {
text-decoration: none;
border: none;
padding: 12px 40px;
font-size: 16px;
background: rgba(255, 255, 255, .7);
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
color: black;
border-radius: 5px;
box-shadow: 7px 6px 28px 1px rgba(0, 0, 0, 0.24);
cursor: pointer;
outline: none;
transition: 0.2s all;
text-align: center;
}
/* Adding transformation when the button is active */

.submitButton:active {
transform: scale(0.98);
/* Scaling button to 0.98 to its original size */
box-shadow: 3px 2px 22px 1px rgba(0, 0, 0, 0.24);
/* Lowering the shadow */
}


.header-footer-background {
background-image: url("../images/title.png");
background-color: #f5e960;
height: 250px;
background-repeat: no-repeat;
background-position: center;

}
.responses-background {
background-color: #f3ffbd;
}






Loading