Website modification

From WPI-AIAA
Revision as of 20:23, 16 November 2023 by Pdentch (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Website and Wiki modification for WPI AIAA and HPRC
For site admins and executive members

Prior installations

Required

Git

  1. Go to https://git-scm.com/download/
  2. Click “Windows”
  3. Click “64-bit Git for Windows Setup”
    1. Assuming you have a 64-bit Windows OS
  4. Save the Git setup application
    1. Example name: Git-2.42.0.2-64-bit.exe
  5. Run the setup application when the download finishes
    1. Proceed using all default settings
  6. Configure your identity for commits made on your system
    1. Open Git Bash
      1. Type it in the Windows search bar
    2. Run the commands:
      1. git config --global user.name "YOUR NAME"
      2. git config --global user.email YOUR-EMAIL@EXAMPLE.COM
  7. If you want, download a Git GUI client application of your preference
    1. Ex: GitHub Desktop or GitKraken

Python

  1. Go to https://www.python.org/downloads/
  2. Click the button under “Download the latest version for Windows”
    1. Ex: “Download Python 3.12.0"
  3. Save the Python setup application
    1. Example name: python-3.11.5-amd64.exe
  4. Run the setup application when the download finishes
    1. Check the box “Add python.exe to PATH”
    2. Proceed using all default settings
  5. If needed, manually add Python to the system PATH environment variable
    1. Type “environment” in the Windows search bar
      1. Open “Edit the system environment variables”
    2. Click “Environment Variables...”
    3. If the variable “Path” exists under User variables for <USER>
      1. Click on Path
      2. Click Edit...
      3. Click New
      4. Enter the path of your downloaded Python application
        1. Can be found by typing “python” in the Windows search bar, right-clicking the Python application → Open file location
        2. Ex: C:\Users\Nate\AppData\Local\Programs\Python\Python311\
      5. Click Ok
      6. Enter the scripts path of your downloaded Python
        1. Repeat the steps above but enter your python path appended with “\scripts”
        2. Ex: C:\Users\Nate\AppData\Local\Programs\Python\Python311\scripts
    4. If the variable “Path” does not exist under User variables for <USER>
      1. Click New
      2. Enter in the information:
        1. Variable name: Path
        2. Variable value: <YOUR PYTHON PATH> ; <YOUR PYTHON PATH>\scripts
          1. Can be found by typing “python” in the Windows search bar, right-clicking the Python application → Open file location
          2. Ex: C:\Users\Nate\AppData\Local\Programs\Python\Python311\; C:\Users\Nate\AppData\Local\Programs\Python\Python311\scripts
        3. Click Ok
  6. Other helpful commands:
    1. python -V
    2. python -m pip install --upgrade pip

Recommended

VS Code IDE

  1. Go to https://code.visualstudio.com/download
  2. Click the download button for Windows
  3. Save the setup application
    1. Example name: VSCodeUserSetup-x64-1.83.1
  4. Run the setup application when the download finishes
    1. Accept the agreement, proceed with the install using all default settings
  5. Run Visual Studio Code
    1. Install the Python extension
      1. On the side bar click the “Extensions” icon
      2. Type “python”
      3. Click Install on the official Python extension from Microsoft
    2. Open project folder
      1. File → Open Folder...
      2. Locate the website repository folder
      3. Proceed with the following steps if the website repository isn’t cloned to your file system yet

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

  1. Copy the clone link
    1. Go to https://github.com/npinkhasov/wpi-aiaa-site
    2. Click the green “Code” button towards the right of the page
    3. Copy the link under Clone
  2. Open Git Bash
    1. Type it in the Windows search bar
    2. If not found, see prior installations instructions for Git above
  3. Navigate to the folder where you wish to clone the website repository
    1. Enter command: cd <YOUR FILE PATH>
    2. Ex: cd C:Users/Nate/Documents
  4. Clone the repository
    1. git clone <COPIED CLONE LINK>
  5. Confirm successful cloning
    1. cd wpi-aiaa-site
    2. git status
      1. This command should return the working status of your local repository

View changes on a local copy of the website before deploying them

  1. Open Windows PowerShell
    1. Type it in the Windows search bar
    2. OR press Windows logo key + R to open the run dialog box and type ‘powershell’
  2. Navigate to the cloned website repository folder on your local system
    1. Enter command: cd -Path ‘C:\<YOUR FILE PATH>\wpi-aiaa-site\’
    2. Ex: cd -Path ‘C:\Users\Nate\Documents\wpi-aiaa-site\’
  3. If not done already, create a Python virtual environment in the website folder (wpi-aiaa-site)
    1. python -m venv env
      1. If the Python command isn’t recognized
        1. Ensure Python is added to the Windows path, see prior installations instructions for Python above
  4. Activate the virtual environment
    1. cd env/Scripts
    2. ./activate
    3. cd ../..
      1. If this error message appears: “script cannot be loaded because the execution of scripts is disabled on this system.”
        1. Start PowerShell with the "Run as Administrator" option
        2. Enter command: Set-ExecutionPolicy RemoteSigned
  5. For easier debugging, enable debug settings in the website file system
    1. Open the settings Python file
      1. Located at wpi-aiaa-site\wpiaiaasite\wpiaiaasite\settings.py
    2. Set the DEBUG variable equal to True
      1. ⚠️ This must be set back to False before committing and pushing any changes to the repository
  6. In the PowerShell, enter the wpiaiaasite folder and initialize the database
    1. cd wpiaiaasite
    2. python manage.py migrate
  7. Run the local host server
    1. python manage.py runserver
  8. View the locally hosted website at the configured port
    1. Open a web browser
    2. Enter URL: http://127.0.0.1:8000
      1. This is an example URL, the runserver command will return the hosted URL to enter
    3. Refresh the page after saving any changes to the website files on your local system copy
      1. Website files should be edited in an IDE such as VS Code
  9. Exit the local host when finished viewing and editing
    1. Press CTRL + C in PowerShell to exit
  10. To exit the virtual environment
    1. deactivate

Push changes to the website repository

This can also be done using a Git GUI client application of your preference. VS Code additionally has built-in source control

  1. Open Git Bash
  2. Navigate to the cloned website repository folder on your local system if not done already
  3. Confirm the correct files have been added/modified
    1. git status
  4. Confirm that the DEBUG variable in settings.py is set equal to False
    1. ⚠️ A push of changes with DEBUG equal to True must be amended immediately
  5. Sync your local copy with any new changes from the remote repository
    1. git pull
      1. Resolve any merge conflicts if necessary
  6. Stage all desired files for commit
    1. git add <MODIFIED FILE NAME>
      1. Run this command for as many changed or added files as necessary
      2. OR add more files as additional arguments to a single add command
      3. Ex: git add wpi-aiaa-site/* to add all changed or new files
    2. Check if the files were added with git status
  7. Commit and push changes to the repository
    1. git commit -m “YOUR COMMIT MESSAGE”
      1. Ensure your commit message is clear, brief, and describes changes to all modified files
    2. git push
  8. Check that your commit was successfully pushed
    1. Go to https://github.com/npinkhasov/wpi-aiaa-site
    2. 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

  1. Open Windows PowerShell while connected to WPI’s network
  2. Enter command: ssh aiaasite@aiaa.wpi.edu
    1. When prompted enter the admin password
  3. Set up an SSH key if you haven’t pulled changes to the server before
    1. Generate a new key
      1. ssh-keygen -t ed25519 -C "YOUR-EMAIL@EXAMPLE.COM"
        1. Use the same email as your GitHub account
    2. When prompted to enter a location to save the key, enter your name as the file name
      1. /home/aiaasite/.ssh/<YOUR NAME>
    3. Enter a password if you want
    4. Manually set up the key if password-based SSH access to the server doesn’t work
      1. Display the key
        1. cat ~/.ssh/<YOUR NAME>.pub
      2. Copy the displayed contents of <YOUR NAME>.pub to a new key
        1. Go to https://github.com/settings/keys
        2. Add a new SSH key

Applying changes

  1. Navigate to the website repository when logged on to the host server in PowerShell using SSH
    1. cd wpi-aiaa-site
  2. Set your SSH key as the active key
    1. eval "$(ssh-agent -s)"
  3. Add your SSH key into the agent
    1. ssh-add ~/.ssh/<YOUR NAME>
    2. Ex: ssh-add ~/.ssh/npinkhasov
  4. Pull changes from the website repository
    1. git pull
  5. Load changes to the server
    1. source AIAAvenv/bin/activate
    2. cd wpiaiaasite
    3. python manage.py collectstatic
      1. Type 'yes' to continue
    4. sudo service apache2 restart
      1. If prompted enter the admin password
  6. Confirm the latest commits took affect
    1. Open a web browser on another device
    2. Go to whatever pages were modified on aiaa.wpi.edu
  7. To exit the virtual environment
    1. deactivate
  8. Exit the SSH connection when finished applying changes
    1. exit

Making changes to the MediaWiki