{"schemaVersion":1,"contentVersion":"3.4.0","id":"foundation.6","languages":{"javascript":{"id":"foundation.6","title":"Choose where typing begins","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Start typing before or after the cursor, at either end of the line, or on a new line.</p><p><strong>Before this lesson:</strong> Reach a line or buffer boundary.</p><p>i starts typing before the cursor and a after it. I starts at the first character that isn't a space and A at the end of the line. o opens a new line below and O opens one above, even above the first line. Esc finishes every insertion. A new line of code may copy the indentation of the line above, so check it before you add spaces.</p><div class=\"pkeys\"><kbd>i</kbd> <kbd>a</kbd> <kbd>I</kbd> <kbd>A</kbd> <kbd>o</kbd> <kbd>O</kbd></div><h3>Example</h3><p>From anywhere on “review”, A then “ today” then Esc makes “review today”. O then “Plan” then Esc adds a new line above. I would add the text to the start of the same line instead.</p><h4>Worked text</h4><pre class=\"lesson-example\">// review</pre><h4>After the edit</h4><pre class=\"lesson-example\">// review today</pre><p>Use Start over to try again.</p>","teaches":["door-i","door-a","door-I","door-A","door-o","door-O"],"introduces":["a","I","A","o","O"],"constraints":[],"drills":[{"task":"The carrier's page should open in a new tab. Add <code>target=\"_blank\" </code> before <code>href</code>.","hint":"W jumps to the next WORD, and i starts typing before the cursor.","mode":"jsx","start":"// The link to the carrier's tracking page, in the order email.\nexport function TrackingLink({ url }) {\n  return <a className=\"tracking\" href={url}>Track your parcel</a>;\n}","startCursor":{"line":2,"ch":23},"paths":[{"keys":["W","i","target=\"_blank\" ","<Esc>"],"tier":"idiomatic","technique":"door-i","core":["door-i"],"note":"i types before the cursor, so land on the first letter of what comes after."}],"target":"// The link to the carrier's tracking page, in the order email.\nexport function TrackingLink({ url }) {\n  return <a className=\"tracking\" target=\"_blank\" href={url}>Track your parcel</a>;\n}","language":"javascript","evidence":"guided","canonicalKey":"foundation.6#0","canonicalFingerprint":"bzakn0"},{"task":"Fix the typo: free delivery is on <code>orders</code> over 50 euros.","hint":"a starts typing after the cursor, so e then a adds to the end of a word.","mode":"jsx","start":"// Shown under the basket total.\nexport function DeliveryNote({ total }) {\n  if (total >= 5000) return <p className=\"note\">Delivery is free.</p>;\n  return (\n    <p className=\"note\">Free delivery on order over 50 euros.</p>\n  );\n}","startCursor":{"line":4,"ch":24},"paths":[{"keys":["4","e","a","s","<Esc>"],"tier":"idiomatic","technique":"door-a","core":["door-a"],"note":"e lands on the last letter of the word, and a types after it."}],"target":"// Shown under the basket total.\nexport function DeliveryNote({ total }) {\n  if (total >= 5000) return <p className=\"note\">Delivery is free.</p>;\n  return (\n    <p className=\"note\">Free delivery on orders over 50 euros.</p>\n  );\n}","language":"javascript","evidence":"guided","canonicalKey":"foundation.6#1","canonicalFingerprint":"1la3wpi"},{"task":"Every request is logged now, which is too noisy. Comment out the <code>console.log</code> line.","hint":"I starts typing before the first character of the line, wherever the cursor is.","mode":"jsx","start":"const API_ROOT = \"https://api.northwind.shop/v3\";\n\nexport async function getJson(path, init = {}) {\n  console.log(\"request\", path, init);\n  const response = await fetch(API_ROOT + path, init);\n  if (!response.ok) throw new Error(`${response.status} for ${path}`);\n  return response.json().catch(() => null);\n}","startCursor":{"line":2,"ch":18},"paths":[{"keys":["j","I","// ","<Esc>"],"tier":"idiomatic","technique":"door-I","core":["door-I"],"note":"I types at the start of the line's text, wherever you are on it."}],"target":"const API_ROOT = \"https://api.northwind.shop/v3\";\n\nexport async function getJson(path, init = {}) {\n  // console.log(\"request\", path, init);\n  const response = await fetch(API_ROOT + path, init);\n  if (!response.ok) throw new Error(`${response.status} for ${path}`);\n  return response.json().catch(() => null);\n}","language":"javascript","evidence":"guided","canonicalKey":"foundation.6#2","canonicalFingerprint":"h6ejwl"},{"task":"The banner only applies to today. Add <code> today</code> to the end of the comment about the warehouse.","hint":"A starts typing at the end of the line, wherever the cursor is.","mode":"jsx","start":"// Shown at the top of every page while it's set.\nexport const banner = {\n  // The warehouse is closed for stocktaking\n  text: \"Orders placed now ship on Monday.\",\n  tone: \"warning\",\n  dismissible: true,\n};","startCursor":{"line":2,"ch":2},"paths":[{"keys":["A"," today","<Esc>"],"tier":"idiomatic","technique":"door-A","core":["door-A"],"note":"A types at the end of the line, wherever you are on it."}],"target":"// Shown at the top of every page while it's set.\nexport const banner = {\n  // The warehouse is closed for stocktaking today\n  text: \"Orders placed now ship on Monday.\",\n  tone: \"warning\",\n  dismissible: true,\n};","language":"javascript","evidence":"guided","canonicalKey":"foundation.6#3","canonicalFingerprint":"1mlm5qa"},{"task":"The staging site needs to call the API too. Add <code>\"https://staging.northwind.shop\",</code> below the admin origin.","hint":"o opens a new line below and copies its indentation.","mode":"jsx","start":"// The sites that may call the API from a browser.\nconst ORIGINS = [\n  \"https://northwind.shop\",\n  \"https://admin.northwind.shop\",\n];\n\nexport function allowOrigin(origin) {\n  return ORIGINS.includes(origin);\n}","startCursor":{"line":2,"ch":12},"paths":[{"keys":["j","o","\"https://staging.northwind.shop\",","<Esc>"],"tier":"idiomatic","technique":"door-o","core":["door-o"],"note":"o opens the new line below with the same indentation."}],"target":"// The sites that may call the API from a browser.\nconst ORIGINS = [\n  \"https://northwind.shop\",\n  \"https://admin.northwind.shop\",\n  \"https://staging.northwind.shop\",\n];\n\nexport function allowOrigin(origin) {\n  return ORIGINS.includes(origin);\n}","language":"javascript","evidence":"guided","canonicalKey":"foundation.6#4","canonicalFingerprint":"7l2arw"},{"task":"Load the shop's styles before anything else. Add <code>import \"./styles.css\";</code> above the first line.","hint":"O opens a new line above.","mode":"jsx","start":"import { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { RouterProvider } from \"react-router-dom\";\nimport { router } from \"./router.jsx\";\n\ncreateRoot(document.getElementById(\"root\")).render(\n  <StrictMode><RouterProvider router={router} /></StrictMode>,\n);","startCursor":{"line":1,"ch":9},"paths":[{"keys":["k","O","import \"./styles.css\";","<Esc>"],"tier":"idiomatic","technique":"door-O","core":["door-O"],"note":"O opens the new line above."}],"target":"import \"./styles.css\";\nimport { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { RouterProvider } from \"react-router-dom\";\nimport { router } from \"./router.jsx\";\n\ncreateRoot(document.getElementById(\"root\")).render(\n  <StrictMode><RouterProvider router={router} /></StrictMode>,\n);","language":"javascript","evidence":"guided","canonicalKey":"foundation.6#5","canonicalFingerprint":"1p0nqjl"}]},"python":{"id":"foundation.6","title":"Choose where typing begins","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Start typing before or after the cursor, at either end of the line, or on a new line.</p><p><strong>Before this lesson:</strong> Reach a line or buffer boundary.</p><p>i starts typing before the cursor and a after it. I starts at the first character that isn't a space and A at the end of the line. o opens a new line below and O opens one above, even above the first line. Esc finishes every insertion. A new line of code may copy the indentation of the line above, so check it before you add spaces.</p><div class=\"pkeys\"><kbd>i</kbd> <kbd>a</kbd> <kbd>I</kbd> <kbd>A</kbd> <kbd>o</kbd> <kbd>O</kbd></div><h3>Example</h3><p>From anywhere on “review”, A then “ today” then Esc makes “review today”. O then “Plan” then Esc adds a new line above. I would add the text to the start of the same line instead.</p><h4>Worked text</h4><pre class=\"lesson-example\"># review</pre><h4>After the edit</h4><pre class=\"lesson-example\"># review today</pre><p>Use Start over to try again.</p>","teaches":["door-i","door-a","door-I","door-A","door-o","door-O"],"introduces":["a","I","A","o","O"],"constraints":[],"drills":[{"task":"The reminder is for accounts that aren't active yet. Add <code>not </code> before <code>user.is_active</code>.","hint":"W jumps to the next WORD, and i starts typing before the cursor.","mode":"python","start":"from shop.emails import send_activation_reminder\n\n\ndef remind(users):\n    \"\"\"Emails everyone who signed up but never clicked the link.\"\"\"\n    for user in users:\n        if user.is_active and user.email:\n            send_activation_reminder(user)","startCursor":{"line":5,"ch":8},"paths":[{"keys":["j","w","i","not ","<Esc>"],"tier":"idiomatic","technique":"door-i","core":["door-i"],"note":"i types before the cursor, so land on the first letter of what comes after."}],"target":"from shop.emails import send_activation_reminder\n\n\ndef remind(users):\n    \"\"\"Emails everyone who signed up but never clicked the link.\"\"\"\n    for user in users:\n        if not user.is_active and user.email:\n            send_activation_reminder(user)","language":"python","evidence":"guided","canonicalKey":"foundation.6#0","canonicalFingerprint":"bzakn0"},{"task":"Fix the typo: free delivery is on <code>orders</code> over 50 euros.","hint":"a starts typing after the cursor, so e then a adds to the end of a word.","mode":"python","start":"from django import template\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef delivery_note(total):\n    if total >= 5000:\n        return \"Delivery is free.\"\n    return \"Free delivery on order over 50 euros.\"","startCursor":{"line":9,"ch":12},"paths":[{"keys":["4","e","a","s","<Esc>"],"tier":"idiomatic","technique":"door-a","core":["door-a"],"note":"e lands on the last letter of the word, and a types after it."}],"target":"from django import template\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef delivery_note(total):\n    if total >= 5000:\n        return \"Delivery is free.\"\n    return \"Free delivery on orders over 50 euros.\"","language":"python","evidence":"guided","canonicalKey":"foundation.6#1","canonicalFingerprint":"1la3wpi"},{"task":"Every request is printed now, which is too noisy. Comment out the <code>print</code> line.","hint":"I starts typing before the first character of the line, wherever the cursor is.","mode":"python","start":"import json\nfrom urllib.request import urlopen\n\nAPI_ROOT = \"https://api.northwind.shop/v3\"\n\n\ndef get_json(path):\n    print(\"request\", path)\n    with urlopen(API_ROOT + path, timeout=5) as response:\n        return json.load(response)","startCursor":{"line":6,"ch":12},"paths":[{"keys":["j","I","# ","<Esc>"],"tier":"idiomatic","technique":"door-I","core":["door-I"],"note":"I types at the start of the line's text, wherever you are on it."}],"target":"import json\nfrom urllib.request import urlopen\n\nAPI_ROOT = \"https://api.northwind.shop/v3\"\n\n\ndef get_json(path):\n    # print(\"request\", path)\n    with urlopen(API_ROOT + path, timeout=5) as response:\n        return json.load(response)","language":"python","evidence":"guided","canonicalKey":"foundation.6#2","canonicalFingerprint":"h6ejwl"},{"task":"People paste their email with a space at the end. Add <code>.strip()</code> to the end of the <code>email</code> line.","hint":"A starts typing at the end of the line, wherever the cursor is.","mode":"python","start":"from django.http import HttpResponseBadRequest\n\n\ndef sign_up(request):\n    \"\"\"Creates an account from the sign-up form.\"\"\"\n    email = request.POST[\"email\"]\n    if \"@\" not in email:\n        return HttpResponseBadRequest(\"That doesn't look like an email address.\")\n    return create_account(email, request.POST[\"password\"])","startCursor":{"line":4,"ch":15},"paths":[{"keys":["j","A",".strip()","<Esc>"],"tier":"idiomatic","technique":"door-A","core":["door-A"],"note":"A types at the end of the line, wherever you are on it."}],"target":"from django.http import HttpResponseBadRequest\n\n\ndef sign_up(request):\n    \"\"\"Creates an account from the sign-up form.\"\"\"\n    email = request.POST[\"email\"].strip()\n    if \"@\" not in email:\n        return HttpResponseBadRequest(\"That doesn't look like an email address.\")\n    return create_account(email, request.POST[\"password\"])","language":"python","evidence":"guided","canonicalKey":"foundation.6#3","canonicalFingerprint":"1mlm5qa"},{"task":"Turn on the new reviews app. Add <code>\"shop.reviews\",</code> below <code>\"shop.orders\",</code>.","hint":"o opens a new line below and copies its indentation.","mode":"python","start":"INSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.sessions\",\n    \"shop.catalog\",\n    \"shop.orders\",\n    \"shop.payments\",\n]","startCursor":{"line":4,"ch":11},"paths":[{"keys":["j","o","\"shop.reviews\",","<Esc>"],"tier":"idiomatic","technique":"door-o","core":["door-o"],"note":"o opens the new line below with the same indentation."}],"target":"INSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.sessions\",\n    \"shop.catalog\",\n    \"shop.orders\",\n    \"shop.reviews\",\n    \"shop.payments\",\n]","language":"python","evidence":"guided","canonicalKey":"foundation.6#4","canonicalFingerprint":"7l2arw"},{"task":"Only signed-in customers may see this page. Add <code>@login_required</code> on the line above <code>def addresses</code>.","hint":"O opens a new line above.","mode":"python","start":"from django.contrib.auth.decorators import login_required\nfrom django.shortcuts import render\n\n\ndef addresses(request):\n    \"\"\"The delivery addresses saved on the account.\"\"\"\n    saved = request.user.addresses.order_by(\"-created\")\n    return render(request, \"addresses.html\", {\"addresses\": saved})","startCursor":{"line":5,"ch":11},"paths":[{"keys":["k","O","@login_required","<Esc>"],"tier":"idiomatic","technique":"door-O","core":["door-O"],"note":"O opens the new line above."}],"target":"from django.contrib.auth.decorators import login_required\nfrom django.shortcuts import render\n\n\n@login_required\ndef addresses(request):\n    \"\"\"The delivery addresses saved on the account.\"\"\"\n    saved = request.user.addresses.order_by(\"-created\")\n    return render(request, \"addresses.html\", {\"addresses\": saved})","language":"python","evidence":"guided","canonicalKey":"foundation.6#5","canonicalFingerprint":"1p0nqjl"}]},"text":{"id":"foundation.6","title":"Choose where typing begins","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Start typing before or after the cursor, at either end of the line, or on a new line.</p><p><strong>Before this lesson:</strong> Reach a line or buffer boundary.</p><p>i starts typing before the cursor and a after it. I starts at the first character that isn't a space and A at the end of the line. o opens a new line below and O opens one above, even above the first line. Esc finishes every insertion. A new line of code may copy the indentation of the line above, so check it before you add spaces.</p><div class=\"pkeys\"><kbd>i</kbd> <kbd>a</kbd> <kbd>I</kbd> <kbd>A</kbd> <kbd>o</kbd> <kbd>O</kbd></div><h3>Example</h3><p>From anywhere on “review”, A then “ today” then Esc makes “review today”. O then “Plan” then Esc adds a new line above. I would add the text to the start of the same line instead.</p><h4>Worked text</h4><pre class=\"lesson-example\">review</pre><h4>After the edit</h4><pre class=\"lesson-example\">review today</pre><p>Use Start over to try again.</p>","teaches":["door-i","door-a","door-I","door-A","door-o","door-O"],"introduces":["a","I","A","o","O"],"constraints":[],"drills":[{"task":"Add <code>short </code> before <code>standup</code>.","hint":"W jumps to the next WORD, and i starts typing before the cursor.","mode":"text/plain","start":"# Standup\n\nWe meet every morning at 9:30 for a standup in the kitchen.\nSay what you did, what you'll do and what's in your way.","startCursor":{"line":2,"ch":34},"paths":[{"keys":["w","i","short ","<Esc>"],"tier":"idiomatic","technique":"door-i","core":["door-i"],"note":"i types before the cursor, so land on the first letter of what comes after."}],"target":"# Standup\n\nWe meet every morning at 9:30 for a short standup in the kitchen.\nSay what you did, what you'll do and what's in your way.","language":"text","evidence":"guided","canonicalKey":"foundation.6#0","canonicalFingerprint":"bzakn0"},{"task":"Fix the typo: free delivery is on <code>orders</code> over 50 euros.","hint":"a starts typing after the cursor, so e then a adds to the end of a word.","mode":"text/plain","start":"# Delivery\n\nWe deliver in the Netherlands, Belgium and Germany.\nFree delivery on order over 50 euros, and 4.95 below that.\nOrders placed before 14:00 leave the warehouse the same day.\nYou get an email with the tracking link when your parcel is on its way.","startCursor":{"line":3,"ch":0},"paths":[{"keys":["4","e","a","s","<Esc>"],"tier":"idiomatic","technique":"door-a","core":["door-a"],"note":"e lands on the last letter of the word, and a types after it."}],"target":"# Delivery\n\nWe deliver in the Netherlands, Belgium and Germany.\nFree delivery on orders over 50 euros, and 4.95 below that.\nOrders placed before 14:00 leave the warehouse the same day.\nYou get an email with the tracking link when your parcel is on its way.","language":"text","evidence":"guided","canonicalKey":"foundation.6#1","canonicalFingerprint":"1la3wpi"},{"task":"Make <code>Bring your laptop charger</code> an item of the list, like the others.","hint":"I starts typing before the first character of the line, wherever the cursor is.","mode":"text/plain","start":"# Your first day\n\n- Come to the office at 9:00 and ask for Kemal.\n- Bring an ID, so we can make your badge.\nBring your laptop charger, we don't have spares.\n- Lunch is on us.","startCursor":{"line":3,"ch":30},"paths":[{"keys":["j","I","- ","<Esc>"],"tier":"idiomatic","technique":"door-I","core":["door-I"],"note":"I types at the start of the line's text, wherever you are on it."}],"target":"# Your first day\n\n- Come to the office at 9:00 and ask for Kemal.\n- Bring an ID, so we can make your badge.\n- Bring your laptop charger, we don't have spares.\n- Lunch is on us.","language":"text","evidence":"guided","canonicalKey":"foundation.6#2","canonicalFingerprint":"h6ejwl"},{"task":"The planning meeting has a time now. Add <code> at 14:00</code> to the end of its line.","hint":"A starts typing at the end of the line, wherever the cursor is.","mode":"text/plain","start":"# Meetings\n\n- Standup: every weekday at 9:30, in the kitchen.\n- Planning: every other Monday\n- Retro: the last Friday of the month, at 16:00.\n- Demo: whenever there's something to show.","startCursor":{"line":2,"ch":13},"paths":[{"keys":["j","A"," at 14:00","<Esc>"],"tier":"idiomatic","technique":"door-A","core":["door-A"],"note":"A types at the end of the line, wherever you are on it."}],"target":"# Meetings\n\n- Standup: every weekday at 9:30, in the kitchen.\n- Planning: every other Monday at 14:00\n- Retro: the last Friday of the month, at 16:00.\n- Demo: whenever there's something to show.","language":"text","evidence":"guided","canonicalKey":"foundation.6#3","canonicalFingerprint":"1mlm5qa"},{"task":"Add <code>- [ ] Post in #announcements</code> below the changelog item.","hint":"o opens a new line below and copies its indentation.","mode":"text/plain","start":"# Before a release\n\n- [ ] Run the end-to-end tests on staging.\n- [ ] Update the changelog.\n- [ ] Tag the release in git.\n- [ ] Deploy, then check the shop and the admin.","startCursor":{"line":2,"ch":14},"paths":[{"keys":["j","o","- [ ] Post in #announcements","<Esc>"],"tier":"idiomatic","technique":"door-o","core":["door-o"],"note":"o opens the new line below with the same indentation."}],"target":"# Before a release\n\n- [ ] Run the end-to-end tests on staging.\n- [ ] Update the changelog.\n- [ ] Post in #announcements\n- [ ] Tag the release in git.\n- [ ] Deploy, then check the shop and the admin.","language":"text","evidence":"guided","canonicalKey":"foundation.6#4","canonicalFingerprint":"7l2arw"},{"task":"Add the greeting <code>Hi Dana,</code> on a line above <code>Thanks for signing up</code>.","hint":"O opens a new line above.","mode":"text/plain","start":"Subject: Welcome to Northwind\n\nThanks for signing up. Your account is ready.\nYou can save addresses and see your orders in it.\n\nPriya and everyone at Northwind","startCursor":{"line":3,"ch":4},"paths":[{"keys":["k","O","Hi Dana,","<Esc>"],"tier":"idiomatic","technique":"door-O","core":["door-O"],"note":"O opens the new line above."}],"target":"Subject: Welcome to Northwind\n\nHi Dana,\nThanks for signing up. Your account is ready.\nYou can save addresses and see your orders in it.\n\nPriya and everyone at Northwind","language":"text","evidence":"guided","canonicalKey":"foundation.6#5","canonicalFingerprint":"1p0nqjl"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Reach a line or buffer boundary.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Start typing before or after the cursor, at either end of the line, or on a new line.</p><p>i starts typing before the cursor and a after it. I starts at the first character that isn't a space and A at the end of the line. o opens a new line below and O opens one above, even above the first line. Esc finishes every insertion. A new line of code may copy the indentation of the line above, so check it before you add spaces.</p><h2 class=\"prose-subhead\">Example</h2><p>From anywhere on “review”, A then “ today” then Esc makes “review today”. O then “Plan” then Esc adds a new line above. I would add the text to the start of the same line instead.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Reach a line or buffer boundary.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Start typing before or after the cursor, at either end of the line, or on a new line.</p><p>i starts typing before the cursor and a after it. I starts at the first character that isn't a space and A at the end of the line. o opens a new line below and O opens one above, even above the first line. Esc finishes every insertion. A new line of code may copy the indentation of the line above, so check it before you add spaces.</p><h2 class=\"prose-subhead\">Example</h2><p>From anywhere on “review”, A then “ today” then Esc makes “review today”. O then “Plan” then Esc adds a new line above. I would add the text to the start of the same line instead.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Reach a line or buffer boundary.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Start typing before or after the cursor, at either end of the line, or on a new line.</p><p>i starts typing before the cursor and a after it. I starts at the first character that isn't a space and A at the end of the line. o opens a new line below and O opens one above, even above the first line. Esc finishes every insertion. A new line of code may copy the indentation of the line above, so check it before you add spaces.</p><h2 class=\"prose-subhead\">Example</h2><p>From anywhere on “review”, A then “ today” then Esc makes “review today”. O then “Plan” then Esc adds a new line above. I would add the text to the start of the same line instead.</p><p>Use Start over to try again.</p></div></details>"}}}