@cryptotaxi247 / kubo / commits / b2323afed

refactor(tour) extract chapters

Brian Tiger Chow committed Nov 4, 2014 at 22:30 UTC b2323afeddca88c6a31de5711ab0a91ffa6d5482
1 file changed +34 -12
tour/all.go
+34 -12
@@ -1,6 +1,9 @@
1 package tour
2
3 -import "sort"
3 +import (
4 + "fmt"
5 + "sort"
6 +)
7
8 func init() {
9 for _, t := range allTopics {
@@ -11,20 +14,33 @@ func init() {
14 sort.Sort(IDSlice(IDs))
15 }
16
17 +var (
18 + Introduction = Chapter(0)
19 + FileBasics = Chapter(1)
20 + NodeBasics = Chapter(2)
21 + MerkleDag = Chapter(3)
22 + Network = Chapter(4)
23 + Daemon = Chapter(5)
24 + Routing = Chapter(6)
25 + Exchange = Chapter(7)
26 + Ipns = Chapter(8)
27 + Mounting = Chapter(9)
28 + Plumbing = Chapter(10)
29 + Formats = Chapter(11)
30 +)
31 +
32 // Topics contains a mapping of Tour Topic ID to Topic
33 var allTopics = []Topic{
16 - Topic{ID: ID("0.0"), Content: IntroHelloMars},
17 - Topic{ID: ID("0.1"), Content: IntroTour},
18 - Topic{ID: ID("0.2"), Content: IntroAboutIpfs},
34 + Topic{ID: Introduction(0), Content: IntroHelloMars},
35 + Topic{ID: Introduction(1), Content: IntroTour},
36 + Topic{ID: Introduction(2), Content: IntroAboutIpfs},
37
20 - // File Basics
21 - Topic{ID: ID("X.0"), Content: FileBasicsFilesystem},
22 - Topic{ID: ID("X.1"), Content: FileBasicsGetting},
23 - Topic{ID: ID("X.2"), Content: FileBasicsAdding},
24 - Topic{ID: ID("X.3"), Content: FileBasicsDirectories},
25 - Topic{ID: ID("X.3"), Content: FileBasicsDirectories},
26 - Topic{ID: ID("X.4"), Content: FileBasicsMounting},
27 - Topic{ID: ID("X.2"), Content: FileBasicsAdding},
38 + Topic{ID: FileBasics(1), Content: FileBasicsFilesystem},
39 + Topic{ID: FileBasics(2), Content: FileBasicsGetting},
40 + Topic{ID: FileBasics(3), Content: FileBasicsAdding},
41 + Topic{ID: FileBasics(4), Content: FileBasicsDirectories},
42 + Topic{ID: FileBasics(5), Content: FileBasicsDistributed},
43 + Topic{ID: FileBasics(6), Content: FileBasicsMounting},
44 }
45
46 // Introduction
@@ -77,3 +93,9 @@ var FileBasicsMounting = Content{
93 Text: `ipfs mount (simple)
94 `,
95 }
96 +
97 +func Chapter(number int) func(topic int) ID {
98 + return func(topic int) ID {
99 + return ID(fmt.Sprintf("%d.%d", number, topic))
100 + }
101 +}