passages 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -2
- data/app/assets/javascripts/passages/application.js +45 -14
- data/app/controllers/passages/routes_controller.rb +3 -1
- data/config/initializers/basic_auth.rb +9 -1
- data/demo.gif +0 -0
- data/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91ad2eb2bfd8de3cb90f430b52679748b6458249
|
4
|
+
data.tar.gz: 2dc1db09ec74c6815f2d5b5b3c236d714b952ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aab33a5ca1ade95fa46865311fd94d9f4bae52fb2079a3dbb78df90ad7a99879e0ba2edba6542fd92c2693b344f234acba823273734cc261253806319673989
|
7
|
+
data.tar.gz: bd078de0461d8dd8367848ebd25a6fdcafd8c19f270282edcf693dd2c348a8563f9518aff855e6cfd6b1f64d3dfdd5a5c25423b8addedc2a0536fe673d84dc49
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,10 @@ This Rails Engine adds the ability to search over different attributes of Ruby o
|
|
8
8
|
|
9
9
|
For example, an internal (or very permissive external) API can now expose a single page that will answer simple questions like: *"What was the HTTP verb for the `/users/clear_password` route?"* or *"Does a v2 or v3 version for this route exist?"*.
|
10
10
|
|
11
|
+
## Demo
|
12
|
+
|
13
|
+
![Demo](demo.gif)
|
14
|
+
|
11
15
|
## Install
|
12
16
|
|
13
17
|
In your `Gemfile`
|
@@ -19,13 +23,13 @@ gem 'passages'
|
|
19
23
|
|
20
24
|
`bundle install`
|
21
25
|
|
22
|
-
The `Passages` engine will **prepend** a `/passages` route to the application's routes.
|
26
|
+
The `Passages` engine will **prepend** a `/passages` route to the application's routes. This means that if a project's `routes.rb` specifically defines a `/passages` route, the `Passages` Engine will not overwrite that.
|
23
27
|
|
24
28
|
Visiting `/passages` will display a search box and list of all known routes in an application.
|
25
29
|
|
26
30
|
## Authorization
|
27
31
|
|
28
|
-
Since there
|
32
|
+
Since there are no environment dependent checks, the `/passages` page uses configurable http basic authentication.
|
29
33
|
|
30
34
|
Default username: **username**
|
31
35
|
|
@@ -1,13 +1,36 @@
|
|
1
1
|
//= require jquery-2.1.4.min
|
2
2
|
|
3
|
-
|
3
|
+
var Highlighter = {
|
4
|
+
highlight: function(result, terms) {
|
5
|
+
$.each(terms.split(' '), function(index, term) {
|
6
|
+
if(term.length > 0 ) {
|
7
|
+
$.each(result.find('td'), function(index, element) {
|
8
|
+
if ($(element).find('span').length == 0){
|
9
|
+
var existingHtml = $(element).html();
|
10
|
+
var replacedHtml = existingHtml.replace(new RegExp("(" + term + ")", "i"), "<span class='highlighted'>$1</span>");
|
11
|
+
$(element).html(replacedHtml);
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
$.each($('element').contents(), function(index, content) {
|
15
|
+
if(content.nodeType == 3) { // nodeType == 3 means it is not a child node
|
16
|
+
$(content).html($(content).html().replace(new RegExp("(" + term + ")", "i"), "<span class='highlighted'>$1</span>"));
|
17
|
+
}
|
18
|
+
});
|
19
|
+
}
|
20
|
+
});
|
21
|
+
}
|
22
|
+
});
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
DomElement = {
|
4
27
|
matchingTerm: 'table.matching-term'
|
5
28
|
};
|
6
29
|
|
7
30
|
function clearAndHideResultTable() {
|
8
31
|
var header = $('table.matching-term .header');
|
9
|
-
$(
|
10
|
-
$(
|
32
|
+
$(DomElement.matchingTerm).html(header);
|
33
|
+
$(DomElement.matchingTerm).hide();
|
11
34
|
}
|
12
35
|
|
13
36
|
function hideNoResults() {
|
@@ -20,28 +43,36 @@ function showNoResults(searchTerm) {
|
|
20
43
|
|
21
44
|
function showResultTable() {
|
22
45
|
hideNoResults();
|
23
|
-
$(
|
46
|
+
$(DomElement.matchingTerm).show();
|
24
47
|
}
|
25
48
|
|
26
49
|
function searchResults(query) {
|
27
50
|
clearAndHideResultTable();
|
28
|
-
|
29
|
-
|
51
|
+
var terms = query.split(' ');
|
52
|
+
var parents = [];
|
30
53
|
|
31
|
-
function
|
32
|
-
|
33
|
-
|
34
|
-
|
54
|
+
$.each(terms, function(index, el) {
|
55
|
+
if (parents.length == 0) {
|
56
|
+
parents = $('[data-search*=' + el + ']').parent('tr');
|
57
|
+
}
|
58
|
+
else if(el.length > 0) {
|
59
|
+
$.each(parents, function(index, parent) {
|
60
|
+
if($(parent).find($('[data-search*=' + el + ']')).length == 0) {
|
61
|
+
parents[index] = null;
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
return parents
|
35
68
|
}
|
36
69
|
|
37
|
-
function addToResultTable(result,
|
70
|
+
function addToResultTable(result, searchTerms){
|
38
71
|
showResultTable();
|
39
72
|
var table = $('.matching-term');
|
40
73
|
var lastChild = table.find('tr:last');
|
41
74
|
|
42
|
-
|
43
|
-
highlight(element, searchTerm);
|
44
|
-
});
|
75
|
+
Highlighter.highlight(result, searchTerms);
|
45
76
|
|
46
77
|
if(lastChild.length == 0) {
|
47
78
|
table.html(result);
|
@@ -6,7 +6,9 @@ require 'passages/engine_route_collection'
|
|
6
6
|
|
7
7
|
module Passages
|
8
8
|
class RoutesController < ActionController::Base
|
9
|
-
|
9
|
+
unless Passages.no_auth?
|
10
|
+
http_basic_authenticate_with name: Passages.username, password: Passages.password
|
11
|
+
end
|
10
12
|
|
11
13
|
layout false
|
12
14
|
|
@@ -7,5 +7,13 @@ module Passages
|
|
7
7
|
ENV['passages_password'] || 'password'
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
def no_auth=(no_auth)
|
11
|
+
@no_auth = no_auth
|
12
|
+
end
|
13
|
+
|
14
|
+
def no_auth?
|
15
|
+
@no_auth.nil? || @no_auth
|
16
|
+
end
|
17
|
+
|
18
|
+
module_function :username, :password, :no_auth=, :no_auth?
|
11
19
|
end
|
data/demo.gif
ADDED
Binary file
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Yesbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- config/initializers/assets.rb
|
62
62
|
- config/initializers/basic_auth.rb
|
63
63
|
- config/routes.rb
|
64
|
+
- demo.gif
|
64
65
|
- lib/passages.rb
|
65
66
|
- lib/passages/engine.rb
|
66
67
|
- lib/passages/engine_route.rb
|