Vaja brez artanisa, dokumentacija, osnove emacs ukazov
parent
1cf45a4629
commit
dac3375fc7
128
index.html
128
index.html
|
@ -3,7 +3,7 @@
|
|||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2024-12-12 čet 21:13 -->
|
||||
<!-- 2024-12-26 čet 21:54 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Kompotov programerski bralni krožek #1: SICP</title>
|
||||
|
@ -198,7 +198,7 @@
|
|||
<body>
|
||||
<div id="content" class="content">
|
||||
<h1 class="title">Kompotov programerski bralni krožek #1: SICP</h1>
|
||||
<div class="footer" id="orgaf3ec15">
|
||||
<div class="footer" id="org24a7aa4">
|
||||
<p>
|
||||
Izvorna koda se nahaja na <a href="https://git.kompot.si/programerski-bralni-krozek/sicp">git.kompot.si</a>.
|
||||
</p>
|
||||
|
@ -214,55 +214,63 @@ Za bralni krožek se dogovarjamo prek (javne) mailing liste, na katero se lahko
|
|||
</p>
|
||||
|
||||
|
||||
<div id="org73a6e4c" class="figure">
|
||||
<div id="org40a42d8" class="figure">
|
||||
<p><img src="./tb.jpg" alt="tb.jpg" />
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org62e23d5" class="outline-2">
|
||||
<h2 id="org62e23d5">Srečanja</h2>
|
||||
<div class="outline-text-2" id="text-org62e23d5">
|
||||
<div id="outline-container-org0f8ae9e" class="outline-2">
|
||||
<h2 id="org0f8ae9e">Srečanja</h2>
|
||||
<div class="outline-text-2" id="text-org0f8ae9e">
|
||||
</div>
|
||||
<div id="outline-container-org4de267c" class="outline-3">
|
||||
<h3 id="org4de267c">#14: četrtek, 12. 12. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org4de267c">
|
||||
<div id="outline-container-org2db3627" class="outline-3">
|
||||
<h3 id="org2db3627">#15: četrtek, 26. 12. 2024 ob 19.00 v Fužinah</h3>
|
||||
<div class="outline-text-3" id="text-org2db3627">
|
||||
<p>
|
||||
Nadaljevali smo z vajo, <a href="vaja/plan.html">plan</a> smo dopolnili z guile kodo, ki ni odvisna od <code>artanis</code>, da bi si malo poenostavili. Poenostavitev je terjala malo več lastne kode.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgd4895a0" class="outline-3">
|
||||
<h3 id="orgd4895a0">#14: četrtek, 12. 12. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orgd4895a0">
|
||||
<p>
|
||||
Pričeli smo s prvo vajo, izbrali smo igro stavkov kot spletno aplikacijo.
|
||||
Dokumentacija je tukaj: <a href="vaja/plan.html">plan za vaje</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgf8abb44" class="outline-3">
|
||||
<h3 id="orgf8abb44">#13: četrtek, 28. 11. 2024 ob 18.45 v CTK</h3>
|
||||
<div id="outline-container-org362e90a" class="outline-3">
|
||||
<h3 id="org362e90a">#13: četrtek, 28. 11. 2024 ob 18.45 v CTK</h3>
|
||||
</div>
|
||||
<div id="outline-container-org7c1f97b" class="outline-3">
|
||||
<h3 id="org7c1f97b">#12: četrtek, 14. 11. 2024 ob 19.15 v CTK</h3>
|
||||
<div id="outline-container-org79dd0de" class="outline-3">
|
||||
<h3 id="org79dd0de">#12: četrtek, 14. 11. 2024 ob 19.15 v CTK</h3>
|
||||
</div>
|
||||
<div id="outline-container-org565e6db" class="outline-3">
|
||||
<h3 id="org565e6db">#11: četrtek, 31. 10. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org565e6db">
|
||||
<div id="outline-container-org0f70ca8" class="outline-3">
|
||||
<h3 id="org0f70ca8">#11: četrtek, 31. 10. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org0f70ca8">
|
||||
<p>
|
||||
2.3.1: Citiranje (quotation)
|
||||
2.3.2: Simbolno odvajanje (symbollic differentiation)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb3c8ad0" class="outline-3">
|
||||
<h3 id="orgb3c8ad0">#10: četrtek, 17. 10. 2024 ob 18.45 v CTK</h3>
|
||||
<div id="outline-container-org5313b3b" class="outline-3">
|
||||
<h3 id="org5313b3b">#10: četrtek, 17. 10. 2024 ob 18.45 v CTK</h3>
|
||||
</div>
|
||||
<div id="outline-container-orge0a8666" class="outline-3">
|
||||
<h3 id="orge0a8666">#9: četrtek, 3. 10. 2024 ob 18.45 v CTK</h3>
|
||||
<div id="outline-container-org9813758" class="outline-3">
|
||||
<h3 id="org9813758">#9: četrtek, 3. 10. 2024 ob 18.45 v CTK</h3>
|
||||
</div>
|
||||
<div id="outline-container-orga264a0b" class="outline-3">
|
||||
<h3 id="orga264a0b">#8: četrtek, 19. 9. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orga264a0b">
|
||||
<div id="outline-container-orgc6261be" class="outline-3">
|
||||
<h3 id="orgc6261be">#8: četrtek, 19. 9. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orgc6261be">
|
||||
<p>
|
||||
Nadaljujemo z drugim poglavjem. (2.2 - Hierarhicne podatkovne strukture in lastnost zaprtosti)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org5807cee" class="outline-3">
|
||||
<h3 id="org5807cee">#8: sreda, 4. 9. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org5807cee">
|
||||
<div id="outline-container-orgeb4f8be" class="outline-3">
|
||||
<h3 id="orgeb4f8be">#8: sreda, 4. 9. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orgeb4f8be">
|
||||
<p>
|
||||
Pregled vsebine 2. poglavja.
|
||||
</p>
|
||||
|
@ -272,23 +280,23 @@ Intervalna algebra: <a href="https://www.sciencedirect.com/science/article/pii/S
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org82d508c" class="outline-3">
|
||||
<h3 id="org82d508c">#8: sreda, 21. 8. 2024 ob 19.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org82d508c">
|
||||
<div id="outline-container-org1ca4b41" class="outline-3">
|
||||
<h3 id="org1ca4b41">#8: sreda, 21. 8. 2024 ob 19.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org1ca4b41">
|
||||
<p>
|
||||
Beremo poglavje 2.1.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgf6f3beb" class="outline-3">
|
||||
<h3 id="orgf6f3beb">#7: sreda, 24. 7. 2024 ob 19.45 v parlamentu</h3>
|
||||
<div id="outline-container-org80593af" class="outline-3">
|
||||
<h3 id="org80593af">#7: sreda, 24. 7. 2024 ob 19.45 v parlamentu</h3>
|
||||
</div>
|
||||
<div id="outline-container-org1365bd8" class="outline-3">
|
||||
<h3 id="org1365bd8">#6: sreda, 10. 7. 2024 ob 19.45 v CTK</h3>
|
||||
<div id="outline-container-org80613e5" class="outline-3">
|
||||
<h3 id="org80613e5">#6: sreda, 10. 7. 2024 ob 19.45 v CTK</h3>
|
||||
</div>
|
||||
<div id="outline-container-orgc302727" class="outline-3">
|
||||
<h3 id="orgc302727">#5: sreda, 12. 6. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orgc302727">
|
||||
<div id="outline-container-orgd87322f" class="outline-3">
|
||||
<h3 id="orgd87322f">#5: sreda, 12. 6. 2024 ob 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orgd87322f">
|
||||
<p>
|
||||
<a href="https://dogodki.kompot.si/events/63a4ad96-7cc2-45a3-8560-18a1a28cf9b5">Povezava</a> do najave dogodka.
|
||||
</p>
|
||||
|
@ -297,27 +305,27 @@ Beremo poglavje 2.1.
|
|||
Beremo prvo podpoglavje drugega poglavja Grajenje abstrakcij s podatki.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org03b94c6" class="outline-4">
|
||||
<h4 id="org03b94c6">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-org03b94c6">
|
||||
<div id="outline-container-org6a53de1" class="outline-4">
|
||||
<h4 id="org6a53de1">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-org6a53de1">
|
||||
<ul class="org-ul">
|
||||
<li><a href="zapiski/g1smo/2_6_zapiski_vaje.html">g1smo</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org2424be3" class="outline-3">
|
||||
<h3 id="org2424be3">#4: sreda, 29. 5. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org2424be3">
|
||||
<div id="outline-container-orgd98864a" class="outline-3">
|
||||
<h3 id="orgd98864a">#4: sreda, 29. 5. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-orgd98864a">
|
||||
<p>
|
||||
Dogodek je <a href="https://dogodki.kompot.si/events/0f3df86f-abc0-4725-bb4c-3587262a672c">tukaj</a>.
|
||||
Preglejujemo naloge iz prvega poglavja.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org28404cd" class="outline-3">
|
||||
<h3 id="org28404cd">#3: četrtek, 16. 5. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org28404cd">
|
||||
<div id="outline-container-org3ebcccf" class="outline-3">
|
||||
<h3 id="org3ebcccf">#3: četrtek, 16. 5. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org3ebcccf">
|
||||
<p>
|
||||
Kot ponavadi je dogodek na našem <a href="https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d">mobilizonu</a>.
|
||||
</p>
|
||||
|
@ -328,9 +336,9 @@ Ker vsebuje poglavje veliko vaj, za katere nismo našli časa, smo se odločili
|
|||
Na srečanju smo skupaj reševali vajo 1.29.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-orgf5f7d24" class="outline-4">
|
||||
<h4 id="orgf5f7d24">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-orgf5f7d24">
|
||||
<div id="outline-container-org729d67f" class="outline-4">
|
||||
<h4 id="org729d67f">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-org729d67f">
|
||||
<ul class="org-ul">
|
||||
<li><a href="zapiski/sicp-lio.html#MissingReference">lio</a></li>
|
||||
<li><a href="./zapiski/g1smo/1_3_zapiski_vaje.html">g1smo</a></li>
|
||||
|
@ -338,9 +346,9 @@ Na srečanju smo skupaj reševali vajo 1.29.
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org7a38ec3" class="outline-3">
|
||||
<h3 id="org7a38ec3">#2: torek, 30. 4. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org7a38ec3">
|
||||
<div id="outline-container-org5788e57" class="outline-3">
|
||||
<h3 id="org5788e57">#2: torek, 30. 4. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org5788e57">
|
||||
<p>
|
||||
Dogodek je <a href="https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d">tukaj</a>.
|
||||
</p>
|
||||
|
@ -349,9 +357,9 @@ Dogodek je <a href="https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a23
|
|||
Nadaljujemo z branjem poglavja 1.2, Procedures and the processes they generate.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org0792bc8" class="outline-4">
|
||||
<h4 id="org0792bc8">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-org0792bc8">
|
||||
<div id="outline-container-org3dc02b6" class="outline-4">
|
||||
<h4 id="org3dc02b6">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-org3dc02b6">
|
||||
<ul class="org-ul">
|
||||
<li><a href="zapiski/sicp_1_2_tina.md">tina</a> (<a href="zapiski/sicp_1_2_tina.scm">vaje</a>, <a href="zapiski/sicp_sec_1_2.scm">druga varjanta</a>)</li>
|
||||
<li><a href="zapiski/sicp-lio.html#MissingReference">lio</a></li>
|
||||
|
@ -360,9 +368,9 @@ Nadaljujemo z branjem poglavja 1.2, Procedures and the processes they generate.
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org299d950" class="outline-3">
|
||||
<h3 id="org299d950">#1: sreda, 17. 4. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org299d950">
|
||||
<div id="outline-container-org794d099" class="outline-3">
|
||||
<h3 id="org794d099">#1: sreda, 17. 4. 2024 18.45 v CTK</h3>
|
||||
<div class="outline-text-3" id="text-org794d099">
|
||||
<p>
|
||||
Beremo uvod in do poglavja 1.2, približno 30 strani.
|
||||
</p>
|
||||
|
@ -371,9 +379,9 @@ Beremo uvod in do poglavja 1.2, približno 30 strani.
|
|||
Link do <a href="https://dogodki.kompot.si/events/76672075-1c6f-48f1-bc37-05dde93371e5">dogodka na dogodki.kompot.si</a>.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-orgb08c8b5" class="outline-4">
|
||||
<h4 id="orgb08c8b5">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-orgb08c8b5">
|
||||
<div id="outline-container-orgaa7e0bd" class="outline-4">
|
||||
<h4 id="orgaa7e0bd">zapiski</h4>
|
||||
<div class="outline-text-4" id="text-orgaa7e0bd">
|
||||
<ul class="org-ul">
|
||||
<li><a href="zapiski/g1smo/1_1_zapiski_vaje.html">g1smo</a></li>
|
||||
<li><a href="zapiski/sicp-lio.html">lio</a></li>
|
||||
|
|
|
@ -14,6 +14,8 @@ Za bralni krožek se dogovarjamo prek (javne) mailing liste, na katero se lahko
|
|||
[[file:./tb.jpg]]
|
||||
|
||||
* Srečanja
|
||||
** #15: četrtek, 26. 12. 2024 ob 19.00 v Fužinah
|
||||
Nadaljevali smo z vajo, [[file:vaja/plan.org][plan]] smo dopolnili z guile kodo, ki ni odvisna od ~artanis~, da bi si malo poenostavili. Poenostavitev je terjala malo več lastne kode.
|
||||
** #14: četrtek, 12. 12. 2024 ob 18.45 v CTK
|
||||
Pričeli smo s prvo vajo, izbrali smo igro stavkov kot spletno aplikacijo.
|
||||
Dokumentacija je tukaj: [[file:vaja/plan.org][plan za vaje]].
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(values '((content-type . (text/plain)))
|
||||
"IGRA STAVKOV SE PRIČENJA. OHOHO"))
|
||||
;; tukajo mramo prebrat index.html in ga iprkazat
|
||||
;; (define index-file (open-input-file "./nova-igra-stavkov/index.html"))
|
||||
;; (let (contents (call-with-input-file "file.txt" get-string-all)))
|
||||
|
||||
(run-server igra-stavkov-handler)
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server)
|
||||
(ice-9 binary-ports))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(values '((content-type . (text/html)))
|
||||
(call-with-input-file "index.html" get-bytevector-all)))
|
||||
;; tukajo mramo prebrat index.html in ga iprkazat
|
||||
|
||||
|
||||
(display "strežnik igre stavkov teče: http://localhost:8080")
|
||||
(run-server igra-stavkov-handler)
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server)
|
||||
(web request)
|
||||
(web response)
|
||||
(web uri)
|
||||
(ice-9 binary-ports))
|
||||
|
||||
|
||||
(define (request-path-components request)
|
||||
(split-and-decode-uri-path (uri-path (request-uri request))))
|
||||
|
||||
|
||||
(define (not-found request)
|
||||
(values (build-response #:code 404)
|
||||
(string-append "Stran ni najdena: "
|
||||
(uri->string (request-uri request)))))
|
||||
|
||||
(define (ustvari-novo-sobo request-body)
|
||||
(display request-body)
|
||||
(values '((content-type . (text/html)))
|
||||
(string-append "<h1>Ustvari novo sobo za " st-igralcev " igralcev</h1>")))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(let ((pot (request-path-components request)))
|
||||
(cond ((equal? pot '())
|
||||
(values '((content-type . (text/html)))
|
||||
(call-with-input-file "index.html" get-bytevector-all)))
|
||||
((equal? pot '("soba" "ustvari"))
|
||||
(ustvari-novo-sobo request-body))
|
||||
|
||||
(else (not-found request)))))
|
||||
|
||||
(display "strežnik igre stavkov teče: http://localhost:8080")
|
||||
(run-server igra-stavkov-handler)
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server)
|
||||
(web request)
|
||||
(web response)
|
||||
(web uri)
|
||||
(ice-9 binary-ports))
|
||||
|
||||
|
||||
(define (request-path-components request)
|
||||
(split-and-decode-uri-path (uri-path (request-uri request))))
|
||||
|
||||
|
||||
(define (not-found request)
|
||||
(values (build-response #:code 404)
|
||||
(string-append "Stran ni najdena: "
|
||||
(uri->string (request-uri request)))))
|
||||
|
||||
(define (ustvari-novo-sobo request-body)
|
||||
(display request-body)
|
||||
(values '((content-type . (text/html)))
|
||||
"<h1>Ustvari novo sobo!</h1>"))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(let ((pot (request-path-components request)))
|
||||
(cond ((equal? pot '())
|
||||
(values '((content-type . (text/html)))
|
||||
(call-with-input-file "index.html" get-bytevector-all)))
|
||||
((equal? pot '("soba" "ustvari"))
|
||||
(debug-info request request-body))
|
||||
|
||||
(else (not-found request)))))
|
||||
|
||||
(define (debug-info request body)
|
||||
(respond
|
||||
`((h1 "Debug!")
|
||||
(table
|
||||
(tr (th "header") (th "value"))
|
||||
,@(map (lambda (pair)
|
||||
`(tr (td (tt ,(with-output-to-string
|
||||
(lambda () (display (car pair))))))
|
||||
(td (tt ,(with-output-to-string
|
||||
(lambda ()
|
||||
(write (cdr pair))))))))
|
||||
(request-headers request))))))
|
||||
|
||||
(display "strežnik igre stavkov teče: http://localhost:8080")
|
||||
(run-server igra-stavkov-handler)
|
|
@ -0,0 +1,29 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>igra stavkov</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>igra stavkov</h1>
|
||||
<h2>v živo</h2>
|
||||
<p>
|
||||
Vsak igralec potrebuje listek in pisalo. Igralci skupaj odgovarjajo na vprašanja, po vsakem odgovoru pa listek prepognejo in podajo naprej. Svoj naslednji odgovor nato napišejo pod prepognjen del in spet podajo listek naprej. Ko odogovorijo na vsa vprašanja, še enkrat podajo listek naprej naslednjemu igralcu in preberejo cel stavek.
|
||||
</p>
|
||||
|
||||
<h2>prek spleta (naša varianta)</h2>
|
||||
<p>
|
||||
Vsak igralec potrebuje računalnik z brskalnikom in internetno povezavo. Dobavna veriga obsega rudnike redkih kovin, silicij, proizvodnjo čipov, komunikacijsko mrežo, etcetera.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Na naši aplikaciji je igra zelo podobna. Izberete število igralcev in ustvarite novo sobo za igranje. Povezavo do sobo pošljete soigralcem in po vrsti odgovarjate na vprašanja, dokler ne izpolnite vseh. Vsakemu igralcu se na koncu izpiše en sestavljen stavek.
|
||||
</p>
|
||||
|
||||
<form method="POST" action="/soba/ustvari">
|
||||
<label for="num-of-players">Izberi število igralcev</label>
|
||||
<input type="number" min="1" name="num-of-players" id="num-of-players"></input>
|
||||
<input type="submit" value="igraj">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
344
vaja/plan.html
344
vaja/plan.html
|
@ -3,7 +3,7 @@
|
|||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2024-12-14 sob 06:33 -->
|
||||
<!-- 2024-12-26 čet 21:54 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>‎</title>
|
||||
|
@ -200,26 +200,29 @@
|
|||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#org3047d1b">1. Plan za vajo</a></li>
|
||||
<li><a href="#orgc256234">2. predlogi</a></li>
|
||||
<li><a href="#org8f4e818">3. tekstualna igra stavkov p</a>
|
||||
<li><a href="#orgf596808">1. Plan za vajo</a>
|
||||
<ul>
|
||||
<li><a href="#orgf2e3d1f">3.1. meta</a></li>
|
||||
<li><a href="#org9a5fa8f">3.2. homepage</a></li>
|
||||
<li><a href="#org8e4a823">3.3. seja igre</a></li>
|
||||
<li><a href="#org090645a">3.4. program</a>
|
||||
<ul>
|
||||
<li><a href="#orgf180008">3.4.1. boilerplate</a></li>
|
||||
<li><a href="#org91c5b7e">3.4.2. navodila za igro</a></li>
|
||||
<li><a href="#org32125e6">1.1. predlogi</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgd29ba3f">3.5. Nova soba</a>
|
||||
<li><a href="#org5bf83a0">2. tekstualna igra stavkov</a>
|
||||
<ul>
|
||||
<li><a href="#org5a1319f">3.5.1. (podatkovni) model sobe</a></li>
|
||||
<li><a href="#orgc249def">3.5.2. krmilnik (controller) sobe</a></li>
|
||||
<li><a href="#org39fdd0b">3.5.3. Forma za vprasanje</a></li>
|
||||
<li><a href="#org610c156">3.5.4. Podatkovni model</a></li>
|
||||
<li><a href="#org94b4a79">3.5.5. sablona za listek</a></li>
|
||||
<li><a href="#orgc9233ba">2.1. meta</a></li>
|
||||
<li><a href="#orgdfca55c">2.2. homepage</a></li>
|
||||
<li><a href="#org9708b52">2.3. seja igre</a></li>
|
||||
<li><a href="#org91eb17a">2.4. program artanis</a>
|
||||
<ul>
|
||||
<li><a href="#orgd58717f">2.4.1. boilerplate</a></li>
|
||||
<li><a href="#org0dd442b">2.4.2. navodila za igro</a></li>
|
||||
<li><a href="#orge93e74a">2.4.3. Nova soba</a></li>
|
||||
<li><a href="#org5b15729">2.4.4. Forma za vprasanje</a></li>
|
||||
<li><a href="#org75060c5">2.4.5. Podatkovni model</a></li>
|
||||
<li><a href="#org8eb32c5">2.4.6. sablona za listek</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org8abbf21">2.5. program guile web server</a>
|
||||
<ul>
|
||||
<li><a href="#org73a6528">2.5.1. navodila</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -227,13 +230,13 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org3047d1b" class="outline-2">
|
||||
<h2 id="org3047d1b"><span class="section-number-2">1.</span> Plan za vajo</h2>
|
||||
<div id="outline-container-orgf596808" class="outline-2">
|
||||
<h2 id="orgf596808"><span class="section-number-2">1.</span> Plan za vajo</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgc256234" class="outline-2">
|
||||
<h2 id="orgc256234"><span class="section-number-2">2.</span> predlogi</h2>
|
||||
<div class="outline-text-2" id="text-2">
|
||||
<div id="outline-container-org32125e6" class="outline-3">
|
||||
<h3 id="org32125e6"><span class="section-number-3">1.1.</span> predlogi</h3>
|
||||
<div class="outline-text-3" id="text-1-1">
|
||||
<ul class="org-ul">
|
||||
<li>tekstualna igra stavkov
|
||||
<ul class="org-ul">
|
||||
|
@ -252,28 +255,24 @@
|
|||
<li>ideja: imeti spletno stran, ki jo na njej sami lahko v zivo urejas (ima vgrajen urejevalnik) in v kolikor testi passajo, se kar sproti deploya</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>
|
||||
'
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org8f4e818" class="outline-2">
|
||||
<h2 id="org8f4e818"><span class="section-number-2">3.</span> tekstualna igra stavkov p</h2>
|
||||
<div class="outline-text-2" id="text-3">
|
||||
</div>
|
||||
<div id="outline-container-orgf2e3d1f" class="outline-3">
|
||||
<h3 id="orgf2e3d1f"><span class="section-number-3">3.1.</span> meta</h3>
|
||||
<div class="outline-text-3" id="text-3-1">
|
||||
<div id="outline-container-org5bf83a0" class="outline-2">
|
||||
<h2 id="org5bf83a0"><span class="section-number-2">2.</span> tekstualna igra stavkov</h2>
|
||||
<div class="outline-text-2" id="text-2">
|
||||
</div>
|
||||
<div id="outline-container-orgc9233ba" class="outline-3">
|
||||
<h3 id="orgc9233ba"><span class="section-number-3">2.1.</span> meta</h3>
|
||||
<div class="outline-text-3" id="text-2-1">
|
||||
<p>
|
||||
Sem pišemo plan za program igranja igre. Poskušamo kratko in jedrnato opisati prvi prototip, ki naj čimprej deluje in je zavoljo enostavnosti karseda podoben igranju v živo. Ob pisanju se poraja veliko idej, za katere je bolje, da se potencialno uvedejo kasneje, sicer se cilj delujočega prototipa sproti prehitro oddaljuje.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org9a5fa8f" class="outline-3">
|
||||
<h3 id="org9a5fa8f"><span class="section-number-3">3.2.</span> homepage</h3>
|
||||
<div class="outline-text-3" id="text-3-2">
|
||||
<div id="outline-container-orgdfca55c" class="outline-3">
|
||||
<h3 id="orgdfca55c"><span class="section-number-3">2.2.</span> homepage</h3>
|
||||
<div class="outline-text-3" id="text-2-2">
|
||||
<p>
|
||||
Na home page imamo kratka navodila in formo nova igra s poljem stevilo igralcev.
|
||||
Submitanje forme te pelje na zgeneriran link, ki ga posljes soigralcem.
|
||||
|
@ -284,9 +283,9 @@ Na tem koraku se generira seja glede na število igralcev.
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org8e4a823" class="outline-3">
|
||||
<h3 id="org8e4a823"><span class="section-number-3">3.3.</span> seja igre</h3>
|
||||
<div class="outline-text-3" id="text-3-3">
|
||||
<div id="outline-container-org9708b52" class="outline-3">
|
||||
<h3 id="org9708b52"><span class="section-number-3">2.3.</span> seja igre</h3>
|
||||
<div class="outline-text-3" id="text-2-3">
|
||||
<p>
|
||||
Meta Podatki
|
||||
</p>
|
||||
|
@ -309,9 +308,9 @@ Ko so vsi oddali odgovore, se ti izpiše stavek, ki ga lahko prebereš ostalim i
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org090645a" class="outline-3">
|
||||
<h3 id="org090645a"><span class="section-number-3">3.4.</span> program</h3>
|
||||
<div class="outline-text-3" id="text-3-4">
|
||||
<div id="outline-container-org91eb17a" class="outline-3">
|
||||
<h3 id="org91eb17a"><span class="section-number-3">2.4.</span> program artanis</h3>
|
||||
<div class="outline-text-3" id="text-2-4">
|
||||
<p>
|
||||
Izbrali smo artanis web framework: <a href="https://artanis.dev/">https://artanis.dev/</a>
|
||||
Namestitev:
|
||||
|
@ -321,9 +320,9 @@ Namestitev:
|
|||
<li>Debian: <code>apt install guix; guix install artanis</code></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="outline-container-orgf180008" class="outline-4">
|
||||
<h4 id="orgf180008"><span class="section-number-4">3.4.1.</span> boilerplate</h4>
|
||||
<div class="outline-text-4" id="text-3-4-1">
|
||||
<div id="outline-container-orgd58717f" class="outline-4">
|
||||
<h4 id="orgd58717f"><span class="section-number-4">2.4.1.</span> boilerplate</h4>
|
||||
<div class="outline-text-4" id="text-2-4-1">
|
||||
<p>
|
||||
Artanis ima orodje za terminal, imenovano <code>art</code>. Z orodje mdr. pripravimo skelet novega projekta: <code>art create igra-stavkov</code>.
|
||||
</p>
|
||||
|
@ -341,7 +340,7 @@ Strežnik se nam odpre na naslovu <a href="http://127.0.0.1:3000">http://127.0.0
|
|||
</p>
|
||||
|
||||
|
||||
<div id="org78f09e6" class="figure">
|
||||
<div id="org403de66" class="figure">
|
||||
<p><img src="./igra-stavkov-1.png" alt="igra-stavkov-1.png" />
|
||||
</p>
|
||||
</div>
|
||||
|
@ -352,9 +351,9 @@ Drugi potem stran vidijo na naslovu <code>http://<ip_naslov>:3000</code>,
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org91c5b7e" class="outline-4">
|
||||
<h4 id="org91c5b7e"><span class="section-number-4">3.4.2.</span> navodila za igro</h4>
|
||||
<div class="outline-text-4" id="text-3-4-2">
|
||||
<div id="outline-container-org0dd442b" class="outline-4">
|
||||
<h4 id="org0dd442b"><span class="section-number-4">2.4.2.</span> navodila za igro</h4>
|
||||
<div class="outline-text-4" id="text-2-4-2">
|
||||
<p>
|
||||
Igro lahko igrata dva ali več igralcev. Igralci skupaj sestavljajo stavke, tako da vnaprej odgovarjajo na vprašanja:
|
||||
</p>
|
||||
|
@ -368,8 +367,8 @@ Igro lahko igrata dva ali več igralcev. Igralci skupaj sestavljajo stavke, tako
|
|||
</ul>
|
||||
</div>
|
||||
<ol class="org-ol">
|
||||
<li><a id="org1c8bee7"></a>v živo<br />
|
||||
<div class="outline-text-5" id="text-3-4-2-1">
|
||||
<li><a id="orga91525e"></a>v živo<br />
|
||||
<div class="outline-text-5" id="text-2-4-2-1">
|
||||
<p>
|
||||
Vsak igralec potrebuje listek in pisalo. Igralci skupaj odgovarjajo na
|
||||
vprašanja, po vsakem odgovoru pa listek prepognejo in podajo naprej. Svoj
|
||||
|
@ -379,8 +378,8 @@ igralcu in preberejo cel stavek.
|
|||
</p>
|
||||
</div>
|
||||
</li>
|
||||
<li><a id="org6f8954c"></a>na naši aplikaciji<br />
|
||||
<div class="outline-text-5" id="text-3-4-2-2">
|
||||
<li><a id="org6b4cd55"></a>na naši aplikaciji<br />
|
||||
<div class="outline-text-5" id="text-2-4-2-2">
|
||||
<p>
|
||||
Na naši aplikaciji je igra zelo podobna. Izberete število igralcev in ustvarite
|
||||
novo sobo za igranje. Povezavo do sobo pošljete soigralcem in po vrsti
|
||||
|
@ -395,7 +394,7 @@ Ustvarimo nov fajl na lokaciji <code>pub/index.html</code>:
|
|||
<div class="org-src-container">
|
||||
<pre class="src src-html"> <<span style="color: #fabd2f;">html</span>>
|
||||
<<span style="color: #fabd2f;">head</span>>
|
||||
<<span style="color: #fabd2f;">meta</span> <span style="color: #83a598;">charset</span>=<span style="color: #b8bb26;">"UTF-8"</span>>
|
||||
<<span style="color: #fabd2f;">meta</span> <span style="color: #83a598;">charset</span>=<span style="color: #b8bb26;">"UTF-8"</span>>
|
||||
<<span style="color: #fabd2f;">meta</span> <span style="color: #83a598;">name</span>=<span style="color: #b8bb26;">"viewport"</span> <span style="color: #83a598;">content</span>=<span style="color: #b8bb26;">"width=device-width, initial-scale=1.0"</span>>
|
||||
<<span style="color: #fabd2f;">title</span>><span style="font-weight: bold; text-decoration: underline;">igra stavkov</span></<span style="color: #fabd2f;">title</span>>
|
||||
</<span style="color: #fabd2f;">head</span>>
|
||||
|
@ -443,7 +442,7 @@ Domača stran se nam zdaj naloži!
|
|||
</p>
|
||||
|
||||
|
||||
<div id="orga999122" class="figure">
|
||||
<div id="org6e01d14" class="figure">
|
||||
<p><img src="igra-stavkov-2.png" alt="igra-stavkov-2.png" />
|
||||
</p>
|
||||
</div>
|
||||
|
@ -451,14 +450,13 @@ Domača stran se nam zdaj naloži!
|
|||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div id="outline-container-orge93e74a" class="outline-4">
|
||||
<h4 id="orge93e74a"><span class="section-number-4">2.4.3.</span> Nova soba</h4>
|
||||
<div class="outline-text-4" id="text-2-4-3">
|
||||
</div>
|
||||
<div id="outline-container-orgd29ba3f" class="outline-3">
|
||||
<h3 id="orgd29ba3f"><span class="section-number-3">3.5.</span> Nova soba</h3>
|
||||
<div class="outline-text-3" id="text-3-5">
|
||||
</div>
|
||||
<div id="outline-container-org5a1319f" class="outline-4">
|
||||
<h4 id="org5a1319f"><span class="section-number-4">3.5.1.</span> (podatkovni) model sobe</h4>
|
||||
<div class="outline-text-4" id="text-3-5-1">
|
||||
<ol class="org-ol">
|
||||
<li><a id="orgcb44d0f"></a>(podatkovni) model sobe<br />
|
||||
<div class="outline-text-5" id="text-2-4-3-1">
|
||||
<p>
|
||||
Zavoljo enostavnosti v <code>conf/artanis.conf</code> omogočimo podporo za sqlite3 bazo (ki je v fajlu in tako nismo odvisno od dodatne programske opreme za shranjevanje stanja):
|
||||
</p>
|
||||
|
@ -494,10 +492,9 @@ Tako se generira skelet podatkovnega modela za sobo v <code>app/models/soba.scm<
|
|||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgc249def" class="outline-4">
|
||||
<h4 id="orgc249def"><span class="section-number-4">3.5.2.</span> krmilnik (controller) sobe</h4>
|
||||
<div class="outline-text-4" id="text-3-5-2">
|
||||
</li>
|
||||
<li><a id="orgba8a8c8"></a>krmilnik (controller) sobe<br />
|
||||
<div class="outline-text-5" id="text-2-4-3-2">
|
||||
<p>
|
||||
Naloga krmilnika je, da ustvari novo sobo in igralko pelje na pravilni link za igranje, shranjuje odgovore in na koncu prikaže stavek.
|
||||
</p>
|
||||
|
@ -514,10 +511,12 @@ To nam ustvari dva nova fajla, <code>app/controllers/soba.scm</code>, s katerim
|
|||
Najprej pa moramo sobo narediti. V <code>ENTRY</code> dodamo pod prej ustvarjeno preusmeritev na index.html POST handler:
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div id="outline-container-org39fdd0b" class="outline-4">
|
||||
<h4 id="org39fdd0b"><span class="section-number-4">3.5.3.</span> Forma za vprasanje</h4>
|
||||
<div class="outline-text-4" id="text-3-5-3">
|
||||
<div id="outline-container-org5b15729" class="outline-4">
|
||||
<h4 id="org5b15729"><span class="section-number-4">2.4.4.</span> Forma za vprasanje</h4>
|
||||
<div class="outline-text-4" id="text-2-4-4">
|
||||
<p>
|
||||
Forma za posamezno vprasanje
|
||||
</p>
|
||||
|
@ -540,9 +539,9 @@ z vprasanjem. Ce ima vse odgovore, prikazemo stavek.
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org610c156" class="outline-4">
|
||||
<h4 id="org610c156"><span class="section-number-4">3.5.4.</span> Podatkovni model</h4>
|
||||
<div class="outline-text-4" id="text-3-5-4">
|
||||
<div id="outline-container-org75060c5" class="outline-4">
|
||||
<h4 id="org75060c5"><span class="section-number-4">2.4.5.</span> Podatkovni model</h4>
|
||||
<div class="outline-text-4" id="text-2-4-5">
|
||||
<p>
|
||||
listek:
|
||||
</p>
|
||||
|
@ -566,9 +565,9 @@ odgovor:
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org94b4a79" class="outline-4">
|
||||
<h4 id="org94b4a79"><span class="section-number-4">3.5.5.</span> sablona za listek</h4>
|
||||
<div class="outline-text-4" id="text-3-5-5">
|
||||
<div id="outline-container-org8eb32c5" class="outline-4">
|
||||
<h4 id="org8eb32c5"><span class="section-number-4">2.4.6.</span> sablona za listek</h4>
|
||||
<div class="outline-text-4" id="text-2-4-6">
|
||||
<p>
|
||||
Ce je listek ze izpolnjen - prikazi cel listek, to je sestavljen stavek.
|
||||
</p>
|
||||
|
@ -580,6 +579,199 @@ Ce listek ni izponjen, prikazi samo zadnje neizpoljneno vprasanje.
|
|||
<p>
|
||||
Submitanje forme ti vrne naslednji listek (ce ga je igralec pred tabo izpolnil).
|
||||
</p>
|
||||
|
||||
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-scheme"><span style="color: #458588;">(</span>list 10 20 30<span style="color: #458588;">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org8abbf21" class="outline-3">
|
||||
<h3 id="org8abbf21"><span class="section-number-3">2.5.</span> program guile web server</h3>
|
||||
<div class="outline-text-3" id="text-2-5">
|
||||
<p>
|
||||
Primer za <a href="https://www.gnu.org/software/guile/manual/html_node/Web-Examples.html">guile web server</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Začnemo z vključitvijo modula za spletni strežnik.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Beremo dva dokumenta iz uradne dokumentacije:
|
||||
<a href="https://www.gnu.org/software/guile/manual/html_node/Web-Server.html">https://www.gnu.org/software/guile/manual/html_node/Web-Server.html</a>
|
||||
<a href="https://www.gnu.org/software/guile/manual/html_node/Web-Examples.html">https://www.gnu.org/software/guile/manual/html_node/Web-Examples.html</a>
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-scheme">#!/usr/bin/env guile !#
|
||||
<span style="color: #458588;">(</span>use-modules <span style="color: #b16286;">(</span>web server<span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">igra-stavkov-handler</span> request request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>values '<span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>content-type . <span style="color: #458588;">(</span>text/plain<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #b8bb26;">"IGRA STAVKOV SE PRIČENJA. OHOHO"</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #7c6f64;">;; </span><span style="color: #7c6f64;">tukajo mramo prebrat index.html in ga iprkazat</span>
|
||||
<span style="color: #7c6f64;">;; </span><span style="color: #7c6f64;">(define index-file (open-input-file "./nova-igra-stavkov/index.html"))</span>
|
||||
<span style="color: #7c6f64;">;; </span><span style="color: #7c6f64;">(let (contents (call-with-input-file "file.txt" get-string-all)))</span>
|
||||
|
||||
<span style="color: #458588;">(</span>run-server igra-stavkov-handler<span style="color: #458588;">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org73a6528" class="outline-4">
|
||||
<h4 id="org73a6528"><span class="section-number-4">2.5.1.</span> navodila</h4>
|
||||
<div class="outline-text-4" id="text-2-5-1">
|
||||
<p>
|
||||
Dodamo html file z navodili:
|
||||
</p>
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-html"> <<span style="color: #fabd2f;">html</span>>
|
||||
<<span style="color: #fabd2f;">head</span>>
|
||||
<<span style="color: #fabd2f;">meta</span> <span style="color: #83a598;">charset</span>=<span style="color: #b8bb26;">"UTF-8"</span>>
|
||||
<<span style="color: #fabd2f;">meta</span> <span style="color: #83a598;">name</span>=<span style="color: #b8bb26;">"viewport"</span> <span style="color: #83a598;">content</span>=<span style="color: #b8bb26;">"width=device-width, initial-scale=1.0"</span>>
|
||||
<<span style="color: #fabd2f;">title</span>><span style="font-weight: bold; text-decoration: underline;">igra stavkov</span></<span style="color: #fabd2f;">title</span>>
|
||||
</<span style="color: #fabd2f;">head</span>>
|
||||
<<span style="color: #fabd2f;">body</span>>
|
||||
<<span style="color: #fabd2f;">h1</span>><span style="font-weight: bold; text-decoration: underline;">igra stavkov</span></<span style="color: #fabd2f;">h1</span>>
|
||||
<<span style="color: #fabd2f;">h2</span>><span style="font-weight: bold; font-style: italic; text-decoration: underline;">v živo</span></<span style="color: #fabd2f;">h2</span>>
|
||||
<<span style="color: #fabd2f;">p</span>>
|
||||
Vsak igralec potrebuje listek in pisalo. Igralci skupaj odgovarjajo na vprašanja, po vsakem odgovoru pa listek prepognejo in podajo naprej. Svoj naslednji odgovor nato napišejo pod prepognjen del in spet podajo listek naprej. Ko odogovorijo na vsa vprašanja, še enkrat podajo listek naprej naslednjemu igralcu in preberejo cel stavek.
|
||||
</<span style="color: #fabd2f;">p</span>>
|
||||
|
||||
<<span style="color: #fabd2f;">h2</span>><span style="font-weight: bold; font-style: italic; text-decoration: underline;">prek spleta (naša varianta)</span></<span style="color: #fabd2f;">h2</span>>
|
||||
<<span style="color: #fabd2f;">p</span>>
|
||||
Vsak igralec potrebuje računalnik z brskalnikom in internetno povezavo. Dobavna veriga obsega rudnike redkih kovin, silicij, proizvodnjo čipov, komunikacijsko mrežo, etcetera.
|
||||
</<span style="color: #fabd2f;">p</span>>
|
||||
|
||||
<<span style="color: #fabd2f;">p</span>>
|
||||
Na naši aplikaciji je igra zelo podobna. Izberete število igralcev in ustvarite novo sobo za igranje. Povezavo do sobo pošljete soigralcem in po vrsti odgovarjate na vprašanja, dokler ne izpolnite vseh. Vsakemu igralcu se na koncu izpiše en sestavljen stavek.
|
||||
</<span style="color: #fabd2f;">p</span>>
|
||||
|
||||
<<span style="color: #fabd2f;">form</span> <span style="color: #83a598;">method</span>=<span style="color: #b8bb26;">"POST"</span> <span style="color: #83a598;">action</span>=<span style="color: #b8bb26;">"/soba/ustvari"</span>>
|
||||
<<span style="color: #fabd2f;">label</span> <span style="color: #83a598;">for</span>=<span style="color: #b8bb26;">"num-of-players"</span>>Izberi število igralcev</<span style="color: #fabd2f;">label</span>>
|
||||
<<span style="color: #fabd2f;">input</span> <span style="color: #83a598;">type</span>=<span style="color: #b8bb26;">"number"</span> <span style="color: #83a598;">min</span>=<span style="color: #b8bb26;">"1"</span> <span style="color: #83a598;">name</span>=<span style="color: #b8bb26;">"num-of-players"</span> <span style="color: #83a598;">id</span>=<span style="color: #b8bb26;">"num-of-players"</span>></<span style="color: #fabd2f;">input</span>>
|
||||
<<span style="color: #fabd2f;">input</span> <span style="color: #83a598;">type</span>=<span style="color: #b8bb26;">"submit"</span> <span style="color: #83a598;">value</span>=<span style="color: #b8bb26;">"igraj"</span>>
|
||||
</<span style="color: #fabd2f;">form</span>>
|
||||
</<span style="color: #fabd2f;">body</span>>
|
||||
</<span style="color: #fabd2f;">html</span>>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Potem prilagodimo handler, da vrne html dokument, ki je zgoraj definiran.
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-scheme">#!/usr/bin/env guile !#
|
||||
<span style="color: #458588;">(</span>use-modules <span style="color: #b16286;">(</span>web server<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>ice-9 binary-ports<span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">igra-stavkov-handler</span> request request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>values '<span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>content-type . <span style="color: #458588;">(</span>text/html<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #8ec07c;">(</span><span style="color: #fb4933;">call-with-input-file</span> <span style="color: #b8bb26;">"index.html"</span> get-bytevector-all<span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #7c6f64;">;; </span><span style="color: #7c6f64;">tukajo mramo prebrat index.html in ga iprkazat</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span>display <span style="color: #b8bb26;">"strežnik igre stavkov teče: http://localhost:8080"</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>run-server igra-stavkov-handler<span style="color: #458588;">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Zdaj moramo pa procesirat obrazec. In sicer preberemo iz <code>request</code> vrednost <code>num-of-players</code>:
|
||||
</p>
|
||||
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-scheme">#!/usr/bin/env guile !#
|
||||
<span style="color: #458588;">(</span>use-modules <span style="color: #b16286;">(</span>web server<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>web request<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>web response<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>web uri<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>ice-9 binary-ports<span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">request-path-components</span> request<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>split-and-decode-uri-path <span style="color: #8ec07c;">(</span>uri-path <span style="color: #d65d0e;">(</span>request-uri request<span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">not-found</span> request<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>values <span style="color: #8ec07c;">(</span>build-response <span style="color: #fe8019;">#:code</span> 404<span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #8ec07c;">(</span>string-append <span style="color: #b8bb26;">"Stran ni najdena: "</span>
|
||||
<span style="color: #d65d0e;">(</span>uri->string <span style="color: #458588;">(</span>request-uri request<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">ustvari-novo-sobo</span> request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>display request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>values '<span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>content-type . <span style="color: #458588;">(</span>text/html<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #8ec07c;">(</span>string-append <span style="color: #b8bb26;">"<h1>Ustvari novo sobo za "</span> st-igralcev <span style="color: #b8bb26;">" igralcev</h1>"</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">igra-stavkov-handler</span> request request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span><span style="color: #fb4933;">let</span> <span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>pot <span style="color: #458588;">(</span>request-path-components request<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #8ec07c;">(</span><span style="color: #fb4933;">cond</span> <span style="color: #d65d0e;">(</span><span style="color: #458588;">(</span>equal? pot '<span style="color: #b16286;">()</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>values '<span style="color: #b16286;">(</span><span style="color: #8ec07c;">(</span>content-type . <span style="color: #d65d0e;">(</span>text/html<span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span><span style="color: #fb4933;">call-with-input-file</span> <span style="color: #b8bb26;">"index.html"</span> get-bytevector-all<span style="color: #b16286;">)</span><span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span>
|
||||
<span style="color: #d65d0e;">(</span><span style="color: #458588;">(</span>equal? pot '<span style="color: #b16286;">(</span><span style="color: #b8bb26;">"soba"</span> <span style="color: #b8bb26;">"ustvari"</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>ustvari-novo-sobo request-body<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span>
|
||||
|
||||
<span style="color: #d65d0e;">(</span><span style="color: #fb4933;">else</span> <span style="color: #458588;">(</span>not-found request<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
<span style="color: #458588;">(</span>display <span style="color: #b8bb26;">"strežnik igre stavkov teče: http://localhost:8080"</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>run-server igra-stavkov-handler<span style="color: #458588;">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-scheme">#!/usr/bin/env guile !#
|
||||
<span style="color: #458588;">(</span>use-modules <span style="color: #b16286;">(</span>web server<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>web request<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>web response<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>web uri<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>ice-9 binary-ports<span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">request-path-components</span> request<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>split-and-decode-uri-path <span style="color: #8ec07c;">(</span>uri-path <span style="color: #d65d0e;">(</span>request-uri request<span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">not-found</span> request<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>values <span style="color: #8ec07c;">(</span>build-response <span style="color: #fe8019;">#:code</span> 404<span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #8ec07c;">(</span>string-append <span style="color: #b8bb26;">"Stran ni najdena: "</span>
|
||||
<span style="color: #d65d0e;">(</span>uri->string <span style="color: #458588;">(</span>request-uri request<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">debug-info</span> request body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>respond
|
||||
`<span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>h1 <span style="color: #b8bb26;">"Debug!"</span><span style="color: #d65d0e;">)</span>
|
||||
<span style="color: #d65d0e;">(</span>table
|
||||
<span style="color: #458588;">(</span>tr <span style="color: #b16286;">(</span>th <span style="color: #b8bb26;">"header"</span><span style="color: #b16286;">)</span> <span style="color: #b16286;">(</span>th <span style="color: #b8bb26;">"value"</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
,@<span style="color: #458588;">(</span><span style="color: #fb4933;">map</span> <span style="color: #b16286;">(</span><span style="color: #fb4933;">lambda</span> <span style="color: #8ec07c;">(</span>pair<span style="color: #8ec07c;">)</span>
|
||||
`<span style="color: #8ec07c;">(</span>tr <span style="color: #d65d0e;">(</span>td <span style="color: #458588;">(</span>tt ,<span style="color: #458588;">(</span>with-output-to-string
|
||||
<span style="color: #b16286;">(</span><span style="color: #fb4933;">lambda</span> <span style="color: #8ec07c;">()</span> <span style="color: #8ec07c;">(</span>display <span style="color: #d65d0e;">(</span>car pair<span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span><span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span>
|
||||
<span style="color: #d65d0e;">(</span>td <span style="color: #458588;">(</span>tt ,<span style="color: #458588;">(</span>with-output-to-string
|
||||
<span style="color: #b16286;">(</span><span style="color: #fb4933;">lambda</span> <span style="color: #8ec07c;">()</span>
|
||||
<span style="color: #8ec07c;">(</span>write <span style="color: #d65d0e;">(</span>cdr pair<span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span><span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>request-headers request<span style="color: #b16286;">)</span><span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">ustvari-novo-sobo</span> request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>display request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span>values '<span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>content-type . <span style="color: #458588;">(</span>text/html<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #b8bb26;">"<h1>Ustvari novo sobo!</h1>"</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
<span style="color: #458588;">(</span><span style="color: #fb4933;">define</span> <span style="color: #b16286;">(</span><span style="color: #fabd2f;">igra-stavkov-handler</span> request request-body<span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span><span style="color: #fb4933;">let</span> <span style="color: #8ec07c;">(</span><span style="color: #d65d0e;">(</span>pot <span style="color: #458588;">(</span>request-path-components request<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span>
|
||||
<span style="color: #8ec07c;">(</span><span style="color: #fb4933;">cond</span> <span style="color: #d65d0e;">(</span><span style="color: #458588;">(</span>equal? pot '<span style="color: #b16286;">()</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>values '<span style="color: #b16286;">(</span><span style="color: #8ec07c;">(</span>content-type . <span style="color: #d65d0e;">(</span>text/html<span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span>
|
||||
<span style="color: #b16286;">(</span><span style="color: #fb4933;">call-with-input-file</span> <span style="color: #b8bb26;">"index.html"</span> get-bytevector-all<span style="color: #b16286;">)</span><span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span>
|
||||
<span style="color: #d65d0e;">(</span><span style="color: #458588;">(</span>equal? pot '<span style="color: #b16286;">(</span><span style="color: #b8bb26;">"soba"</span> <span style="color: #b8bb26;">"ustvari"</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>debug-info request request-body<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span>
|
||||
|
||||
<span style="color: #d65d0e;">(</span><span style="color: #fb4933;">else</span> <span style="color: #458588;">(</span>not-found request<span style="color: #458588;">)</span><span style="color: #d65d0e;">)</span><span style="color: #8ec07c;">)</span><span style="color: #b16286;">)</span><span style="color: #458588;">)</span>
|
||||
|
||||
|
||||
<span style="color: #458588;">(</span>display <span style="color: #b8bb26;">"strežnik igre stavkov teče: http://localhost:8080"</span><span style="color: #458588;">)</span>
|
||||
<span style="color: #458588;">(</span>run-server igra-stavkov-handler<span style="color: #458588;">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
196
vaja/plan.org
196
vaja/plan.org
|
@ -1,7 +1,6 @@
|
|||
* Plan za vajo
|
||||
|
||||
* predlogi
|
||||
|
||||
** predlogi
|
||||
- tekstualna igra stavkov
|
||||
- tista s sestavljanjem povedi je pa iz une igre, mi smo dostkrat igral, neki v smislu, da mora igrat 6+ ljudi in pol vsak napise na vrh lista eno stvar in pol prepogne in list krozi -- po vrsti grejo neki takega: kdo, kdaj, kje, zakaj, s cim, kaj dela ... pol pa ven loh pridejo kr zabavni stavki ... in da je odprto na spletni strani skos naslednje vprasanje, ko se odgovori zadnja stvar (kaj dela), se izpise poved med ze dokoncane, in se zacne nova
|
||||
- igra v [[https://dthompson.us/projects/chickadee.html][chickadee]]-ju
|
||||
|
@ -14,9 +13,7 @@
|
|||
- ideja: imeti spletno stran, ki jo na njej sami lahko v zivo urejas (ima vgrajen urejevalnik) in v kolikor testi passajo, se kar sproti deploya
|
||||
|
||||
|
||||
'
|
||||
|
||||
* tekstualna igra stavkov p
|
||||
* tekstualna igra stavkov
|
||||
** meta
|
||||
Sem pišemo plan za program igranja igre. Poskušamo kratko in jedrnato opisati prvi prototip, ki naj čimprej deluje in je zavoljo enostavnosti karseda podoben igranju v živo. Ob pisanju se poraja veliko idej, za katere je bolje, da se potencialno uvedejo kasneje, sicer se cilj delujočega prototipa sproti prehitro oddaljuje.
|
||||
|
||||
|
@ -39,7 +36,7 @@ Igra "prepozna" obiskovalca nekako unikatno - lahko je session in cookie (kar se
|
|||
Ko oddaš odgovore, te pelje na link za rezlultate, kjer piše, koliko odgovorov igralcov še čakamo.
|
||||
Ko so vsi oddali odgovore, se ti izpiše stavek, ki ga lahko prebereš ostalim igralcem.
|
||||
|
||||
** program
|
||||
** program artanis
|
||||
|
||||
Izbrali smo artanis web framework: https://artanis.dev/
|
||||
Namestitev:
|
||||
|
@ -89,10 +86,10 @@ izpiše en sestavljen stavek.
|
|||
|
||||
Ustvarimo nov fajl na lokaciji ~pub/index.html~:
|
||||
|
||||
#+begin_src html :tangle ./igra-stavkov/pub/index.html
|
||||
#+begin_src html :tangle ./igra-stavkov/pub/index.html
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>igra stavkov</title>
|
||||
</head>
|
||||
|
@ -112,7 +109,7 @@ Ustvarimo nov fajl na lokaciji ~pub/index.html~:
|
|||
<p>
|
||||
Na naši aplikaciji je igra zelo podobna. Izberete število igralcev in ustvarite novo sobo za igranje. Povezavo do sobo pošljete soigralcem in po vrsti odgovarjate na vprašanja, dokler ne izpolnite vseh. Vsakemu igralcu se na koncu izpiše en sestavljen stavek.
|
||||
</p>
|
||||
|
||||
|
||||
<form method="POST" action="/soba/ustvari">
|
||||
<label for="num-of-players">Izberi število igralcev</label>
|
||||
<input type="number" min="1" name="num-of-players" id="num-of-players"></input>
|
||||
|
@ -133,9 +130,9 @@ Domača stran se nam zdaj naloži!
|
|||
|
||||
[[file:igra-stavkov-2.png]]
|
||||
|
||||
** Nova soba
|
||||
*** Nova soba
|
||||
|
||||
*** (podatkovni) model sobe
|
||||
**** (podatkovni) model sobe
|
||||
Zavoljo enostavnosti v ~conf/artanis.conf~ omogočimo podporo za sqlite3 bazo (ki je v fajlu in tako nismo odvisno od dodatne programske opreme za shranjevanje stanja):
|
||||
|
||||
#+begin_src conf
|
||||
|
@ -159,7 +156,7 @@ Tako se generira skelet podatkovnega modela za sobo v ~app/models/soba.scm~, ki
|
|||
(stevilo_igralcev tinyint (#:not-null)))
|
||||
#+end_src
|
||||
|
||||
*** krmilnik (controller) sobe
|
||||
**** krmilnik (controller) sobe
|
||||
Naloga krmilnika je, da ustvari novo sobo in igralko pelje na pravilni link za igranje, shranjuje odgovore in na koncu prikaže stavek.
|
||||
|
||||
Ustvarimo ga z ukazom: ~art draw controller soba listek~
|
||||
|
@ -209,3 +206,178 @@ Ce je listek ze izpolnjen - prikazi cel listek, to je sestavljen stavek.
|
|||
Ce listek ni izponjen, prikazi samo zadnje neizpoljneno vprasanje.
|
||||
|
||||
Submitanje forme ti vrne naslednji listek (ce ga je igralec pred tabo izpolnil).
|
||||
|
||||
|
||||
#+begin_src scheme
|
||||
(list 10 20 30)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
| 10 | 20 | 30 |
|
||||
|
||||
|
||||
** program guile web server
|
||||
|
||||
Primer za [[https://www.gnu.org/software/guile/manual/html_node/Web-Examples.html][guile web server]].
|
||||
|
||||
Začnemo z vključitvijo modula za spletni strežnik.
|
||||
|
||||
Beremo dva dokumenta iz uradne dokumentacije:
|
||||
https://www.gnu.org/software/guile/manual/html_node/Web-Server.html
|
||||
https://www.gnu.org/software/guile/manual/html_node/Web-Examples.html
|
||||
|
||||
#+begin_src scheme :tangle ./nova-igra-stavkov/app.scm
|
||||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(values '((content-type . (text/plain)))
|
||||
"IGRA STAVKOV SE PRIČENJA. OHOHO"))
|
||||
;; tukajo mramo prebrat index.html in ga iprkazat
|
||||
;; (define index-file (open-input-file "./nova-igra-stavkov/index.html"))
|
||||
;; (let (contents (call-with-input-file "file.txt" get-string-all)))
|
||||
|
||||
(run-server igra-stavkov-handler)
|
||||
#+end_src
|
||||
|
||||
*** navodila
|
||||
|
||||
Dodamo html file z navodili:
|
||||
#+begin_src html :tangle ./nova-igra-stavkov/index.html
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>igra stavkov</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>igra stavkov</h1>
|
||||
<h2>v živo</h2>
|
||||
<p>
|
||||
Vsak igralec potrebuje listek in pisalo. Igralci skupaj odgovarjajo na vprašanja, po vsakem odgovoru pa listek prepognejo in podajo naprej. Svoj naslednji odgovor nato napišejo pod prepognjen del in spet podajo listek naprej. Ko odogovorijo na vsa vprašanja, še enkrat podajo listek naprej naslednjemu igralcu in preberejo cel stavek.
|
||||
</p>
|
||||
|
||||
<h2>prek spleta (naša varianta)</h2>
|
||||
<p>
|
||||
Vsak igralec potrebuje računalnik z brskalnikom in internetno povezavo. Dobavna veriga obsega rudnike redkih kovin, silicij, proizvodnjo čipov, komunikacijsko mrežo, etcetera.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Na naši aplikaciji je igra zelo podobna. Izberete število igralcev in ustvarite novo sobo za igranje. Povezavo do sobo pošljete soigralcem in po vrsti odgovarjate na vprašanja, dokler ne izpolnite vseh. Vsakemu igralcu se na koncu izpiše en sestavljen stavek.
|
||||
</p>
|
||||
|
||||
<form method="POST" action="/soba/ustvari">
|
||||
<label for="num-of-players">Izberi število igralcev</label>
|
||||
<input type="number" min="1" name="num-of-players" id="num-of-players"></input>
|
||||
<input type="submit" value="igraj">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
#+end_src
|
||||
|
||||
Potem prilagodimo handler, da vrne html dokument, ki je zgoraj definiran.
|
||||
|
||||
#+begin_src scheme :tangle ./nova-igra-stavkov/app2.scm
|
||||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server)
|
||||
(ice-9 binary-ports))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(values '((content-type . (text/html)))
|
||||
(call-with-input-file "index.html" get-bytevector-all)))
|
||||
;; tukajo mramo prebrat index.html in ga iprkazat
|
||||
|
||||
|
||||
(display "strežnik igre stavkov teče: http://localhost:8080")
|
||||
(run-server igra-stavkov-handler)
|
||||
#+end_src
|
||||
|
||||
Zdaj moramo pa procesirat obrazec. In sicer preberemo iz ~request~ vrednost ~num-of-players~:
|
||||
|
||||
#+begin_src scheme :tangle ./nova-igra-stavkov/app3.scm
|
||||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server)
|
||||
(web request)
|
||||
(web response)
|
||||
(web uri)
|
||||
(ice-9 binary-ports))
|
||||
|
||||
|
||||
(define (request-path-components request)
|
||||
(split-and-decode-uri-path (uri-path (request-uri request))))
|
||||
|
||||
|
||||
(define (not-found request)
|
||||
(values (build-response #:code 404)
|
||||
(string-append "Stran ni najdena: "
|
||||
(uri->string (request-uri request)))))
|
||||
|
||||
(define (ustvari-novo-sobo request-body)
|
||||
(display request-body)
|
||||
(values '((content-type . (text/html)))
|
||||
(string-append "<h1>Ustvari novo sobo za " st-igralcev " igralcev</h1>")))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(let ((pot (request-path-components request)))
|
||||
(cond ((equal? pot '())
|
||||
(values '((content-type . (text/html)))
|
||||
(call-with-input-file "index.html" get-bytevector-all)))
|
||||
((equal? pot '("soba" "ustvari"))
|
||||
(ustvari-novo-sobo request-body))
|
||||
|
||||
(else (not-found request)))))
|
||||
|
||||
(display "strežnik igre stavkov teče: http://localhost:8080")
|
||||
(run-server igra-stavkov-handler)
|
||||
#+end_src
|
||||
|
||||
#+begin_src scheme :tangle ./nova-igra-stavkov/app4.scm
|
||||
#!/usr/bin/env guile !#
|
||||
(use-modules (web server)
|
||||
(web request)
|
||||
(web response)
|
||||
(web uri)
|
||||
(ice-9 binary-ports))
|
||||
|
||||
|
||||
(define (request-path-components request)
|
||||
(split-and-decode-uri-path (uri-path (request-uri request))))
|
||||
|
||||
|
||||
(define (not-found request)
|
||||
(values (build-response #:code 404)
|
||||
(string-append "Stran ni najdena: "
|
||||
(uri->string (request-uri request)))))
|
||||
(define (debug-info request body)
|
||||
(respond
|
||||
`((h1 "Debug!")
|
||||
(table
|
||||
(tr (th "header") (th "value"))
|
||||
,@(map (lambda (pair)
|
||||
`(tr (td (tt ,(with-output-to-string
|
||||
(lambda () (display (car pair))))))
|
||||
(td (tt ,(with-output-to-string
|
||||
(lambda ()
|
||||
(write (cdr pair))))))))
|
||||
(request-headers request))))))
|
||||
|
||||
|
||||
(define (ustvari-novo-sobo request-body)
|
||||
(display request-body)
|
||||
(values '((content-type . (text/html)))
|
||||
"<h1>Ustvari novo sobo!</h1>"))
|
||||
|
||||
(define (igra-stavkov-handler request request-body)
|
||||
(let ((pot (request-path-components request)))
|
||||
(cond ((equal? pot '())
|
||||
(values '((content-type . (text/html)))
|
||||
(call-with-input-file "index.html" get-bytevector-all)))
|
||||
((equal? pot '("soba" "ustvari"))
|
||||
(debug-info request request-body))
|
||||
|
||||
(else (not-found request)))))
|
||||
|
||||
|
||||
(display "strežnik igre stavkov teče: http://localhost:8080")
|
||||
(run-server igra-stavkov-handler)
|
||||
#+end_src
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2024-12-26 čet 19:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>‎</title>
|
||||
<meta name="author" content="Yuri" />
|
||||
<meta name="generator" content="Org Mode" />
|
||||
<style type="text/css">
|
||||
#content { max-width: 60em; margin: auto; }
|
||||
.title { text-align: center;
|
||||
margin-bottom: .2em; }
|
||||
.subtitle { text-align: center;
|
||||
font-size: medium;
|
||||
font-weight: bold;
|
||||
margin-top:0; }
|
||||
.todo { font-family: monospace; color: red; }
|
||||
.done { font-family: monospace; color: green; }
|
||||
.priority { font-family: monospace; color: orange; }
|
||||
.tag { background-color: #eee; font-family: monospace;
|
||||
padding: 2px; font-size: 80%; font-weight: normal; }
|
||||
.timestamp { color: #bebebe; }
|
||||
.timestamp-kwd { color: #5f9ea0; }
|
||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
|
||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
|
||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
|
||||
.underline { text-decoration: underline; }
|
||||
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
|
||||
p.verse { margin-left: 3%; }
|
||||
pre {
|
||||
border: 1px solid #e6e6e6;
|
||||
border-radius: 3px;
|
||||
background-color: #f2f2f2;
|
||||
padding: 8pt;
|
||||
font-family: monospace;
|
||||
overflow: auto;
|
||||
margin: 1.2em;
|
||||
}
|
||||
pre.src {
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
}
|
||||
pre.src:before {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: 12px;
|
||||
padding: 3px;
|
||||
color: #555;
|
||||
background-color: #f2f2f299;
|
||||
}
|
||||
pre.src:hover:before { display: inline; margin-top: 14px;}
|
||||
/* Languages per Org manual */
|
||||
pre.src-asymptote:before { content: 'Asymptote'; }
|
||||
pre.src-awk:before { content: 'Awk'; }
|
||||
pre.src-authinfo::before { content: 'Authinfo'; }
|
||||
pre.src-C:before { content: 'C'; }
|
||||
/* pre.src-C++ doesn't work in CSS */
|
||||
pre.src-clojure:before { content: 'Clojure'; }
|
||||
pre.src-css:before { content: 'CSS'; }
|
||||
pre.src-D:before { content: 'D'; }
|
||||
pre.src-ditaa:before { content: 'ditaa'; }
|
||||
pre.src-dot:before { content: 'Graphviz'; }
|
||||
pre.src-calc:before { content: 'Emacs Calc'; }
|
||||
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
|
||||
pre.src-fortran:before { content: 'Fortran'; }
|
||||
pre.src-gnuplot:before { content: 'gnuplot'; }
|
||||
pre.src-haskell:before { content: 'Haskell'; }
|
||||
pre.src-hledger:before { content: 'hledger'; }
|
||||
pre.src-java:before { content: 'Java'; }
|
||||
pre.src-js:before { content: 'Javascript'; }
|
||||
pre.src-latex:before { content: 'LaTeX'; }
|
||||
pre.src-ledger:before { content: 'Ledger'; }
|
||||
pre.src-lisp:before { content: 'Lisp'; }
|
||||
pre.src-lilypond:before { content: 'Lilypond'; }
|
||||
pre.src-lua:before { content: 'Lua'; }
|
||||
pre.src-matlab:before { content: 'MATLAB'; }
|
||||
pre.src-mscgen:before { content: 'Mscgen'; }
|
||||
pre.src-ocaml:before { content: 'Objective Caml'; }
|
||||
pre.src-octave:before { content: 'Octave'; }
|
||||
pre.src-org:before { content: 'Org mode'; }
|
||||
pre.src-oz:before { content: 'OZ'; }
|
||||
pre.src-plantuml:before { content: 'Plantuml'; }
|
||||
pre.src-processing:before { content: 'Processing.js'; }
|
||||
pre.src-python:before { content: 'Python'; }
|
||||
pre.src-R:before { content: 'R'; }
|
||||
pre.src-ruby:before { content: 'Ruby'; }
|
||||
pre.src-sass:before { content: 'Sass'; }
|
||||
pre.src-scheme:before { content: 'Scheme'; }
|
||||
pre.src-screen:before { content: 'Gnu Screen'; }
|
||||
pre.src-sed:before { content: 'Sed'; }
|
||||
pre.src-sh:before { content: 'shell'; }
|
||||
pre.src-sql:before { content: 'SQL'; }
|
||||
pre.src-sqlite:before { content: 'SQLite'; }
|
||||
/* additional languages in org.el's org-babel-load-languages alist */
|
||||
pre.src-forth:before { content: 'Forth'; }
|
||||
pre.src-io:before { content: 'IO'; }
|
||||
pre.src-J:before { content: 'J'; }
|
||||
pre.src-makefile:before { content: 'Makefile'; }
|
||||
pre.src-maxima:before { content: 'Maxima'; }
|
||||
pre.src-perl:before { content: 'Perl'; }
|
||||
pre.src-picolisp:before { content: 'Pico Lisp'; }
|
||||
pre.src-scala:before { content: 'Scala'; }
|
||||
pre.src-shell:before { content: 'Shell Script'; }
|
||||
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
|
||||
/* additional language identifiers per "defun org-babel-execute"
|
||||
in ob-*.el */
|
||||
pre.src-cpp:before { content: 'C++'; }
|
||||
pre.src-abc:before { content: 'ABC'; }
|
||||
pre.src-coq:before { content: 'Coq'; }
|
||||
pre.src-groovy:before { content: 'Groovy'; }
|
||||
/* additional language identifiers from org-babel-shell-names in
|
||||
ob-shell.el: ob-shell is the only babel language using a lambda to put
|
||||
the execution function name together. */
|
||||
pre.src-bash:before { content: 'bash'; }
|
||||
pre.src-csh:before { content: 'csh'; }
|
||||
pre.src-ash:before { content: 'ash'; }
|
||||
pre.src-dash:before { content: 'dash'; }
|
||||
pre.src-ksh:before { content: 'ksh'; }
|
||||
pre.src-mksh:before { content: 'mksh'; }
|
||||
pre.src-posh:before { content: 'posh'; }
|
||||
/* Additional Emacs modes also supported by the LaTeX listings package */
|
||||
pre.src-ada:before { content: 'Ada'; }
|
||||
pre.src-asm:before { content: 'Assembler'; }
|
||||
pre.src-caml:before { content: 'Caml'; }
|
||||
pre.src-delphi:before { content: 'Delphi'; }
|
||||
pre.src-html:before { content: 'HTML'; }
|
||||
pre.src-idl:before { content: 'IDL'; }
|
||||
pre.src-mercury:before { content: 'Mercury'; }
|
||||
pre.src-metapost:before { content: 'MetaPost'; }
|
||||
pre.src-modula-2:before { content: 'Modula-2'; }
|
||||
pre.src-pascal:before { content: 'Pascal'; }
|
||||
pre.src-ps:before { content: 'PostScript'; }
|
||||
pre.src-prolog:before { content: 'Prolog'; }
|
||||
pre.src-simula:before { content: 'Simula'; }
|
||||
pre.src-tcl:before { content: 'tcl'; }
|
||||
pre.src-tex:before { content: 'TeX'; }
|
||||
pre.src-plain-tex:before { content: 'Plain TeX'; }
|
||||
pre.src-verilog:before { content: 'Verilog'; }
|
||||
pre.src-vhdl:before { content: 'VHDL'; }
|
||||
pre.src-xml:before { content: 'XML'; }
|
||||
pre.src-nxml:before { content: 'XML'; }
|
||||
/* add a generic configuration mode; LaTeX export needs an additional
|
||||
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
|
||||
pre.src-conf:before { content: 'Configuration File'; }
|
||||
|
||||
table { border-collapse:collapse; }
|
||||
caption.t-above { caption-side: top; }
|
||||
caption.t-bottom { caption-side: bottom; }
|
||||
td, th { vertical-align:top; }
|
||||
th.org-right { text-align: center; }
|
||||
th.org-left { text-align: center; }
|
||||
th.org-center { text-align: center; }
|
||||
td.org-right { text-align: right; }
|
||||
td.org-left { text-align: left; }
|
||||
td.org-center { text-align: center; }
|
||||
dt { font-weight: bold; }
|
||||
.footpara { display: inline; }
|
||||
.footdef { margin-bottom: 1em; }
|
||||
.figure { padding: 1em; }
|
||||
.figure p { text-align: center; }
|
||||
.equation-container {
|
||||
display: table;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.equation {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.equation-label {
|
||||
display: table-cell;
|
||||
text-align: right;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.inlinetask {
|
||||
padding: 10px;
|
||||
border: 2px solid gray;
|
||||
margin: 10px;
|
||||
background: #ffffcc;
|
||||
}
|
||||
#org-div-home-and-up
|
||||
{ text-align: right; font-size: 70%; white-space: nowrap; }
|
||||
textarea { overflow-x: auto; }
|
||||
.linenr { font-size: smaller }
|
||||
.code-highlighted { background-color: #ffff00; }
|
||||
.org-info-js_info-navigation { border-style: none; }
|
||||
#org-info-js_console-label
|
||||
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
|
||||
.org-info-js_search-highlight
|
||||
{ background-color: #ffff00; color: #000000; font-weight: bold; }
|
||||
.org-svg { }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content" class="content">
|
||||
<div id="table-of-contents" role="doc-toc">
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#org7d6553c">1. Komande</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org7d6553c" class="outline-2">
|
||||
<h2 id="org7d6553c"><span class="section-number-2">1.</span> Komande</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
<p>
|
||||
crdt-connect: povezi se na sejo za kolaborativno urejanje
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>Alt-x</code>: za izvajanje funkcij
|
||||
<code>ctrl-x</code>: ukaz, ki mu sledijo podukazi
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<code>C-x 1</code>: maximize current window
|
||||
<code>C-x 0</code>: close current window
|
||||
<code>C-SCP</code> (ctrl-space): zacne delat region (ko je regijoa znacena, lahko pritiesns oklepaj, ali pa marsikaj dreugga in ti bo regijo vstalvio v)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Yuri</p>
|
||||
<p class="date">Created: 2024-12-26 čet 19:56</p>
|
||||
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,42 @@
|
|||
* Komande
|
||||
|
||||
crdt-connect: povezi se na sejo za kolaborativno urejanje
|
||||
|
||||
~Alt-x~: za izvajanje funkcij
|
||||
~ctrl-x~: ukaz, ki mu sledijo podukazi
|
||||
|
||||
~C-x 1~: maximize current window ~C-x 0~: close current window ~C-SCP~
|
||||
(ctrl-space): zacne delat region (ko je regijoa znacena, lahko pritiesns
|
||||
oklepaj, ali pa marsikaj dreugga in ti bo regijo vstalvio v te znake)
|
||||
|
||||
~C-x C-c~ zapri emsac
|
||||
~C-x C-f~ odpri dokument
|
||||
|
||||
~C-c C-l~ vstavljanje linka (v orgmode)
|
||||
|
||||
~C-x C-s~ shrani trenuitn fajl
|
||||
|
||||
* orgmode
|
||||
|
||||
~*~ naslov
|
||||
~**~ podnaslov
|
||||
~***~ pod podnaslov
|
||||
...
|
||||
|
||||
*L* inkanje fajlov
|
||||
|
||||
~C-c C-l~ naredi lk (lahko url, lahko faj.l .. )in.
|
||||
|
||||
~C-c C-o~ odpri li.nk
|
||||
|
||||
[[file:plan.org::*(podatkovni) model sobe][Link do fajla plan.org]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue