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 CHANGED
@@ -3,4 +3,8 @@
3
3
  * Adds a basic search to web front-end
4
4
  * Beginning of the work towards cross-platform notifications
5
5
 
6
- 0.4.2 (Not yet released)
6
+ 0.4.2 (12/13/2012)
7
+
8
+ * Fixes search on blank results case
9
+
10
+ 0.4.3 (Not Yet Released)
@@ -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
- results[descriptor] = runner.search(term)
19
+ repo_results = runner.search(term)
20
+ results[descriptor] = repo_results unless repo_results.empty?
20
21
  end
21
22
  results
22
23
  end
@@ -2,6 +2,8 @@ body {
2
2
  padding-top: 50px;
3
3
  }
4
4
 
5
+ .contents a { color: inherit; }
6
+
5
7
  .inline-file {
6
8
  width:100%;
7
9
  min-height: 600px;
@@ -27,6 +27,7 @@ GitDocs = {
27
27
  $(document).ready(function() {
28
28
  GitDocs.linkBreadcrumbs();
29
29
  GitDocs.fillDirMeta();
30
+ StringFormatter.autoLink();
30
31
  });
31
32
 
32
33
  // Redirect to edit page for new file when new file form is submitted
@@ -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 = {
@@ -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)}").scan(/(.*?):([^\n]*)/) do |(file, context)|
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
@@ -1,3 +1,3 @@
1
1
  module Gitdocs
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -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.each do |repo, search_results|
5
- %h2= repo.name
6
- %dl
7
- - search_results.each do |res|
8
- %dt
9
- %a{:href => "/#{repo.index}/#{res.file}"}
10
- = "/#{res.file}"
11
- %dd
12
- = res.context
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" }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gitdocs
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.1
5
+ version: 0.4.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Hull