fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

1// Copyright 2016 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package web 16 17import ( 18 "time" 19 20 "github.com/sourcegraph/zoekt" 21) 22 23type ApiSearchResult struct { 24 Result *ResultInput `json:"result,omitempty"` 25 Repos *RepoListInput `json:"repos,omitempty"` 26} 27 28type LastInput struct { 29 Query string 30 Num int 31 Ctx int 32 33 // If set, focus on the search box. 34 AutoFocus bool 35 36 // If true, the next search will run in debug mode. 37 Debug bool 38} 39 40// Result holds the data provided to the search results template. 41type ResultInput struct { 42 Last LastInput 43 QueryStr string 44 Query string 45 Stats zoekt.Stats 46 Duration time.Duration 47 FileMatches []*FileMatch 48} 49 50// FileMatch holds the per file data provided to search results template 51type FileMatch struct { 52 FileName string 53 Repo string 54 ResultID string 55 Language string 56 // If this was a duplicate result, this will contain the file 57 // of the first match. 58 DuplicateID string 59 60 Branches []string 61 Matches []Match 62 URL string 63 64 // Don't expose to caller of JSON API 65 Score float64 `json:"-"` 66 ScoreDebug string `json:"-"` 67} 68 69// Match holds the per line data provided to the search results template 70type Match struct { 71 URL string 72 FileName string 73 LineNum int 74 75 Fragments []Fragment 76 Before string `json:",omitempty"` 77 After string `json:",omitempty"` 78 79 // Don't expose to caller of JSON API 80 Score float64 `json:"-"` 81 ScoreDebug string `json:"-"` 82} 83 84// Fragment holds data of a single contiguous match within in a line 85// for the results template. 86type Fragment struct { 87 Pre string 88 Match string 89 Post string 90} 91 92// SearchBoxInput is provided to the SearchBox template. 93type SearchBoxInput struct { 94 Last LastInput 95 Stats *zoekt.RepoStats 96 Version string 97 Uptime time.Duration 98} 99 100// RepoListInput is provided to the RepoList template. 101type RepoListInput struct { 102 Last LastInput 103 Stats zoekt.RepoStats 104 Repos []Repository 105} 106 107// Branch holds the metadata for a indexed branch. 108type Branch struct { 109 Name string 110 Version string 111 URL string 112} 113 114// Repository holds the metadata for an indexed repository. 115type Repository struct { 116 Name string 117 URL string 118 IndexTime time.Time 119 Branches []Branch 120 Files int64 121 122 // Total amount of content bytes. 123 Size int64 124 // Total resident RAM usage in bytes. 125 MemorySize int64 126} 127 128// PrintInput is provided to the server.Print template. 129type PrintInput struct { 130 Repo, Name string 131 Lines []string 132 Last LastInput 133}