Website modification
Website and Wiki modification for WPI AIAA and HPRC
For site admins and executive members
Prior installations
Required
Git
- Go to https://git-scm.com/download/
- Click “Windows”
- Click “64-bit Git for Windows Setup”
- Assuming you have a 64-bit Windows OS
- Save the Git setup application
- Example name: Git-2.42.0.2-64-bit.exe
- Run the setup application when the download finishes
- Proceed using all default settings
- Configure your identity for commits made on your system
- Open Git Bash
- Type it in the Windows search bar
- Run the commands:
git config --global user.name "YOUR NAME"
git config --global user.email YOUR-EMAIL@EXAMPLE.COM
- Open Git Bash
- If you want, download a Git GUI client application of your preference
- Ex: GitHub Desktop or GitKraken
Python
- Go to https://www.python.org/downloads/
- Click the button under “Download the latest version for Windows”
- Ex: “Download Python 3.12.0"
- Save the Python setup application
- Example name: python-3.11.5-amd64.exe
- Run the setup application when the download finishes
- Check the box “Add python.exe to PATH”
- Proceed using all default settings
- If needed, manually add Python to the system PATH environment variable
- Type “environment” in the Windows search bar
- Open “Edit the system environment variables”
- Click “Environment Variables...”
- If the variable “Path” exists under User variables for <USER>
- Click on Path
- Click Edit...
- Click New
- Enter the path of your downloaded Python application
- Can be found by typing “python” in the Windows search bar, right-clicking the Python application → Open file location
- Ex: C:\Users\Nate\AppData\Local\Programs\Python\Python311\
- Click Ok
- Enter the scripts path of your downloaded Python
- Repeat the steps above but enter your python path appended with “\scripts”
- Ex: C:\Users\Nate\AppData\Local\Programs\Python\Python311\scripts
- If the variable “Path” does not exist under User variables for <USER>
- Click New
- Enter in the information:
- Variable name: Path
- Variable value: <YOUR PYTHON PATH> ; <YOUR PYTHON PATH>\scripts
- Can be found by typing “python” in the Windows search bar, right-clicking the Python application → Open file location
- Ex: C:\Users\Nate\AppData\Local\Programs\Python\Python311\; C:\Users\Nate\AppData\Local\Programs\Python\Python311\scripts
- Click Ok
- Type “environment” in the Windows search bar
- Other helpful commands:
python -V
python -m pip install --upgrade pip
Recommended
VS Code IDE
- Go to https://code.visualstudio.com/download
- Click the download button for Windows
- Save the setup application
- Example name: VSCodeUserSetup-x64-1.83.1
- Run the setup application when the download finishes
- Accept the agreement, proceed with the install using all default settings
- Run Visual Studio Code
- Install the Python extension
- On the side bar click the “Extensions” icon
- Type “python”
- Click Install on the official Python extension from Microsoft
- Open project folder
- File → Open Folder...
- Locate the website repository folder
- Proceed with the following steps if the website repository isn’t cloned to your file system yet
- Install the Python extension
Making changes to the website
Clone the website GitHub repository, if not done already
This can also be done using a Git GUI client application of your preference
- Copy the clone link
- Go to https://github.com/npinkhasov/wpi-aiaa-site
- Click the green “Code” button towards the right of the page
- Copy the link under Clone
- Open Git Bash
- Type it in the Windows search bar
- If not found, see prior installations instructions for Git above
- Navigate to the folder where you wish to clone the website repository
- Enter command:
cd <YOUR FILE PATH>
- Ex:
cd C:Users/Nate/Documents
- Enter command:
- Clone the repository
git clone <COPIED CLONE LINK>
- Confirm successful cloning
cd wpi-aiaa-site
git status
- This command should return the working status of your local repository
View changes on a local copy of the website before deploying them
- Open Windows PowerShell
- Type it in the Windows search bar
- OR press Windows logo key + R to open the run dialog box and type ‘powershell’
- Navigate to the cloned website repository folder on your local system
- Enter command:
cd -Path ‘C:\<YOUR FILE PATH>\wpi-aiaa-site\’
- Ex:
cd -Path ‘C:\Users\Nate\Documents\wpi-aiaa-site\’
- Enter command:
- If not done already, create a Python virtual environment in the website folder (wpi-aiaa-site)
python -m venv env
- If the Python command isn’t recognized
- Ensure Python is added to the Windows path, see prior installations instructions for Python above
- If the Python command isn’t recognized
- Activate the virtual environment
cd env/Scripts
./activate
cd ../..
- If this error message appears: “script cannot be loaded because the execution of scripts is disabled on this system.”
- Start PowerShell with the "Run as Administrator" option
- Enter command:
Set-ExecutionPolicy RemoteSigned
- If this error message appears: “script cannot be loaded because the execution of scripts is disabled on this system.”
- For easier debugging, enable debug settings in the website file system
- Open the settings Python file
- Located at wpi-aiaa-site\wpiaiaasite\wpiaiaasite\settings.py
- Set the
DEBUG
variable equal toTrue
- This must be set back to False before committing and pushing any changes to the repository
- Open the settings Python file
- In the PowerShell, enter the wpiaiaasite folder and initialize the database
cd wpiaiaasite
python manage.py migrate
- Run the local host server
python manage.py runserver
- View the locally hosted website at the configured port
- Open a web browser
- Enter URL: http://127.0.0.1:8000
- This is an example URL, the runserver command will return the hosted URL to enter
- Refresh the page after saving any changes to the website files on your local system copy
- Website files should be edited in an IDE such as VS Code
- Exit the local host when finished viewing and editing
- Press CTRL + C in PowerShell to exit
- To exit the virtual environment
deactivate
Push changes to the website repository
This can also be done using a Git GUI client application of your preference
- Open Git Bash
- Navigate to the cloned website repository folder on your local system if not done already
- Confirm the correct files have been added/modified
git status
- Confirm that the
DEBUG
variable in settings.py is set equal toFalse
- A push of changes with
DEBUG
equal toTrue
must be amended immediately
- A push of changes with
- Stage all desired files for commit
git add <MODIFIED FILE NAME>
- Run this command for as many changed or added files as necessary
- OR add more files as additional arguments to a single add command
- Check if the files were added with git status
- Commit and push changes to the repository
git commit -m “YOUR COMMIT MESSAGE”
- Ensure your commit message is clear, brief, and describes changes to all modified files
git push
- Check that your commit was successfully pushed
- Go to https://github.com/npinkhasov/wpi-aiaa-site
- Click “Commits” towards the right of the page
Deploying changes to the website
Can only be done when connected to WPI network, either with device physically on campus or through GlobalProtect VPN
Logging on to the host server
- Open Windows PowerShell while connected to WPI’s network
- Enter command:
ssh aiaasite@aiaa.wpi.edu
- When prompted enter the admin password
- Set up an SSH key if you haven’t pulled changes to the server before
- Generate a new key
ssh-keygen -t ed25519 -C "YOUR-EMAIL@EXAMPLE.COM"
- Use the same email as your GitHub account
- When prompted to enter a location to save the key, enter your name as the file name
/home/aiaasite/.ssh/<YOUR NAME>
- Enter a password if you want
- Manually set up the key if password-based SSH access to the server doesn’t work
- Display the key
cat ~/.ssh/<YOUR NAME>.pub
- Copy the displayed contents of <YOUR NAME>.pub to a new key
- Go to https://github.com/settings/keys
- Add a new SSH key
- Display the key
- Generate a new key
Applying changes
- Navigate to the website repository when logged on to the host server in PowerShell using SSH
cd wpi-aiaa-site
- Set your SSH key as the active key
eval "$(ssh-agent -s)"
- Add your SSH key into the agent
ssh-add ~/.ssh/<YOUR NAME>
- Ex:
ssh-add ~/.ssh/npinkhasov
- Pull changes from the website repository
git pull
- Load changes to the server
source AIAAvenv/bin/activate
cd wpiaiaasite
python manage.py collectstatic
sudo service apache2 restart
- If prompted enter the admin password
- Confirm the latest commits took affect
- Open a web browser on another device
- Go to whatever pages were modified on aiaa.wpi.edu
- To exit the virtual environment
deactivate
- Exit the SSH connection when finished applying changes
exit