Skip to content

Commit

Permalink
Sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Oct 2, 2023
1 parent 53e1679 commit 2506b81
Show file tree
Hide file tree
Showing 6 changed files with 3,001 additions and 8,549 deletions.
189 changes: 39 additions & 150 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,122 +8,13 @@
/>
<meta name="Description" content="Put your description here." />
<base href="/" />
<script type="module">
import "reveal.js/dist/reveal.css";
import "reveal.js/dist/theme/black.css";
import "reveal.js/plugin/highlight/monokai.css";
import "@mythosthesia/reveal-course-preset/styles.css";
</script>

<style>
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
background-color: #ededed;
--r-main-font-size: 24px;
--r-heading-margin: 20px 0 12px 0;
}

.slides {
width: 75% !important;
}

.container {
top: 0 !important;
display: flex !important;
flex-direction: row !important;
}
.column {
display: flex;
flex-direction: column;
}
.row {
display: flex;
flex-direction: row;
}

ul {
width: 100%;
}

section {
text-align: left;
}

.popover {
position: absolute;
background-color: #4d4d4d;
padding: 1rem 2rem;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
border-radius: 10px;
width: auto;
transform: translate(16px, -15px);
max-width: 600px;
white-space: break-spaces;
}
.popover:after {
content: "";
position: absolute;
top: 6px;
left: -8px;
border-style: solid;
border-width: 18px 12px 0;
border-color: #4d4d4d transparent;
display: block;
width: 0;
z-index: 1;
transform: translate(-50%, 50%) rotate(90deg);
}

.popover .hljs-meta,
.popover .hljs-class,
.popover .hljs-keyword,
.popover .hljs-string,
.popover .hljs-title {
color: rgb(221, 221, 221) !important;
font-weight: normal;
}

.reveal pre code {
max-height: 800px !important;
}

.dna {
background-color: green;
}
.zome {
background-color: blue;
}
.coordinator-zomes {
background-color: lightblue;
}

.dna,
.cell,
.zome,
.coordinator-zomes,
.source-chain,
.happ-bundle,
.box,
.dna-bundle,
.dht-shard,
.conductor,
.happ {
display: flex;
align-items: center;
justify-content: center;
padding: 12px;
border-width: 3px;
border-color: rgb(209, 209, 209);
border-style: solid;
}
</style>
<link rel="stylesheet" href="/node_modules/reveal.js/dist/reveal.css" />

<link
rel="stylesheet"
href="/node_modules/reveal.js/dist/theme/black.css"
/>
<link
rel="stylesheet"
href="/node_modules/reveal.js/plugin/highlight/monokai.css"
/>
<title>Holochain Lesson 3</title>
</head>

Expand All @@ -146,16 +37,21 @@ <h1>HDK: retrieving source chains</h1>
</fragment>

<!-- prettier-ignore -->
<fragment animate="balanced separate-comments by-line with-ancestry">
<fragment>
<pre
class="fragment fade-in"
><code class="rust" data-noescape>use hdk::prelude::*;
><code class="rust" data-noescape data-trim
animate="by-line balanced with-ancestry separate-comments trailing-comments-in-popover strike-on-error-in-comment"
>
use hdk::prelude::*;

#[hdk_extern]
fn query_my_full_chain(_: ()) -> ExternResult&lt;Vec&lt;Record&gt;&gt; {
let filter = ChainQueryFilter::new(); // We'll see more options

let my_full_chain: Vec&lt;Record&gt; = query(filter)?;<span class="fragment fade-in-then-out popover"><li class="fragment fade-in-then-semi-out">Does not do any network call</li><li class="fragment fade-in-then-semi-out">Records are returned in ascendent order (from oldest to newest)</li></span> // No network calls
let my_full_chain: Vec&lt;Record&gt; = query(filter)?; // - Does not do any network call
// - Records are returned in ascendent
// order (from oldest to newest)

Ok(my_full_chain)
}
Expand All @@ -166,17 +62,19 @@ <h1>HDK: retrieving source chains</h1>
<section>
<h3>query() (II)</h3>
<!-- prettier-ignore -->
<fragment animate="balanced separate-comments by-line with-ancestry">
<fragment>

<pre
class="fragment fade-in"
><code class="rust" data-noescape>use hdk::prelude::*;
><code class="rust" data-noescape data-trim
animate="by-line balanced with-ancestry separate-comments trailing-comments-in-popover strike-on-error-in-comment"
>
use hdk::prelude::*;

#[hdk_entry_helper]
struct Comment {
comment: String
}

#[hdk_entry_defs]
#[unit_enum(UnitEntryTypes)]
enum EntryTypes {
Expand All @@ -185,21 +83,20 @@ <h3>query() (II)</h3>

#[hdk_extern]
fn query_my_comments(_: ()) -> ExternResult&lt;Vec&lt;Record&gt;&gt; {
let comment_entry_type: EntryType = UnitEntryTypes::Comment.try_into()?;<span class="fragment fade-in-then-out popover">Generated with "#[unit_enum(UnitEntryTypes)]"</span>

let filter = ChainQueryFilter::new().entry_type(comment_entry_type); // Filter by the given entry type

let comment_entry_type: EntryType = UnitEntryTypes::Comment.try_into()?; // Generated with
// "#[unit_enum()]"
let filter = ChainQueryFilter::new().entry_type(comment_entry_type); // Filter by the
// given entrytype
let all_my_comments = query(filter)?; // Only the records which create or update comments

Ok(all_my_comments)
}

#[hdk_extern]
fn query_all_links_i_created(_: ()) -> ExternResult&lt;Vec&lt;Record&gt;&gt; {
let filter = ChainQueryFilter::new().action_type(ActionType::CreateLink<span class="fragment fade-in-then-out popover">May be any kind of action</span>);

let all_links_i_created = query(filter)?; // Only the records whose action is of type "CreateLink"

let filter = ChainQueryFilter::new().action_type(ActionType::CreateLink); // May be any kind
// of action
let all_links_i_created = query(filter)?; // Only the records whose action
// is of the "CreateLink" variant
Ok(all_links_i_created)
}
</code></pre>
Expand All @@ -217,19 +114,24 @@ <h3>query() (II)</h3>
</fragment>

<!-- prettier-ignore -->
<fragment animate="balanced separate-comments by-line with-ancestry">
<fragment>
<pre
class="fragment fade-in"
><code class="rust" data-noescape>use hdk::prelude::*;
><code class="rust" data-noescape data-trim
animate="by-line balanced with-ancestry separate-comments trailing-comments-in-popover strike-on-error-in-comment"
>
use hdk::prelude::*;

#[hdk_extern]
fn get_comments_created_by(author: AgentPubKey) -> ExternResult&lt;Vec&lt;ActionHash&gt;&gt; {
let filter = ChainQueryFilter::new(); // Same options as "query"

let agent_activity = get_agent_activity(
author,<!-- TODO: fix taking into account the latest API -->
author,
filter,
ActivityRequest::Full
ActivityRequest::Full // - "ActivityRequest" can be:
// - "Full": request the list of action hashes for the full chain
// - "Status": request only the status of the chain
)?;
}
</code></pre>
Expand All @@ -244,23 +146,10 @@ <h1>That's it!</h1>

<script type="module">
import Reveal from "reveal.js";
import Markdown from "reveal.js/plugin/markdown/markdown.esm.js";
import RevealHighlight from "reveal.js/plugin/highlight/highlight.esm.js";
import RevealNotes from "reveal.js/plugin/notes/notes.esm.js";
import RevealAnimateFragments from "reveal.js-animate-fragments";
import RevealEliminateEmptyLines from "reveal.js-animate-fragments";
import { plugins, config } from "@mythosthesia/reveal-course-preset";

let deck = new Reveal({
transition: "none",
plugins: [
Markdown,
RevealHighlight,
RevealNotes,
RevealAnimateFragments,
RevealEliminateEmptyLines,
],
});
deck.initialize();
let deck = new Reveal();
deck.initialize(config);
</script>
</body>
</html>
Loading

0 comments on commit 2506b81

Please sign in to comment.