Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull custom hound fork forward #3

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $(GOPATH)/bin/hound: ui/bindata.go $(SRCS)
go install github.com/hound-search/hound/cmds/hound

.build/bin/go-bindata:
GOPATH=`pwd`/.build go get github.com/go-bindata/go-bindata/...
GOPATH=`pwd`/.build go install github.com/go-bindata/go-bindata/...

ui/bindata.go: .build/bin/go-bindata node_modules $(wildcard ui/assets/**/*)
rsync -r ui/assets/* .build/ui
Expand All @@ -37,7 +37,7 @@ test:

lint:
export GO111MODULE=on
go get github.com/golangci/golangci-lint/cmd/golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint
export GOPATH=/tmp/gopath
export PATH=$GOPATH/bin:$PATH
golangci-lint run ./...
Expand Down
29 changes: 29 additions & 0 deletions ui/assets/css/hound.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ button:focus {
margin-right: 10px;
}

#result > .actions {
padding: 5px 0 30px 0;
}

#result > .actions > button {
margin: 2px;
float: right;
background-color: #f5f5f5;
color: #666;
}
.repo {
margin-bottom: 100px;
}
Expand All @@ -227,6 +237,7 @@ button:focus {
color: #666;
font-size: 24px;
padding-bottom: 5px;
cursor: pointer;
}

.repo > .title > .name {
Expand All @@ -238,6 +249,11 @@ button:focus {
margin-right: 10px;
}

.repo > .title > .indicator {
vertical-align: text-top;
padding-left: 10px;
}

.files > .moar {
height: 55px;
vertical-align: top;
Expand All @@ -250,11 +266,16 @@ button:focus {
border: 1px solid #d8d8d8;
}

.file.closed {
margin: 10px 0 0 0;
}

.file > .title {
padding: 10px 10px 10px 20px;
display: block;
line-height: 30px;
background-color: #f5f5f5;
cursor: pointer;
}

.title a {
Expand All @@ -266,6 +287,14 @@ button:focus {
overflow: auto;
}

.file.closed > .file-body {
display: none;
}

.file.open > .file-boby {
display: block;
}

.match {
border-bottom: 2px solid #f0f0f0;
}
Expand Down
Binary file added ui/assets/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/assets/index.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>{{ .Title }}</title>
<link rel="shortcut icon" type="image/png" href="images/favicon.png" />
<link rel="stylesheet" href="css/octicons/octicons.css">
<link rel="stylesheet" href="css/hound.css">
<link rel="search" href="//{{ .Host }}/open_search.xml"
Expand Down
22 changes: 12 additions & 10 deletions ui/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function UrlToRepo(repo, path, line, rev) {
var url = repo.url.replace(/\.git$/, ''),
pattern = repo['url-pattern'],
filename = path.substring(path.lastIndexOf('/') + 1),
anchor = line ? ExpandVars(pattern.anchor, { line : line, filename : filename }) : '';
anchor = line ? ExpandVars(pattern.anchor, { line : line, filename : filename, repo : repo }) : '';

// Determine if the URL passed is a GitHub wiki
var wikiUrl = /\.wiki$/.exec(url);
Expand All @@ -19,16 +19,18 @@ export function UrlToRepo(repo, path, line, rev) {
anchor = '' // wikis do not support direct line linking
}

// Hacky solution to fix _some more_ of the 404's when using SSH style URLs.
// This works for both github style URLs (git@github.com:username/Foo.git) and
// bitbucket style URLs (ssh://hg@bitbucket.org/username/Foo).
// Check for ssh:// and hg:// protocol URLs
// match the protocol, optionally a basic auth indicator, a
// hostname, optionally a port, and then a path
var ssh_protocol = /^(git|hg|ssh):\/\/([^@\/]+@)?([^:\/]+)(:[0-9]+)?\/(.*)/.exec(url);

// Regex explained: Match either `git` or `hg` followed by an `@`.
// Next, slurp up the hostname by reading until either a `:` or `/` is found.
// Finally, grab all remaining characters.
var sshParts = /(git|hg)@(.*?)(:|\/)(.*)/.exec(url);
if (sshParts) {
url = '//' + sshParts[2] + '/' + sshParts[4];
// Check for bare git+ssh URIs (e.g., user@hostname:path
var bare_ssh = /^([^@]+)@([^:]+):(.*)/.exec(url);

if (ssh_protocol) {
url = '//' + ssh_protocol[3] + '/' + ssh_protocol[5];
} else if (bare_ssh) {
url = '//' + bare_ssh[2] + '/' + bare_ssh[4];
}

// I'm sure there is a nicer React/jsx way to do this:
Expand Down
161 changes: 128 additions & 33 deletions ui/assets/js/hound.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,61 +668,132 @@ var ContentFor = function(line, regexp) {
return buffer.join('');
};

var FilesView = React.createClass({
onLoadMore: function(event) {
Model.LoadMore(this.props.repo);
var FileContentView = React.createClass({
getInitialState: function() {
return { open: true };
},

render: function() {
var rev = this.props.rev,
repo = this.props.repo,
regexp = this.props.regexp,
matches = this.props.matches,
totalMatches = this.props.totalMatches;
var files = matches.map(function(match, index) {
var filename = match.Filename,
blocks = CoalesceMatches(match.Matches);
toggleContent: function() {
this.state.open ? this.closeContent(): this.openContent();
},
openContent: function() {
this.setState({open: true});
},
closeContent: function() {
this.setState({open: false});
},
render: function () {
var repo = this.props.repo,
rev = this.props.rev,
regexp = this.props.regexp,
fileName = this.props.fileName,
blocks = this.props.blocks;
var matches = blocks.map(function(block) {
var lines = block.map(function(line) {
var content = ContentFor(line, regexp);
return (
<div className="line">
<a href={Model.UrlToRepo(repo, filename, line.Number, rev)}
<a href={Model.UrlToRepo(repo, fileName, line.Number, rev)}
className="lnum"
target="_blank">{line.Number}</a>
<span className="lval" dangerouslySetInnerHTML={{__html:content}} />
</div>
);
});

return (
<div className="match">{lines}</div>
);
});

return (
<div className="file">
<div className="title">
<a href={Model.UrlToRepo(repo, match.Filename, null, rev)}>
{match.Filename}
<div className={"file " + (this.state.open ? 'open' : 'closed')}>
<div className="title" onClick={this.toggleContent}>
<a href={Model.UrlToRepo(repo, fileName, null, rev)}>
{fileName}
</a>
</div>
<div className="file-body">
{matches}
</div>
</div>
);
}
});

var FilesView = React.createClass({
onLoadMore: function(event) {
Model.LoadMore(this.props.repo);
},

render: function() {
var rev = this.props.rev,
repo = this.props.repo,
regexp = this.props.regexp,
matches = this.props.matches,
totalMatches = this.props.totalMatches;

var files = matches.map(function (match, index) {
return <FileContentView ref={"file-"+index}
repo={repo}
rev={rev}
fileName={match.Filename}
blocks={CoalesceMatches(match.Matches)}
regexp={regexp}/>
});


var more = '';
if (matches.length < totalMatches) {
more = (<button className="moar" onClick={this.onLoadMore}>Load all {totalMatches} matches in {Model.NameForRepo(repo)}</button>);
}

return (
<div className="files">
{files}
{more}
{files}
{more}
</div>
);
}
});

var RepoView = React.createClass({
getInitialState: function() {
return { open: true };
},
toggleRepo: function() {
this.state.open ? this.closeRepo(): this.openRepo();
},
openOrCloseRepo: function (to_open) {
for (var ref in this.refs.filesView.refs) {
if (ref.startsWith("file-")) {
if (to_open) {
this.refs.filesView.refs[ref].openContent();
} else {
this.refs.filesView.refs[ref].closeContent();
}
}
}
this.setState({open: to_open});
},
openRepo: function() {
this.openOrCloseRepo(true);
},
closeRepo: function() {
this.openOrCloseRepo(false);
},
render: function() {
return (
<div className={"repo " + (this.state.open? "open":"closed")}>
<div className="title" onClick={this.toggleRepo}>
<span className="mega-octicon octicon-repo"></span>
<span className="name">{Model.NameForRepo(this.props.repo)}</span>
<span className={"indicator octicon octicon-chevron-"+ (this.state.open? "up":"down")} onClick={this.toggleRepo}></span>
</div>
<FilesView ref="filesView"
matches={this.props.matches}
rev={this.props.rev}
repo={this.props.repo}
regexp={this.props.regexp}
totalMatches={this.props.files} />
</div>
);
}
Expand All @@ -738,6 +809,23 @@ var ResultView = React.createClass({
});
});
},
openOrCloseAll: function (to_open) {
for (var ref in this.refs) {
if (ref.startsWith("repo-")) {
if (to_open) {
this.refs[ref].openRepo();
} else {
this.refs[ref].closeRepo();
}
}
}
},
openAll: function () {
this.openOrCloseAll(true);
},
closeAll: function () {
this.openOrCloseAll(false);
},
getInitialState: function() {
return { results: null };
},
Expand Down Expand Up @@ -767,21 +855,28 @@ var ResultView = React.createClass({
results = this.state.results || [];
var repos = results.map(function(result, index) {
return (
<div className="repo">
<div className="title">
<span className="mega-octicon octicon-repo"></span>
<span className="name">{Model.NameForRepo(result.Repo)}</span>
</div>
<FilesView matches={result.Matches}
rev={result.Rev}
repo={result.Repo}
regexp={regexp}
totalMatches={result.FilesWithMatch} />
</div>
<RepoView ref={"repo-"+index}
matches={result.Matches}
rev={result.Rev}
repo={result.Repo}
regexp={regexp}
files={result.FilesWithMatch}/>
);
});
var actions = '';
if (results.length > 0) {
actions = (
<div className="actions">
<button onClick={this.openAll}><span className="octicon octicon-chevron-down"></span> Expand all</button>
<button onClick={this.closeAll}><span className="octicon octicon-chevron-up"></span> Collapse all</button>
</div>
)
}
return (
<div id="result">{repos}</div>
<div id="result">
{actions}
{repos}
</div>
);
}
});
Expand Down
79 changes: 51 additions & 28 deletions ui/bindata.go

Large diffs are not rendered by default.

Loading