├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── DESIGN.md ├── LICENSE ├── README.md ├── backend ├── Docker │ ├── Dockerfile │ ├── fpm.toml │ └── main.f90 ├── Pipfile ├── app.py ├── fpm.toml ├── tutorial.yml └── wsgi.py ├── frontend ├── .env ├── package.json ├── public │ ├── fortran-logo.png │ ├── index.html │ ├── manifest.json │ └── robots.txt └── src │ ├── App.css │ ├── App.js │ ├── Editor.js │ ├── InputBox.js │ ├── Navbar.js │ ├── TutorialCard.js │ ├── fortran-logo.png │ ├── index.css │ ├── index.js │ └── tutorial.json └── systemd ├── initialize-services.sh ├── playground-reverse-proxy.service └── playground-server.service /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy frontend 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | 16 | - name: Install Node 17 | uses: actions/setup-node@v2 18 | with: 19 | node-version: 16.x 20 | 21 | - name: Install dependencies 📦 22 | working-directory: ./frontend 23 | run: npm install 24 | 25 | - name: Build 🔨 26 | working-directory: ./frontend 27 | run: | 28 | npm run build 29 | touch build/.nojekyll 30 | echo play.fortran-lang.org > build/CNAME 31 | env: 32 | REACT_APP_PLAYGROUND_API_URL: https://play-api.fortran-lang.org 33 | 34 | - name: Deploy 🚀 35 | uses: JamesIves/github-pages-deploy-action@v4.4.0 36 | with: 37 | branch: gh-pages 38 | folder: ./frontend/build 39 | single-commit: true 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | frontend/node_modules 2 | -------------------------------------------------------------------------------- /DESIGN.md: -------------------------------------------------------------------------------- 1 | # The Fortran Playground Design 2 | 3 | This document describes the design of the software that implements the Fortran 4 | Playground. 5 | Currently covered is the design of the frontend component of the system. 6 | The design of the backend will be documented in a later update. 7 | 8 | The playground consists of a frontend built using React which communicates with 9 | a Flask App responsible for executing user codes in a sandboxed environment 10 | using a Docker Container. 11 | 12 | ## Frontend 13 | 14 | There are various components which handle different parts of the website. 15 | All the styling is done using React-Bootstrap components. 16 | 17 | ### Editor 18 | 19 | We use an Ace Editor port for React called 20 | [React-Ace](https://github.com/securingsincity/react-ace). 21 | All information about Editor settings is stored under `frontend/src/Editor.js`. 22 | The editor settings are passed down as props to the react-ace component and 23 | offer various configuration options check 24 | [this page](https://securingsincity.github.io/react-ace/) to experiment with 25 | different parameters. 26 | For example, to change the theme import it from react-ace library: 27 | ``` 28 | import "ace-builds/src-noconflict/theme-github"; 29 | ``` 30 | and change the theme prop inside `Editor.js`. 31 | 32 | ### Navbar 33 | 34 | The navbar is configured under `frontend/src/Navbar.js`. 35 | It uses the default bootstrap navbar component. 36 | 37 | ### Tutorial 38 | 39 | The content for tutorial is stored inside the tutorial.json file, which is 40 | generated by the backend from `tutorial.yml` file. 41 | A tutorial part consists of 3 sections- a title, content inside it and the code 42 | for the respective exercise. 43 | To add a new exercise append the three parameters inside the file at 44 | `src/backend/tutorial.yml`, e.g.: 45 | 46 | ``` 47 | - title: Heading for exercise 48 | content: A breif explanation for the topic 49 | code: "Code for the exercise" 50 | ``` 51 | 52 | Restart the server so it can compile the yaml into a JSON. 53 | The changes will be immediately reflected. 54 | To update the tutorial you can commit this JSON to the main repository via a 55 | pull request. 56 | 57 | Please make sure that you configure the code properly with proper string 58 | formatting. 59 | This can be done by entering the code inside the editor first and copying the 60 | outputted "code" parameter inside the POST request. 61 | This also ensures your code works properly. 62 | 63 | The tutorial is handled by the `TutorialCard` component insidde 64 | `src/TutorialCard.js` with respective props for Heading and Title. 65 | The change for code happens automatically by the `tutFunc` function inside 66 | `App.js` bounded by the switching buttons. 67 | 68 | ### InputBox 69 | 70 | The InputBox is a separate component which has props passed down from `App.js` 71 | to effectively manage state for the input. 72 | 73 | ### App 74 | 75 | The source file `frontend/src/App.js` houses all of our states and major 76 | functionalities (API Calls, Library Selection). 77 | 78 | 1. States: 79 | * Text: Code inside the editor. 80 | * Output: Output the is received from the backend after execution on container. 81 | * Input: User input for the code that is to be executed 82 | * Exercise: Current exercise the user is on 83 | There are also states which hold information on status for various toggleable 84 | elements on the site: 85 | * isLoading: Spinner until output is received from API 86 | * inputOn: Input box button toggle 87 | * showTutorial: Prompt for the quickstart tutorial 88 | * show: Pop up modal for library selection 89 | * stdlibOn: State that manages whether stdlib has been selected by user or not 90 | 2. Buttons for the tutorial are managed by `goRight` and `goLeft` functions, 91 | they iterate on the tutorial.json using `exercise` state. 92 | 3. API: POST Request to the backend server is done via `handleClick` function. 93 | The request contains 3 parameters code, the input for it and the libraries 94 | selected by the user. 95 | The response from this request is stored in the output state. 96 | 4. Custom styling from buttons is stored under the style tag inside run-button 97 | class. 98 | 5. The Output Section is inside the terminal class. 99 | All elements in this section are made via Bootstrap Cards. 100 | The Tutorial Card Component is also inside the terminal class. 101 | 6. The Modal Pop up for library selection is also a part of this section. 102 | It holds the switches for libraries toggle. 103 | 7. To add a new library in the frontend, add a new `
232 |
260 | Use the editor on the left to type your code, you can select your{' '} 261 | libraries 262 | and provide custom input for your code 263 | using the respective buttons. 264 |
265 |266 | New to Fortran? 267 |
Try our Quickstart Tutorial
268 | 269 | 270 |