forked from sourcegraph/zoekt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
134 lines (113 loc) · 3 KB
/
Copy pathapi.go
File metadata and controls
134 lines (113 loc) · 3 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
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package web
import (
"time"
"github.com/sourcegraph/zoekt"
)
type ApiSearchResult struct {
Result *ResultInput `json:"result,omitempty"`
Repos *RepoListInput `json:"repos,omitempty"`
}
type LastInput struct {
Query string
Num int
Ctx int
// If set, focus on the search box.
AutoFocus bool
// If true, the next search will run in debug mode.
Debug bool
}
// Result holds the data provided to the search results template.
type ResultInput struct {
Last LastInput
QueryStr string
Query string
Stats zoekt.Stats
Duration time.Duration
FileMatches []*FileMatch
}
// FileMatch holds the per file data provided to search results template
type FileMatch struct {
FileName string
Repo string
ResultID string
Language string
// If this was a duplicate result, this will contain the file
// of the first index.
DuplicateID string
Branches []string
Matches []Match
URL string
// Don't expose to caller of JSON API
Score float64 `json:"-"`
ScoreDebug string `json:"-"`
}
// Match holds the per line data provided to the search results template
type Match struct {
URL string
FileName string
LineNum int
Fragments []Fragment
Before string `json:",omitempty"`
After string `json:",omitempty"`
// Don't expose to caller of JSON API
Score float64 `json:"-"`
ScoreDebug string `json:"-"`
}
// Fragment holds data of a single contiguous match within in a line
// for the results template.
type Fragment struct {
Pre string
Match string
Post string
}
// SearchBoxInput is provided to the SearchBox template.
type SearchBoxInput struct {
Last LastInput
Stats *zoekt.RepoStats
Version string
Uptime time.Duration
}
// RepoListInput is provided to the RepoList template.
type RepoListInput struct {
Last LastInput
Stats zoekt.RepoStats
Repos []Repository
}
// Branch holds the metadata for a indexed branch.
type Branch struct {
Name string
Version string
URL string
}
// Repository holds the metadata for an indexed repository.
type Repository struct {
Name string
URL string
IndexTime time.Time
Branches []Branch
Files int64
Metadata map[string]string
// Total amount of content bytes.
Size int64
// Total resident RAM usage in bytes.
MemorySize int64
}
// PrintInput is provided to the server.Print template.
type PrintInput struct {
Repo, Name string
Lines []string
Last LastInput
}