# gochan.js development

## Before you start
To do frontend development for gochan, make sure you have Node JS and npm installed (the package names and installation methods may vary depending on distribution and OS).
Depending on your npm version, you may need to run this if you have the most up to date npm version available in your distro's repo but still get an error saying something like "Missing required argument #1" when you run `npm install`.
```
sudo npm install -g n
sudo n latest
sudo npm install -g npm
hash -d npm
npm install
```
(make sure you run these commands in the frontend directory)

## Building
You can technically use the npm build script directly for building gochan.js, but it's more convenient to just run `./build.py js` from the gochan repo root directory.

If you want to have it watch the JS files for changes and rebuild them when you make any in realtime, use the `--watch` flag.

If you want to run [ESLint](https://eslint.org/) on the JS code to find potential issues, use the `--eslint` flag, or the `--eslint-fix` flag to have ESLint try to automatically fix some issues it finds.

To install your gochan.js after building it, run `./build.py install --js`.

## Testing
Gochan unit testing with [Jest](https://jestjs.io) is still in its early stages and can be run by calling `npm run test` from the frontend directory.



# Theme development using Sass
If you want, you can install [Sass](https://sass-lang.com/install) to streamline writing CSS stylesheets. It requires node.js as a dependency so if you don't want to install it and Sass's dependencies (and its dependencies' dependencies,...) the CSS files generated by Sass are provided.

To use sass, run `./build.py sass`. If you want to minify the created css files, use the `--minify` flag. If you want sass to watch the input directory for changes as you edit and save the files, use the `--watch` flag.

If you are upgading from gochan 2.2, delete your html/css directory unless you have made themes that you want to keep. Then rebuild the pages. (/manage/rebuildall)

## Attribution
The BunkerChan, Clear, and Dark themes come from the imageboard BunkerChan. Burichan is based on the theme with the same name from Kusaba X. Photon comes from nol.ch (I think?) that as far as I know no longer exists. Pipes was created by a user (Mbyte?) on Lunachan (defunct). Yotsuba and Yotsuba B are based on the themes with the same names from 4chan.