Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
toBeOfUse committed May 3, 2024
1 parent 3e8bf60 commit a882de5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 deletions.
70 changes: 46 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
# HacKSU website
# The HacKSU Website

## Project setup
```
npm install
```
Note that you can edit some of the site's content without changing its source code. Go to https://hacksu.com/login to log in. If you have the "Leader" role in the HacKSU Discord, you'll be given access to the admin pages and be able to edit the meetings and leadership pages, etc.

### Compiles and hot-reloads for development
## Guide to development

This uses Vite to create a development server.

```
npm run dev
```
Install [Node.js](https://nodejs.org/en) and [yarn](https://yarnpkg.com/).

### Compiles and minifies for production
### Install dependencies

This step uses vite-ssg to save the site's content as HTML. Keep this step in mind when developing the site; if you write code in a Vue component that directly accesses objects that are provided by a browser, like `window`, this step will crash, since this initial build is not run in a browser. You can usually move code that accesses browser-y stuff to a callback like `onMounted` to avoid this.
Run this before attempting to start the site:

```
npm run build
yarn install
```

### Editing Content

Go to https://hacksu.com/login (or http://localhost:8000/login if you're developing the site) to log in. If you have the "Member" role in the HacKSU Discord, you'll be given access to the admin pages and be able to edit the site's content.

### db folder

The DB folder stores JSON files that act as the database for the site's content, which changes often. "entities.js" stores the schema for the objects that will be stored in these files. You should be able to update the database through the admin interface without needing to create or modify these files directly. However, if this site is migrated to another server, transferring the .json files from the old server to the new one is a good idea. (They are not committed to GitHub or git, as they aren't part of the source code and change regularly.)

## Server Configuration
### The configuration file

In order for the site to work properly, a server.config.json file must be present in the root directory. An example configuration file is provided below:
```

```json
{
"sendgrid": {
"token": "sendgrid token goes here"
Expand All @@ -46,3 +32,39 @@ In order for the site to work properly, a server.config.json file must be presen
}
}
```

The session secret should be some random or otherwise arbitrary string.

The Sendgrid token should be an API key for a Sendgrid account but also it is not currently used anyway.

The Discord client ID and secret should correspond to some Discord application that has the ability to log users in to hacksu.com. You can create such an application by going to the [Discord developer portal](https://discord.com/developers/applications/), hitting "New Application", and adding redirects in the OAuth2 page like so:

![](discord-oauth-callbacks.png)

Grab the client ID and secret from the OAuth2 page in the new application's settings and add them to the server.config.json file. Then, go to localhost:8000/login (which is the local development equivalent of https://hacksu.com/login) to initiate the login process using this Discord application. This setup allows leaders (with the "Leader" role in the HacKSU Discord server) to automatically authenticate themselves and make edits to the content on the site.

The Discord application whose client ID and secret are currently used in the server configuration on the live site belongs to me (Mitch) and will work unless I someday accidentally delete it.

### Run a server in debug mode with hot-reloading for development

```
yarn dev
```

Then go to the localhost URL that shows up in the browser console.

### Bundle for production

```
yarn build
```

This step uses [vite-ssg](https://github.com/antfu-collective/vite-ssg) to save the site's content as HTML. Keep this step in mind when developing the site; if you write code in a Vue component that directly accesses objects that are provided by a browser, like `window`, this step will crash, since this initial build is not run in a browser. You can usually move code that accesses browser-y stuff to a callback like `onMounted` to avoid this.

### Deploy your changes

When you push to the master branch of this repository, the Github action located in `.github/workflows/build_and_deploy.yml` will hopefully push all new changes to the actual web server that hosts the site.

### Note on stored data

The "db" folder stores JSON files that act as the database for the site's content. `entities.js` stores the schema for the objects that will be stored in these files. You should be able to update the database through the admin interface without needing to create or modify these files directly. However, if this site is migrated to another server, transferring the .json files and the pictures in `public/event-photos` and `public/staff-photos` from the old server to the new one is a good idea. (These things are not committed to GitHub or git, as they aren't part of the source code and change regularly.)
Binary file added discord-oauth-callbacks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ if (process.env.NODE_ENV == "production"){

let port = process.env.PORT || 8000;
app.listen(port, function () {
console.log("Listening on port", port);
console.log(`Running at http://localhost:${port}`);
});

0 comments on commit a882de5

Please sign in to comment.