From 8e199291d95f3e1960fdbf049da3e3d5878050e7 Mon Sep 17 00:00:00 2001 From: Sam Bishop Date: Mon, 21 Aug 2023 15:33:31 +0930 Subject: [PATCH] Add shell annotations on code blocks in English docs. Added annotations for a lot of markdown code blocks that were missing the shell annotation to highlight them correctly. --- en/chromebook_setup/instructions.md | 11 +-- en/cloud_development_setup/instructions.md | 12 ++-- en/css/README.md | 1 + en/deploy/README.md | 13 ++-- en/deploy/install_git.md | 6 +- en/deploy/pythonanywhere.md | 8 +-- en/django_admin/README.md | 4 +- en/django_forms/README.md | 4 +- en/django_installation/instructions.md | 32 ++++----- en/django_models/README.md | 8 +-- en/django_orm/README.md | 2 +- en/django_start_project/README.md | 16 +++-- en/django_templates/README.md | 4 +- en/extend_your_application/README.md | 6 +- en/html/README.md | 12 ++-- en/intro_to_command_line/README.md | 78 ++++++++++++++-------- en/python_installation/instructions.md | 13 ++-- en/python_introduction/README.md | 33 ++++----- en/python_introduction/prompt.md | 2 +- en/template_extending/README.md | 1 + 20 files changed, 149 insertions(+), 117 deletions(-) diff --git a/en/chromebook_setup/instructions.md b/en/chromebook_setup/instructions.md index 973e368c6a0..eea56317f4c 100644 --- a/en/chromebook_setup/instructions.md +++ b/en/chromebook_setup/instructions.md @@ -24,7 +24,7 @@ Now you should see an interface with a sidebar, buttons at the left. Click "Terminal" button to open terminal window with prompt like this: {% filename %}Terminal{% endfilename %} -``` +```shell $ ``` @@ -53,7 +53,7 @@ Now you should see an interface with a sidebar, a big main window with some text, and a small window at the bottom that looks something like this: {% filename %}bash{% endfilename %} -``` +```shell yourusername:~/workspace $ ``` @@ -69,7 +69,7 @@ bigger. 4. Click on the Tools dropdown list (at the bottom left side of the window), then on Terminal button to open terminal tab with a prompt like this: {% filename %}Terminal{% endfilename %} -``` +```shell app@name-of-your-glitch-project:~ ``` @@ -111,7 +111,7 @@ python3 manage.py runserver $PORT Once these files are created, go to the Terminal and execute the following commands to create your first Django project: {% filename %}Terminal{% endfilename %} -``` +```shell django-admin.py startproject mysite . refresh ``` @@ -140,6 +140,7 @@ LOGGING = { }, } ``` + This will create a `debug.log` file detailing Django operations and any error messages that might come up, making it much easier to fix if your website does not work. The initial restarting of the Glitch project should fail. @@ -156,7 +157,7 @@ things don't get mixed up between projects. Run: {% filename %}Cloud 9{% endfilename %} -``` +```shell mkdir djangogirls cd djangogirls python3 -m venv myvenv diff --git a/en/cloud_development_setup/instructions.md b/en/cloud_development_setup/instructions.md index 9e89fcc288d..dd93a68d9f5 100644 --- a/en/cloud_development_setup/instructions.md +++ b/en/cloud_development_setup/instructions.md @@ -29,7 +29,7 @@ All you need to do is find a directory in which you want to create the `virtuale For this tutorial we will be using a new directory `djangogirls` from your home directory: {% filename %}command-line{% endfilename %} -``` +```shell $ mkdir djangogirls $ cd djangogirls ``` @@ -38,23 +38,23 @@ We will make a virtualenv called `myvenv`. To create a new `virtualenv` on RunCode, you first need to install the `virtualenv` module. To do so, first you need to update the packages in your environment ->``` +>```shell >$ sudo apt-get update -y >``` > then install `virtualenv` by running the command: ->``` +>```shell >$ sudo apt-get install -y virtualenv >``` > After this you can create the `virtualenv` run the command: ->``` +>```shell >$ virtualenv -p python myvenv >``` > and a new `virtualenv` with the name `myvenv` or whatever name you chose should be created in your `djangogirls` folder. ## Working with a Virtual Environment >Start your virtual environment by running: ->``` +>```shell >$ . myvenv/bin/activate >``` @@ -82,7 +82,7 @@ Django~={{ book.django_version }} Now, run `pip install -r requirements.txt` to install Django. {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~$ pip install -r requirements.txt Collecting Django~={{ book.django_version }} (from -r requirements.txt (line 1)) Downloading Django-{{ book.django_version }}-py3-none-any.whl (7.9MB) diff --git a/en/css/README.md b/en/css/README.md index 7769a2fcd1b..2dcff6dea53 100644 --- a/en/css/README.md +++ b/en/css/README.md @@ -107,6 +107,7 @@ Between the `` and `` tags, after the links to the Bootstrap CSS fi ```html ``` + The browser reads the files in the order they're given, so we need to make sure this is in the right place. Otherwise the code in our file may be overriden by code in Bootstrap files. We just told our template where our CSS file is located. diff --git a/en/deploy/README.md b/en/deploy/README.md index fbc01880e53..2ab08c49212 100644 --- a/en/deploy/README.md +++ b/en/deploy/README.md @@ -23,12 +23,13 @@ Git tracks changes to a particular set of files in what's called a code reposito > **Note** Check your current working directory with a `pwd` (Mac OS X/Linux) or `cd` (Windows) command before initializing the repository. You should be in the `djangogirls` folder. {% filename %}command-line{% endfilename %} -``` +```shell $ git init Initialized empty Git repository in ~/djangogirls/.git/ $ git config --global user.name "Your Name" $ git config --global user.email you@example.com ``` + Initializing the git repository is something we need to do only once per project (and you won't have to re-enter the username and email ever again). ### Adjusting your branch name @@ -36,7 +37,7 @@ Initializing the git repository is something we need to do only once per project If the version of Git that you are using is older than **2.28**, you will need to change the name of your branch to "main". To determine the version of Git, please enter the following command: {% filename %}command-line{% endfilename %} -``` +```shell $ git --version git version 2.xx... ``` @@ -44,7 +45,7 @@ git version 2.xx... Only if the second number of the version, shown as "xx" above, is less than 28, will you need to enter the following command to rename your branch. If it is 28 or higher, please continue to "Ignoring files". As in "Initializing", this is something we need to do only once per project, as well as only when your version of Git is less than 2.28: {% filename %}command-line{% endfilename %} -``` +```shell $ git branch -M main ``` @@ -100,7 +101,7 @@ Instead use `ls -a` to see the `.gitignore` file. It's a good idea to use a `git status` command before `git add` or whenever you find yourself unsure of what has changed. This will help prevent any surprises from happening, such as wrong files being added or committed. The `git status` command returns information about any untracked/modified/staged files, the branch status, and much more. The output should be similar to the following: {% filename %}command-line{% endfilename %} -``` +```shell $ git status On branch main @@ -121,7 +122,7 @@ nothing added to commit but untracked files present (use "git add" to track) And finally we save our changes. Go to your console and run these commands: {% filename %}command-line{% endfilename %} -``` +```shell $ git add . $ git commit -m "My Django Girls app, first commit" [...] @@ -151,7 +152,7 @@ Now we need to hook up the Git repository on your computer to the one up on GitH Type the following into your console (replace `` with the username you entered when you created your GitHub account, but without the angle-brackets -- the URL should match the clone URL you just saw). {% filename %}command-line{% endfilename %} -``` +```shell $ git remote add origin https://github.com//my-first-blog.git $ git push -u origin main ``` diff --git a/en/deploy/install_git.md b/en/deploy/install_git.md index 9dbf5c43566..4af471125b5 100644 --- a/en/deploy/install_git.md +++ b/en/deploy/install_git.md @@ -36,7 +36,7 @@ $ sudo apt install git This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject. {% filename %}command-line{% endfilename %} -``` +```shell $ git config --global --add init.defaultBranch main ``` @@ -55,7 +55,7 @@ $ sudo dnf install git This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject. {% filename %}command-line{% endfilename %} -``` +```shell $ git config --global --add init.defaultBranch main ``` @@ -74,7 +74,7 @@ $ sudo zypper install git This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject. {% filename %}command-line{% endfilename %} -``` +```shell $ git config --global --add init.defaultBranch main ``` diff --git a/en/deploy/pythonanywhere.md b/en/deploy/pythonanywhere.md index d67d7fb062d..d0b6437247e 100644 --- a/en/deploy/pythonanywhere.md +++ b/en/deploy/pythonanywhere.md @@ -16,7 +16,7 @@ Go back to the main [PythonAnywhere Dashboard](https://www.pythonanywhere.com/) Deploying a web app on PythonAnywhere involves pulling down your code from GitHub, and then configuring PythonAnywhere to recognise it and start serving it as a web application. There are manual ways of doing it, but PythonAnywhere provides a helper tool that will do it all for you. Let's install it first: {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ pip{{ book.pa_py_version }} install --user pythonanywhere ``` @@ -25,7 +25,7 @@ That should print out some things like `Collecting pythonanywhere`, and eventual Now we run the helper to automatically configure our app from GitHub. Type the following into the console on PythonAnywhere (don't forget to use your GitHub username in place of ``, so that the URL matches the clone URL from GitHub): {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ pa_autoconfigure_django.py --python={{ book.pa_py_version }} https://github.com//my-first-blog.git ``` @@ -43,7 +43,7 @@ On PythonAnywhere all those steps are automated, but they're the same steps you The main thing to notice right now is that your database on PythonAnywhere is actually totally separate from your database on your own computer, so it can have different posts and admin accounts. As a result, just as we did on your own computer, we need to initialize the admin account with `createsuperuser`. PythonAnywhere has automatically activated your virtualenv for you, so all you need to do is run: {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell (ola.pythonanywhere.com) $ python manage.py createsuperuser ``` @@ -52,7 +52,7 @@ Type in the details for your admin user. Best to use the same ones as you're us Now, if you like, you can also take a look at your code on PythonAnywhere using `ls`: {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell (ola.pythonanywhere.com) $ ls blog db.sqlite3 manage.py mysite requirements.txt static (ola.pythonanywhere.com) $ ls blog/ diff --git a/en/django_admin/README.md b/en/django_admin/README.md index 5ed5e08cc62..95292e5a79a 100644 --- a/en/django_admin/README.md +++ b/en/django_admin/README.md @@ -23,12 +23,12 @@ To log in, you need to create a *superuser* - a user account that has control ov > Remember, to write new commands while the web server is running, open a new terminal window and activate your virtualenv. We reviewed how to write new commands in the Your first Django project! chapter, in the Starting the web server section. {% filename %}Mac OS X or Linux:{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py createsuperuser ``` {% filename %}Windows:{% endfilename %} -``` +```shell (myvenv) C:\Users\Name\djangogirls> python manage.py createsuperuser ``` diff --git a/en/django_forms/README.md b/en/django_forms/README.md index 475f6e3f5dc..9e9eebed399 100644 --- a/en/django_forms/README.md +++ b/en/django_forms/README.md @@ -433,7 +433,7 @@ Let's see if all this works on PythonAnywhere. Time for another deploy! * First, commit your new code, and push it up to GitHub: {% filename %}command-line{% endfilename %} -``` +```shell $ git status $ git add . $ git status @@ -444,7 +444,7 @@ $ git push * Then, in a [PythonAnywhere Bash console](https://www.pythonanywhere.com/consoles/): {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ cd ~/.pythonanywhere.com $ git pull [...] diff --git a/en/django_installation/instructions.md b/en/django_installation/instructions.md index 91ad29f6360..fcd8b7b4ee8 100644 --- a/en/django_installation/instructions.md +++ b/en/django_installation/instructions.md @@ -19,7 +19,7 @@ All you need to do is find a directory in which you want to create the `virtuale For this tutorial we will be using a new directory `djangogirls` from your home directory: {% filename %}command-line{% endfilename %} -``` +```shell $ mkdir djangogirls $ cd djangogirls ``` @@ -27,7 +27,7 @@ $ cd djangogirls We will make a virtualenv called `myvenv`. The general command will be in the format: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 -m venv myvenv ``` @@ -37,7 +37,7 @@ data-collapse=true ces--> To create a new `virtualenv`, you need to open the command prompt and run `python -m venv myvenv`. It will look like this: {% filename %}command-line{% endfilename %} -``` +```shell C:\Users\Name\djangogirls> python -m venv myvenv ``` @@ -52,7 +52,7 @@ We can create a `virtualenv` on both Linux and OS X by running `python3 -m venv It will look like this: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 -m venv myvenv ``` @@ -61,7 +61,7 @@ $ python3 -m venv myvenv > __NOTE:__ On some versions of Debian/Ubuntu you may receive the following error: >{% filename %}command-line{% endfilename %} ->``` +>```shell >The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. > apt install python3-venv >You may need to use sudo with that command. After installing the python3-venv package, recreate your virtual environment. @@ -69,7 +69,7 @@ $ python3 -m venv myvenv > > In this case, follow the instructions above and install the `python3-venv` package: >{% filename %}command-line{% endfilename %} ->``` +>```shell >$ sudo apt install python3-venv >``` @@ -83,7 +83,7 @@ $ python3 -m venv myvenv > To get around this, use the `virtualenv` command instead. >{% filename %}command-line{% endfilename %} ->``` +>```shell >$ sudo apt install python-virtualenv >$ virtualenv --python=python{{ book.py_version }} myvenv >``` @@ -98,7 +98,7 @@ $ python3 -m venv myvenv > then instead run: > >{% filename %}command-line{% endfilename %} ->``` +>```shell >sudo apt install python{{ book.py_version }}-venv >``` @@ -115,14 +115,14 @@ data-collapse=true ces--> Start your virtual environment by running: {% filename %}command-line{% endfilename %} -``` +```shell C:\Users\Name\djangogirls> myvenv\Scripts\activate ``` > __NOTE:__ On Windows 10 you might get an error in the Windows PowerShell that says `execution of scripts is disabled on this system`. In this case, open another Windows PowerShell with the "Run as Administrator" option. Then try typing the following command before starting your virtual environment: > >{% filename %}command-line{% endfilename %} ->``` +>```powershell >C:\WINDOWS\system32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned > Execution Policy Change > The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A @@ -132,7 +132,7 @@ C:\Users\Name\djangogirls> myvenv\Scripts\activate > __NOTE:__ For users of the popular editor VS Code, which comes with an integrated terminal based off windows PowerShell, if you wish to stick with the integrated terminal, you may run the following command to activate your virtual environment: > ->``` +>```shell >$ . myvenv\Scripts\activate.ps1 >``` >The advantage is that you don't have to switch between editor windows and command-line windows @@ -145,7 +145,7 @@ data-collapse=true ces--> Start your virtual environment by running: {% filename %}command-line{% endfilename %} -``` +```shell $ source myvenv/bin/activate ``` @@ -154,7 +154,7 @@ Remember to replace `myvenv` with your chosen `virtualenv` name! > __NOTE:__ If the command `source` is not available, try doing this instead: > >{% filename %}command-line{% endfilename %} ->``` +>```shell >$ . myvenv/bin/activate >``` @@ -173,7 +173,7 @@ Now that you have your `virtualenv` started, you can install Django. Before we do that, we should make sure we have the latest version of `pip`, the software that we use to install Django: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~$ python -m pip install --upgrade pip ``` @@ -201,7 +201,7 @@ Django~={{ book.django_version }} Now, run `pip install -r requirements.txt` to install Django. {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~$ pip install -r requirements.txt Collecting Django~={{ book.django_version }} (from -r requirements.txt (line 1)) Downloading Django-{{ book.django_version }}-py3-none-any.whl (7.9MB) @@ -222,7 +222,7 @@ data-collapse=true ces--> > Your command line might freeze when you try to install Django. If this happens, instead of the above command use: > >{% filename %}command-line{% endfilename %} ->``` +>```shell >C:\Users\Name\djangogirls> python -m pip install -r requirements.txt >``` diff --git a/en/django_models/README.md b/en/django_models/README.md index 39681112642..58241538b98 100644 --- a/en/django_models/README.md +++ b/en/django_models/README.md @@ -67,12 +67,12 @@ You can think of a model in the database as a spreadsheet with columns (fields) To keep everything tidy, we will create a separate application inside our project. It is very nice to have everything organized from the very beginning. To create an application we need to run the following command in the console (from `djangogirls` directory where `manage.py` file is): {% filename %}Mac OS X and Linux:{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py startapp blog ``` {% filename %}Windows:{% endfilename %} -``` +```shell (myvenv) C:\Users\Name\djangogirls> python manage.py startapp blog ``` @@ -179,7 +179,7 @@ If something is still not clear about models, feel free to ask your coach! We kn The last step here is to add our new model to our database. First we have to make Django know that we have some changes in our model. (We have just created it!) Go to your console window and type `python manage.py makemigrations blog`. It will look like this: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py makemigrations blog Migrations for 'blog': blog/migrations/0001_initial.py @@ -191,7 +191,7 @@ Migrations for 'blog': Django prepared a migration file for us that we now have to apply to our database. Type `python manage.py migrate blog` and the output should be as follows: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py migrate blog Operations to perform: Apply all migrations: blog diff --git a/en/django_orm/README.md b/en/django_orm/README.md index 54ec2a1d2ae..a052b8b63a8 100644 --- a/en/django_orm/README.md +++ b/en/django_orm/README.md @@ -15,7 +15,7 @@ It's easiest to learn by example. Let's try this, shall we? Open up your local console (not on PythonAnywhere) and type this command: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py shell ``` diff --git a/en/django_start_project/README.md b/en/django_start_project/README.md index ce1ef96ca0c..eda9b31ed13 100644 --- a/en/django_start_project/README.md +++ b/en/django_start_project/README.md @@ -21,7 +21,7 @@ The names of some files and directories are very important for Django. You shoul In your Mac OS X or Linux console, you should run the following command. **Don't forget to add the period (or dot) `.` at the end!** {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ django-admin startproject mysite . ``` @@ -37,7 +37,7 @@ The `(myvenv) ~/djangogirls$` part shown here is just example of the prompt that On Windows you should run the following command. **(Don't forget to add the period (or dot) `.` at the end)**: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) C:\Users\Name\djangogirls> django-admin.exe startproject mysite . ``` > The period `.` is crucial because it tells the script to install Django in your current directory (for which the period `.` is a short-hand reference). @@ -62,6 +62,7 @@ djangogirls │   └── ... └── requirements.txt ``` + > **Note**: in your directory structure, you will also see your `myvenv` directory that we created before. `manage.py` is a script that helps with management of the site. With it we will be able (amongst other things) to start a web server on our computer without installing anything else. @@ -176,7 +177,7 @@ DATABASES = { To create a database for our blog, let's run the following in the console: `python manage.py migrate` (we need to be in the `djangogirls` directory that contains the `manage.py` file). If that goes well, you should see something like this: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions @@ -208,20 +209,21 @@ And we're done! Time to start the web server and see if our website is working! You need to be in the directory that contains the `manage.py` file (the `djangogirls` directory). In the console, we can start the web server by running `python manage.py runserver`: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py runserver ``` If you are on a Chromebook, use this command instead: {% filename %}Cloud 9{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py runserver 0.0.0.0:8080 ``` + or this one if you are using Glitch: {% filename %}Glitch.com terminal{% endfilename %} -``` +```shell $ refresh ``` @@ -229,7 +231,7 @@ $ refresh If you are on Windows and this fails with `UnicodeDecodeError`, use this command instead: {% filename %}command-line{% endfilename %} -``` +```shell (myvenv) ~/djangogirls$ python manage.py runserver 0:8000 ``` diff --git a/en/django_templates/README.md b/en/django_templates/README.md index 6086ba883d5..3093c772a0d 100644 --- a/en/django_templates/README.md +++ b/en/django_templates/README.md @@ -74,7 +74,7 @@ It'd be good to see if your website will still be working on the public Internet * First, push your code to GitHub {% filename %}command-line{% endfilename %} -``` +```shell $ git status [...] $ git add . @@ -88,7 +88,7 @@ $ git push * Then, log back in to [PythonAnywhere](https://www.pythonanywhere.com/consoles/) and go to your **Bash console** (or start a new one), and run: {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ cd .pythonanywhere.com $ git pull [...] diff --git a/en/extend_your_application/README.md b/en/extend_your_application/README.md index 3335ff7be80..46990aa7285 100644 --- a/en/extend_your_application/README.md +++ b/en/extend_your_application/README.md @@ -183,7 +183,7 @@ Yay! It works! It'd be good to see if your website still works on PythonAnywhere, right? Let's try deploying again. {% filename %}command-line{% endfilename %} -``` +```shell $ git status $ git add . $ git status @@ -194,7 +194,7 @@ $ git push Then, in a [PythonAnywhere Bash console](https://www.pythonanywhere.com/consoles/): {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ cd ~/.pythonanywhere.com $ git pull [...] @@ -210,7 +210,7 @@ Servers like PythonAnywhere like to treat "static files" (like CSS files) differ Start by activating your virtualenv if it's not still active from earlier (PythonAnywhere uses a command called `workon` to do this, it's just like the `source myenv/bin/activate` command you use on your own computer): {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ workon .pythonanywhere.com (ola.pythonanywhere.com)$ python manage.py collectstatic [...] diff --git a/en/html/README.md b/en/html/README.md index 075f29732a9..5fe1963822b 100644 --- a/en/html/README.md +++ b/en/html/README.md @@ -171,28 +171,28 @@ It'd be good to see all this out and live on the Internet, right? Let's do anot First off, let's see what files have changed since we last deployed (run these commands locally, not on PythonAnywhere): {% filename %}command-line{% endfilename %} -``` +```shell $ git status ``` Make sure you're in the `djangogirls` directory and let's tell `git` to include all the changes in this directory: {% filename %}command-line{% endfilename %} -``` +```shell $ git add . ``` Before we upload all the files, let's check what `git` will be uploading (all the files that `git` will upload should now appear in green): {% filename %}command-line{% endfilename %} -``` +```shell $ git status ``` We're almost there, now it's time to tell it to save this change in its history. We're going to give it a "commit message" where we describe what we've changed. You can type anything you'd like at this stage, but it's helpful to type something descriptive so that you can remember what you've done in the future. {% filename %}command-line{% endfilename %} -``` +```shell $ git commit -m "Changed the HTML for the site." ``` @@ -201,7 +201,7 @@ $ git commit -m "Changed the HTML for the site." Once we've done that, we upload (push) our changes up to GitHub: {% filename %}command-line{% endfilename %} -``` +```shell $ git push ``` @@ -210,7 +210,7 @@ $ git push * Open up the [PythonAnywhere consoles page](https://www.pythonanywhere.com/consoles/) and go to your **Bash console** (or start a new one). Then, run: {% filename %}PythonAnywhere command-line{% endfilename %} -``` +```shell $ cd ~/.pythonanywhere.com $ git pull [...] diff --git a/en/intro_to_command_line/README.md b/en/intro_to_command_line/README.md index b7c67bb6f03..07936a7d6cb 100644 --- a/en/intro_to_command_line/README.md +++ b/en/intro_to_command_line/README.md @@ -30,9 +30,10 @@ You now should see a white or black window that is waiting for your commands. If you're on Mac or Linux, you probably see a `$`, like this: {% filename %}command-line{% endfilename %} -``` +```shell $ ``` + @@ -41,7 +42,7 @@ $ On Windows, you probably see a `>`, like this: {% filename %}command-line{% endfilename %} -``` +```shell > ``` @@ -64,7 +65,7 @@ Let's start by typing this command: {% filename %}command-line{% endfilename %} -``` +```shell $ whoami ``` @@ -74,7 +75,7 @@ $ whoami {% filename %}command-line{% endfilename %} -``` +```shell > whoami ``` @@ -83,7 +84,7 @@ $ whoami And then hit `enter`. This is our result: {% filename %}command-line{% endfilename %} -``` +```shell $ whoami olasitarska ``` @@ -104,7 +105,7 @@ It'd be nice to know where are we now, right? Let's see. Type this command and h {% filename %}command-line{% endfilename %} -``` +```shell $ pwd /Users/olasitarska ``` @@ -117,10 +118,11 @@ $ pwd {% filename %}command-line{% endfilename %} -``` +```shell > cd C:\Users\olasitarska ``` + > Note: 'cd' stands for 'change directory'. With PowerShell you can use pwd just like on Linux or Mac OS X. @@ -154,7 +156,7 @@ So what's in it? It'd be cool to find out. Let's see: {% filename %}command-line{% endfilename %} -``` +```shell $ ls Applications Desktop @@ -162,13 +164,14 @@ Downloads Music ... ``` + {% filename %}command-line{% endfilename %} -``` +```shell > dir Directory of C:\Users\olasitarska 05/08/2020 07:28 PM Applications @@ -177,6 +180,7 @@ Music 05/08/2020 07:28 PM Music ... ``` + > Note: In PowerShell you can also use 'ls' like on Linux and Mac OS X. @@ -189,15 +193,16 @@ Now, let's go to our Desktop directory: {% filename %}command-line{% endfilename %} -``` +```shell $ cd Desktop ``` + {% filename %}command-line{% endfilename %} -``` +```shell $ cd Desktop ``` @@ -214,9 +219,10 @@ for example, `Schreibtisch` for German. {% filename %}command-line{% endfilename %} -``` +```shell > cd Desktop ``` + Check if it's really changed: @@ -224,19 +230,21 @@ Check if it's really changed: {% filename %}command-line{% endfilename %} -``` +```shell $ pwd /Users/olasitarska/Desktop ``` + {% filename %}command-line{% endfilename %} -``` +```shell > cd C:\Users\olasitarska\Desktop ``` + Here it is! @@ -252,18 +260,20 @@ How about creating a practice directory on your desktop? You can do it this way: {% filename %}command-line{% endfilename %} -``` +```shell $ mkdir practice ``` + {% filename %}command-line{% endfilename %} -``` +```shell > mkdir practice ``` + This little command will create a folder with the name `practice` on your desktop. You can check if it's there by looking on your Desktop or by running a `ls` or `dir` command! Try it. :) @@ -281,24 +291,26 @@ A small challenge for you: in your newly created `practice` directory, create a {% filename %}command-line{% endfilename %} -``` +```shell $ cd practice $ mkdir test $ ls test ``` + {% filename %}command-line{% endfilename %} -``` +```shell > cd practice > mkdir test > dir 05/08/2020 07:28 PM test ``` + Congrats! :) @@ -314,18 +326,20 @@ First, we need to get back to Desktop: {% filename %}command-line{% endfilename %} -``` +```shell $ cd .. ``` + {% filename %}command-line{% endfilename %} -``` +```shell > cd .. ``` + Using `..` with the `cd` command will change your current directory to the parent directory (that is, the directory that contains your current directory). @@ -335,20 +349,22 @@ Check where you are: {% filename %}command-line{% endfilename %} -``` +```shell $ pwd /Users/olasitarska/Desktop ``` + {% filename %}command-line{% endfilename %} -``` +```shell > cd C:\Users\olasitarska\Desktop ``` + Now time to delete the `practice` directory: @@ -358,19 +374,21 @@ Now time to delete the `practice` directory: {% filename %}command-line{% endfilename %} -``` +```shell $ rm -r practice ``` + {% filename %}command-line{% endfilename %} -``` +```shell > rmdir /S practice practice, Are you sure ? Y ``` + Done! To be sure it's actually deleted, let's check it: @@ -378,18 +396,20 @@ Done! To be sure it's actually deleted, let's check it: {% filename %}command-line{% endfilename %} -``` +```shell $ ls ``` + {% filename %}command-line{% endfilename %} -``` +```shell > dir ``` + ### Exit @@ -399,18 +419,20 @@ That's it for now! You can safely close the command line now. Let's do it the ha {% filename %}command-line{% endfilename %} -``` +```shell $ exit ``` + {% filename %}command-line{% endfilename %} -``` +```shell > exit ``` + Cool, huh? :) diff --git a/en/python_installation/instructions.md b/en/python_installation/instructions.md index 4365eea826d..df2b2a425c9 100644 --- a/en/python_installation/instructions.md +++ b/en/python_installation/instructions.md @@ -46,7 +46,7 @@ data-collapse=true ces--> It is very likely that you already have Python installed out of the box. To check if you have it installed (and which version it is), open a console and type the following command: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 --version Python {{ book.py_release }} ``` @@ -54,7 +54,7 @@ Python {{ book.py_release }} If you have a different version of Python installed, at least {{ book.py_min_version }} (e.g. {{ book.py_min_release }}), then you don't have to upgrade. If you don't have Python installed, or if you want a different version, first check what Linux distribution you are using with the following command: {% filename %}command-line{% endfilename %} -``` +```shell $ grep '^NAME=' /etc/os-release ``` @@ -67,7 +67,7 @@ Afterwards, depending on the result, follow one of the following installation gu Type this command into your console: {% filename %}command-line{% endfilename %} -``` +```shell $ sudo apt install python3 ``` @@ -79,7 +79,7 @@ data-collapse=true ces--> Use this command in your console: {% filename %}command-line{% endfilename %} -``` +```shell $ sudo dnf install python3 ``` @@ -93,7 +93,7 @@ data-collapse=true ces--> Use this command in your console: {% filename %}command-line{% endfilename %} -``` +```shell $ sudo zypper install python3 ``` @@ -102,10 +102,11 @@ $ sudo zypper install python3 Verify the installation was successful by opening a command prompt and running the `python3` command: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 --version Python {{ book.py_release }} ``` + The version shown may be different from {{ book.py_release }} -- it should match the version you installed. **NOTE:** If you're on Windows and you get an error message that `python3` wasn't found, try using `python` (without the `3`) and check if it still might be a version of Python that is {{ book.py_min_version }} or higher. If that doesn't work either, you may open a new command prompt and try again; this happens if you use a command prompt left open from before the Python installation. diff --git a/en/python_introduction/README.md b/en/python_introduction/README.md index f30dc47334f..afd20c0f28b 100644 --- a/en/python_introduction/README.md +++ b/en/python_introduction/README.md @@ -580,9 +580,10 @@ data-collapse=true ces--> On a Mac, the command will look something like this: {% filename %}command-line{% endfilename %} -``` +```shell $ cd ~/Desktop ``` + On Linux, it will be like this: {% filename %}command-line{% endfilename %} -``` +```shell $ cd ~/Desktop ``` @@ -604,9 +605,10 @@ $ cd ~/Desktop On Windows Command Prompt, it will be like this: {% filename %}command-line{% endfilename %} -``` +```shell > cd %HomePath%\Desktop ``` + @@ -615,9 +617,10 @@ On Windows Command Prompt, it will be like this: And on Windows Powershell, it will be like this: {% filename %}command-line{% endfilename %} -``` +```shell > cd $Home\Desktop ``` + @@ -626,7 +629,7 @@ If you get stuck, ask for help. That's exactly what the coaches are here for! Now use Python to execute the code in the file like this: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hello, Django girls! ``` @@ -656,7 +659,7 @@ if 3 > 2: If we were to save and run this, we'd see an error like this: {% filename %}{{ warning_icon }} command-line{% endfilename %} -``` +```shell $ python3 python_intro.py File "python_intro.py", line 2 ^ @@ -698,7 +701,7 @@ else: When this is run it will print out: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py 5 is indeed greater than 2 ``` @@ -719,7 +722,7 @@ else: and executed: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hey Sonja! ``` @@ -748,7 +751,7 @@ else: Python runs through each test in sequence and prints: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Perfect, I can hear all the details ``` @@ -806,7 +809,7 @@ You may wonder why we've written the name of the function at the bottom of the f Let's run this now and see what happens: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hi there! How are you? @@ -842,7 +845,7 @@ hi() Remember: The `print` function is indented four spaces within the `if` statement. This is because the function runs when the condition is met. Let's see how it works now: {% filename %}{{ warning_icon }} command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Traceback (most recent call last): File "python_intro.py", line 10, in @@ -862,7 +865,7 @@ hi("Ola") And run it again: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hi Ola! ``` @@ -877,7 +880,7 @@ hi("Sonja") And run it: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hi Sonja! ``` @@ -904,7 +907,7 @@ hi("Rachel") Let's call the code now: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hi Rachel! ``` @@ -951,7 +954,7 @@ for name in girls: And when we run it: {% filename %}command-line{% endfilename %} -``` +```shell $ python3 python_intro.py Hi Rachel! Next girl diff --git a/en/python_introduction/prompt.md b/en/python_introduction/prompt.md index 20ff92b9173..95c5ef73b24 100644 --- a/en/python_introduction/prompt.md +++ b/en/python_introduction/prompt.md @@ -9,7 +9,7 @@ Once you're ready, follow the instructions below. We want to open up a Python console, so type in `python` on Windows or `python3` on Mac OS/Linux and hit `enter`. {% filename %}command-line{% endfilename %} -``` +```shell $ python3 Python {{ book.py_release }} (...) Type "help", "copyright", "credits" or "license" for more information. diff --git a/en/template_extending/README.md b/en/template_extending/README.md index a5c74f347d1..2e29111aa70 100644 --- a/en/template_extending/README.md +++ b/en/template_extending/README.md @@ -85,6 +85,7 @@ Then in `base.html`, replace your whole `` (everything between `` an {% block content %} {% endblock %} ``` + But why? You just created a `block`! You used the template tag `{% block %}` to make an area that will have HTML inserted in it. That HTML will come from another template that extends this template (`base.html`). We will show you how to do this in a moment. Now save `base.html` and open your `blog/templates/blog/post_list.html` again in the code editor.