LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/json" | 9 "encoding/json" |
10 "flag" | 10 "flag" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 showTimestamps = flag.Bool("timestamps", false, "show timestamps with di
rectory listings") | 64 showTimestamps = flag.Bool("timestamps", false, "show timestamps with di
rectory listings") |
65 templateDir = flag.String("templates", "", "directory containing alte
rnate template files") | 65 templateDir = flag.String("templates", "", "directory containing alte
rnate template files") |
66 | 66 |
67 // search index | 67 // search index |
68 indexEnabled = flag.Bool("index", false, "enable search index") | 68 indexEnabled = flag.Bool("index", false, "enable search index") |
69 indexFiles = flag.String("index_files", "", "glob pattern specifying i
ndex files;"+ | 69 indexFiles = flag.String("index_files", "", "glob pattern specifying i
ndex files;"+ |
70 "if not empty, the index is read from these files in sor
ted order") | 70 "if not empty, the index is read from these files in sor
ted order") |
71 maxResults = flag.Int("maxresults", 10000, "maximum number of full te
xt search results shown") | 71 maxResults = flag.Int("maxresults", 10000, "maximum number of full te
xt search results shown") |
72 indexThrottle = flag.Float64("index_throttle", 0.75, "index throttle val
ue; 0.0 = no time allocated, 1.0 = full throttle") | 72 indexThrottle = flag.Float64("index_throttle", 0.75, "index throttle val
ue; 0.0 = no time allocated, 1.0 = full throttle") |
73 | 73 |
74 » // file system mapping | 74 » // file system information |
75 » fs = nameSpace{} // the underlying file system for godoc | 75 » fsTree RWValue // *Directory tree of packages, updated with each sy
nc |
76 » fsTree RWValue // *Directory tree of packages, updated with e
ach sync | 76 » fsModified RWValue // timestamp of last call to invalidateIndex |
77 » fsModified RWValue // timestamp of last call to invalidateIndex | 77 » docMetadata RWValue // mapping from paths to *Metadata |
78 » docMetadata RWValue // mapping from paths to *Metadata | |
79 | 78 |
80 // http handlers | 79 // http handlers |
81 fileServer http.Handler // default file server | 80 fileServer http.Handler // default file server |
82 cmdHandler docServer | 81 cmdHandler docServer |
83 pkgHandler docServer | 82 pkgHandler docServer |
84 ) | 83 ) |
85 | 84 |
86 func initHandlers() { | 85 func initHandlers() { |
87 // Add named directories in -path argument as | 86 // Add named directories in -path argument as |
88 // subdirectories of src/pkg. | 87 // subdirectories of src/pkg. |
(...skipping 21 matching lines...) Expand all Loading... |
110 } | 109 } |
111 | 110 |
112 func initFSTree() { | 111 func initFSTree() { |
113 dir := newDirectory(pathpkg.Join("/", *testDir), -1) | 112 dir := newDirectory(pathpkg.Join("/", *testDir), -1) |
114 if dir == nil { | 113 if dir == nil { |
115 log.Println("Warning: FSTree is nil") | 114 log.Println("Warning: FSTree is nil") |
116 return | 115 return |
117 } | 116 } |
118 fsTree.set(dir) | 117 fsTree.set(dir) |
119 invalidateIndex() | 118 invalidateIndex() |
120 } | |
121 | |
122 // ---------------------------------------------------------------------------- | |
123 // Directory filters | |
124 | |
125 // isParentOf returns true if p is a parent of (or the same as) q | |
126 // where p and q are directory paths. | |
127 func isParentOf(p, q string) bool { | |
128 n := len(p) | |
129 return strings.HasPrefix(q, p) && (len(q) <= n || q[n] == '/') | |
130 } | |
131 | |
132 func initDirTrees() { | |
133 } | 119 } |
134 | 120 |
135 // ---------------------------------------------------------------------------- | 121 // ---------------------------------------------------------------------------- |
136 // Tab conversion | 122 // Tab conversion |
137 | 123 |
138 var spaces = []byte(" ") // 32 spaces seems like
a good number | 124 var spaces = []byte(" ") // 32 spaces seems like
a good number |
139 | 125 |
140 const ( | 126 const ( |
141 indenting = iota | 127 indenting = iota |
142 collecting | 128 collecting |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 updateIndex() | 1389 updateIndex() |
1404 } | 1390 } |
1405 delay := 60 * time.Second // by default, try every 60s | 1391 delay := 60 * time.Second // by default, try every 60s |
1406 if *testDir != "" { | 1392 if *testDir != "" { |
1407 // in test mode, try once a second for fast startup | 1393 // in test mode, try once a second for fast startup |
1408 delay = 1 * time.Second | 1394 delay = 1 * time.Second |
1409 } | 1395 } |
1410 time.Sleep(delay) | 1396 time.Sleep(delay) |
1411 } | 1397 } |
1412 } | 1398 } |
LEFT | RIGHT |