Skip to content

Commit

Permalink
Prettified codebase (#348)
Browse files Browse the repository at this point in the history
- setup prettier config file for the repo
- ran prettier on the entire repo
- updated docs
- added GitHub Action that creates a commit on PRs to master if the code isn't prettified.

closes #324
  • Loading branch information
AnimeAllstar authored Jan 10, 2023
1 parent d43a414 commit e59c35a
Show file tree
Hide file tree
Showing 821 changed files with 7,543 additions and 7,208 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prettifier

on:
pull_request:
branches: [master]

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --write **/*.+(js|html|css|json|md|yaml)
only_changed: True
prettier_plugins: prettier-plugin-go-template
commit_message: "Prettified code"
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.12.1
25 changes: 25 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"overrides": [
{
"files": [
"*.html"
],
"options": {
"parser": "go-template",
"goTemplateBracketSpacing": true,
"bracketSameLine": true
}
},
{
"files": [
"*.js"
],
"options": {
"trailingComma": "none",
"tabs": true,
"tabWidth": 2,
"printWidth": 120
}
}
]
}
73 changes: 41 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,35 @@

Website for the UBC Computer Science Student Society.

## Installation

- [install Hugo](https://gohugo.io/installation/) - to build the website. The current version of Hugo used is listed in [`netlify.toml`](netlify.toml), under the key `HUGO_VERSION`.
- [install Node](https://nodejs.org/) - to install npm. The current version of Node used is in [`.nvmrc`](.nvmrc). This is used by Netlify to build the site with the [correct version of Node](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript).
- [install Yarn](https://classic.yarnpkg.com/lang/en/docs/install/) - to install dependencies and run scripts
- [install nvm](https://github.com/nvm-sh/nvm) - to ensure the correct version of Node is used. Take a look at [this](https://stackoverflow.com/a/57839539/8488681) to see how to use [`.nvmrc`](.nvmrc) to automatically switch to the correct version of Node.

```bash
# clone the repository
git clone https://github.com/ubccsss/ubccsss.org.git

# cd into the repository
cd ubccsss.org

# ensure that the correct version of Node is used
nvm use

# install dependencies
yarn install

# start the development server
hugo server
```

## Contributing

We welcome contributions of any kind including pages, suggestions, bug reports,
pull requests etc. We would love to hear from you.
We welcome contributions of any kind including pages, suggestions, bug reports, pull requests etc. We would love to hear from you.

When you submit a PR, we automatically run the [Prettier](https://prettier.io/) code formatter with the [prettier-plugin-go-template](https://github.com/NiklasPor/prettier-plugin-go-template) plugin to help with Go template formatting. **Please ensure you checkout the latest version of your PR after any formatting commits have been made when continuing to work on your PR.**

Additional documentation can be found in the [`docs`](./docs) folder.

Expand All @@ -31,26 +56,19 @@ There's a course review form on each course page at [ubccsss.org/services/course

##### `content`

Contains content files corresponding to every post, event, and page.
The `events` folder contains events which can be added to a student's calendar,
and the `posts` folder contain general posts to display.
Contains content files corresponding to every post, event, and page. The `events` folder contains events which can be added to a student's calendar, and the `posts` folder contain general posts to display.

##### `data`

YAML files with some data used elsewhere in the site, including the Cube's
address, images for the 3D cube on the homepage, and social media links.
YAML files with some data used elsewhere in the site, including the Cube's address, images for the 3D cube on the homepage, and social media links.

##### `layouts` and `themes`.

HTML template files for the site. The
[hugo-bootstrap](https://themes.gohugo.io/hugo-bootstrap/) theme is used as a
base for the site. Files with the same name in the `layouts` folder override
files in the `themes/hugo-bootstrap` folder.
HTML template files for the site. The [hugo-bootstrap](https://themes.gohugo.io/hugo-bootstrap/) theme is used as a base for the site. Files with the same name in the `layouts` folder override files in the `themes/hugo-bootstrap` folder.

##### `static`

Static files that are copied into the website with no modifications. Images and
PDF files are placed here.
Static files that are copied into the website with no modifications. Images and PDF files are placed here.

#### Headers and Redirects

Expand Down Expand Up @@ -80,6 +98,7 @@ The `config` folder contains the following folders:
`_default` contains the base configuration files, and depending on the environment, the files in the other folders will be automatically merged into the base configuration if `_merge: deep` is added to the base file.

`hugo server` runs the site in development mode by default.

`hugo` builds the site in production mode by default.

Read the [Hugo docs](https://gohugo.io/getting-started/configuration/) for more information on how they work.
Expand All @@ -97,30 +116,20 @@ Currently, there are three enviornment variables:

netlify.toml contains the configuration for the Netlify. `HUGO_ENV` is used to select the environment for different Netlify environments.

### Build

To view the site locally, you need to clone this repository:
### Dev Scripts

```bash
git clone https://github.com/ubccsss/ubccsss.org.git
```
# format all files
yarn format

You'll also need to
[install Hugo](https://gohugo.io/getting-started/installing/). The current
version of Hugo used is listed in the [`netlify.toml`](netlify.toml) file, under
the key `HUGO_VERSION`.
# check for formatting errors
yarn dry

Then to view the website in your browser, run Hugo and open up the link:
# start the development server
yarn dev

```bash
▶ hugo server

Building sites ...
.
.
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
# build the website
yarn build
```

## Related
Expand Down
12 changes: 9 additions & 3 deletions assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ body {
overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .navbar-brand {
h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand {
font-family: "Montserrat", sans-serif;
}

Expand Down Expand Up @@ -60,8 +66,8 @@ a {

@media only screen and (max-width: 992px) {
.dropdown-menu {
border: none;
background-color: #fcfcfc;
border: none;
background-color: #fcfcfc;
}

.dropdown-item:active {
Expand Down
16 changes: 7 additions & 9 deletions assets/js/create-github-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const WORKER_URL = form.dataset.workerurl;

// call createGithubPR if form is valid and display link to the new PR
(() => {
document.getElementById("github-pr-year-taken").max =
new Date().getFullYear();
document.getElementById("github-pr-year-taken").max = new Date().getFullYear();

form.addEventListener("submit", async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -57,8 +56,7 @@ const createGithubPR = async () => {
const difficulty = document.getElementById("github-pr-difficulty").value;
const quality = document.getElementById("github-pr-quality").value;
const sessionTaken =
document.getElementById("github-pr-year-taken").value +
document.getElementById("github-pr-session-taken").value;
document.getElementById("github-pr-year-taken").value + document.getElementById("github-pr-session-taken").value;

// check if reCAPTCHA has been completed
const token = grecaptcha.getResponse();
Expand All @@ -71,11 +69,11 @@ const createGithubPR = async () => {
const pr = await fetch(WORKER_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
recaptcha: {
token: token,
token: token
},
details: {
course: course,
Expand All @@ -84,9 +82,9 @@ const createGithubPR = async () => {
reference: reference,
difficulty: difficulty,
quality: quality,
sessionTaken: sessionTaken,
},
}),
sessionTaken: sessionTaken
}
})
});
const json = await pr.json();
if (pr.ok) {
Expand Down
22 changes: 11 additions & 11 deletions assets/js/grades-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
}

function addDescription(list, term, details) {
const dt = document.createElement('dt');
const dd = document.createElement('dd');
dt.className = 'col-sm-3';
const dt = document.createElement("dt");
const dd = document.createElement("dd");
dt.className = "col-sm-3";
dt.textContent = term;
dd.className = 'col-sm-9';
dd.textContent = details.toFixed(2) + '%';
dd.className = "col-sm-9";
dd.textContent = details.toFixed(2) + "%";
list.append(dt, dd);
}

const gradesEl = document.getElementsByClassName('grades-api')[0];
const gradesEl = document.getElementsByClassName("grades-api")[0];
const grades = await loadGrades(gradesEl.dataset.subject, gradesEl.dataset.course);
const { average, average_past_5_yrs, max_course_avg, min_course_avg, stdev } = grades;
const fragment = document.createDocumentFragment();
addDescription(fragment, 'Average (all time)', average);
addDescription(fragment, 'Average (past 5 years)', average_past_5_yrs);
addDescription(fragment, 'Highest Average', max_course_avg);
addDescription(fragment, 'Lowest Average', min_course_avg);
addDescription(fragment, 'Standard Deviation', stdev);
addDescription(fragment, "Average (all time)", average);
addDescription(fragment, "Average (past 5 years)", average_past_5_yrs);
addDescription(fragment, "Highest Average", max_course_avg);
addDescription(fragment, "Lowest Average", min_course_avg);
addDescription(fragment, "Standard Deviation", stdev);
gradesEl.append(fragment);
})();
52 changes: 26 additions & 26 deletions assets/js/newsletter.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
(() => {
// add 10 second delay in showing the newsletter popup
setTimeout(() => {
const newsletterModalEl = document.getElementById('newsletter-modal');
const newsletterModal = new bootstrap.Modal(newsletterModalEl);
if (document.cookie.indexOf('newsletter') < 0) {
newsletterModalEl.addEventListener('hide.bs.modal', (event) => {
// activeElement is the element that triggered the modal to hide
const activeElement = document.activeElement;
// if the user clicks on the join button, set a cookie to not show the popup again
if (activeElement.id === 'join-btn') {
document.cookie = `newsletter=1; path=/;`;
} else if (activeElement.id === 'maybe-later-btn') {
// if the user clicks on the maybe later button, set a cookie to show the popup again in 3 months
const expiryDate = new Date();
expiryDate.setMonth(expiryDate.getMonth() + 3);
document.cookie = `newsletter=1; expires=${expiryDate.toUTCString()}; path=/;`;
} else {
// if the user exits the popup in any other way (clicking outside the modal / ESC key),
// set a cookie to show the popup again in 1 month
const expiryDate = new Date();
expiryDate.setMonth(expiryDate.getMonth() + 1);
document.cookie = `newsletter=1; expires=${expiryDate.toUTCString()}; path=/;`;
}
})
newsletterModal.show();
// add 10 second delay in showing the newsletter popup
setTimeout(() => {
const newsletterModalEl = document.getElementById("newsletter-modal");
const newsletterModal = new bootstrap.Modal(newsletterModalEl);
if (document.cookie.indexOf("newsletter") < 0) {
newsletterModalEl.addEventListener("hide.bs.modal", (event) => {
// activeElement is the element that triggered the modal to hide
const activeElement = document.activeElement;
// if the user clicks on the join button, set a cookie to not show the popup again
if (activeElement.id === "join-btn") {
document.cookie = `newsletter=1; path=/;`;
} else if (activeElement.id === "maybe-later-btn") {
// if the user clicks on the maybe later button, set a cookie to show the popup again in 3 months
const expiryDate = new Date();
expiryDate.setMonth(expiryDate.getMonth() + 3);
document.cookie = `newsletter=1; expires=${expiryDate.toUTCString()}; path=/;`;
} else {
// if the user exits the popup in any other way (clicking outside the modal / ESC key),
// set a cookie to show the popup again in 1 month
const expiryDate = new Date();
expiryDate.setMonth(expiryDate.getMonth() + 1);
document.cookie = `newsletter=1; expires=${expiryDate.toUTCString()}; path=/;`;
}
}, 10_000);
});
newsletterModal.show();
}
}, 10_000);
})();
3 changes: 2 additions & 1 deletion content/about/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 'About Us'
title: "About Us"
layout: single
aliases:
- /club/about
Expand Down Expand Up @@ -48,6 +48,7 @@ of ICICS/CS, turn right, and we'll be at the end of the hallway, beside the unde
### How do I find out about CSSS events?

We'll be publishing our events:

- here on our website (which also has an [RSS feed](/index.xml)),
- [Tweeting them](https://twitter.com/ubccsss),
- posting them on our [Facebook page](https://www.facebook.com/ubccsss/) and our [Instagram](https://www.instagram.com/ubc_csss/),
Expand Down
1 change: 1 addition & 0 deletions content/about/clubs.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following UBC CS-related clubs are partners of the CSSS. Click on each club
Know another CS club that would like to be listed? Please open an issue on the [ubccsss/ubccsss.org](https://github.com/ubccsss/ubccsss.org/issues/new) GitHub repo, or reach out via the [suggestions box](https://ubccsss.org/contact/suggestions-box/).

## Engineering Design Teams

Many engineering design teams accept computer science students, and need software engineers. A list of all engineering design teams can be found <a href="https://teams.engineering.ubc.ca/the-teams/">here</a>.

## Club Events Calendar
Expand Down
16 changes: 8 additions & 8 deletions content/about/constitution.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ The CSSS is governed by its constitution as a subsidiary organization of the
[UBC Alma Mater Society](https://www.ams.ubc.ca/). The known history of the
club's constitutions and bylaws is maintained below.

- [November 29, 2022 **(current)**](/files/constitution-20221129.pdf)
- [March 22, 2019](/files/constitution-20190322.pdf)
- [March 15, 2016](/files/constitution-20160315.pdf)
- [December 26, 2014](/files/constitution-20141226.pdf)
- [March 4, 2013](/files/constitution-20130304.pdf)
- [July 7, 2012](/files/constitution-20120712.pdf)
- [March 28, 2012](/files/constitution-20120328.pdf)
- [September 28, 2008](/files/constitution-20080928.pdf)
- [November 29, 2022 **(current)**](/files/constitution-20221129.pdf)
- [March 22, 2019](/files/constitution-20190322.pdf)
- [March 15, 2016](/files/constitution-20160315.pdf)
- [December 26, 2014](/files/constitution-20141226.pdf)
- [March 4, 2013](/files/constitution-20130304.pdf)
- [July 7, 2012](/files/constitution-20120712.pdf)
- [March 28, 2012](/files/constitution-20120328.pdf)
- [September 28, 2008](/files/constitution-20080928.pdf)

### What's in the constitution?

Expand Down
Loading

0 comments on commit e59c35a

Please sign in to comment.