Technológie internetuInternet Technologies / Týždeň 2Week 2

Príkazový riadok a HTMLThe command line and HTML

Dnes sa naučíš tri veci: pohybovať sa v príkazovom riadku, pracovať v editore vi a vyrobiť prvú stránku, ktorá pobeží na sigma. Nové pojmy sú v tabuľke (table) pojmov.

Today you learn three things: moving around the command line, working in the vi editor and making your first page that runs on sigma. New terms are in the table of terms.

TeóriaTheory

Prečo príkazový riadok

Na svojom počítači klikáš myšou na ikony a okná. Server takto nefunguje: nemá monitor ani myš a pripájaš sa naň na diaľku. Keď sa pripojíš na sigma, uvidíš len riadok, do ktorého píšeš príkazy. Tomu sa hovorí príkazový riadok alebo terminál.

Terminál máš aj v Kubeflow (vo VS Code cez menu ☰ → Terminal → New Terminal). Kubeflow aj sigma bežia na Linuxe, takže príkazy, ktoré sa dnes naučíš, fungujú na oboch rovnako.

Prompt: podľa čoho spoznáš, kde si

Keď terminál čaká na tvoj príkaz, na začiatku riadku vypíše prompt. Z neho sa dozvieš, kto si, na ktorom počítači si a v ktorom priečinku stojíš:

jovyan@vscode-0:~$      ← Kubeflow: používateľ jovyan, počítač vscode-0, priečinok ~
jn123ab@sigma:~$        ← sigma: tvoj TUKE login, počítač sigma, priečinok ~

Znak ~ znamená tvoj domovský priečinok. Za znakom $ píšeš príkaz a potvrdíš ho klávesom Enter.

Základné príkazy

S týmito príkazmi vystačíš celý semester:

Čo chceš urobiť Príkaz
zistiť, v ktorom priečinku si pwd
vypísať, čo je v priečinku ls
vypísať aj skryté súbory a podrobnosti ls -la
vojsť do priečinka cd nazov
vrátiť sa o úroveň vyššie cd ..
vrátiť sa do domovského priečinka cd ~
vytvoriť priečinok mkdir nazov
vytvoriť priečinok aj s podpriečinkami mkdir -p a/b/c
vytvoriť prázdny súbor touch file.txt
skopírovať súbor cp zdroj ciel
presunúť alebo premenovať súbor mv stary novy
zmazať súbor rm subor
zmazať priečinok aj s obsahom rm -r priecinok
vypísať obsah súboru cat file.txt
vyčistiť obrazovku clear
vypísať príkazy, ktoré si doteraz zadal history
pripojiť sa na sigma ssh login@sigma.tuke.sk
odpojiť sa zo sigma exit

Cesty k súborom

Cesta hovorí, kde súbor alebo priečinok leží. Priečinky sa v nej oddeľujú lomkou /.

Zápis Čo znamená
/ koreň, začiatok celého disku
~ tvoj domovský priečinok
. priečinok, v ktorom práve stojíš
.. priečinok o úroveň vyššie
/home/jovyan/web absolútna cesta: začína lomkou a platí, nech stojíš kdekoľvek
web/ti relatívna cesta: počíta sa od priečinka, v ktorom práve stojíš

Ako si ušetriť prácu a nervy

  • Kláves Tab dopĺňa názvy súborov a priečinkov. Napíš prvé písmená a stlač Tab. Ak sa nič nedoplní, taký súbor v priečinku nie je.
  • Šípkou hore sa vrátiš k predchádzajúcim príkazom, nemusíš ich písať znova.
  • Ak sa príkaz zasekne a prompt sa nevracia, stlač Ctrl + C.
  • Príkaz rm maže natrvalo, v termináli nie je kôš. Pred mazaním si cez pwd over, kde stojíš.
  • Nové príkazy skúšaj v priečinku ~/pieskovisko. V ~/web máš zadania a tie si nechceš pokaziť.

Editor vi

Vi je textový editor, ktorý beží priamo v termináli. Nájdeš ho na každom linuxovom serveri, aj tam, kde iný editor nie je. Niekedy sa doň dostaneš aj nechtiac, napríklad keď na serveri spustíš git commit bez -m a Git ti otvorí editor na napísanie popisu. Preto ho treba vedieť aspoň otvoriť, niečo napísať, uložiť a zavrieť.

Trochu histórie

Na Stack Overflow patrí k najčítanejším otázkam všetkých čias otázka „Ako sa dostanem von z editora Vim?“. Prečítali ju milióny programátorov, takže ak sa ti to stane, nie si sám. Vi napísal Bill Joy v roku 1976 pre terminál ADM-3A. Ten terminál mal šípky natlačené na klávesoch H J K L, a preto sa vo vi dodnes dá pohybovať aj nimi. Kláves Esc bol tam, kde je dnes Tab, takže sa naň siahalo ľahko. A kláves Home mal na sebe vlnovku ~. Preto dnes ~ znamená domovský priečinok.

Ako vi spustíš

Za príkaz vi napíšeš názov súboru a stlačíš Enter:

vi about-me.txt

Ak súbor existuje, otvorí sa. Ak neexistuje, vi ho vytvorí, keď ho prvýkrát uložíš. Prázdne riadky sú na ľavom okraji označené vlnovkou ~.

Prečo po stlačení klávesov nič nepíše

Vi má režimy. Po spustení je v normálnom režime, a v ňom klávesy nepíšu text, ale vykonávajú príkazy. Preto sa zdá, že vi nereaguje alebo robí čudné veci. Písať môžeš až vo vkladacom režime.

Režim Ako sa doň dostaneš Čo robia klávesy Ako ho spoznáš
normálny po spustení vi, alebo klávesom Esc vykonávajú príkazy dole nič nesvieti
vkladací klávesom i píšu text dole je -- INSERT --
príkazový riadok dvojbodkou : v normálnom režime napíšeš príkaz a stlačíš Enter dole je :

Postup: otvor, napíš, ulož a zavri

  1. Napíš vi about-me.txt a stlač Enter. Súbor sa otvorí v normálnom režime.
  2. Stlač i. Dole sa objaví -- INSERT -- a môžeš písať.
  3. Napíš text. Medzi riadkami sa pohybuješ šípkami.
  4. Stlač Esc. Nápis -- INSERT -- zmizne a si späť v normálnom režime.
  5. Napíš :wq a stlač Enter. Vi súbor uloží, zavrie sa a si späť v termináli.

Ako vi zavrieť

Všetky tieto príkazy píšeš v normálnom režime (ak si nie si istý, najprv stlač Esc) a potvrdíš ich klávesom Enter:

Čo chceš Čo napíšeš
uložiť zmeny a zavrieť :wq
zavrieť, keď si nič nemenil :q
zavrieť a zmeny zahodiť :q!
len uložiť a pokračovať v práci :w

Ak napíšeš :q a vi odpovie E37: No write since last change, v súbore máš neuložené zmeny. Rozhodni sa: :wq ich uloží, :q! ich zahodí.

Keď sa stratíš a nevieš, čo sa deje: stlač dvakrát Esc, napíš :q! a stlač Enter. Vi sa zavrie bez uloženia a si späť v termináli. Toto funguje vždy.

Úpravy textu v normálnom režime

Kláves Čo urobí
x zmaže znak pod kurzorom
dd zmaže celý riadok
u vráti poslednú zmenu späť
/slovo a Enter vyhľadá slovo, n skočí na ďalší výskyt

Vi v Kubeflow

V Kubeflow príkaz vi spustí Vim, čo je vylepšený vi. Všetko, čo je opísané vyššie, v ňom platí. Ak chceš jednoduchší editor bez režimov, použi nano: po spustení v ňom rovno píšeš a ovládanie máš vypísané dole (Ctrl + O uloží, Ctrl + X zavrie). Skratku Ctrl + W v termináli nepoužívaj, lebo terminál beží v prehliadači a ten by zavrel celú kartu s Kubeflow.

Kubeflow a sigma: dva počítače

Pracuješ na dvoch počítačoch naraz a je dobré vedieť, čo sa deje kde:

Kubeflow  ~/web/ti/cv01/  ── uloženie (SFTP) ──>  sigma  ~/public_html/ti/cv01/
    │                                                  │
    └── commit + push ──> GitHub                       └──> https://sigma.tuke.sk/student/meno.priezvisko/ti/cv01/
  • Kód píšeš v Kubeflow. Každý súbor, ktorý uložíš vo VS Code, sa automaticky nahrá na sigma.
  • Na sigma web server zobrazí len to, čo je v priečinku public_html.
  • Úlohu odovzdáš tak, že zmeny commitneš a pushneš na GitHub. Na sigma sa necommituje nič, tam sa súbory len nahrávajú.
  • Zadanie od učiteľa prijmeš v Classroom 50. GitHub ti k nemu vytvorí vlastné repository a to si naklonuješ do ~/web/ti/cv01. Postup je v návode 04 Odovzdávanie.

Kostra HTML stránky

HTML je obyčajný text, v ktorom značky (tag) hovoria prehliadaču, čo je nadpis (heading), čo odsek (paragraph), čo obrázok (image) a podobne. Každá HTML stránka má rovnakú kostru:

  • <!doctype html> hovorí, že ide o HTML5.
  • <html lang="sk"> obaľuje celú stránku a určuje jej jazyk.
  • <head> obsahuje informácie o stránke, ktoré sa nezobrazujú: kódovanie <meta charset="utf-8"> (aby sa správne zobrazila diakritika), nastavenie pre mobil <meta name="viewport" ...>, názov card v prehliadači <title> a prepojenie na súbor so štýlmi <link rel="stylesheet" href="style.css">.
  • <body> obsahuje všetko, čo na stránke vidno.

Vo VS Code nemusíš kostru písať ručne: do prázdneho súboru .html napíš výkričník ! a stlač Tab.

Najčastejšie prvky (elements)

Element Na čo slúži
<h1> až <h6> headings, h1 je hlavný a na stránke býva raz
<p> paragraph textu
<strong>, <em> dôležité slovo, zdôraznené slovo
<ul>, <ol>, <li> nečíslovaný zoznam (list), číslovaný list, položka zoznamu
<table>, <thead>, <tr>, <th>, <td> table, jej header, riadok, bunka header, bežná bunka
<img src="..." alt="..."> obrázok; alt je text, ktorý sa zobrazí alebo prečíta, keď obrázok nevidno
<a href="..."> link; href="#contact" skočí na element s id="contact" na tej istej stránke
<header>, <nav>, <main>, <section>, <footer> časti stránky: header, menu, hlavný obsah, section, footer

CSS v kocke

HTML určuje, čo na stránke je, CSS určuje, ako to vyzerá. Štýly píšeme do samostatného súboru style.css. Každé pravidlo má tvar selector { property: hodnota; }. Selektor (Selector) hovorí, ktorých elements sa pravidlo týka:

h2 { color: #a3274f; }            /* všetky headings h2 budú bordové */
table, th, td { border: 1px solid #999; }

Najčastejšie chyby a čo znamenajú

Čo vidíš Príčina Riešenie
command not found preklep v názve príkazu skontroluj príkaz; šípka hore ho vráti na opravu
No such file or directory súbor alebo priečinok s týmto názvom tu nie je pwd ukáže, kde stojíš, ls ukáže, čo tu je; názvy dopĺňaj klávesom Tab
Permission denied do tohto miesta nemáš právo zapisovať pracuj vo svojom domovskom priečinku ~
vo vi sa po stlačení klávesov nič nepíše vi je v normálnom režime stlač i, dole sa objaví -- INSERT --
E37: No write since last change v súbore sú neuložené zmeny :wq ich uloží, :q! ich zahodí
prompt sa nevracia príkaz stále beží alebo čaká na vstup Ctrl + C
prehliadač hlási 403 Forbidden web server nesmie priečinok čítať na sigma chmod 755 public_html
prehliadač hlási 404 Not Found súbor na sigma nie je, alebo je v adrese preklep Upload Folder a kontrola adresy
namiesto ľ, š, č sú čudné znaky chýba <meta charset="utf-8"> doplň ho do <head>
image sa nezobrazí názov súboru nesedí so src, aj veľké a malé písmená súbor sa volá presne photo.jpg
stránka je bez farieb a písma style.css sa nenašiel skontroluj href v <link> a či je súbor v tom istom priečinku

Why the command line

On your own computer you click icons and windows with the mouse. A server does not work like that: it has no monitor and no mouse, and you connect to it remotely. When you connect to sigma, all you see is a line where you type commands. This is called the command line or the terminal.

You also have a terminal in Kubeflow (in VS Code through the ☰ → Terminal → New Terminal menu). Kubeflow and sigma both run Linux, so the commands you learn today work the same on both.

The prompt: how you know where you are

When the terminal waits for your command, it prints a prompt at the start of the line. It tells you who you are, which computer you are on and which folder you are in:

jovyan@vscode-0:~$      ← Kubeflow: user jovyan, computer vscode-0, folder ~
jn123ab@sigma:~$        ← sigma: your TUKE login, computer sigma, folder ~

The ~ sign means your home folder. You type the command after the $ sign and confirm it with Enter.

Basic commands

These commands are enough for the whole semester:

What you want to do Command
find out which folder you are in pwd
list what is in the folder ls
list hidden files and details too ls -la
go into a folder cd name
go one level up cd ..
go back to your home folder cd ~
create a folder mkdir name
create a folder with subfolders mkdir -p a/b/c
create an empty file touch file.txt
copy a file cp source target
move or rename a file mv old new
delete a file rm file
delete a folder with its content rm -r folder
print the content of a file cat file.txt
clear the screen clear
list the commands you have typed so far history
connect to sigma ssh login@sigma.tuke.sk
disconnect from sigma exit

Paths to files

A path says where a file or folder is. Folders in it are separated by a slash /.

Written What it means
/ the root, the start of the whole disk
~ your home folder
. the folder you are in right now
.. the folder one level up
/home/jovyan/web an absolute path: starts with a slash and works wherever you are
web/ti a relative path: counted from the folder you are in right now

How to save work and nerves

  • The Tab key completes file and folder names. Type the first letters and press Tab. If nothing is completed, there is no such file in the folder.
  • The up arrow brings back your previous commands, so you do not have to type them again.
  • If a command gets stuck and the prompt does not come back, press Ctrl + C.
  • rm deletes permanently; there is no recycle bin in the terminal. Before deleting, check where you are with pwd.
  • Try new commands in the ~/pieskovisko folder. Your assignments are in ~/web and you do not want to break them.

The vi editor

Vi is a text editor that runs directly in the terminal. You will find it on every Linux server, even where there is no other editor. Sometimes you end up in it by accident, for example when you run git commit without -m on a server and Git opens an editor for the commit message. That is why you need to know at least how to open it, type something, save and close it.

A bit of history

One of the most-read questions of all time on Stack Overflow is “How do I exit the Vim editor?”. Millions of programmers have read it, so if it happens to you, you are not alone. Bill Joy wrote vi in 1976 for the ADM-3A terminal. That terminal had arrows printed on the keys H J K L, which is why you can still move with them in vi. The Esc key sat where Tab is today, so it was easy to reach. And the Home key carried a tilde ~. That is why ~ means the home folder today.

How to start vi

Type vi followed by a file name and press Enter:

vi about-me.txt

If the file exists, it opens. If it does not, vi creates it the first time you save. Empty lines are marked with a tilde ~ on the left edge.

Why nothing is typed when you press keys

Vi has modes. After it starts it is in normal mode, and there the keys do not type text, they run commands. That is why vi seems not to react or to do strange things. You can type only in insert mode.

Mode How to get there What the keys do How you recognise it
normal after vi starts, or with Esc run commands nothing at the bottom
insert with i type text -- INSERT -- at the bottom
command line with a colon : in normal mode you type a command and press Enter : at the bottom

Steps: open, type, save and close

  1. Type vi about-me.txt and press Enter. The file opens in normal mode.
  2. Press i. -- INSERT -- appears at the bottom and you can type.
  3. Type your text. Move between lines with the arrow keys.
  4. Press Esc. -- INSERT -- disappears and you are back in normal mode.
  5. Type :wq and press Enter. Vi saves the file, closes and you are back in the terminal.

How to close vi

You type all of these in normal mode (if you are not sure, press Esc first) and confirm them with Enter:

What you want What you type
save the changes and close :wq
close when you changed nothing :q
close and throw the changes away :q!
only save and keep working :w

If you type :q and vi answers E37: No write since last change, the file has unsaved changes. Decide: :wq saves them, :q! throws them away.

When you are lost and do not know what is going on: press Esc twice, type :q! and press Enter. Vi closes without saving and you are back in the terminal. This always works.

Editing text in normal mode

Key What it does
x deletes the character under the cursor
dd deletes the whole line
u undoes the last change
/word and Enter searches for a word, n jumps to the next match

Vi in Kubeflow

In Kubeflow the vi command starts Vim, an improved vi. Everything described above works in it. If you want a simpler editor without modes, use nano: you type right after it starts, and the controls are listed at the bottom (Ctrl + O saves, Ctrl + X closes). Do not use Ctrl + W in the terminal: the terminal runs in the browser, and the browser would close the whole Kubeflow tab.

Kubeflow and sigma: two computers

You work on two computers at once, and it helps to know what happens where:

Kubeflow  ~/web/ti/cv01/  ── save (SFTP) ──>  sigma  ~/public_html/ti/cv01/
    │                                              │
    └── commit + push ──> GitHub                   └──> https://sigma.tuke.sk/student/name.surname/ti/cv01/
  • You write code in Kubeflow. Every file you save in VS Code is uploaded to sigma automatically.
  • On sigma the web server shows only what is in the public_html folder.
  • You submit a task by committing and pushing your changes to GitHub. Nothing is committed to sigma; files are only uploaded there.
  • You accept the teacher’s assignment in Classroom 50. GitHub creates your own repository for it, and you clone it into ~/web/ti/cv01. The steps are in guide 04 Submitting.

The skeleton of an HTML page

HTML is plain text in which tags tell the browser what is a heading, what is a paragraph, what is an image and so on. Every HTML page has the same skeleton:

  • <!doctype html> says this is HTML5.
  • <html lang="sk"> wraps the whole page and sets its language.
  • <head> holds information about the page that is not displayed: the encoding <meta charset="utf-8"> (so that special characters display correctly), the mobile setting <meta name="viewport" ...>, the browser tab title <title> and the link to the style file <link rel="stylesheet" href="style.css">.
  • <body> holds everything you see on the page.

In VS Code you do not have to type the skeleton by hand: type an exclamation mark ! into an empty .html file and press Tab.

The most common elements

Element What it is for
<h1> to <h6> headings; h1 is the main one and usually appears once per page
<p> a paragraph of text
<strong>, <em> an important word, an emphasised word
<ul>, <ol>, <li> unordered list, ordered list, list item
<table>, <thead>, <tr>, <th>, <td> table, its header, row, header cell, ordinary cell
<img src="..." alt="..."> image; alt is the text shown or read aloud when the image cannot be seen
<a href="..."> link; href="#contact" jumps to the element with id="contact" on the same page
<header>, <nav>, <main>, <section>, <footer> page parts: header, menu, main content, section, footer

CSS in a nutshell

HTML says what is on the page, CSS says how it looks. We write styles into a separate file style.css. Every rule looks like selector { property: value; }. The selector says which elements the rule applies to:

h2 { color: #a3274f; }            /* all h2 headings turn burgundy */
table, th, td { border: 1px solid #999; }

The most common errors and what they mean

What you see Cause Fix
command not found a typo in the command name check the command; the up arrow brings it back for fixing
No such file or directory there is no file or folder with this name here pwd shows where you are, ls shows what is here; complete names with Tab
Permission denied you are not allowed to write to this place work in your home folder ~
nothing is typed in vi when you press keys vi is in normal mode press i; -- INSERT -- appears at the bottom
E37: No write since last change the file has unsaved changes :wq saves them, :q! throws them away
the prompt does not come back the command is still running or waiting for input Ctrl + C
the browser shows 403 Forbidden the web server may not read the folder on sigma chmod 755 public_html
the browser shows 404 Not Found the file is not on sigma, or there is a typo in the address Upload Folder and check the address
strange characters instead of accented letters <meta charset="utf-8"> is missing add it to the <head>
the image is not displayed the file name does not match src, including upper and lower case the file is called exactly photo.jpg
the page has no colours and fonts style.css was not found check href in the <link> and that the file is in the same folder

UkážkyExamples

Ukážka 1: prvé kroky v termináli

cd ~
mkdir pieskovisko
cd pieskovisko
pwd
mkdir -p projekt/css
touch projekt/index.html
ls -la projekt
cp projekt/index.html copy.html
mv copy.html backup.html
rm backup.html

Ukážka 2: vi v skratke

vi about-me.txt        otvorí (alebo vytvorí) súbor
i                   vkladací režim, píšeš
Esc                 späť do normálneho režimu
:wq                 ulož a odíď
cat about-me.txt       kontrola, čo je v súbore

Ukážka 3: na sigma

ssh jn123ab@sigma.tuke.sk
pwd
ls -la
ls public_html/ti/cv01
exit

Ak ls vypíše „No such file or directory”, priečinok ešte neexistuje:

mkdir -p public_html/ti/cv01
chmod 755 public_html

chmod 755 dovolí web serveru priečinok čítať. Bez toho prehliadač hlási 403 Forbidden.

Cesta k súboru na sigma a jeho adresa na webe:

/home/jn123ab/
└── public_html/            ->  https://sigma.tuke.sk/student/meno.priezvisko/
    └── ti/
        └── cv01/
            └── index.html  ->  https://sigma.tuke.sk/student/meno.priezvisko/ti/cv01/

Ukážka 4: prompt pre AI na prvú stránku

Stránku nepíšeš ručne, zadáš ju AI. Dobrý prompt presne povie, čo chceš dostať:

Vytvor mi jednoduchú webovú stránku v HTML5 v slovenčine (lang="sk", kódovanie UTF-8)
a k nej samostatný súbor style.css. Bez JavaScriptu a bez frameworkov (žiadny Bootstrap).

Stránka je jedna (index.html) a má obsahovať:
- header s heading h1 a menu, ktoré odkazuje na section na tej istej stránke
  pomocou kotiev (href="#..."),
- section s headings h2, aspoň dva paragraphs textu, zvýraznené slovo (strong, em),
- nečíslovaný a číslovaný zoznam,
- table s header (thead) a aspoň 3 riadkami, s viditeľným ohraničením buniek,
- image zo súboru photo.jpg v tom istom priečinku, s attribute alt,
- link na externú stránku, ktorý sa otvorí v novej karte prehliadača,
- footer s mojím menom a rokom.

CSS nech je jednoduché a čitateľné: písmo, obmedzená šírka obsahu a centrovanie,
farba headings, menu vedľa seba, ohraničenie table, image nesmie pretiecť mimo stránku.

Do HTML aj CSS daj krátke komentáre po slovensky, ktoré vysvetlia, na čo slúži
každý element, aby som kódu rozumel.

Téma stránky: [DOPLŇ]

Prečo je prompt napísaný práve takto:

  • jazyk a UTF-8: slovenské znaky sa zobrazia správne,
  • bez JavaScriptu a frameworkov: dostaneš len HTML a CSS, ktorým dnes rozumieš,
  • zoznam elements: AI nič nevynechá a nič nepridá navyše,
  • komentáre v kóde: kód vieš prečítať a vysvetliť, čo budeš robiť pri obhajobe,
  • téma projektu: každý má inú stránku.

Keď výsledok nesedí, celý prompt nepíš znova. Napíš AI, čo presne treba opraviť, napríklad: „Table nemá ohraničenie buniek, oprav CSS.”

Example 1: first steps in the terminal

cd ~
mkdir pieskovisko
cd pieskovisko
pwd
mkdir -p projekt/css
touch projekt/index.html
ls -la projekt
cp projekt/index.html copy.html
mv copy.html backup.html
rm backup.html

Example 2: vi in short

vi about-me.txt        opens (or creates) the file
i                   insert mode, you type
Esc                 back to normal mode
:wq                 save and quit
cat about-me.txt       check what is in the file

Example 3: on sigma

ssh jn123ab@sigma.tuke.sk
pwd
ls -la
ls public_html/ti/cv01
exit

If ls prints “No such file or directory”, the folder does not exist yet:

mkdir -p public_html/ti/cv01
chmod 755 public_html

chmod 755 lets the web server read the folder. Without it the browser shows 403 Forbidden.

The path of a file on sigma and its address on the web:

/home/jn123ab/
└── public_html/            ->  https://sigma.tuke.sk/student/name.surname/
    └── ti/
        └── cv01/
            └── index.html  ->  https://sigma.tuke.sk/student/name.surname/ti/cv01/

Example 4: an AI prompt for your first page

You do not write the page by hand, you give it to an AI. A good prompt says exactly what you want to get:

Create a simple web page in HTML5 (set the lang attribute to the page language,
UTF-8 encoding) and a separate style.css file. No JavaScript and no frameworks
(no Bootstrap).

It is a single page (index.html) and it contains:
- a header with an h1 heading and a menu linking to sections on the same page
  using anchors (href="#..."),
- sections with h2 headings, at least two paragraphs of text, an emphasised word
  (strong, em),
- an unordered and an ordered list,
- a table with a header (thead) and at least 3 rows, with visible cell borders,
- an image from the file photo.jpg in the same folder, with an alt attribute,
- a link to an external website that opens in a new tab,
- a footer with my name and the year.

Keep the CSS simple and readable: font, limited content width and centring,
heading colour, menu items side by side, table borders, the image must not
overflow the page.

Add short comments in English to both the HTML and the CSS explaining what every
element is for, so that I understand the code.

Page topic: [FILL IN]

Why the prompt is written this way:

  • language and UTF-8: special characters display correctly,
  • no JavaScript and no frameworks: you get only HTML and CSS, which you understand today,
  • the list of elements: the AI leaves nothing out and adds nothing extra,
  • comments in the code: you can read the code and explain it, which is what you do at the defence,
  • the project topic: everyone gets a different page.

When the result is not right, do not rewrite the whole prompt. Tell the AI exactly what to fix, for example: “The table cells have no borders, fix the CSS.”

Úlohy na cvičenieLab tasks

Úlohy dostaneš aj ako zadanie cv01 v Classroom 50, sú v súbore README.md v tvojom repository.

Link na zadanie cv01: prijať zadanie
(platí pre skupiny B. Stehlíkovej; ostatné skupiny dostanú link od svojho cvičiaceho)

Úloha 2.1: Príprava Kubeflow a zadanie. Priprav si Kubeflow podľa návodu 04 Odovzdávanie, časť 1: v Explorer je hore WEB, dole na stavovej lište je Go Live. Ak tam nie je, rozšírenia vráti tento príkaz v termináli:

code-server --install-extension Natizyskunk.sftp --install-extension yandeu.five-server --install-extension bmewburn.vscode-intelephense-client --install-extension mblode.twig-language-2

Potom F1, Developer: Reload Window. Nastavenie pripojenia na sigma zostáva, netreba ho robiť znova. Prijmi zadanie cv01 v Classroom 50 (link je vyššie) a repository naklonuj do ~/web/ti/cv01 podľa návodu 04, časti 2 a 3.

Úloha 2.2: Pieskovisko. V termináli v Kubeflow si vytvor ~/pieskovisko a v ňom len príkazmi, bez myši, štruktúru projekt/css, projekt/img a prázdne súbory projekt/index.html a notes.txt. Jeden súbor skopíruj, jeden premenuj a jeden zmaž. Po každom kroku to over cez ls -la.

Úloha 2.3: Vi. V pieskovisku vytvor vo vi súbor about-me.txt s tromi riadkami: meno, téma tvojho semestrálneho projektu, jedna vec, ktorú si sa dnes naučil. Ulož a odíď. Otvor ho znova, zmaž riadok cez dd, vráť ho cez u a odíď bez uloženia cez :q!. Cez cat over, že súbor má stále tri riadky.

Úloha 2.4: História. Na konci práce v termináli ulož históriu do súboru: history > ~/pieskovisko/history.txt.

Úloha 2.5: Stránka cez AI. Prompt z Ukážky 4 vlož do AI, na koniec doplň tému svojho projektu. Výsledok ulož do ~/web/ti/cv01 ako index.html a style.css. Image pretiahni myšou z počítača do priečinka cv01 v Explorer a premenuj ho na photo.jpg. Stránku si pozri cez Five Server a čo nesedí, nechaj AI opraviť. Prečítaj komentáre v kóde: každý element musíš vedieť vysvetliť.

Úloha 2.6: Odovzdanie. Skopíruj do zadania súbory z pieskoviska: cp ~/pieskovisko/history.txt ~/pieskovisko/about-me.txt ~/web/ti/cv01/. Potom commit a push podľa návodu 04 Odovzdávanie.

Úloha 2.7: Upload Folder a kontrola na sigma. Podľa návodu 04, časť 7: klikni pravým na priečinok cv01 a v menu úplne dole zvoľ Upload Folder. Na sigma tým doplníš aj pretiahnutý image a súbory z terminálu. Potom sa cez ssh pripoj na sigma a skontroluj, že v public_html/ti/cv01 sú tvoje súbory (Ukážka 3). Nakoniec otvor v prehliadači https://sigma.tuke.sk/student/meno.priezvisko/ti/cv01/.

Hodnotenie: 1 bod. V repository cv01 na GitHub aj na sigma je funkčná stránka, history.txt a about-me.txt. Commit a push najneskôr do nasledujúceho cvičenia.

You also get the tasks as the assignment cv01 in Classroom 50, in the file README.md in your repository.

Link to the assignment cv01: accept the assignment
(for B. Stehlíková’s groups; other groups get the link from their lab teacher)

Task 2.1: Getting Kubeflow ready and the assignment. Get Kubeflow ready following guide 04 Submitting, part 1: Explorer shows WEB at the top, the status bar at the bottom shows Go Live. If it does not, this terminal command brings the extensions back:

code-server --install-extension Natizyskunk.sftp --install-extension yandeu.five-server --install-extension bmewburn.vscode-intelephense-client --install-extension mblode.twig-language-2

Then F1, Developer: Reload Window. The connection settings for sigma stay, you do not have to set them up again. Accept the assignment cv01 in Classroom 50 (the link is above) and clone the repository into ~/web/ti/cv01 following guide 04, parts 2 and 3.

Task 2.2: Sandbox. In the Kubeflow terminal create ~/pieskovisko and inside it, using commands only and no mouse, the structure projekt/css, projekt/img and empty files projekt/index.html and notes.txt. Copy one file, rename one and delete one. Check each step with ls -la.

Task 2.3: Vi. In the sandbox create a file about-me.txt in vi with three lines: your name, the topic of your semester project, one thing you learned today. Save and quit. Open it again, delete a line with dd, bring it back with u and quit without saving with :q!. Check with cat that the file still has three lines.

Task 2.4: History. At the end of your terminal work save the history into a file: history > ~/pieskovisko/history.txt.

Task 2.5: A page made with AI. Paste the prompt from Example 4 into an AI and fill in the topic of your project at the end. Save the result into ~/web/ti/cv01 as index.html and style.css. Drag an image from your computer into the cv01 folder in Explorer and rename it to photo.jpg. View the page with Five Server and let the AI fix whatever is not right. Read the comments in the code: you must be able to explain every element.

Task 2.6: Submitting. Copy the sandbox files into the assignment: cp ~/pieskovisko/history.txt ~/pieskovisko/about-me.txt ~/web/ti/cv01/. Then commit and push following guide 04 Submitting.

Task 2.7: Upload Folder and the check on sigma. Following guide 04, part 7: right-click the cv01 folder and choose Upload Folder at the very bottom of the menu. This also gets the dragged image and the files from the terminal to sigma. Then connect to sigma with ssh and check that your files are in public_html/ti/cv01 (Example 3). Finally open https://sigma.tuke.sk/student/name.surname/ti/cv01/ in the browser.

Grading: 1 point. A working page, history.txt and about-me.txt are in the cv01 repository on GitHub and on sigma. Commit and push by the next lab at the latest.

Obhajoba a live codingDefence and live coding

Pri obhajobe budú použité iba otázky a úlohy z týchto zoznamov. Live coding robíš v kópii, odovzdaný stav v cv01 sa nezmení. Kópiu si priprav pred obhajobou:

cd ~/web/ti
mkdir -p obhajoba1
rsync -a --exclude .git cv01/ obhajoba1/cv01/

Potom klikni pravým na priečinok obhajoba1 a v menu úplne dole zvoľ Upload Folder. Kópia je na https://sigma.tuke.sk/student/meno.priezvisko/ti/obhajoba1/cv01/.

Vysvetli (code walkthrough)

  1. Prečítaj prompt terminálu jovyan@vscode-0:~/web/ti$: čo znamená každá časť.
  2. Čo vypíše pwd a čo ls -la.
  3. Aký je rozdiel medzi absolútnou a relatívnou cestou. Ukáž obe na svojom priečinku cv01.
  4. Čo znamenajú ~, . a ...
  5. Čo urobí mkdir -p projekt/css a načo je -p.
  6. Aký je rozdiel medzi cp a mv.
  7. Aké režimy má vi a ako spoznáš, v ktorom si.
  8. Aký je rozdiel medzi :wq a :q!.
  9. Čo sa deje v Kubeflow, čo na sigma a čo na GitHub.
  10. Prečo je tvoja stránka v priečinku public_html a ako z cesty k súboru vznikne adresa na webe.
  11. Čo hovorí <!doctype html> a atribút (attribute) lang.
  12. Načo je <meta charset="utf-8">.
  13. Čo patrí do <head> a čo do <body>.
  14. Aký je rozdiel medzi <ul> a <ol>.
  15. Z akých tags sa skladá tvoja table.
  16. Načo je attribute alt pri image.
  17. Ako funguje odkaz (link) v menu, ktorý skočí na sekciu (section) na tej istej stránke.
  18. Čo robí <link rel="stylesheet" href="style.css">.
  19. Prečítaj jedno pravidlo zo svojho style.css: čo je selector, čo property a čo hodnota.

Uprav (live coding)

  1. V termináli vytvor priečinok a v ňom prázdny súbor. Súbor premenuj.
  2. Vo vi pridaj do súboru about-me.txt jeden riadok a ulož ho.
  3. Pridaj položku do zoznamu.
  4. Pridaj riadok do table.
  5. Pridaj do table stĺpec (column).
  6. Pridaj novú section s heading h2 a link na ňu do menu.
  7. Zmeň text alt pri image.
  8. Pridaj link na externú stránku, ktorý sa otvorí v novej karte prehliadača.
  9. Zmeň v style.css farbu všetkých headings h2.
  10. Zmeň v style.css ohraničenie table.

Zdôvodni (design decisions)

  1. Prečo sa učíme príkazový riadok, keď máme myš.
  2. Prečo je CSS v samostatnom súbore style.css.
  3. Prečo má image attribute alt.
  4. Prečo sú v HTML tag header, nav, main a footer, a nie iba div.
  5. Prečo máš rozumieť kódu, ktorý ti napísala AI.

Definition of Done

  • Repository cv01 je na GitHub: index.html, style.css, photo.jpg, history.txt, about-me.txt.
  • Stránka je na sigma a zobrazuje sa aj s image.
  • Diakritika sa zobrazuje správne.
  • Každý element na svojej stránke vieš pomenovať a vysvetliť.

Only the questions and tasks from these lists are used at the defence. You do the live coding in a copy; the submitted state in cv01 does not change. Prepare the copy before the defence:

cd ~/web/ti
mkdir -p obhajoba1
rsync -a --exclude .git cv01/ obhajoba1/cv01/

Then right-click the obhajoba1 folder and choose Upload Folder at the very bottom of the menu. The copy is at https://sigma.tuke.sk/student/name.surname/ti/obhajoba1/cv01/.

Explain (code walkthrough)

  1. Read the terminal prompt jovyan@vscode-0:~/web/ti$: what each part means.
  2. What pwd prints and what ls -la prints.
  3. The difference between an absolute and a relative path. Show both on your cv01 folder.
  4. What ~, . and .. mean.
  5. What mkdir -p projekt/css does and what -p is for.
  6. The difference between cp and mv.
  7. Which modes vi has and how you recognise which one you are in.
  8. The difference between :wq and :q!.
  9. What happens in Kubeflow, what on sigma and what on GitHub.
  10. Why your page is in the public_html folder and how the file path becomes a web address.
  11. What <!doctype html> and the lang attribute say.
  12. What <meta charset="utf-8"> is for.
  13. What belongs in <head> and what in <body>.
  14. The difference between <ul> and <ol>.
  15. Which tags your table consists of.
  16. What the alt attribute of an image is for.
  17. How a menu link that jumps to a section on the same page works.
  18. What <link rel="stylesheet" href="style.css"> does.
  19. Read one rule from your style.css: which part is the selector, the property and the value.

Modify (live coding)

  1. In the terminal create a folder and an empty file in it. Rename the file.
  2. In vi add one line to the about-me.txt file and save it.
  3. Add an item to a list.
  4. Add a row to the table.
  5. Add a column to the table.
  6. Add a new section with an h2 heading and a link to it in the menu.
  7. Change the alt text of the image.
  8. Add a link to an external website that opens in a new tab.
  9. Change the colour of all h2 headings in style.css.
  10. Change the table border in style.css.

Justify (design decisions)

  1. Why we learn the command line when we have a mouse.
  2. Why the CSS is in a separate style.css file.
  3. Why the image has an alt attribute.
  4. Why HTML has the tags header, nav, main and footer, and not just div.
  5. Why you should understand code that an AI wrote for you.

Definition of Done

  • The repository cv01 is on GitHub: index.html, style.css, photo.jpg, history.txt, about-me.txt.
  • The page is on sigma and is displayed with the image.
  • Accented characters are displayed correctly.
  • You can name and explain every element on your page.