origen 0.7.6 → 0.7.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 273cd4ec500be111fe541e1bd647d1d4a5d33116
4
- data.tar.gz: 8aa30d894b3822c2b7475bdb6c87c94a75107e4e
3
+ metadata.gz: 55a0a4e8ad4368f828c29d55fcbd1e2c533276f7
4
+ data.tar.gz: 4a894872729fbb79801e9c98cb5d9e6cf7f2fc26
5
5
  SHA512:
6
- metadata.gz: 9ff01e3074e12fb22bfe92f41fd9f740436978708c583c6a05d3cbdd7004e80d82ff1ad73e6157ef7f996df25a07799798f98fb8b855f53b8676184178b6c39e
7
- data.tar.gz: bff1eb0b296d486b59232cf5d3a3ae6cefaf537ffcacfa903bd6a945a5f3b6c2e0d6206b648c4c8acebdaf86e4e5c05114450cfba78ccdd93b442d41416bd004
6
+ metadata.gz: 0be4fa923fbb1c97519f13c20a82b106cbf7bbeae07646e6a26bca64b6abd9df5fee15ee97452e54461998d48742423f56e44aa6d970b7119928c238f0395680
7
+ data.tar.gz: 39a0a321e38e7e1ff2f3acb953816428e57f6c961d0f4eace51678c6a54ab9c8dab6b6659c18a5ecaa02a65baaef4af35061a61b648af1734c6ce5c4dcb4634e
@@ -1,7 +1,7 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
3
  MINOR = 7
4
- BUGFIX = 6
4
+ BUGFIX = 7
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
@@ -10,8 +10,9 @@ class SearchFilter < Nanoc::Filter
10
10
  url = assigns[:item_rep].path
11
11
  #first_image = doc.xpath('//img/@src').to_a[0]
12
12
  document = {
13
- title: extract_first(doc, '//article//*[self::h1 or self::h2]/text()'),
14
- subtitle: extract_first(doc, '//article//*[self::h3]/text()'),
13
+ # See this next time you need to fix this: https://gist.github.com/LeCoupa/8c305ec8c713aad07b14
14
+ title: extract_first(doc, '//article/*/h1 | //article/*/h2 | //article/h1 | //article/h2'),
15
+ subtitle: extract_first(doc, '//article/*/h3 | //article/h3'),
15
16
  body: extract_all(doc, '//article//*/text()'),
16
17
  #img: (first_image.nil?) ? '' : first_image.value(),
17
18
  #alt: extract_values(doc, '//article//img/@alt')
@@ -25,46 +25,65 @@ $.getJSON("<%= path '' %>" + "/" + search_json, function(json) {
25
25
  });
26
26
 
27
27
  $(function() {
28
- $("#search button").click(function() {
28
+ $("#search button").click(function(e) {
29
29
  search(true);
30
+ return false;
30
31
  });
31
32
  $("#search input").keypress(function(e) {
32
- if(e.which == 13) {
33
+ if(e.which === 13) {
33
34
  e.preventDefault();
34
35
  search(false);
36
+ return false;
35
37
  }
36
38
  });
37
39
  })
38
40
 
39
41
  function search(go) {
40
- var term = $("#search input").val();
41
- // Wait for search index to populate
42
- while (!window.index) {};
43
- var results = window.index.search(term);
42
+ // If the search index has populated
43
+ if (window.index) {
44
+ var term = $("#search input").val();
45
+ var results = window.index.search(term);
44
46
 
45
- if(results && results.length == 1) {
46
- window.location.replace("<%= path "" %>" + results[0].ref + "?highlight=" + escape(term));
47
- } else if(results && results.length > 1) {
48
- if (go) {
49
- window.location.replace("<%= path "" %>" + results[0].ref + "?highlight=" + escape(term));
47
+ if(results && results.length === 1) {
48
+ window.location = "<%= path "" %>" + results[0].ref + "?highlight=" + escape(term);
49
+ } else if(results && results.length > 1) {
50
+ if (go) {
51
+ window.location = "<%= path "" %>" + results[0].ref + "?highlight=" + escape(term);
52
+ } else {
53
+ displayResults(results, term);
54
+ }
50
55
  } else {
51
- displayResults(results, term);
56
+ alert("Found nothing");
52
57
  }
53
58
  } else {
54
- alert("Found nothing");
59
+ // Otherwise try again in 200ms
60
+ setTimeout(search(go), 200);
55
61
  }
56
62
  }
57
63
 
58
64
  function displayResults(results, term) {
59
65
  var resultTemplate = $("search-view-template");
60
- var container = $("article");
66
+ var container = $(".search-results");
67
+ if (!container[0]) {
68
+ // Fall back to original behavior
69
+ container = $("article");
70
+ }
61
71
 
62
72
  container.empty();
63
- container.append("<h2>Results</h2>");
73
+ container.append("<h2>Search Results</h2>");
64
74
 
65
75
  $.each(results, function(i, result) {
66
76
  var article = window.articles[result.ref];
67
- container.append("<p><a href=\"<%= path "" %>" + result.ref + "?highlight=" + escape(term) + "\">" + article.title + " - " + article.subtitle + "</a></p>");
77
+ var text = article.title;
78
+ if (article.subtitle) {
79
+ if (text) {
80
+ text = text + " - " + article.subtitle;
81
+ } else {
82
+ text = article.subtitle;
83
+ }
84
+ }
85
+
86
+ container.append("<p><a href=\"<%= path "" %>" + result.ref + "?highlight=" + escape(term) + "\">" + text + "</a></p>");
68
87
  });
69
88
  }
70
89
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty