Skip to content

Commit bb703e0

Browse files
Merge branch 'add-test-pages' into feat/countly-event-tracking
2 parents da2af72 + 42bf9bc commit bb703e0

19 files changed

+370
-4
lines changed

src/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ import MutableFileSystem10 from './tutorials/Mutable-File-System/10.vue'
4545
import MutableFileSystem11 from './tutorials/Mutable-File-System/11.vue'
4646
import Tests01 from './tutorials/Tests/01.vue'
4747
import Tests02 from './tutorials/Tests/02.vue'
48+
import Tests03 from './tutorials/Tests/03.vue'
49+
import Tests04 from './tutorials/Tests/04.vue'
50+
import Tests05 from './tutorials/Tests/05.vue'
51+
import Tests06 from './tutorials/Tests/06.vue'
52+
import Tests07 from './tutorials/Tests/07.vue'
53+
import Tests08 from './tutorials/Tests/08.vue'
4854

4955
Vue
5056
.use(VueRouter)
@@ -100,6 +106,12 @@ const routes = [
100106
{ path: '/tests', component: Landing, props: { tutorialId: 'tests' } },
101107
{ path: '/tests/01', component: Tests01 },
102108
{ path: '/tests/02', component: Tests02 },
109+
{ path: '/tests/03', component: Tests03 },
110+
{ path: '/tests/04', component: Tests04 },
111+
{ path: '/tests/05', component: Tests05 },
112+
{ path: '/tests/06', component: Tests06 },
113+
{ path: '/tests/07', component: Tests07 },
114+
{ path: '/tests/08', component: Tests08 },
103115
{ path: '/tests/resources', component: ResourcesLesson, props: { tutorialId: 'tests' } },
104116
// 404
105117
{ path: '*', name: '404' }

src/static/tutorials.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,33 @@
146146
"description": "We'll need to delete this before we merge!",
147147
"lessons": [
148148
{ "to": "/tests/01", "name": "Sample multiple choice lesson" },
149-
{ "to": "/tests/02", "name": "This is another lesson" }
149+
{ "to": "/tests/02", "name": "Another multiple choice lesson" },
150+
{ "to": "/tests/03", "name": "Sample text-only lesson" },
151+
{ "to": "/tests/04", "name": "Another text-only lesson" },
152+
{ "to": "/tests/05", "name": "Sample excercise lesson with useful concepts box" },
153+
{ "to": "/tests/06", "name": "Another excercise lesson without concepts" },
154+
{ "to": "/tests/07", "name": "Sample file upload lesson" },
155+
{ "to": "/tests/08", "name": "Another file upload lesson" }
150156
],
151157
"resources": [
152158
{
153-
"title": "JS-IPFS Files API",
154-
"link": "https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md",
159+
"title": "Lipsum",
160+
"link": "https://www.lipsum.com/",
155161
"type": "docs",
156-
"description": "Notice that these docs contain two sections, one for top-level methods relevant to files and one for the Mutable File System (MFS) you learned about in this tutorial."
162+
"description": "This is a pretend resource."
163+
},
164+
{
165+
"title": "Lorem Ipsum",
166+
"link": "https://loremipsum.io/",
167+
"type": "demo",
168+
"description": "What a great fake resource!"
169+
170+
},
171+
{
172+
"title": "This Fake ProtoSchool Tutorial",
173+
"link": "http://localhost:3000/#/tests",
174+
"type": "tutorial",
175+
"description": "The best fake resource ever."
157176
}
158177
]
159178
}

src/tutorials/Tests/03.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Oh hey there!
2+
3+
This is a sample **text-only lesson**. Great reading, huh?

src/tutorials/Tests/03.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<Lesson
3+
:text="text"
4+
lessonTitle="Sample text-only lesson" />
5+
</template>
6+
7+
<script>
8+
import Lesson from '../../components/Lesson'
9+
import text from './03.md'
10+
11+
export default {
12+
components: {
13+
Lesson
14+
},
15+
data: () => {
16+
return { text }
17+
}
18+
}
19+
</script>

src/tutorials/Tests/04.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is another sample **text-only lesson**. Hope you're enjoying this.

src/tutorials/Tests/04.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<Lesson
3+
:text="text"
4+
lessonTitle="Another text-only lesson" />
5+
</template>
6+
7+
<script>
8+
import Lesson from '../../components/Lesson'
9+
import text from './04.md'
10+
11+
export default {
12+
components: {
13+
Lesson
14+
},
15+
data: () => {
16+
return { text }
17+
}
18+
}
19+
</script>

src/tutorials/Tests/05-concepts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**CID** - Content Identifier. An unique address for a block of data in IPFS that is derived from its content.

src/tutorials/Tests/05-exercise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `ipfs.dag.put` to create a node for the data `{ test: 1 }`. Return the CID of your new node.

src/tutorials/Tests/05.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
**This is a sample standard excercise lesson with a useful concepts box.**
2+
3+
In this tutorial we'll be exploring the IPFS DAG API, which lets us store data
4+
objects in IPFS. (You can store more exciting things in IPFS, like your favorite
5+
cat GIF, but you'd need to use a different API for that.)
6+
7+
You can create a new node by passing a data object into the `ipfs.dag.put` method,
8+
which returns a Content Identifier (CID) for the newly created node.
9+
10+
```javascript
11+
ipfs.dag.put({ hello: 'world' })
12+
```
13+
14+
A CID is an address for a block of data in IPFS that is derived from its content. Every
15+
time someone puts the same `{ hello: 'world' }` data into IPFS, they'll get back an
16+
identical CID to the one you got. If they put in `{ hell0: 'w0rld' }` instead, the
17+
CID will be different.
18+
19+
_Note: Throughout our lessons we'll be using a code editor like the one below.
20+
Enter your solution code within the `run` function that's pre-populated for you,
21+
being sure to return the requested value within that function. (You won't need to
22+
update the `return run` line at the end; that's just there to make the code editor work.)_

src/tutorials/Tests/05.vue

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<Lesson
3+
:text="text"
4+
:validate="validate"
5+
:exercise="exercise"
6+
:concepts="concepts"
7+
:solution="solution"
8+
lessonTitle="Sample excercise lesson with useful concepts box">
9+
</Lesson>
10+
</template>
11+
12+
<script>
13+
import Lesson from '../../components/Lesson'
14+
import text from './05.md'
15+
import concepts from './05-concepts.md'
16+
import exercise from './05-exercise.md'
17+
import CID from 'cids'
18+
19+
const validate = async (result, ipfs) => {
20+
if (!result) {
21+
return { fail: 'You forgot to return a result :)' }
22+
}
23+
24+
if (!CID.isCID(result)) {
25+
return { fail: 'Did not return a valid CID instance.' }
26+
}
27+
28+
const hash = 'bafyreicaoyussrycqolu4k2iaxleu2uakjlq57tuxq3djxn4wnyfp4yk3y'
29+
if (result.toBaseEncodedString() === hash) {
30+
return { success: 'Everything works!' }
31+
} else {
32+
const obj = await ipfs.dag.get(result)
33+
const expected = JSON.stringify({ test: 1 })
34+
const got = JSON.stringify(obj.value)
35+
36+
return { fail: `Was expecting \`${expected}\` but got \`${got}\`.` }
37+
}
38+
}
39+
40+
const solution = `/* globals ipfs */
41+
42+
const run = async () => {
43+
let cid = await ipfs.dag.put({ test: 1 })
44+
return cid
45+
}
46+
47+
return run
48+
`
49+
50+
export default {
51+
components: {
52+
Lesson
53+
},
54+
data: () => {
55+
return { text, validate, exercise, concepts, solution }
56+
}
57+
}
58+
</script>

src/tutorials/Tests/06-exercise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `ipfs.dag.put` to create a node for the data `{ test: 1 }`. Return the CID of your new node.

src/tutorials/Tests/06.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
**This is a sample standard excercise lesson with a useful concepts box.**
2+
3+
In this tutorial we'll be exploring the IPFS DAG API, which lets us store data
4+
objects in IPFS. (You can store more exciting things in IPFS, like your favorite
5+
cat GIF, but you'd need to use a different API for that.)
6+
7+
You can create a new node by passing a data object into the `ipfs.dag.put` method,
8+
which returns a Content Identifier (CID) for the newly created node.
9+
10+
```javascript
11+
ipfs.dag.put({ hello: 'world' })
12+
```
13+
14+
A CID is an address for a block of data in IPFS that is derived from its content. Every
15+
time someone puts the same `{ hello: 'world' }` data into IPFS, they'll get back an
16+
identical CID to the one you got. If they put in `{ hell0: 'w0rld' }` instead, the
17+
CID will be different.
18+
19+
_Note: Throughout our lessons we'll be using a code editor like the one below.
20+
Enter your solution code within the `run` function that's pre-populated for you,
21+
being sure to return the requested value within that function. (You won't need to
22+
update the `return run` line at the end; that's just there to make the code editor work.)_

src/tutorials/Tests/06.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<Lesson
3+
:text="text"
4+
:validate="validate"
5+
:exercise="exercise"
6+
:solution="solution"
7+
lessonTitle="Another excercise lesson without concepts">
8+
</Lesson>
9+
</template>
10+
11+
<script>
12+
import Lesson from '../../components/Lesson'
13+
import text from './06.md'
14+
import exercise from './05-exercise.md'
15+
import CID from 'cids'
16+
17+
const validate = async (result, ipfs) => {
18+
if (!result) {
19+
return { fail: 'You forgot to return a result :)' }
20+
}
21+
22+
if (!CID.isCID(result)) {
23+
return { fail: 'Did not return a valid CID instance.' }
24+
}
25+
26+
const hash = 'bafyreicaoyussrycqolu4k2iaxleu2uakjlq57tuxq3djxn4wnyfp4yk3y'
27+
if (result.toBaseEncodedString() === hash) {
28+
return { success: 'Everything works!' }
29+
} else {
30+
const obj = await ipfs.dag.get(result)
31+
const expected = JSON.stringify({ test: 1 })
32+
const got = JSON.stringify(obj.value)
33+
34+
return { fail: `Was expecting \`${expected}\` but got \`${got}\`.` }
35+
}
36+
}
37+
38+
const solution = `/* globals ipfs */
39+
40+
const run = async () => {
41+
let cid = await ipfs.dag.put({ test: 1 })
42+
return cid
43+
}
44+
45+
return run
46+
`
47+
48+
export default {
49+
components: {
50+
Lesson
51+
},
52+
data: () => {
53+
return { text, validate, exercise, solution }
54+
}
55+
}
56+
</script>

src/tutorials/Tests/07-exercise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
First, upload one or more files by dragging and dropping below or clicking to make a selection from your file explorer. Next, in the code editor, remove the comment markers (`//`) that precede `return files` within the `run` function.

src/tutorials/Tests/07.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**This is a sample file lesson.**
2+
3+
As a matter of security, web browsers don't let us directly change files that live in your computer's file system. Therefore you'll need to upload one or more files to the browser that you can use throughout this tutorial.
4+
5+
Within each exercise, you'll see that you can upload files from your computer either by dragging and dropping or selecting them from your file explorer. If you look closely at the `run` function in the code editor, you'll notice that it now takes an argument `files`. When you upload files from your computer, we'll make sure they're passed into the function as the `files` array. As long as you don't refresh your browser, these files will remain accessible for the next lesson in the tutorial, but you'll also have the option to upload different files to work with for each lesson.
6+
7+
To practice, let's upload one or more files from your computer and take a look at what's been received by the browser as the `files` array.

src/tutorials/Tests/07.vue

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<FileLesson
3+
:text="text"
4+
:code="code"
5+
:validate="validate"
6+
:modules="modules"
7+
:exercise="exercise"
8+
:solution="solution"
9+
lessonTitle="Sample file upload lesson">
10+
</FileLesson>
11+
</template>
12+
13+
<script>
14+
import FileLesson from '../../components/FileLesson.vue'
15+
import text from './07.md'
16+
import exercise from './07-exercise.md'
17+
import { logFiles } from '../../utils/files'
18+
19+
const validate = async (result, ipfs) => {
20+
if (!result || typeof result.length === 'undefined') {
21+
return { fail: 'Looks like you forgot to return a result. Did you forget to remove the `//` before `return files`?' }
22+
} else if (typeof result.length === 'number') {
23+
const fileCount = result.length > 1 ? `${result.length} files` : '1 file'
24+
return {
25+
success: `You successfully uploaded ${fileCount}!`,
26+
logDesc: "Check out the data below to see the data now accessible in the `files` array. Note that these files are only in the browser right now. In the next lesson we'll see how to add them to IPFS.",
27+
log: logFiles(result)
28+
}
29+
} else {
30+
return { fail: 'Something is wrong. Reset the code and see the instructions.' }
31+
}
32+
}
33+
34+
const code = `const run = async (files) => {
35+
/* remove the '//' on the line below to complete this challenge */
36+
// return files
37+
}
38+
return run
39+
`
40+
41+
const solution = `const run = async (files) => {
42+
return files
43+
}
44+
45+
return run
46+
`
47+
48+
const modules = { cids: require('cids') }
49+
50+
export default {
51+
components: {
52+
FileLesson
53+
},
54+
data: () => {
55+
return { text, validate, code, modules, exercise, solution }
56+
}
57+
}
58+
</script>

src/tutorials/Tests/08-exercise.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
First, upload one or more files by dragging and dropping below or clicking to make a selection from your file explorer. Next, in the code editor, remove the comment markers (`//`) that precede `return files` within the `run` function.

src/tutorials/Tests/08.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**This is a sample file lesson.**
2+
3+
As a matter of security, web browsers don't let us directly change files that live in your computer's file system. Therefore you'll need to upload one or more files to the browser that you can use throughout this tutorial.
4+
5+
Within each exercise, you'll see that you can upload files from your computer either by dragging and dropping or selecting them from your file explorer. If you look closely at the `run` function in the code editor, you'll notice that it now takes an argument `files`. When you upload files from your computer, we'll make sure they're passed into the function as the `files` array. As long as you don't refresh your browser, these files will remain accessible for the next lesson in the tutorial, but you'll also have the option to upload different files to work with for each lesson.
6+
7+
To practice, let's upload one or more files from your computer and take a look at what's been received by the browser as the `files` array.

0 commit comments

Comments
 (0)