Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 6dfb6a3

Browse files
committed
fixing headings in Part 5
1 parent 3ddce1c commit 6dfb6a3

8 files changed

+42
-40
lines changed

05_Customizing_OrbitDB/00_Introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Customizing OrbitDB
1+
# Part 5: Customizing OrbitDB
22

33
In the first chapter of this Field Manual,
44
we described how you might create

05_Customizing_OrbitDB/01_Definitions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# What are Stores, AccessControllers and Indicies.
1+
## What are Stores, AccessControllers and Indicies.
22

33
Before we start to implement
44
our custom store, access controller, and index
@@ -7,7 +7,7 @@ notes, we should probably define what a `Store`,
77
`AccessController`, and `Index` are and what
88
function they have in OrbitDB.
99

10-
## The Store
10+
### The Store
1111

1212
You have already worked with several
1313
Stores in the Tutorial.
@@ -22,7 +22,7 @@ functions to access them, like `get`, `put` or `set`,
2222
with which you could easily interact with
2323
the database itself.
2424

25-
## The Index
25+
### The Index
2626

2727
But a store doesn't actually
2828
store the current state of the database in the RAM,
@@ -37,7 +37,7 @@ of the current state of the database.
3737
The index is then used by the `Store`
3838
to implement its API.
3939

40-
## The Access Controllers
40+
### The Access Controllers
4141

4242
Access Controllers or short ACL (Access Control List)
4343
were already discussed [02: Managing Data](../01_Tutorial/02_Managing_Data).

05_Customizing_OrbitDB/02_Choosing_a_data_structure.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Choosing a data structure
1+
## Choosing a data structure
22

33
Let's start implementing a comment system
44
by choosing how we want to represent the
@@ -12,7 +12,7 @@ implementing the Access Controller,
1212
since the Access Controller is very
1313
much independent from the Store and Index.
1414

15-
## Requirements
15+
### Requirements
1616

1717
Our data structure should achieve two things:
1818

@@ -25,7 +25,7 @@ Each tree's root would be the Notes pieces and the
2525
children of that root would be the comments,
2626
the comments comments and so on and so on.
2727

28-
## Generating the Trees from the `ipfs-log`
28+
### Generating the Trees from the `ipfs-log`
2929

3030
Before starting to implement this data structure,
3131
we'll also have to consider, how to generate
@@ -47,17 +47,17 @@ For our purposes there can be these operations:
4747

4848
This seems pretty straight forward.
4949

50-
## What happens when we delete notes or comments, with all those comments referring to them?
50+
### What happens when we delete notes or comments, with all those comments referring to them?
5151

5252
I propose using a simple rule: If a comment or piece of notes
5353
is deleted, all those refering to it are deleted too.
5454
Otherwise this tutorial becomes a complicated mess.
5555

56-
# Implementing the Index.
56+
## Implementing the Index.
5757

5858
Let's start by adding a new file to your project folder (if you haven't yet created one, do that now).
5959

60-
## Isomorphic Bookends.
60+
### Isomorphic Bookends.
6161

6262
You know the drill, before starting with the actual implementation
6363
of the Index, we have to define the bookends, that make our code
@@ -79,7 +79,7 @@ libraries from OrbitDB.
7979

8080
It is using duck typing, instead of inheritance.
8181

82-
## Defining the `NotesIndex` class.
82+
### Defining the `NotesIndex` class.
8383

8484
Next, let's define the actual class
8585
of the `NotesIndex`.
@@ -96,7 +96,7 @@ class NotesIndex {
9696
We initialize the index to an empty object at first, because
9797
we don't yet have any data.
9898

99-
## Defining the `TreeNode` helper class.
99+
### Defining the `TreeNode` helper class.
100100

101101
After this, let's first implement our own `TreeNode` data type,
102102
that'll be used to represent the trees mentioned above.

05_Customizing_OrbitDB/03_Defining_the_Index.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Defining the Index
1+
## Defining the Index
22

33
In the last chapter we
44
considered how we
@@ -19,7 +19,7 @@ actually define the Index
1919
or what makes the `NotesIndex`
2020
class an `Index`.
2121

22-
## A few utility functions.
22+
### A few utility functions.
2323

2424
Let's first define a few
2525
utility functions for fetching content from
@@ -33,7 +33,7 @@ The last will be very helpful to UI Designers
3333
who have the crucial task of translating this data structure into
3434
pleasant UI.
3535

36-
### `getNotes`
36+
#### `getNotes`
3737

3838
But let's start with a simple `NotesIndex.getNotes` function.
3939

@@ -47,7 +47,7 @@ We fetch the tree with that CID and then only
4747
care for the `data` field of the `TreeNode`, because
4848
that's where the sheet music is actually stored.
4949

50-
### `getComments`
50+
#### `getComments`
5151

5252
Now implement the `NotesIndex.getComments(cid)` function like this:
5353

@@ -61,7 +61,7 @@ Get comments is almost entirely identical to `getNotes`, except
6161
that we don't return the `data`, but the `children` field of
6262
the `TreeNode`.
6363

64-
### `getComments` with chronological order
64+
#### `getComments` with chronological order
6565

6666
Now, let's get to our third and final `get` functions: `getComments`,
6767
but now with an argument: `flat = true`.
@@ -90,7 +90,7 @@ getComments(cid, flat = true) {
9090

9191
Replace the `getComments` function above, by this.
9292

93-
#### What happens here?
93+
##### What happens here?
9494

9595
We first define a helper function `flatten`, which goes
9696
through the array of children and adds each node
@@ -99,7 +99,7 @@ Then we sort it based on an id field in ascending order.
9999
If you pass in `flat = false`, you'll still get the old
100100
behavior.
101101

102-
### The `updateIndex` function
102+
#### The `updateIndex` function
103103

104104
Up until this point, we have been
105105
writing utility functions that are
@@ -168,7 +168,7 @@ Index can handle:
168168
- `ADDCOMMENT` to add a comment to a piece of notes or some other comments.
169169
- `DELETECOMMENT` to delete a comment.
170170

171-
### Implementing `ADDNOTES` handling
171+
#### Implementing `ADDNOTES` handling
172172

173173
Add notes is by far the simplest operation to handle,
174174
since we just need to add a new `TreeNode` to the `_index`.
@@ -180,7 +180,7 @@ case "ADDNOTES":
180180
break;
181181
```
182182

183-
### Implementing `DELETENOTES` handling
183+
#### Implementing `DELETENOTES` handling
184184

185185
And deleting notes is the inverse:
186186

@@ -191,7 +191,7 @@ case "DELETENOTES":
191191
break;
192192
```
193193

194-
### Implementing `ADDCOMMENT` handling
194+
#### Implementing `ADDCOMMENT` handling
195195

196196
Adding comments is a little more complicated.
197197
We first have to find the parent of the comment in the notes
@@ -254,7 +254,7 @@ After this, the `TreeNode` that is referred to by the Operator's
254254
And at last, we store the created `TreeNode`, in `_comments`
255255
for later.
256256

257-
### Implementing `DELETECOMMENT` handling
257+
#### Implementing `DELETECOMMENT` handling
258258

259259
After the monster of a branch above, this case is
260260
pretty relaxing in comparison:
@@ -267,7 +267,7 @@ case "DELETECOMMENT":
267267
break;
268268
```
269269

270-
## Conclusion
270+
### Conclusion
271271

272272
We have now defined the complete
273273
`Index` for the comment system.

05_Customizing_OrbitDB/04_Defining_the_Store.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Defining the Store
1+
## Defining the Store
22

33
We now have our own
44
`Index` in `NotesIndex.js`.
@@ -29,12 +29,12 @@ Tutorial in this Manual.
2929
Because there are five built-in
3030
stores, which will I not bother recounting here.
3131

32-
# The `NotesStore` class
32+
### The `NotesStore` class
3333

3434
You should now add a new JavaScript file
3535
and call it `NotesStore.js`.
3636

37-
## Isomorphic Bookends
37+
#### Isomorphic Bookends
3838

3939
For the third time in this Manual:
4040
Let's define an isomorphic bookend:
@@ -58,7 +58,7 @@ try {
5858

5959
We'll from now on be working inside the `notesStore` function.
6060

61-
## Defining the `NotesStore` class
61+
### Defining the `NotesStore` class
6262

6363
To define a Store, we have to extend
6464
an existing Store class.
@@ -84,7 +84,7 @@ class NoteStore extends OrbitDB.EventStore {
8484
return NoteStore
8585
```
8686

87-
### What is happening here?
87+
#### What is happening here?
8888

8989
The Store receives four parameters in it's `constructor`:
9090

@@ -101,7 +101,7 @@ the options already has an `Index` specified.
101101
Besides this, all stores have to have a `type` property,
102102
to uniquely identify the `NotesStore`.
103103

104-
## Defining a `getNotes` and `getComments`
104+
### Defining a `getNotes` and `getComments`
105105

106106
We should probably implement a few get
107107
functions. But this is really low effort,
@@ -123,7 +123,7 @@ As you can see, `this._index` is an instance of the `NotesIndex`,
123123
if no other Index was passed in to the constructor,
124124
and we can easily access the methods we defined in the Index.
125125

126-
## Adding Data to the Store
126+
### Adding Data to the Store
127127

128128
Now, let's finally add some data
129129
to our Store.
@@ -203,7 +203,7 @@ prior to adding an operation:
203203
- Formatting (with Protobuf)
204204
- Encryption and Decryption
205205

206-
### Adding Comments
206+
#### Adding Comments
207207

208208
After a user added their
209209
musical notes to their Database,
@@ -239,7 +239,7 @@ information about the auther.
239239
See the [Implementing `ADDCOMMENT` handling](03_Defining_the_Index.md#Implementing-ADDCOMMENT-handling)
240240
section of the previous chapter.
241241

242-
# Other Stores
242+
## Other Stores
243243

244244
You might note that this is a very complicated
245245
custom store and index.
@@ -256,7 +256,7 @@ can be very illuminating and inspiring.
256256
I would advice reading the [`EventIndex.js`](https://github.com/orbitdb/orbit-db-eventstore/blob/main/src/EventIndex.js)
257257
and the [KVStore's Store and Index files](https://github.com/orbitdb/orbit-db-kvstore/blob/main/src/).
258258

259-
# Key Takeaways
259+
## Key Takeaways
260260

261261
- Stores inherit from each other. So you can extend built-in stores.
262262
- Stores work with the `Index` and the `this._addOperation` mostly.

05_Customizing_OrbitDB/05_Conclusion.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# On Customizing OrbitDB
1+
## On Customizing OrbitDB
22

33
In conclusion this
44
part of the Field
@@ -35,7 +35,7 @@ and has no time to bother
3535
about CRDTs, `oplogs` and
3636
other such complexities.
3737

38-
# Where to go from here?
38+
### Where to go from here?
3939

4040
The source code in this
4141
tutorial is incomplete

05_Customizing_OrbitDB/06_AccessControllers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Moderating your Comment Threads.
1+
## Moderating your Comment Threads.
22

33
We have now gotten a store that
44
you can publish notes and comments with.

05_Customizing_OrbitDB/07_Implementing_a_custom_AccessController.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Implementing a custom Access controllers
1+
## Implementing a custom Access controllers
22

33
And after these things, let us now consider
44
how we might implement a custom access controller.
@@ -11,10 +11,12 @@ to implement:
1111
- The author of a comment and the creator can delete a comment.
1212
- The creator can ban somebody from commenting on the entire database.
1313

14-
## Implementation
14+
### Implementation
1515

1616
Similarly to the `Store`s,
1717
Access Controllers are implemented
1818
using inherited classes.
1919
Let's implement a `NotesAccessController.js`
2020
file with these Isomorphic bookends:
21+
22+
**Note:** TBD

0 commit comments

Comments
 (0)