Skip to content

Commit

Permalink
Update mdBook tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Lilic committed Jul 7, 2021
1 parent b4f719e commit f926551
Show file tree
Hide file tree
Showing 11 changed files with 821 additions and 13 deletions.
2 changes: 1 addition & 1 deletion book/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="intro.html"><strong aria-hidden="true">1.</strong> Introduction</a></li></ol>
<ol class="chapter"><li class="chapter-item expanded affix "><a href="index.html">Introduction</a></li><li class="chapter-item expanded "><a href="tutorials.html"><strong aria-hidden="true">1.</strong> Tutorials</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="tutorials/mdbook.html"><strong aria-hidden="true">1.1.</strong> Deploy an MdBook</a></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
Expand Down
8 changes: 7 additions & 1 deletion book/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="intro.html"><strong aria-hidden="true">1.</strong> Introduction</a></li></ol>
<ol class="chapter"><li class="chapter-item expanded affix "><a href="index.html" class="active">Introduction</a></li><li class="chapter-item expanded "><a href="tutorials.html"><strong aria-hidden="true">1.</strong> Tutorials</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="tutorials/mdbook.html"><strong aria-hidden="true">1.1.</strong> Deploy an MdBook</a></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
Expand Down Expand Up @@ -147,12 +147,18 @@ <h1 id="internet-computer-developer-documentation"><a class="header" href="#inte

<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="next" href="tutorials.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>

<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="next" href="tutorials.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>

</div>
Expand Down
197 changes: 196 additions & 1 deletion book/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="intro.html"><strong aria-hidden="true">1.</strong> Introduction</a></li></ol>
<ol class="chapter"><li class="chapter-item expanded affix "><a href="index.html">Introduction</a></li><li class="chapter-item expanded "><a href="tutorials.html"><strong aria-hidden="true">1.</strong> Tutorials</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="tutorials/mdbook.html"><strong aria-hidden="true">1.1.</strong> Deploy an MdBook</a></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
Expand Down Expand Up @@ -143,6 +143,201 @@ <h1 id="internet-computer-developer-documentation"><a class="header" href="#inte
<p>The main Dfinity Foundation developer documentation can be found at the <a href="https://sdk.dfinity.org/">DFINITY SDK</a> and it is encouraged that all developers review the Official documentation for getting started on the Internet Computer.</p>
<p>This documentation is designed to be a self-service documentation tool for the Internet Computer developer community. This repository is open sourced and any developer can submit a pull request to have the documentation updated.</p>
<p>Stay tuned for more updates!</p>
<div style="break-before: page; page-break-before: always;"></div><p>This section will serve as a hands-on guide for how to do specific tasks on the Internet Computer.</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="installing-an-mdbook-on-the-internet-computer"><a class="header" href="#installing-an-mdbook-on-the-internet-computer">Installing an mdbook on the Internet Computer</a></h1>
<p><a href="https://github.com/rust-lang/mdBook">mdBook</a> is a utility to create modern online books from Markdown files.</p>
<p>This website is a mdBook website! It uses Markdown to generate the content and lives on the Internet Computer.</p>
<p>In this tutorial we will show you how to:</p>
<ol>
<li>Install mdBook locally</li>
<li>Deploy your first mdBook onto a local replica</li>
<li>Deploy your first mdBook to the production Internet Computer network</li>
</ol>
<h2 id="install-mdbook-locally"><a class="header" href="#install-mdbook-locally">Install mdBook Locally</a></h2>
<p>If you have your Rust and Cargo development environment already set up, installing <code>mdBook</code> is as easy as using Cargo:</p>
<pre><code>cargo install mdbook
</code></pre>
<h2 id="deploy-your-first-mdbook-onto-a-local-replica"><a class="header" href="#deploy-your-first-mdbook-onto-a-local-replica">Deploy your first mdBook onto a local replica</a></h2>
<p>First, create a new <code>dfx</code> project <code>mymdbook</code></p>
<pre><code>dfx new mymdbook
</code></pre>
<p><code>dfx</code> will then auto-generate the requisite files for your new dfx project:</p>
<pre><code>% dfx new mymdbook
Fetching manifest https://sdk.dfinity.org/manifest.json
Creating new project &quot;mymdbook&quot;...
CREATE mymdbook/src/mymdbook_assets/assets/sample-asset.txt (24B)...
CREATE mymdbook/src/mymdbook/main.mo (107B)...
CREATE mymdbook/dfx.json (478B)...
CREATE mymdbook/.gitignore (165B)...
CREATE mymdbook/README.md (1.16KB)...
CREATE mymdbook/src/mymdbook_assets/src/index.js (521B)...
CREATE mymdbook/src/mymdbook_assets/src/index.html (538B)...
CREATE mymdbook/src/mymdbook_assets/assets/logo.png (24.80KB)...
CREATE mymdbook/src/mymdbook_assets/assets/main.css (484B)...
CREATE mymdbook/package.json (479B)...
CREATE mymdbook/webpack.config.js (2.92KB)...
⠉ Installing node dependencies...
Done.
Creating git repository...

===============================================================================
Welcome to the internet computer developer community!
You're using dfx 0.7.2

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀▀▄▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▀ ▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀ ▀▄▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄▀ ▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀ ▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄ ▀▄▄▄▄▄▄▄▄▄▄▄▄▀ ▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄
▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▀
▀▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▀ ▀▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀ ▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀ ▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀ ▀▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀
▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀



To learn more before you start coding, see the documentation available online:

- Quick Start: https://sdk.dfinity.org/docs/quickstart/quickstart-intro.html
- SDK Developer Tools: https://sdk.dfinity.org/docs/developers-guide/sdk-guide.html
- Motoko Language Guide: https://sdk.dfinity.org/docs/language-guide/motoko.html
- Motoko Quick Reference: https://sdk.dfinity.org/docs/language-guide/language-manual.html

If you want to work on programs right away, try the following commands to get started:

cd mymdbook
dfx help
dfx new --help

===============================================================================
</code></pre>
<p>Change into your <code>mymdbook</code> directory and initialize the <code>mdbook</code>:</p>
<pre><code>% cd mymdbook
% mdbook init

Do you want a .gitignore to be created? (y/n)
n
What title would you like to give the book?
mymdbook
[INFO] (mdbook::book::init): Creating a new book with stub content

All done, no errors...
</code></pre>
<p>You will not need the <code>dfx</code> generated Motoko or asset canister code for this tutorial, feel free to delete those</p>
<pre><code>rm -rf src/mymdbook/
</code></pre>
<p>Delete all the contents in your <code>dfx.json</code> and create an entry for your <code>mdbook</code>:</p>
<pre><code>{
&quot;canisters&quot;: {
&quot;book&quot;: {
&quot;type&quot;: &quot;assets&quot;,
&quot;source&quot;: [&quot;book&quot;]
}
}
}
</code></pre>
<p>Build your <code>mdbook</code>:</p>
<pre><code>% mdbook build
[INFO] (mdbook::book): Book building has started
[INFO] (mdbook::book): Running the html backend
</code></pre>
<p>Ensure that you have a replica running locally:</p>
<pre><code>dfx start --background
</code></pre>
<p>Then <code>dfx deploy</code>!:</p>
<pre><code>% dfx deploy
Creating a wallet canister on the local network.
The wallet canister on the &quot;local&quot; network for user &quot;default&quot; is &quot;r7inp-6aaaa-aaaaa-aaabq-cai&quot;
Deploying all canisters.
Creating canisters...
Creating canister &quot;book&quot;...
&quot;book&quot; canister created with canister id: &quot;rkp4c-7iaaa-aaaaa-aaaca-cai&quot;
Building canisters...
Building frontend...
Installing canisters...
Creating UI canister on the local network.
The UI canister on the &quot;local&quot; network is &quot;rno2w-sqaaa-aaaaa-aaacq-cai&quot;
Installing code for canister book, with canister_id rkp4c-7iaaa-aaaaa-aaaca-cai
Authorizing our identity (default) to the asset canister...
Uploading assets to asset canister...
/mark.min.js 1/1 (17320 bytes)
/mark.min.js (gzip) 1/1 (5950 bytes)
/searcher.js 1/1 (18474 bytes)
/searcher.js (gzip) 1/1 (5082 bytes)
/highlight.css 1/1 (1215 bytes)
/highlight.css (gzip) 1/1 (575 bytes)
/index.html 1/1 (8405 bytes)
/index.html (gzip) 1/1 (2125 bytes)
/ayu-highlight.css 1/1 (947 bytes)
/ayu-highlight.css (gzip) 1/1 (440 bytes)
/FontAwesome/css/font-awesome.css 1/1 (31000 bytes)
/FontAwesome/css/font-awesome.css (gzip) 1/1 (6995 bytes)
/FontAwesome/fonts/fontawesome-webfont.svg 1/1 (444379 bytes)
/FontAwesome/fonts/FontAwesome.ttf 1/1 (165548 bytes)
/FontAwesome/fonts/fontawesome-webfont.woff2 1/1 (77160 bytes)
/FontAwesome/fonts/fontawesome-webfont.ttf 1/1 (165548 bytes)
/FontAwesome/fonts/fontawesome-webfont.woff 1/1 (98024 bytes)
/FontAwesome/fonts/fontawesome-webfont.eot 1/1 (165742 bytes)
/css/variables.css 1/1 (5944 bytes)
/css/variables.css (gzip) 1/1 (1156 bytes)
/css/general.css 1/1 (3915 bytes)
/css/general.css (gzip) 1/1 (1522 bytes)
/css/print.css 1/1 (757 bytes)
/css/print.css (gzip) 1/1 (400 bytes)
/css/chrome.css 1/1 (9324 bytes)
/css/chrome.css (gzip) 1/1 (2351 bytes)
/searchindex.js 1/1 (1377 bytes)
/searchindex.js (gzip) 1/1 (444 bytes)
/clipboard.min.js 1/1 (10754 bytes)
/clipboard.min.js (gzip) 1/1 (3353 bytes)
/404.html 1/1 (8538 bytes)
/404.html (gzip) 1/1 (2206 bytes)
/print.html 1/1 (8615 bytes)
/print.html (gzip) 1/1 (2188 bytes)
/favicon.png 1/1 (5679 bytes)
/highlight.js 1/1 (135394 bytes)
/highlight.js (gzip) 1/1 (46066 bytes)
/tomorrow-night.css 1/1 (1741 bytes)
/tomorrow-night.css (gzip) 1/1 (676 bytes)
/chapter_1.html 1/1 (8420 bytes)
/chapter_1.html (gzip) 1/1 (2132 bytes)
/mymdbook/main.mo 1/1 (107 bytes)
/elasticlunr.min.js 1/1 (18051 bytes)
/elasticlunr.min.js (gzip) 1/1 (5510 bytes)
/fonts/SOURCE-CODE-PRO-LICENSE.txt 1/1 (4528 bytes)
/fonts/SOURCE-CODE-PRO-LICENSE.txt (gzip) 1/1 (2009 bytes)
/fonts/open-sans-v17-all-charsets-800italic.woff2 1/1 (40812 bytes)
/fonts/open-sans-v17-all-charsets-800.woff2 1/1 (44536 bytes)
/fonts/OPEN-SANS-LICENSE.txt 1/1 (11358 bytes)
/fonts/OPEN-SANS-LICENSE.txt (gzip) 1/1 (3972 bytes)
/fonts/open-sans-v17-all-charsets-regular.woff2 1/1 (43236 bytes)
/fonts/open-sans-v17-all-charsets-300.woff2 1/1 (44352 bytes)
/fonts/open-sans-v17-all-charsets-600italic.woff2 1/1 (42120 bytes)
/fonts/open-sans-v17-all-charsets-700italic.woff2 1/1 (40800 bytes)
/fonts/open-sans-v17-all-charsets-300italic.woff2 1/1 (40656 bytes)
/fonts/open-sans-v17-all-charsets-700.woff2 1/1 (44988 bytes)
/fonts/open-sans-v17-all-charsets-600.woff2 1/1 (44936 bytes)
/fonts/source-code-pro-v11-all-charsets-500.woff2 1/1 (59140 bytes)
/fonts/open-sans-v17-all-charsets-italic.woff2 1/1 (41076 bytes)
/fonts/fonts.css 1/1 (3620 bytes)
/fonts/fonts.css (gzip) 1/1 (568 bytes)
/book.js 1/1 (24328 bytes)
/book.js (gzip) 1/1 (5572 bytes)
/favicon.svg 1/1 (1835 bytes)
/searchindex.json 1/1 (1346 bytes)
Deployed canisters.
</code></pre>
<p>Navigate to <a href="http://rkp4c-7iaaa-aaaaa-aaaca-cai.localhost:8000/">http://rkp4c-7iaaa-aaaaa-aaaca-cai.localhost:8000/</a> (replacing the canister URL with the one that your console reported) and you should be able to see your mdbook! Huzzah!</p>
<h2 id="deploy-your-first-mdbook-to-the-production-internet-computer-network"><a class="header" href="#deploy-your-first-mdbook-to-the-production-internet-computer-network">Deploy your first mdBook to the production Internet Computer network</a></h2>
<p>If you've gone through the steps required to create your cycles wallet and to top it up, deploying will be as easy as:</p>
<pre><code>dfx deploy --network ic
</code></pre>

</main>

Expand Down
Loading

0 comments on commit f926551

Please sign in to comment.