Skip to content

Commit

Permalink
Restore lost changes (hedyorg#2041)
Browse files Browse the repository at this point in the history
Restore changes that were accidentally lost when PR hedyorg#1948 was merged.
  • Loading branch information
rix0rrr authored Feb 18, 2022
1 parent c8f6aa5 commit 1804382
Show file tree
Hide file tree
Showing 138 changed files with 586 additions and 254 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ batchhedy/output_*
#generated grammars
grammars-Total/*.lark
*.tsbuildinfo
!/content/adventures-transformed/
!/content/level-defaults-transformed/
!/coursedata/adventures-transformed/
!/coursedata/level-defaults-transformed/

#vscode excludes
.vscode
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ on which IDE you are using. Here are the IDEs we know about:
{
// ...
"yaml.schemas": {
"content/adventures/adventures.schema.json": "adventures/*.yaml"
"coursedata/adventures/adventures.schema.json": "adventures/*.yaml"
}
}
```
Expand All @@ -138,6 +138,6 @@ on which IDE you are using. Here are the IDEs we know about:
* Open **Preferences**
* Navigate to **Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings**.
* Click the **+** to add a new schema.
* Behind **Schema file or URL**, click the browse button and navigate to the `<your Hedy checkout>/content/adventures/adventures.schema.json` file.
* Click the **+** at the bottom, select **Directory**. In the new line that appears, paste `content/adventures`.
* Behind **Schema file or URL**, click the browse button and navigate to the `<your Hedy checkout>/coursedata/adventures/adventures.schema.json` file.
* Click the **+** at the bottom, select **Directory**. In the new line that appears, paste `coursedata/adventures`.
* Click **OK** to close the window.
26 changes: 15 additions & 11 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
Provide a general summary of your changes in the Title of the PR
**Please fill out this template by replacing all content between < >**

< Provide a one line summary of your changes in the Title of the PR >

**Description**

Describe your changes in detail. Please use present tense without a subject to describe your PR, for example: "Fix**es** issue 123" or "Adds translations of levels 1 to 12 for Polish"
< Changes in detail > Use present tense without a subject to describe your PR, for example: "Adds translations of levels 1 to 12 to Polish"

**Fix for**
**Fixes < issue or discussion number >**

Describe what issue or discussion your pr concerns
< Always link the number of the issue or of the discussion that your pr concerns. >
Notable exception: adding content may be done without an accompanying issue

**How to test**

Describe how to run your code to see it is action. See this https://github.com/Felienne/hedy/pull/880#issue-1016304308 for an example.
< If this is a UI change, describe how to run your code to see it in action. See this https://github.com/Felienne/hedy/pull/880#issue-1016304308 for an example >
< If this is a language change, add a few tests showing the difference >

**Checklist**
Done? Check if you have it all in place using this list*

- [ ] Describes changes in the format above (present tense)
- [ ] Links to an existing issue or discussion
- [ ] Has a "How to test" section

If you're unsure about any of these, don't hesitate to ask. We're here to help!
- [ ] Links to an existing issue or discussion (if not, create an issue first)
- [ ] Describes changes clear in the format above (present tense, no subject)
- [ ] Has a "how to test" section
- [ ] Only one thing is done in this pull request (specifically please try to refrain from mixing textual changes to the yamls from code changes)

* If you're unsure about any of these, don't hesitate to ask. We're here to help!
8 changes: 4 additions & 4 deletions TRANSLATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ Help Hedy with translations (in the code base, some coding experience needed)

If you would like to add a new translation, there are five places where files are located that need to be translated:

1) The folder [level-defaults](https://github.com/Felienne/hedy/blob/main/content/level-defaults/) has a file for each language. That file controls what the landing page for each levels looks like. It is probably easiest to copy the [English file](https://github.com/Felienne/hedy/blob/main/content/level-defaults/en.yaml), rename it and translate that. Tip: example variables can be translated too, that is probably helpful for learners!
1) The folder [level-defaults](https://github.com/Felienne/hedy/blob/main/coursedata/level-defaults/) has a file for each language. That file controls what the landing page for each levels looks like. It is probably easiest to copy the [English file](https://github.com/Felienne/hedy/blob/main/coursedata/level-defaults/en.yaml), rename it and translate that. Tip: example variables can be translated too, that is probably helpful for learners!

2) In the folder [texts](https://github.com/Felienne/hedy/tree/main/content/texts) there is a file for each language too. That file translate UI-elements like menu headers, and, important, the error messages Hedy programmers will see. As above, copying the [English file](https://github.com/Felienne/hedy/blob/main/content/texts/en.yaml) and translate that.
2) In the folder [texts](https://github.com/Felienne/hedy/tree/main/coursedata/texts) there is a file for each language too. That file translate UI-elements like menu headers, and, important, the error messages Hedy programmers will see. As above, copying the [English file](https://github.com/Felienne/hedy/blob/main/coursedata/texts/en.yaml) and translate that.

3) In the folder [keywords](https://github.com/Felienne/hedy/tree/main/content/keywords) there is a file for each language too. That file makes it possible for kids to write code using a translation for keywords like 'print' or 'echo'.
3) In the folder [keywords](https://github.com/Felienne/hedy/tree/main/coursedata/keywords) there is a file for each language too. That file makes it possible for kids to write code using a translation for keywords like 'print' or 'echo'.

4) The [folder](https://github.com/Felienne/hedy/tree/main/content/adventures) that control the assignments kids see in the user interface for each of the levels. While not mandatory, the assignments in this section are of help for kids to better explore each level. If you do not translate them, the English version will be shown.
4) The [folder](https://github.com/Felienne/hedy/tree/main/coursedata/adventures) that control the assignments kids see in the user interface for each of the levels. While not mandatory, the assignments in this section are of help for kids to better explore each level. If you do not translate them, the English version will be shown.

5) *optional* The folder [main](https://github.com/Felienne/hedy/tree/main/main) controls the web pages around Hedy. [start](https://github.com/Felienne/hedy/blob/main/main/start-en.md) holds the content of the start page, and there are page with press, contact info too. These do not necessariyl have to be translated, if you don't people will then see the English version, but kids can still program in their own native language.

Expand Down
38 changes: 23 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# Set the current directory to the root Hedy folder
os.chdir(os.path.join(os.getcwd(), __file__.replace(os.path.basename(__file__), '')))

# Define and load all available language content
# Define and load all available language data
ALL_LANGUAGES = {
'en': 'English',
'nl': 'Nederlands',
Expand Down Expand Up @@ -103,9 +103,19 @@
""")

# Preamble that will be used for non-Turtle programs
# numerals list generated from: https://replit.com/@mevrHermans/multilangnumerals

NORMAL_PREFIX_CODE = textwrap.dedent("""\
# coding=utf8
import random, time
global int_saver
int_saver = int
def int(s):
if isinstance(s, str):
numerals_dict = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', '𑁦': '0', '𑁧': '1', '𑁨': '2', '𑁩': '3', '𑁪': '4', '𑁫': '5', '𑁬': '6', '𑁭': '7', '𑁮': '8', '𑁯': '9', '०': '0', '१': '1', '२': '2', '३': '3', '४': '4', '५': '5', '६': '6', '७': '7', '८': '8', '९': '9', '૦': '0', '૧': '1', '૨': '2', '૩': '3', '૪': '4', '૫': '5', '૬': '6', '૭': '7', '૮': '8', '૯': '9', '੦': '0', '੧': '1', '੨': '2', '੩': '3', '੪': '4', '੫': '5', '੬': '6', '੭': '7', '੮': '8', '੯': '9', '০': '0', '১': '1', '২': '2', '৩': '3', '৪': '4', '৫': '5', '৬': '6', '৭': '7', '৮': '8', '৯': '9', '೦': '0', '೧': '1', '೨': '2', '೩': '3', '೪': '4', '೫': '5', '೬': '6', '೭': '7', '೮': '8', '೯': '9', '୦': '0', '୧': '1', '୨': '2', '୩': '3', '୪': '4', '୫': '5', '୬': '6', '୭': '7', '୮': '8', '୯': '9', '൦': '0', '൧': '1', '൨': '2', '൩': '3', '൪': '4', '൫': '5', '൬': '6', '൭': '7', '൮': '8', '൯': '9', '௦': '0', '௧': '1', '௨': '2', '௩': '3', '௪': '4', '௫': '5', '௬': '6', '௭': '7', '௮': '8', '௯': '9', '౦': '0', '౧': '1', '౨': '2', '౩': '3', '౪': '4', '౫': '5', '౬': '6', '౭': '7', '౮': '8', '౯': '9', '၀': '0', '၁': '1', '၂': '2', '၃': '3', '၄': '4', '၅': '5', '၆': '6', '၇': '7', '၈': '8', '၉': '9', '༠': '0', '༡': '1', '༢': '2', '༣': '3', '༤': '4', '༥': '5', '༦': '6', '༧': '7', '༨': '8', '༩': '9', '᠐': '0', '᠑': '1', '᠒': '2', '᠓': '3', '᠔': '4', '᠕': '5', '᠖': '6', '᠗': '7', '᠘': '8', '᠙': '9', '០': '0', '១': '1', '២': '2', '៣': '3', '៤': '4', '៥': '5', '៦': '6', '៧': '7', '៨': '8', '៩': '9', '๐': '0', '๑': '1', '๒': '2', '๓': '3', '๔': '4', '๕': '5', '๖': '6', '๗': '7', '๘': '8', '๙': '9', '໐': '0', '໑': '1', '໒': '2', '໓': '3', '໔': '4', '໕': '5', '໖': '6', '໗': '7', '໘': '8', '໙': '9', '꧐': '0', '꧑': '1', '꧒': '2', '꧓': '3', '꧔': '4', '꧕': '5', '꧖': '6', '꧗': '7', '꧘': '8', '꧙': '9', '٠': '0', '١': '1', '٢': '2', '٣': '3', '٤': '4', '٥': '5', '٦': '6', '٧': '7', '٨': '8', '٩': '9', '۰': '0', '۱': '1', '۲': '2', '۳': '3', '۴': '4', '۵': '5', '۶': '6', '۷': '7', '۸': '8', '۹': '9', '〇': '0', '一': '1', '二': '2', '三': '3', '四': '4', '五': '5', '六': '6', '七': '7', '八': '8', '九': '9', '零': '0'}
latin_numerals = ''.join([numerals_dict[letter] for letter in s])
return int_saver(latin_numerals)
return(int_saver(s))
""")


Expand Down Expand Up @@ -1230,17 +1240,15 @@ def update_public_profile(user):

@app.route('/translate/<source>/<target>')
def translate_fromto(source, target):
source_file = f'{source}.yaml'
source_adventures = YamlFile.for_file(utils.construct_content_path('adventures', source_file)).to_dict()
source_levels = YamlFile.for_file(utils.construct_content_path('level-defaults', source_file)).to_dict()
source_texts = YamlFile.for_file(utils.construct_content_path('texts', source_file)).to_dict()
source_keywords = YamlFile.for_file(utils.construct_content_path('keywords', source_file)).to_dict()

target_file = f'{target}.yaml'
target_adventures = YamlFile.for_file(utils.construct_content_path('adventures', target_file)).to_dict()
target_levels = YamlFile.for_file(utils.construct_content_path('level-defaults', target_file)).to_dict()
target_texts = YamlFile.for_file(utils.construct_content_path('texts', target_file)).to_dict()
target_keywords = YamlFile.for_file(utils.construct_content_path('keywords', target_file)).to_dict()
source_adventures = YamlFile.for_file(f'coursedata/adventures/{source}.yaml').to_dict()
source_levels = YamlFile.for_file(f'coursedata/level-defaults/{source}.yaml').to_dict()
source_texts = YamlFile.for_file(f'coursedata/texts/{source}.yaml').to_dict()
source_keywords = YamlFile.for_file(f'coursedata/keywords/{source}.yaml').to_dict()

target_adventures = YamlFile.for_file(f'coursedata/adventures/{target}.yaml').to_dict()
target_levels = YamlFile.for_file(f'coursedata/level-defaults/{target}.yaml').to_dict()
target_texts = YamlFile.for_file(f'coursedata/texts/{target}.yaml').to_dict()
target_keywords = YamlFile.for_file(f'coursedata/keywords/{target}.yaml').to_dict()

files = []

Expand Down Expand Up @@ -1272,10 +1280,10 @@ def translate_fromto(source, target):

@app.route('/update_yaml', methods=['POST'])
def update_yaml():
filename = utils.construct_content_path(request.form['file'])
# The file MUST point to something inside our 'content' directory
filename = path.join('coursedata', request.form['file'])
# The file MUST point to something inside our 'coursedata' directory
filepath = path.abspath(filename)
expected_path = utils.construct_content_path()
expected_path = path.abspath('coursedata')
if not filepath.startswith(expected_path):
raise RuntimeError('Invalid path given')

Expand Down
2 changes: 1 addition & 1 deletion batchhedy/batchhedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def run(filenames, report, top, check = None, ):
print(f"Total transpile time: {sum(runtimes):10f}s ")
print(f"Average transpile time: {sum(runtimes)/len(runtimes):10f}s ")
else:
# Compare with previous content
# Compare with previous data
previous_total_time = sum(float(
checkdata[job.filename]["transpile time"]
) for job in jobs)
Expand Down
2 changes: 1 addition & 1 deletion build-tools/github/validate-texts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const yaml = require ('yaml');

const ajv = new (require ('ajv'));

const path = require ('path').join (process.argv [2], '../../content/texts') + '/';
const path = require ('path').join (process.argv [2], '../../coursedata/texts') + '/';

// The English translation is our reference
const texts = yaml.parse (fs.readFileSync(path + 'en.yaml', 'utf8'));
Expand Down
2 changes: 1 addition & 1 deletion build-tools/github/validate-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ echo "------> Validating YAML"

pajv=$scriptdir/../../node_modules/.bin/pajv

cd ../../content/adventures/
cd ../../coursedata/adventures/
$pajv validate \
--errors=text \
-s "adventures.schema.json" \
Expand Down
8 changes: 4 additions & 4 deletions build-tools/heroku/generate-syntax-keywords
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#Takes the keywords from content/keywords/'lang'.yaml and creates a syntaxLang-'lang'.ts file for that language
#Takes the keywords from coursedata/keywords/'lang'.yaml and creates a syntaxLang-'lang'.ts file for that language
#How to use: add the argument for which language you want when using the script, e.g. 'generate-syntax-keywords en' for english
#Note that for the highlighter to work you will still need to import syntaxLang-'lang'.ts in index.ts and app.ts,
#as well as properly integrate it into syntaxModesRules.ts (so importing it properly and placing it in the switch statement for language)
Expand All @@ -17,18 +17,18 @@ export const LANG_"$1 "= {" > static/js/syntaxLang-$1.ts
regex='(.\S*): ((\w| \w)*)'
if [ $1 == 'en' ]
then
cat ./content/keywords/en.yaml | while read line; do
cat ./coursedata/keywords/en.yaml | while read line; do
[[ "$line" =~ $regex ]] #Compares the line being read to the regex and split it off into arguments ${BASH_REMATCH} 1 through 3
echo ${line/${BASH_REMATCH[0]}/\'_${BASH_REMATCH[1]^^}\':\'${BASH_REMATCH[2]}\',} >> static/js/syntaxLang-$1.ts
done
else
linenr=0
cat ./content/keywords/$1.yaml | while read line; do
cat ./coursedata/keywords/$1.yaml | while read line; do
[[ "$line" =~ $regex ]] #Compares the line being read to the regex and split it off into arguments ${BASH_REMATCH} 1 through 3
newline=${line/${BASH_REMATCH[0]}/\'_${BASH_REMATCH[1]^^}\':\'(?:${BASH_REMATCH[2]}\|}
#searches for the equivalent to the current line in en.yaml, parses and appends the english keywords, then finishes the sentence
linenr=$(( linenr+1 ))
engline=$(sed "${linenr}q;d" ./content/keywords/en.yaml)
engline=$(sed "${linenr}q;d" ./coursedata/keywords/en.yaml)
[[ "$engline" =~ $regex ]]
newline="${newline}${BASH_REMATCH[2]})',"
echo ${newline}>> static/js/syntaxLang-$1.ts
Expand Down
4 changes: 3 additions & 1 deletion build-tools/heroku/tailwind/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

html {
@apply font-light;
/* https://stackoverflow.com/questions/1417934/how-to-prevent-scrollbar-from-repositioning-web-page */
overflow-x: hidden;
margin-right: calc(-1 * (100vw - 100%));
}

.font-slab {
Expand All @@ -26,7 +29,6 @@ h4 {




* + p, * + ul, * + ol, * + pre {
@apply mt-4;
}
Expand Down
2 changes: 1 addition & 1 deletion build-tools/heroku/tailwind/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
// Put any file here that could contain HTML or CSS classes.
'../../../templates/**/*.html',
'../../../main/**/*.md',
'../../../content/**/*.md',
'../../../coursedata/**/*.md',
'../../../static/js/**/*.js',
],
theme: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1804382

Please sign in to comment.