From b2323afeddca88c6a31de5711ab0a91ffa6d5482 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 4 Nov 2014 22:30:30 -0800 Subject: [PATCH] refactor(tour) extract chapters --- tour/all.go | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/tour/all.go b/tour/all.go index 3bb3da777..723249a1e 100644 --- a/tour/all.go +++ b/tour/all.go @@ -1,6 +1,9 @@ package tour -import "sort" +import ( + "fmt" + "sort" +) func init() { for _, t := range allTopics { @@ -11,20 +14,33 @@ func init() { sort.Sort(IDSlice(IDs)) } +var ( + Introduction = Chapter(0) + FileBasics = Chapter(1) + NodeBasics = Chapter(2) + MerkleDag = Chapter(3) + Network = Chapter(4) + Daemon = Chapter(5) + Routing = Chapter(6) + Exchange = Chapter(7) + Ipns = Chapter(8) + Mounting = Chapter(9) + Plumbing = Chapter(10) + Formats = Chapter(11) +) + // Topics contains a mapping of Tour Topic ID to Topic var allTopics = []Topic{ - Topic{ID: ID("0.0"), Content: IntroHelloMars}, - Topic{ID: ID("0.1"), Content: IntroTour}, - Topic{ID: ID("0.2"), Content: IntroAboutIpfs}, + Topic{ID: Introduction(0), Content: IntroHelloMars}, + Topic{ID: Introduction(1), Content: IntroTour}, + Topic{ID: Introduction(2), Content: IntroAboutIpfs}, - // File Basics - Topic{ID: ID("X.0"), Content: FileBasicsFilesystem}, - Topic{ID: ID("X.1"), Content: FileBasicsGetting}, - Topic{ID: ID("X.2"), Content: FileBasicsAdding}, - Topic{ID: ID("X.3"), Content: FileBasicsDirectories}, - Topic{ID: ID("X.3"), Content: FileBasicsDirectories}, - Topic{ID: ID("X.4"), Content: FileBasicsMounting}, - Topic{ID: ID("X.2"), Content: FileBasicsAdding}, + Topic{ID: FileBasics(1), Content: FileBasicsFilesystem}, + Topic{ID: FileBasics(2), Content: FileBasicsGetting}, + Topic{ID: FileBasics(3), Content: FileBasicsAdding}, + Topic{ID: FileBasics(4), Content: FileBasicsDirectories}, + Topic{ID: FileBasics(5), Content: FileBasicsDistributed}, + Topic{ID: FileBasics(6), Content: FileBasicsMounting}, } // Introduction @@ -77,3 +93,9 @@ var FileBasicsMounting = Content{ Text: `ipfs mount (simple) `, } + +func Chapter(number int) func(topic int) ID { + return func(topic int) ID { + return ID(fmt.Sprintf("%d.%d", number, topic)) + } +}