Skip to content

Commit

Permalink
Deploying to gh-pages from @ 8a3102f 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
sake92 committed Feb 1, 2024
1 parent 9ef6c1c commit a61456c
Show file tree
Hide file tree
Showing 13 changed files with 443 additions and 320 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<li><a href="tutorials/validation.html">Validation</a></li>
<li><a href="tutorials/sql-db.html">SQL DB</a></li>
<li><a href="tutorials/tests.html">Tests</a></li>
<li><a href="tutorials/htmx.html">HTMX</a></li>
</ul>
</li>
<li>
Expand Down
86 changes: 44 additions & 42 deletions tutorials/handling-forms.html

Large diffs are not rendered by default.

55 changes: 28 additions & 27 deletions tutorials/hello-world.html

Large diffs are not rendered by default.

77 changes: 42 additions & 35 deletions tutorials/html.html

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions tutorials/htmx.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tutorials/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
padding-left: 3em;
font-size: .8em;
}
</style></head><body><div class="hidden-print"><nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top"><div class="container-fluid"><a class="navbar-brand" href="../index.html"><span><img src="../images/favicon.svg" alt="logo" width="32" height="32" /></span> Sharaf</a><button type="button" class="navbar-toggler collapsed" data-bs-toggle="collapse" data-bs-target="#main-navbar"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="main-navbar"><ul class="navbar-nav"></ul><ul class="navbar-nav ms-auto"><li class="nav-item"><a href="index.html" class="active nav-link">Tutorials</a></li><li class="nav-item"><a href="../howtos/index.html" class="nav-link">How-Tos</a></li><li class="nav-item"><a href="../reference/index.html" class="nav-link">Reference</a></li><li class="nav-item"><a href="../philosophy/index.html" class="nav-link">Philosophy</a></li></ul></div></div></nav></div><div class="container-fluid"><div class="row"><div class="col-md-3 d-flex justify-content-end hidden-print"><nav class="affix"><ul class="nav nav-pills flex-column"><li><a href="index.html" class="nav-link active">Tutorials</a></li><li><a href="hello-world.html" class="nav-link ">Hello World</a></li><li><a href="path-params.html" class="nav-link ">Path Params</a></li><li><a href="query-params.html" class="nav-link ">Query Params</a></li><li><a href="static-files.html" class="nav-link ">Static Files</a></li><li><a href="html.html" class="nav-link ">HTML</a></li><li><a href="handling-forms.html" class="nav-link ">Handling Forms</a></li><li><a href="json-api.html" class="nav-link ">JSON API</a></li><li><a href="validation.html" class="nav-link ">Validation</a></li><li><a href="sql-db.html" class="nav-link ">SQL DB</a></li><li><a href="tests.html" class="nav-link ">Tests</a></li></ul></nav></div><div data-bs-spy="scroll" data-bs-target="#tocScrollspy" class="col-md-6"><div class="hidden-print"></div><nav><ul class="pagination justify-content-center"><li class="disabled page-item"><a href="#" class="page-link">Previous</a></li><li title="Hello World" class="page-item"><a href="hello-world.html" class="page-link">Next</a></li></ul></nav><div><section id="quickstart"><h2>Quickstart</h2><p>Get started quickly with Sharaf framework.</p>
</style></head><body><div class="hidden-print"><nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top"><div class="container-fluid"><a class="navbar-brand" href="../index.html"><span><img src="../images/favicon.svg" alt="logo" width="32" height="32" /></span> Sharaf</a><button type="button" class="navbar-toggler collapsed" data-bs-toggle="collapse" data-bs-target="#main-navbar"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="main-navbar"><ul class="navbar-nav"></ul><ul class="navbar-nav ms-auto"><li class="nav-item"><a href="index.html" class="active nav-link">Tutorials</a></li><li class="nav-item"><a href="../howtos/index.html" class="nav-link">How-Tos</a></li><li class="nav-item"><a href="../reference/index.html" class="nav-link">Reference</a></li><li class="nav-item"><a href="../philosophy/index.html" class="nav-link">Philosophy</a></li></ul></div></div></nav></div><div class="container-fluid"><div class="row"><div class="col-md-3 d-flex justify-content-end hidden-print"><nav class="affix"><ul class="nav nav-pills flex-column"><li><a href="index.html" class="nav-link active">Tutorials</a></li><li><a href="hello-world.html" class="nav-link ">Hello World</a></li><li><a href="path-params.html" class="nav-link ">Path Params</a></li><li><a href="query-params.html" class="nav-link ">Query Params</a></li><li><a href="static-files.html" class="nav-link ">Static Files</a></li><li><a href="html.html" class="nav-link ">HTML</a></li><li><a href="handling-forms.html" class="nav-link ">Handling Forms</a></li><li><a href="json-api.html" class="nav-link ">JSON API</a></li><li><a href="validation.html" class="nav-link ">Validation</a></li><li><a href="sql-db.html" class="nav-link ">SQL DB</a></li><li><a href="tests.html" class="nav-link ">Tests</a></li><li><a href="htmx.html" class="nav-link ">HTMX</a></li></ul></nav></div><div data-bs-spy="scroll" data-bs-target="#tocScrollspy" class="col-md-6"><div class="hidden-print"></div><nav><ul class="pagination justify-content-center"><li class="disabled page-item"><a href="#" class="page-link">Previous</a></li><li title="Hello World" class="page-item"><a href="hello-world.html" class="page-link">Next</a></li></ul></nav><div><section id="quickstart"><h2>Quickstart</h2><p>Get started quickly with Sharaf framework.</p>
<section id="mill"><h3>Mill</h3><pre><code class="language-scala">def ivyDeps = super.ivyDeps() ++ Agg(
ivy&quot;ba.sake::sharaf:0.0.18&quot;
ivy&quot;ba.sake::sharaf:0.0.21&quot;
)
def scalacOptions = super.scalacOptions() ++ Seq(&quot;-Yretain-trees&quot;)
</code></pre>
Expand All @@ -43,11 +43,11 @@
<li><a href="https://github.com/sake92/sharaf-fullstack.g8">fullstack</a></li>
</ul>
</section><section id="sbt"><h3>Sbt</h3><pre><code class="language-scala">libraryDependencies ++= Seq(
&quot;ba.sake&quot; %% &quot;sharaf&quot; % &quot;0.0.18&quot;
&quot;ba.sake&quot; %% &quot;sharaf&quot; % &quot;0.0.21&quot;
),
scalacOptions ++= Seq(&quot;-Yretain-trees&quot;)
</code></pre>
</section><section id="scala-cli"><h3>Scala CLI</h3><pre><code class="language-scala">//&gt; using dep ba.sake::sharaf:0.0.18
</section><section id="scala-cli"><h3>Scala CLI</h3><pre><code class="language-scala">//&gt; using dep ba.sake::sharaf:0.0.21
scala-cli my_script.sc --scala-option -Yretain-trees
</code></pre>
</section><section id="examples"><h3>Examples</h3><ul>
Expand Down
14 changes: 8 additions & 6 deletions tutorials/json-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
padding-left: 3em;
font-size: .8em;
}
</style></head><body><div class="hidden-print"><nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top"><div class="container-fluid"><a class="navbar-brand" href="../index.html"><span><img src="../images/favicon.svg" alt="logo" width="32" height="32" /></span> Sharaf</a><button type="button" class="navbar-toggler collapsed" data-bs-toggle="collapse" data-bs-target="#main-navbar"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="main-navbar"><ul class="navbar-nav"></ul><ul class="navbar-nav ms-auto"><li class="nav-item"><a href="index.html" class="active nav-link">Tutorials</a></li><li class="nav-item"><a href="../howtos/index.html" class="nav-link">How-Tos</a></li><li class="nav-item"><a href="../reference/index.html" class="nav-link">Reference</a></li><li class="nav-item"><a href="../philosophy/index.html" class="nav-link">Philosophy</a></li></ul></div></div></nav></div><div class="container-fluid"><div class="row"><div class="col-md-3 d-flex justify-content-end hidden-print"><nav class="affix"><ul class="nav nav-pills flex-column"><li><a href="index.html" class="nav-link ">Tutorials</a></li><li><a href="hello-world.html" class="nav-link ">Hello World</a></li><li><a href="path-params.html" class="nav-link ">Path Params</a></li><li><a href="query-params.html" class="nav-link ">Query Params</a></li><li><a href="static-files.html" class="nav-link ">Static Files</a></li><li><a href="html.html" class="nav-link ">HTML</a></li><li><a href="handling-forms.html" class="nav-link ">Handling Forms</a></li><li><a href="json-api.html" class="nav-link active">JSON API</a></li><li><a href="validation.html" class="nav-link ">Validation</a></li><li><a href="sql-db.html" class="nav-link ">SQL DB</a></li><li><a href="tests.html" class="nav-link ">Tests</a></li></ul></nav></div><div data-bs-spy="scroll" data-bs-target="#tocScrollspy" class="col-md-6"><div class="hidden-print"></div><nav><ul class="pagination justify-content-center"><li title="Handling Forms" class="page-item"><a href="handling-forms.html" class="page-link">Previous</a></li><li title="Validation" class="page-item"><a href="validation.html" class="page-link">Next</a></li></ul></nav><div><section id="model-definition"><h2>Model definition</h2><p>Let's make a simple JSON API in scala-cli.<br />
</style></head><body><div class="hidden-print"><nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top"><div class="container-fluid"><a class="navbar-brand" href="../index.html"><span><img src="../images/favicon.svg" alt="logo" width="32" height="32" /></span> Sharaf</a><button type="button" class="navbar-toggler collapsed" data-bs-toggle="collapse" data-bs-target="#main-navbar"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="main-navbar"><ul class="navbar-nav"></ul><ul class="navbar-nav ms-auto"><li class="nav-item"><a href="index.html" class="active nav-link">Tutorials</a></li><li class="nav-item"><a href="../howtos/index.html" class="nav-link">How-Tos</a></li><li class="nav-item"><a href="../reference/index.html" class="nav-link">Reference</a></li><li class="nav-item"><a href="../philosophy/index.html" class="nav-link">Philosophy</a></li></ul></div></div></nav></div><div class="container-fluid"><div class="row"><div class="col-md-3 d-flex justify-content-end hidden-print"><nav class="affix"><ul class="nav nav-pills flex-column"><li><a href="index.html" class="nav-link ">Tutorials</a></li><li><a href="hello-world.html" class="nav-link ">Hello World</a></li><li><a href="path-params.html" class="nav-link ">Path Params</a></li><li><a href="query-params.html" class="nav-link ">Query Params</a></li><li><a href="static-files.html" class="nav-link ">Static Files</a></li><li><a href="html.html" class="nav-link ">HTML</a></li><li><a href="handling-forms.html" class="nav-link ">Handling Forms</a></li><li><a href="json-api.html" class="nav-link active">JSON API</a></li><li><a href="validation.html" class="nav-link ">Validation</a></li><li><a href="sql-db.html" class="nav-link ">SQL DB</a></li><li><a href="tests.html" class="nav-link ">Tests</a></li><li><a href="htmx.html" class="nav-link ">HTMX</a></li></ul></nav></div><div data-bs-spy="scroll" data-bs-target="#tocScrollspy" class="col-md-6"><div class="hidden-print"></div><nav><ul class="pagination justify-content-center"><li title="Handling Forms" class="page-item"><a href="handling-forms.html" class="page-link">Previous</a></li><li title="Validation" class="page-item"><a href="validation.html" class="page-link">Next</a></li></ul></nav><div><section id="model-definition"><h2>Model definition</h2><p>Let's make a simple JSON API in scala-cli.<br />
Create a file <code>json_api.sc</code> and paste this code into it:</p>
<pre><code class="language-scala">//&gt; using scala &quot;3.3.1&quot;
//&gt; using dep ba.sake::sharaf:0.0.18
<pre><code class="language-scala"> //&gt; using scala &quot;3.3.1&quot;
//&gt; using dep ba.sake::sharaf:0.0.21

import io.undertow.Undertow
import ba.sake.tupson.JsonRW
Expand All @@ -44,12 +44,14 @@
case class Car(brand: String, model: String, quantity: Int) derives JsonRW

var db: Seq[Car] = Seq()


</code></pre>
<p>Here we defined a <code>Car</code> model, which <code>derives JsonRW</code>, so we can use the JSON support from Sharaf.</p>
<p>We also use a <code>var db: Seq[Car]</code> to store our data.<br />
(don't do this for real projects)</p>
</section><section id="routes-definition"><h2>Routes definition</h2><p>Next step is to define a few routes for getting and adding cars:</p>
<pre><code class="language-scala">val routes = Routes:
<pre><code class="language-scala">val routes = Routes:
case GET() -&gt; Path(&quot;cars&quot;) =&gt;
Response.withBody(db)

Expand All @@ -67,8 +69,7 @@
<p>The third route binds the JSON body from the HTTP request.<br />
Then we add it to the database.</p>
</section><section id="running-the-server"><h2>Running the server</h2><p>Finally, start up the server:</p>
<pre><code class="language-scala">Undertow
.builder
<pre><code class="language-scala"> Undertow.builder
.addHttpListener(8181, &quot;localhost&quot;)
.setHandler(
SharafHandler(routes).withErrorMapper(ErrorMapper.json)
Expand All @@ -77,6 +78,7 @@
.start()

println(s&quot;Server started at http://localhost:8181&quot;)

</code></pre>
<p>and run it like this:</p>
<pre><code class="language-sh">scala-cli json_api.sc
Expand Down
57 changes: 30 additions & 27 deletions tutorials/path-params.html

Large diffs are not rendered by default.

Loading

0 comments on commit a61456c

Please sign in to comment.