Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📜 rename commands to keywords where applicable #6053

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
os.path.basename(__file__), '')))


COMMANDS = collections.defaultdict(hedy_content.NoSuchCommand)
CHEATSHEETS = collections.defaultdict(hedy_content.NoSuchFile)
for lang in ALL_LANGUAGES.keys():
COMMANDS[lang] = hedy_content.Commands(lang)
CHEATSHEETS[lang] = hedy_content.Cheatsheets(lang)

ADVENTURES = collections.defaultdict(hedy_content.NoSuchAdventure)
for lang in ALL_LANGUAGES.keys():
Expand Down Expand Up @@ -1026,15 +1026,15 @@ def version_page():
commit=commit)


@app.route('/commands/<id>')
def all_commands(id):
@app.route('/keywords/<id>')
def all_keywords(id):
program = g_db().program_by_id(id)
code = program.get('code')
level = program.get('level')
lang = program.get('lang')
return render_template(
'commands.html',
commands=hedy.all_commands(code, level, lang))
'keywords.html',
keywords=hedy.all_keywords(code, level, lang))


@app.route('/programs', methods=['GET'])
Expand Down Expand Up @@ -1195,8 +1195,8 @@ def tutorial_index():
if not current_user()['username']:
return redirect('/login')
level = 1
cheatsheet = COMMANDS[g.lang].get_commands_for_level(level, g.keyword_lang)
commands = hedy.commands_per_level.get(level)
cheatsheet = CHEATSHEETS[g.lang].get_keywords_for_level(level, g.keyword_lang)
commands = hedy.keywords_per_level.get(level)
adventures = load_adventures_for_level(level)
parsons = len(PARSONS[g.lang].get_parsons_data_for_level(level))
initial_tab = adventures[0].short_name
Expand Down Expand Up @@ -1347,7 +1347,7 @@ def hour_of_code(level, program_id=None):
# Add the available levels to the customizations dict -> simplify
# implementation on the front-end
customizations['available_levels'] = available_levels
cheatsheet = COMMANDS[g.lang].get_commands_for_level(level, g.keyword_lang)
cheatsheet = CHEATSHEETS[g.lang].get_keywords_for_level(level, g.keyword_lang)

load_customized_adventures(level, customizations, adventures)
load_saved_programs(level, adventures, loaded_program)
Expand Down Expand Up @@ -1395,7 +1395,7 @@ def hour_of_code(level, program_id=None):
prev_level, next_level = utils.find_prev_next_levels(
list(available_levels), level_number)

commands = hedy.commands_per_level.get(level)
commands = hedy.keywords_per_level.get(level)
return render_template(
"code-page.html",
level_nr=str(level_number),
Expand Down Expand Up @@ -1557,7 +1557,7 @@ def index(level, program_id):
# Add the available levels to the customizations dict -> simplify
# implementation on the front-end
customizations['available_levels'] = available_levels
cheatsheet = COMMANDS[g.lang].get_commands_for_level(level, g.keyword_lang)
cheatsheet = CHEATSHEETS[g.lang].get_keywords_for_level(level, g.keyword_lang)

adventures = load_adventures_for_level(level)
load_customized_adventures(level, customizations, adventures)
Expand Down Expand Up @@ -1630,7 +1630,7 @@ def index(level, program_id):
for i, adventure in enumerate(adventures):
if adventure.save_info:
completed = i
commands = hedy.commands_per_level.get(level)
commands = hedy.keywords_per_level.get(level)
return render_template(
"code-page.html",
level_nr=str(level_number),
Expand Down Expand Up @@ -1788,7 +1788,7 @@ def tryit(level, program_id):
# Add the available levels to the customizations dict -> simplify
# implementation on the front-end
customizations['available_levels'] = available_levels
cheatsheet = COMMANDS[g.lang].get_commands_for_level(level, g.keyword_lang)
cheatsheet = CHEATSHEETS[g.lang].get_keywords_for_level(level, g.keyword_lang)

adventures = load_adventures_for_level(level)
load_customized_adventures(level, customizations, adventures)
Expand Down Expand Up @@ -1861,7 +1861,7 @@ def tryit(level, program_id):
for i, adventure in enumerate(adventures):
if adventure.save_info:
completed = i
commands = hedy.commands_per_level.get(level)
commands = hedy.keywords_per_level.get(level)
return render_template(
"hedy-page/code-page.html",
level_nr=str(level_number),
Expand Down Expand Up @@ -2117,7 +2117,7 @@ def get_specific_adventure(name, level, mode):
prev_level, next_level = utils.find_prev_next_levels(customizations["available_levels"], level)

# Add the commands to enable the language switcher dropdown
commands = hedy.commands_per_level.get(level)
commands = hedy.keywords_per_level.get(level)
raw = mode == 'raw'
initial_tab = name
initial_adventure = adventures[0]
Expand Down Expand Up @@ -2218,7 +2218,7 @@ def get_cheatsheet_page(level):
except BaseException:
return utils.error_page(error=404, ui_message=gettext('no_such_level'))

commands = COMMANDS[g.lang].get_commands_for_level(level, g.keyword_lang)
commands = CHEATSHEETS[g.lang].get_keywords_for_level(level, g.keyword_lang)

return render_template("printable/cheatsheet.html", commands=commands, level=level)

Expand Down
Loading
Loading