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 32 // If set, focus on the search box. 33 AutoFocus bool 34 35 // If true, the next search will run in debug mode. 36 Debug bool 37} 38 39// Result holds the data provided to the search results template. 40type ResultInput struct { 41 Last LastInput 42 QueryStr string 43 Query string 44 Stats zoekt.Stats 45 Duration time.Duration 46 FileMatches []*FileMatch 47} 48 49// FileMatch holds the per file data provided to search results template 50type FileMatch struct { 51 FileName string 52 Repo string 53 ResultID string 54 Language string 55 // If this was a duplicate result, this will contain the file 56 // of the first match. 57 DuplicateID string 58 59 Branches []string 60 Matches []Match 61 URL string 62 63 // Don't expose to caller of JSON API 64 Score float64 `json:"-"` 65 ScoreDebug string `json:"-"` 66} 67 68// Match holds the per line data provided to the search results template 69type Match struct { 70 URL string 71 FileName string 72 LineNum int 73 74 Fragments []Fragment 75 Before string `json:",omitempty"` 76 After string `json:",omitempty"` 77 78 // Don't expose to caller of JSON API 79 Score float64 `json:"-"` 80 ScoreDebug string `json:"-"` 81} 82 83// Fragment holds data of a single contiguous match within in a line 84// for the results template. 85type Fragment struct { 86 Pre string 87 Match string 88 Post string 89} 90 91// SearchBoxInput is provided to the SearchBox template. 92type SearchBoxInput struct { 93 Last LastInput 94 Stats *zoekt.RepoStats 95 Version string 96 Uptime time.Duration 97} 98 99// RepoListInput is provided to the RepoList template. 100type RepoListInput struct { 101 Last LastInput 102 Stats zoekt.RepoStats 103 Repos []Repository 104} 105 106// Branch holds the metadata for a indexed branch. 107type Branch struct { 108 Name string 109 Version string 110 URL string 111} 112 113// Repository holds the metadata for an indexed repository. 114type Repository struct { 115 Name string 116 URL string 117 IndexTime time.Time 118 Branches []Branch 119 Files int64 120 121 // Total amount of content bytes. 122 Size int64 123 // Total resident RAM usage in bytes. 124 MemorySize int64 125} 126 127// PrintInput is provided to the server.Print template. 128type PrintInput struct { 129 Repo, Name string 130 Lines []string 131 Last LastInput 132}