Skip to content

Commit

Permalink
Merge branch 'master' into github-persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz committed Jun 24, 2021
2 parents 2d00c77 + ca0dbc4 commit 69af9a3
Show file tree
Hide file tree
Showing 67 changed files with 1,556 additions and 1,667 deletions.
42 changes: 24 additions & 18 deletions .github/workflows/build-development.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
name: Build source-academy.github.io
name: Build sourceacademy.org
on:
push:
branches:
- master

jobs:
deploy:
name: Deploy to GitHub Pages
name: Build and deploy sourceacademy.org
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js
uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Setup Sentry CLI
run: |
curl -sL https://sentry.io/get-cli/ | INSTALL_DIR=. bash
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down Expand Up @@ -50,28 +53,31 @@ jobs:
REACT_APP_ENVIRONMENT: "pages"
REACT_APP_MODULE_BACKEND_URL: https://source-academy.github.io/modules
REACT_APP_SHAREDB_BACKEND_URL: ${{ secrets.REACT_APP_SHAREDB_BACKEND_URL }}
REACT_APP_SW_EXCLUDE_REGEXES: '["^/source", "^/sicp", "^/modules", "^/ev3-source"]'
PUBLIC_URL: "https://source-academy.github.io"
PUBLIC_URL: "https://sourceacademy.org"
REACT_APP_GITHUB_OAUTH_PROXY_URL: ${{ secrets.REACT_APP_GITHUB_OAUTH_PROXY_URL }}
REACT_APP_GITHUB_CLIENT_ID: ${{ secrets.REACT_APP_GITHUB_CLIENT_ID }}
- name: Create symbolic links
- name: Create Sentry release
working-directory: build
run: |
SENTRY_RELEASE="cadet-frontend@$REACT_APP_VERSION"
"$GITHUB_WORKSPACE/sentry-cli" releases new -p "$SENTRY_PROJECT" "$SENTRY_RELEASE"
"$GITHUB_WORKSPACE/sentry-cli" releases set-commits --auto "$SENTRY_RELEASE"
"$GITHUB_WORKSPACE/sentry-cli" releases files "$SENTRY_RELEASE" upload-sourcemaps --url-prefix '~/static/js' --rewrite static/js
"$GITHUB_WORKSPACE/sentry-cli" releases finalize "$SENTRY_RELEASE"
"$GITHUB_WORKSPACE/sentry-cli" releases deploys "$SENTRY_RELEASE" new -e pages
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: sourceacademy
SENTRY_PROJECT: cadet-frontend
REACT_APP_VERSION: ${{ format('{0}-{1}', github.sha, steps.get-time.outputs.time) }}
- name: Remove sourcemaps
working-directory: build
run: |
set -euxo pipefail
ln -s index.html build/playground.html
ln -s index.html build/contributors.html
ln -s index.html build/sourcecast.html
ln -s index.html build/interactive-sicp.html
mkdir -p build/interactive-sicp
declare -a arr=("index" "foreword" "prefaces03" "prefaces84" "prefaces96" "acknowledgements" "1" "1.1" "1.1.1" "1.1.2" "1.1.3" "1.1.4" "1.1.5" "1.1.6" "1.1.7" "1.1.8" "1.2" "1.2.1" "1.2.2" "1.2.3" "1.2.4" "1.2.5" "1.2.6" "1.3" "1.3.1" "1.3.2" "1.3.3" "1.3.4" "2" "2.1" "2.1.1" "2.1.2" "2.1.3" "2.1.4" "2.2" "2.2.1" "2.2.2" "2.2.3" "2.2.4" "2.3" "2.3.1" "2.3.2" "2.3.3" "2.3.4" "2.4" "2.4.1" "2.4.2" "2.4.3" "2.5" "2.5.1" "2.5.2" "2.5.3" "3" "3.1" "3.1.1" "3.1.2" "3.1.3" "3.2" "3.2.1" "3.2.2" "3.2.3" "3.2.4" "3.3" "3.3.1" "3.3.2" "3.3.3" "3.3.4" "3.3.5" "3.4" "3.4.1" "3.4.2" "3.5" "3.5.1" "3.5.2" "3.5.3" "3.5.4" "3.5.5" "4" "4.1" "4.1.1" "4.1.2" "4.1.3" "4.1.4" "4.1.5" "4.1.6" "4.1.7" "4.2" "4.2.1" "4.2.2" "4.2.3" "4.3" "4.3.1" "4.3.2" "4.3.3" "4.4" "4.4.1" "4.4.2" "4.4.3" "4.4.4" "5" "5.1" "5.1.1" "5.1.2" "5.1.3" "5.1.4" "5.1.5" "5.2" "5.2.1" "5.2.2" "5.2.3" "5.2.4" "5.3" "5.3.1" "5.3.2" "5.4" "5.4.1" "5.4.2" "5.4.3" "5.4.4" "5.5" "5.5.1" "5.5.2" "5.5.3" "5.5.4" "5.5.5" "5.5.6" "5.5.7" "references" "making-of")
for i in "${arr[@]}"; do
ln -s ../index.html build/interactive-sicp/$i.html
done
# the `ln`s above are a hack to make GitHub Pages route /playground
# and /contributors etc to index, instead of 404-ing.
find -name '*.map' -print -delete
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
external_repository: source-academy/source-academy.github.io
external_repository: source-academy/sourceacademy.org
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
publish_dir: ./build
publish_branch: master
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
[![Coverage Status](https://coveralls.io/repos/github/source-academy/cadet-frontend/badge.svg?branch=master)](https://coveralls.io/github/source-academy/cadet-frontend?branch=master)
[![License](https://img.shields.io/github/license/source-academy/cadet-frontend)](https://github.com/source-academy/cadet-frontend/blob/master/LICENSE)

The Source Academy (<https://source-academy.github.io/>) is an immersive online experiential environment for learning programming. It is developed by a community of learners (also called "Source Academy") who use the book [Structure and Interpretation of Computer Programs, JavaScript Adaptation](https://source-academy.github.io/interactive-sicp) (SICP JS). This repository houses the sources for the frontend of the Source Academy, written in ReactJS with Redux.
The Source Academy (<https://sourceacademy.org/>) is an immersive online experiential environment for learning programming. It is developed by a community of learners (also called "Source Academy") who use the book [Structure and Interpretation of Computer Programs, JavaScript Adaptation](https://sourceacademy.org/sicpjs) (SICP JS). This repository houses the sources for the frontend of the Source Academy, written in ReactJS with Redux.

## Features

- Playground to write and test programs
- Built-in Debugger and Visualizer to interact with your programs
- Missions/Quests/Contests to solve challenging problems while learning about programming fundamentals
Expand Down
227 changes: 0 additions & 227 deletions public/externalLibs/inspector/inspector.js
Original file line number Diff line number Diff line change
@@ -1,225 +1,4 @@
(function (exports) {
var container = document.createElement('div');
container.id = 'inspector-container';

const builtins = [
'Infinity',
'NaN',
'accumulate',
'alert',
'append',
'apply_in_underlying_javascript',
'array_length',
'assoc',
'black',
'blue',
'brown',
'build_list',
'build_stream',
'color',
'display',
'display_list',
'draw_data',
'enum_list',
'enum_stream',
'equal',
'error',
'eval_stream',
'filter',
'for_each',
'get_time',
'green',
'has_own_property',
'head',
'indigo',
'integers_from',
'is',
'is_NaN',
'is_array',
'is_boolean',
'is_function',
'is_list',
'is_null',
'is_number',
'is_object',
'is_pair',
'is_stream',
'is_string',
'is_undefined',
'length',
'list',
'list_ref',
'list_to_stream',
'list_to_string',
'map',
'math_E',
'math_LN10',
'math_LN2',
'math_LOG10E',
'math_LOG2E',
'math_PI',
'math_SQRT1_2',
'math_SQRT2',
'math_abs',
'math_acos',
'math_acosh',
'math_asin',
'math_asinh',
'math_atan',
'math_atan2',
'math_atanh',
'math_cbrt',
'math_ceil',
'math_clz32',
'math_cos',
'math_cosh',
'math_exp',
'math_expm1',
'math_floor',
'math_fround',
'math_hypot',
'math_imul',
'math_log',
'math_log10',
'math_log1p',
'math_log2',
'math_max',
'math_min',
'math_pow',
'math_random',
'math_round',
'math_sign',
'math_sin',
'math_sinh',
'math_sqrt',
'math_tan',
'math_tanh',
'math_toSource',
'math_trunc',
'member',
'orange',
'pair',
'parse',
'parse_int',
'pink',
'prompt',
'purple',
'quarter_turn_left',
'quarter_turn_right',
'random_color',
'raw_display',
'red',
'remove',
'remove_all',
'reverse',
'rotate',
'runtime',
'scale',
'scale_independent',
'set_head',
'set_tail',
'show',
'stack',
'stack_frac',
'stackn',
'stream',
'stream_append',
'stream_filter',
'stream_for_each',
'stream_length',
'stream_map',
'stream_member',
'stream_ref',
'stream_remove',
'stream_remove_all',
'stream_reverse',
'stream_tail',
'stream_to_list',
'stringify',
'tail',
'translate',
'undefined',
'white',
'yellow'
];

function filter(str) {
// regex to match: replacement for match
swapTable = {
programEnvironment: 'Program',
forLoopEnvironment: 'Body of <code>for</code>',
forBlockEnvironment: 'Control statement of <code>for</code>',
blockEnvironment: 'Block',
'[.]* => [.]*': ' => ',
'{[\\s\\S]*}': '{...}',
'Symbol.*': '-'
};
for (var r in swapTable) {
str = str.replace(new RegExp(r), swapTable[r]);
}
return str;
}

function updateContext(context, stringify) {
// Hides the default text
const defaultText = document.getElementById('inspector-default-text');
if (defaultText) {
defaultText.hidden = true;
}

function dumpTable(env) {
var res = '';
for (var k in env) {
if (builtins.indexOf('' + k) < 0) {
var str = filter(stringify(env[k]));
res +=
'<tr><td class="inspect-table-obj-name">' +
k +
'</td>' +
'<td class="inspect-table-obj-details"><code>' +
filter(str) +
'</code></td></tr>';
}
}
return res.length > 0 ? res : undefined;
}

function drawOutput() {
var frames = context.context.runtime.environments;
container.innerHTML = '';
for (var frame of frames) {
var envtoString = dumpTable(frame.head);
if (envtoString == undefined) {
// skipping either empty frame or perhaps the global
continue;
}
var newtable = document.createElement('table');
newtable.classList.add('inspect-scope-table');
newtable.innerHTML = '<colgroup><col width="20%"><col width="80%"></colgroup>';
var tbody = document.createElement('tbody');
tbody.innerHTML =
'</br><caption><strong>' + filter(frame.name) + '</strong></caption>' + envtoString;
newtable.appendChild(tbody);
container.appendChild(newtable);
}
}

// icon to blink
const icon = document.getElementById('inspector-icon');

if (context) {
drawOutput();
if (icon) {
icon.classList.add('side-content-tab-alert'); // this blinks the icon
}
} else if (icon) {
// here we have no context! don't alert the inspector...
document.getElementById('inspector-default-text').hidden = false;
icon.classList.remove('side-content-tab-alert');
container.innerHTML = '';
}
}

function highlightClean() {
var gutterCells = document.getElementsByClassName('ace_gutter-cell');
var aceLines = document.getElementsByClassName('ace_line');
Expand All @@ -241,12 +20,6 @@
}

exports.Inspector = {
builtins,
filter,
init: function (parent) {
parent.appendChild(container);
},
updateContext,
highlightLine,
highlightClean
};
Expand Down
2 changes: 1 addition & 1 deletion src/commons/__tests__/__snapshots__/Markdown.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Markdown page renders correctly 1`] = `
"<Memo(Markdown) content=\\"\\\\nWelcome to the Source Academy playground!\\\\n\\\\nThe language [_Source_](https://source-academy.github.io/source/) is the official language of the textbook [_Structure and\\\\nInterpretation of Computer Programs, JavaScript Adaptation_](https://source-academy.github.io/interactive-sicp/). You have chosen the sublanguage [_Source §1_](https://source-academy.github.io/source/source_1/).\\\\n\\\\nIn the editor on the left, you can use the [_Ace keyboard shortcuts_](https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts) \\\\nand also the [_Source Academy keyboard shortcuts_](https://github.com/source-academy/cadet-frontend/wiki/Source-Academy-Keyboard-Shortcuts).\\\\n\\\\n\\" openLinksInNewWindow={true}>
"<Memo(Markdown) content=\\"\\\\nWelcome to the Source Academy playground!\\\\n\\\\nThe language [_Source_](https://docs.sourceacademy.org/) is the official language of the textbook [_Structure and\\\\nInterpretation of Computer Programs, JavaScript Adaptation_](https://sourceacademy.org/sicpjs/). You have chosen the sublanguage [_Source §1_](https://docs.sourceacademy.org/source_1/).\\\\n\\\\nIn the editor on the left, you can use the [_Ace keyboard shortcuts_](https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts) \\\\nand also the [_Source Academy keyboard shortcuts_](https://github.com/source-academy/cadet-frontend/wiki/Source-Academy-Keyboard-Shortcuts).\\\\n\\\\n\\" openLinksInNewWindow={true}>
<div className=\\"md bp3-running-text\\" dangerouslySetInnerHTML={{...}} />
</Memo(Markdown)>"
`;
20 changes: 7 additions & 13 deletions src/commons/application/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import Academy from '../../pages/academy/AcademyContainer';
import Achievement from '../../pages/achievement/AchievementContainer';
import Contributors from '../../pages/contributors/Contributors';
import Disabled from '../../pages/disabled/Disabled';
import GitHubAssessmentWorkspaceContainer from '../../pages/githubAssessments/GitHubAssessmentWorkspaceContainer';
import GitHubMissionListing from '../../pages/githubAssessments/GitHubMissionListing';
import GitHubClassroom from '../../pages/githubAssessments/GitHubClassroom';
import GitHubCallback from '../../pages/githubCallback/GitHubCallback';
import Login from '../../pages/login/LoginContainer';
import MissionControlContainer from '../../pages/missionControl/MissionControlContainer';
Expand Down Expand Up @@ -149,24 +148,19 @@ const Application: React.FC<ApplicationProps> = props => {
<Route path="/sourcecast/:sourcecastId?" component={SourcecastContainer} />
{Constants.enableGitHubAssessments && (
<Route
path="/githubassessments/missions"
path="/githubassessments"
component={() => (
<GitHubMissionListing
<GitHubClassroom
handleGitHubLogIn={props.handleGitHubLogIn}
handleGitHubLogOut={props.handleGitHubLogOut}
/>
)}
/>
)}
{Constants.enableGitHubAssessments && (
<Route
path="/githubassessments/editor"
component={GitHubAssessmentWorkspaceContainer}
/>
)}
<Route path="/callback/github" component={GitHubCallback} />
<Route exact path="/interactive-sicp" render={redirectToSicp} />
<Route path="/interactive-sicp/:section" component={Sicp} />
<Redirect from="/interactive-sicp/:section?" to="/sicpjs/:section?" />
<Route exact path="/sicpjs" render={redirectToSicp} />
<Route path="/sicpjs/:section" component={Sicp} />
{fullPaths}
<Route
exact={true}
Expand All @@ -184,7 +178,7 @@ const Application: React.FC<ApplicationProps> = props => {
const redirectToPlayground = () => <Redirect to="/playground" />;
const redirectToAcademy = () => <Redirect to="/academy" />;
const redirectToLogin = () => <Redirect to="/login" />;
const redirectToSicp = () => <Redirect to="/interactive-sicp/index" />;
const redirectToSicp = () => <Redirect to="/sicpjs/index" />;

/**
* A user routes to /academy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ exports[`Application renders correctly 1`] = `
<Route path=\\"/playground\\" component={[Function: C] { displayName: 'withRouter(Connect(Playground))', WrappedComponent: [Function: Playground], propTypes: { wrappedComponentRef: [Function: bound checkType] { isRequired: [Function: bound checkType] } } }} />
<Route path=\\"/contributors\\" component={[function]} />
<Route path=\\"/sourcecast/:sourcecastId?\\" component={[Function: C] { displayName: 'withRouter(Connect(Sourcecast))', WrappedComponent: [Function: Sourcecast], propTypes: { wrappedComponentRef: [Function: bound checkType] { isRequired: [Function: bound checkType] } } }} />
<Route path=\\"/githubassessments/missions\\" component={[Function: component]} />
<Route path=\\"/githubassessments/editor\\" component={[Function: C] { displayName: 'withRouter(Connect(GitHubAssessmentWorkspace))', WrappedComponent: [Function: GitHubAssessmentWorkspace], propTypes: { wrappedComponentRef: [Function: bound checkType] { isRequired: [Function: bound checkType] } } }} />
<Route path=\\"/githubassessments\\" component={[Function: component]} />
<Route path=\\"/callback/github\\" component={[Function: GitHubCallback]} />
<Route exact={true} path=\\"/interactive-sicp\\" render={[Function: redirectToSicp]} />
<Route path=\\"/interactive-sicp/:section\\" component={[Function: Sicp]} />
<Redirect from=\\"/interactive-sicp/:section?\\" to=\\"/sicpjs/:section?\\" />
<Route exact={true} path=\\"/sicpjs\\" render={[Function: redirectToSicp]} />
<Route path=\\"/sicpjs/:section\\" component={[Function: Sicp]} />
<Route path=\\"/academy\\" render={[Function: redirectToLogin]} />
<Route path=\\"/mission-control/:assessmentId(-?\\\\\\\\d+)?/:questionId(\\\\\\\\d+)?\\" render={[Function: toIncubator]} />
<Route path=\\"/login\\" render={[Function (anonymous)]} />
Expand Down
Loading

0 comments on commit 69af9a3

Please sign in to comment.