gitdocs 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -1
- data/lib/gitdocs/manager.rb +2 -1
- data/lib/gitdocs/public/css/app.css +2 -0
- data/lib/gitdocs/public/js/app.js +1 -0
- data/lib/gitdocs/public/js/util.js +17 -0
- data/lib/gitdocs/runner.rb +2 -2
- data/lib/gitdocs/version.rb +1 -1
- data/lib/gitdocs/views/search.haml +13 -10
- metadata +1 -1
data/CHANGELOG
CHANGED
data/lib/gitdocs/manager.rb
CHANGED
@@ -16,7 +16,8 @@ module Gitdocs
|
|
16
16
|
results = {}
|
17
17
|
@runners.each_with_index do |runner, index|
|
18
18
|
descriptor = RepoDescriptor.new(runner.root, index)
|
19
|
-
|
19
|
+
repo_results = runner.search(term)
|
20
|
+
results[descriptor] = repo_results unless repo_results.empty?
|
20
21
|
end
|
21
22
|
results
|
22
23
|
end
|
@@ -16,6 +16,23 @@ Utils = {
|
|
16
16
|
}
|
17
17
|
};
|
18
18
|
|
19
|
+
// Strings
|
20
|
+
StringFormatter = {
|
21
|
+
// autolink text within a plain text file
|
22
|
+
// apply to the wrapper around any text (.autolink)
|
23
|
+
autoLink : function() {
|
24
|
+
$('.autolink:not(.linked)').each(function(index, item) {
|
25
|
+
var result = $(item).html().toString() + ' ';
|
26
|
+
$(result.match(/(https?.*?)[^<\s]*/gm)).each(function(index, linkString) {
|
27
|
+
var link = "<a href='" + linkString + "' target='_blank'>" + linkString + "</a>";
|
28
|
+
result = result.replace(linkString, link);
|
29
|
+
$(item).addClass('linked');
|
30
|
+
});
|
31
|
+
$(item).html(result.slice(0, -1));
|
32
|
+
});
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
19
36
|
// DATES
|
20
37
|
// RelativeDate.time_ago_in_words(date)
|
21
38
|
var RelativeDate = {
|
data/lib/gitdocs/runner.rb
CHANGED
@@ -14,8 +14,8 @@ module Gitdocs
|
|
14
14
|
SearchResult = Struct.new(:file, :context)
|
15
15
|
def search(term)
|
16
16
|
results = []
|
17
|
-
sh_string("git grep #{ShellTools.escape(term)}")
|
18
|
-
results << SearchResult.new(file, context)
|
17
|
+
if result_test = sh_string("git grep #{ShellTools.escape(term)}")
|
18
|
+
result_test.scan(/(.*?):([^\n]*)/) { |(file, context)| results << SearchResult.new(file, context) }
|
19
19
|
end
|
20
20
|
results
|
21
21
|
end
|
data/lib/gitdocs/version.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
- @title = "Matches for #{request.params['q'].inspect}"
|
2
2
|
|
3
3
|
.results{ "data-query" => request.params['q'] }
|
4
|
-
- results.
|
5
|
-
%h2
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
-if results.empty?
|
5
|
+
%h2 No results
|
6
|
+
-else
|
7
|
+
- results.each do |repo, search_results|
|
8
|
+
%h2= repo.name
|
9
|
+
%dl
|
10
|
+
- search_results.each do |res|
|
11
|
+
%dt
|
12
|
+
%a{:href => "/#{repo.index}/#{res.file}"}
|
13
|
+
= "/#{res.file}"
|
14
|
+
%dd
|
15
|
+
= res.context
|
13
16
|
|
14
|
-
%script{ :src => "/js/search.js", :type => "text/javascript", :charset => "utf-8" }
|
17
|
+
%script{ :src => "/js/search.js", :type => "text/javascript", :charset => "utf-8" }
|