Klik di sini untuk versi Bahasa Indonesia.
This repository contains code for Indonesian Online Math Contest's website which can be accessed in https://ktom-tomi.or.id. This website is made by two members of our organization:
- Herbert Ilhan Tanujaya (@donjar)
- Jonathan Mulyawan Woenardi (@woenardi)
This website was originally made to learn web development in Ruby on Rails. However, the source code keeps on expanding as we add on more features.
Note: the following set-up procedure runs on Ubuntu 20.04 LTS. These steps are recommended although need not be followed exactly. If you wish to run Ubuntu on another OS, you may want to consider VirtualBox to run Ubuntu in a virtual machine.
For the project to run on your machine, you would need to install several packages:
software-properties-common, as a dependency for several packages belowpostgresqlfor the databasetexlivefor LaTeX parsing.texlive-fullis recommended, althoughtexlive-basewould suffice for most parts
You can use apt for installing the above packages by the command
sudo apt install <packagename>- Install the prerequisite packages
- Download the files in the repository, through
git cloneor otherwise - We would also need
ruby, and for the purposes of version management we would like to recommend usingrvmorrbenv. This step shows how to set uprvmand may be skipped if you prefer other ways of version management. This step will follow closely with the official Ubuntu installation guide here, and modified slightly to suit the project:- Add the PPA and install the required packages:
sudo apt-add-repository -y ppa:rael-gc/rvm sudo apt-get update sudo apt-get install rvm
- Add your user to the rvm group (replace
<yourusername>by your username):sudo usermod -a -G rvm <yourusername>
- Change your terminal to run command as login shell. This can be done manually through
/bin/bash --login; if you are using the default GNOME terminal you can configure it by clicking on the hamburger button (three horizontal lines) on the top right corner of the terminal window and selecting Preferences. In the preferences window under your Profile on the left sidebar, select your profile, and click on the Command tab. Check the 'Run command as login shell' checkbox - Reboot
- Enable local gemsets by using
rvm user gemsets
- Now you can install
ruby. This project currently uses ruby 2.5.0 (check the Gemfile in the project folder root if you are unsure, it should be in one of the first few lines), so we will install that version of ruby by using the commandIf you have installed other version(s) of ruby, you can change the default ruby version by using the commandrvm install 2.5.0
and this would require closing and reopening your terminal to take effectrvm --default use 2.5.0
- Add the PPA and install the required packages:
- Check that you have the correct version of ruby (currently 2.5.0, check against the Gemfile). This can be done by running
ruby --version
- Install
bundleron the correct version. Currently, bundler 1.17.3 is recommended for the project. For more details on the bundler version, refer to the Gemfile.lock file.gem install bundler -v 1.17.3
- From the directory of the project, run
to install the gems needed
bundle install
- Make sure that
postgresqlis installed. Now we move to creating our database:- Make a file called
database.ymlin theconfigfolder. You can do this by copying the givendatabase.yml.defaultfile in the project - We will make a user in postgresql. For the purposes of this guide, we will make
a user with username
ubuntuand passwordpassword. Please ensure that the username and the password in the following steps match the ones in yourdatabase.yml:- Go to postgres shell:
sudo -u postgres psql - Create the user:
create user ubuntu with encrypted password 'password'; - Elevate user privilege:
alter user "ubuntu" with superuser;
- Go to postgres shell:
- Now we will set the database up with
bundle exec rake db:setup - Run all migration files by
bundle exec rake db:migrate
- Make a file called
- Create
.envfile in the root directory and copy over the contents from.env.defaultto.env. Populate the variables inside.envwith the appropriate values. - The initial setup to run the server has been done. To run the local server, use
bundle exec rails s - Last, you may wish to make an admin in the website (by default would be on
0.0.0.0:3000). Do the following steps to make an admin account in the website:- Make a user as per normal in the website
- No email will be sent, instead we need to go to rails console and manually enable the user.
Open the rails console by
bundle exec rails cand runUser.first.enable - To elevate the privilege of this user to admin, do the following in the rails console:
User.first.add_role :panitia User.first.add_role :admin
This completes the initial set up guide for the website.
Please fork :D