forked from meteor/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoc.js
More file actions
155 lines (151 loc) · 4.22 KB
/
toc.js
File metadata and controls
155 lines (151 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
var section = function (title, options) {
return _.extend({}, {
type: "section",
title: title,
}, options);
};
var item = function (name, options) {
if (! options) {
options = {
longname: name
};
}
return _.extend({}, {
type: "item",
name: name
}, options);
};
var sections = [
section("", {
subsections: [
section("Quick Start", {
id: "quickstart"
}),
section("Learning Resources", {
id: "learning-resources"
}),
section("Command Line Tool", {
id: "command-line"
}),
section("File Structure", {
id: "filestructure"
}),
section("Building Mobile Apps", {
id: "buildingmobileapps"
})
]
}),
section("Templates", {
id: "templates",
subtitle: "Create views that update automatically when data changes",
items: [
item("Defining templates in HTML", {id: "defining-templates"}),
item("Template.<em>name</em>.helpers", {longname: "Template#helpers"}),
item("Template.<em>name</em>.events", {longname: "Template#events"}),
item("Template.<em>name</em>.onRendered", {longname: "Template#onRendered"}),
item("<em>template</em>.findAll", {longname: "Blaze.TemplateInstance#findAll"}),
item("<em>template</em>.find", {longname: "Blaze.TemplateInstance#find"})
]
}),
section("Session", {
id: "session",
subtitle: "Store temporary data for the user interface",
items: [
item("Session.set"),
item("Session.get")
]
}),
section("Tracker", {
id: "tracker",
subtitle: "Re-run functions when data changes",
items: [
item("Tracker.autorun")
]
}),
section("Collections", {
id: "collections",
subtitle: "Store persistent data",
items: [
item("Mongo.Collection"),
item("<em>collection</em>.findOne", {longname: "Mongo.Collection#findOne"}),
item("<em>collection</em>.find", {longname: "Mongo.Collection#find"}),
item("<em>collection</em>.insert", {longname: "Mongo.Collection#insert"}),
item("<em>collection</em>.update", {longname: "Mongo.Collection#update"}),
item("<em>collection</em>.remove", {longname: "Mongo.Collection#remove"}),
item("<em>collection</em>.allow", {longname: "Mongo.Collection#allow"}),
item("<em>collection</em>.deny", {longname: "Mongo.Collection#deny"}),
]
}),
section("Accounts", {
id: "accounts",
subtitle: "Let users log in with passwords, Facebook, Google, GitHub, etc.",
items: [
item("{{> loginButtons}}", {id: "loginButtons"}),
item("Meteor.user"),
item("Meteor.userId"),
item("Meteor.users"),
item("{{currentUser}}", {longname: "currentUser"})
]
}),
section("Methods", {
id: "methods",
subtitle: "Call server functions from the client",
items: [
item("Meteor.methods"),
item("Meteor.call"),
item("Meteor.Error")
]
}),
section("Publish / Subscribe", {
id: "pubsub",
subtitle: "Sync part of your data to the client",
items: [
item("Meteor.publish"),
item("Meteor.subscribe")
]
}),
section("Environment", {
id: "environment",
subtitle: "Control when and where your code runs",
items: [
item("Meteor.isClient"),
item("Meteor.isServer"),
item("Meteor.startup")
]
}),
section("Packages", {
id: "packages",
subtitle: "Choose from thousands of community packages",
items: [
item("Searching for packages", {id: "searchingforpackages"}),
item("accounts-ui", {id: "accountsui"}),
item("coffeescript"),
item("email"),
item("jade"),
item("jquery"),
item("http"),
item("less"),
item("markdown"),
item("underscore"),
item("spiderable")
]
})
];
var linkPrefix = "#/basic/";
var linkFromIdLongname = function (id, longname) {
if (id) {
return linkPrefix + id;
} else if (longname) {
return linkPrefix + longname.replace(/[#.]/g, "-");
}
};
Template.basicTableOfContents.helpers({
sections: sections,
linkForItem: function () {
return linkFromIdLongname(this.id, this.longname);
},
maybeCurrent: function () {
return Session.get('urlHash') === linkFromIdLongname(this.id, this.longname)
? 'current' : '';
}
});