coursegen 0.8.3 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pr.yml +19 -0
  3. data/.gitignore +3 -0
  4. data/Gemfile.lock +60 -35
  5. data/README.md +285 -69
  6. data/Rakefile +10 -1
  7. data/coursegen.gemspec +26 -26
  8. data/lib/coursegen.rb +5 -2
  9. data/lib/coursegen/cli.rb +49 -14
  10. data/lib/coursegen/course/data/citem.rb +10 -1
  11. data/lib/coursegen/course/data/data_adaptor.rb +16 -6
  12. data/lib/coursegen/course/data/section.rb +1 -1
  13. data/lib/coursegen/course/helpers/bootstrap_markup.rb +15 -15
  14. data/lib/coursegen/course/helpers/content_helpers.rb +86 -71
  15. data/lib/coursegen/course/helpers/formatting_helpers.rb +6 -10
  16. data/lib/coursegen/course/helpers/ical_feed_helpers.rb +2 -1
  17. data/lib/coursegen/course/helpers/lecture_helpers.rb +3 -2
  18. data/lib/coursegen/course/helpers/list_of.rb +40 -20
  19. data/lib/coursegen/course/helpers/list_of_helpers.rb +20 -14
  20. data/lib/coursegen/course/helpers/logging_helpers.rb +13 -12
  21. data/lib/coursegen/course/helpers/navigation_helpers.rb +62 -23
  22. data/lib/coursegen/course/helpers/sidebar_helpers.rb +19 -18
  23. data/lib/coursegen/course/helpers/table_helpers.rb +5 -4
  24. data/lib/coursegen/course/schedule/scheduler.rb +52 -19
  25. data/lib/coursegen/templates.rb +30 -23
  26. data/lib/coursegen/version.rb +3 -1
  27. data/spec/lectures_spec.rb +60 -50
  28. data/spec/play_spec.rb +24 -12
  29. data/spec/scheduler_spec.rb +87 -27
  30. data/tech_debt.md +5 -0
  31. data/templates/Rules +14 -19
  32. data/templates/cg_config.rb +105 -21
  33. data/templates/content/bootstrap/css/custom.css +87 -151
  34. data/templates/content/bootstrap/css/full-width-pics.css +8 -64
  35. data/templates/content/bootstrap/css/postit.css +7 -0
  36. data/templates/content/bootstrap/css/toasty.css +3 -0
  37. data/templates/content/content/index.md.erb +1 -1
  38. data/templates/content/content/intro/course_toc.md.erb +0 -1
  39. data/templates/content/content/intro/welcome.md.erb +1 -3
  40. data/templates/content/content/lectures/part1/02_here_we_go.md.erb +22 -1
  41. data/templates/content/content/lectures/part2/01_start_part2.md.erb +2 -1
  42. data/templates/content/content/lectures/part2/02_continue_part2.md.erb +3 -2
  43. data/templates/layouts/banner.html.erb +4 -4
  44. data/templates/layouts/body_footer.html +3 -4
  45. data/templates/layouts/body_header.html.erb +25 -7
  46. data/templates/layouts/bottom_includes.html.erb +21 -10
  47. data/templates/layouts/course.html.erb +7 -21
  48. data/templates/layouts/helpful_box.html +1 -1
  49. data/templates/layouts/nav-menus.html.erb +16 -36
  50. data/templates/layouts/sidebar.html.erb +9 -8
  51. data/templates/layouts/slides.html.erb +69 -0
  52. data/templates/layouts/top_includes.html.erb +24 -23
  53. metadata +32 -24
  54. data/.DS_Store +0 -0
  55. data/.vscode/settings.json +0 -2
  56. data/templates/.DS_Store +0 -0
  57. data/templates/Guardfile +0 -9
  58. data/templates/content/bootstrap/css/tipuesearch.css +0 -163
  59. data/templates/content/bootstrap/js/tipuesearch.js +0 -379
  60. data/templates/content/bootstrap/js/tipuesearch.min.js +0 -12
  61. data/templates/content/bootstrap/js/tipuesearch_content.js +0 -13
  62. data/templates/content/bootstrap/js/tipuesearch_set.js +0 -23
  63. data/templates/layouts/main_navbar.html.erb +0 -21
@@ -1,31 +1,32 @@
1
+ <!-- Required meta tags -->
1
2
  <meta charset="utf-8">
2
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
3
- <meta name="viewport" content="width=device-width, initial-scale=1">
4
- <meta name="description" content="">
5
- <meta name="author" content="">
3
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
4
 
7
- <!-- Latest compiled and minified CSS -->
8
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
5
+ <!-- Bootstrap CSS -->
6
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
7
+ integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
9
8
 
10
9
  <!-- Custom CSS -->
11
10
  <link rel="stylesheet" href="/bootstrap/css/custom.css">
12
- <link rel="stylesheet" href="/bootstrap/css/full-width-pics.css" >
13
11
 
14
- <!-- tipueserch -->
15
- <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400">
12
+ <!-- prism pretty source code -->
13
+ <link rel="stylesheet" href="http://prismjs.com/themes/prism-okaidia.css" />
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.0/prism.min.js"></script>
16
15
 
17
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
16
+ <!-- jQuery first, then Popper.js, then Bootstrap JS -->
17
+ <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
18
+ <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
19
+ integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous">
20
+ </script>
18
21
 
19
- <script src="/tipuesearch/tipuesearch_content.js"></script>
20
- <link rel="stylesheet" href="/bootstrap/css/tipuesearch.css">
21
- <script src="/bootstrap/js/tipuesearch_set.js"></script>
22
- <script src="/bootstrap/js/tipuesearch.min.js"></script>
23
- <!-- end tipueserch -->
24
-
25
-
26
- <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
27
- <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
28
- <!--[if lt IE 9]>
29
- <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
30
- <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
31
- <![endif]-->
22
+ <script src="https://kit.fontawesome.com/63b40b4055.js" crossorigin="anonymous"></script>
23
+ <%#
24
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css"
25
+ integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
26
+ %>
27
+ <!-- docsearch -->
28
+ <link
29
+ rel="stylesheet"
30
+ href="https://cdn.jsdelivr.net/npm/docsearch.js@2.6.3/dist/cdn/docsearch.min.css"
31
+ />
32
+ <!-- end docsearch -->
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coursegen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pito Salas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: nanoc
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: thor
70
+ name: adsf
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rubytree
84
+ name: byebug
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: nokogiri
112
+ name: guard
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -109,7 +123,7 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: activesupport
126
+ name: guard-shell
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - ">="
@@ -123,7 +137,7 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: kramdown
140
+ name: icalendar
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
@@ -137,7 +151,7 @@ dependencies:
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
- name: adsf
154
+ name: kramdown
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
@@ -151,7 +165,7 @@ dependencies:
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
- name: guard
168
+ name: nanoc
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - ">="
@@ -165,7 +179,7 @@ dependencies:
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
- name: guard-shell
182
+ name: nokogiri
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
185
  - - ">="
@@ -179,7 +193,7 @@ dependencies:
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
- name: tzinfo
196
+ name: rubytree
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
@@ -193,7 +207,7 @@ dependencies:
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
- name: icalendar
210
+ name: thor
197
211
  requirement: !ruby/object:Gem::Requirement
198
212
  requirements:
199
213
  - - ">="
@@ -207,7 +221,7 @@ dependencies:
207
221
  - !ruby/object:Gem::Version
208
222
  version: '0'
209
223
  - !ruby/object:Gem::Dependency
210
- name: byebug
224
+ name: tzinfo
211
225
  requirement: !ruby/object:Gem::Requirement
212
226
  requirements:
213
227
  - - ">="
@@ -228,9 +242,8 @@ executables:
228
242
  extensions: []
229
243
  extra_rdoc_files: []
230
244
  files:
231
- - ".DS_Store"
245
+ - ".github/workflows/pr.yml"
232
246
  - ".gitignore"
233
- - ".vscode/settings.json"
234
247
  - Gemfile
235
248
  - Gemfile.lock
236
249
  - LICENSE.txt
@@ -273,16 +286,15 @@ files:
273
286
  - spec/spec_helper.rb
274
287
  - spec/toc_spec.rb
275
288
  - tech_debt.md
276
- - templates/.DS_Store
277
289
  - templates/.gitignore
278
- - templates/Guardfile
279
290
  - templates/Rules
280
291
  - templates/cg_config.rb
281
292
  - templates/cg_config.rb_sample
282
293
  - templates/content/bootstrap/css/custom.css
283
294
  - templates/content/bootstrap/css/full-width-pics.css
295
+ - templates/content/bootstrap/css/postit.css
284
296
  - templates/content/bootstrap/css/prettyquote.css
285
- - templates/content/bootstrap/css/tipuesearch.css
297
+ - templates/content/bootstrap/css/toasty.css
286
298
  - templates/content/bootstrap/fonts/glyphicons-halflings-regular.ttf
287
299
  - templates/content/bootstrap/images/image1.jpg
288
300
  - templates/content/bootstrap/images/image10.jpg
@@ -296,10 +308,6 @@ files:
296
308
  - templates/content/bootstrap/images/loader.gif
297
309
  - templates/content/bootstrap/images/search.png
298
310
  - templates/content/bootstrap/js/custom.js
299
- - templates/content/bootstrap/js/tipuesearch.js
300
- - templates/content/bootstrap/js/tipuesearch.min.js
301
- - templates/content/bootstrap/js/tipuesearch_content.js
302
- - templates/content/bootstrap/js/tipuesearch_set.js
303
311
  - templates/content/content/extras/extra_content.md.erb
304
312
  - templates/content/content/index.md.erb
305
313
  - templates/content/content/intro/course_toc.md.erb
@@ -318,9 +326,9 @@ files:
318
326
  - templates/layouts/bottom_includes.html.erb
319
327
  - templates/layouts/course.html.erb
320
328
  - templates/layouts/helpful_box.html
321
- - templates/layouts/main_navbar.html.erb
322
329
  - templates/layouts/nav-menus.html.erb
323
330
  - templates/layouts/sidebar.html.erb
331
+ - templates/layouts/slides.html.erb
324
332
  - templates/layouts/top_includes.html.erb
325
333
  - templates/lib/default.rb
326
334
  homepage: ''
data/.DS_Store DELETED
Binary file
@@ -1,2 +0,0 @@
1
- {
2
- }
Binary file
@@ -1,9 +0,0 @@
1
- # Add files and commands to this file, like the example:
2
- # watch(%r{file/path}) { `command(s)` }
3
- #
4
- guard :shell do
5
- directories %w(. /mydev/cg-topics)
6
- watch(/.erb/) { |m| `cg compile` }
7
- watch(/.rb/) { |m| `cg compile` }
8
- watch(/Rules/) { |m| `cg compile` }
9
- end
@@ -1,163 +0,0 @@
1
-
2
- /*
3
- Tipue Search 3.1
4
- Copyright (c) 2013 Tipue
5
- Tipue Search is released under the MIT License
6
- http://www.tipue.com/search
7
- */
8
-
9
-
10
- #tipue_search_input
11
- {
12
- font: 12px/1.7 'Open Sans', sans-serif;
13
- color: #333;
14
- width: 150px;
15
- border: 1px solid #e2e2e2;
16
- border-radius: 0;
17
- -moz-appearance: none;
18
- -webkit-appearance: none;
19
- box-shadow: none;
20
- outline: 0;
21
- }
22
- #tipue_search_input:focus
23
- {
24
- border: 1px solid #ccc;
25
- }
26
- #tipue_search_button
27
- {
28
- width: 70px;
29
- height: 36px;
30
- border: 0;
31
- border-radius: 1px;
32
- background: #75a8fb url('img/search.png') no-repeat center;
33
- outline: none;
34
- }
35
- #tipue_search_button:hover
36
- {
37
- background-color: #5193fb;
38
- }
39
-
40
- #tipue_search_content
41
- {
42
- clear: left;
43
- max-width: 650px;
44
- padding: 25px 0 13px 0;
45
- margin: 0;
46
- }
47
- #tipue_search_loading
48
- {
49
- padding-top: 60px;
50
- background: #fff url('img/loader.gif') no-repeat left;
51
- }
52
-
53
- #tipue_search_warning_head
54
- {
55
- font: 300 16px/1.6 'Open Sans', sans-serif;
56
- color: #333;
57
- }
58
- #tipue_search_warning
59
- {
60
- font: 13px/1.6 'Open Sans', sans-serif;
61
- color: #333;
62
- margin: 7px 0;
63
- }
64
- #tipue_search_warning a
65
- {
66
- color: #096;
67
- font-weight: 300;
68
- text-decoration: none;
69
- }
70
- #tipue_search_warning a:hover
71
- {
72
- color: #333;
73
- }
74
- #tipue_search_results_count
75
- {
76
- font: 13px/1.6 'Open Sans', sans-serif;
77
- color: #333;
78
- }
79
- .tipue_search_content_title
80
- {
81
- font: 300 23px/1.6 'Open Sans', sans-serif;
82
- text-rendering: optimizelegibility;
83
- }
84
- .tipue_search_content_title a
85
- {
86
- color: #3f72d8;
87
- text-decoration: none;
88
- }
89
- .tipue_search_content_title a:hover
90
- {
91
- color: #333;
92
- }
93
- .tipue_search_content_text
94
- {
95
- font: 13px/1.7 'Open Sans', sans-serif;
96
- color: #333;
97
- word-break: break-all;
98
- word-break: break-word;
99
- -webkit-hyphens: auto;
100
- -moz-hyphens: auto;
101
- hyphens: auto;
102
- }
103
- .tipue_search_content_loc
104
- {
105
- font: 300 13px/1.7 'Open Sans', sans-serif;
106
- word-break: break-all;
107
- word-break: break-word;
108
- -webkit-hyphens: auto;
109
- -moz-hyphens: auto;
110
- hyphens: auto;
111
- }
112
- .tipue_search_content_loc a
113
- {
114
- color: #096;
115
- text-decoration: none;
116
- }
117
- .tipue_search_content_loc a:hover
118
- {
119
- color: #333;
120
- }
121
- #tipue_search_foot
122
- {
123
- margin: 51px 0 21px 0;
124
- }
125
- #tipue_search_foot_boxes
126
- {
127
- padding: 0;
128
- margin: 0;
129
- font: 12px/1 'Open Sans', sans-serif;
130
- }
131
- #tipue_search_foot_boxes li
132
- {
133
- list-style: none;
134
- margin: 0;
135
- padding: 0;
136
- display: inline;
137
- }
138
- #tipue_search_foot_boxes li a
139
- {
140
- padding: 9px 15px 10px 15px;
141
- background-color: #f1f1f1;
142
- border: 1px solid #dcdcdc;
143
- border-radius: 1px;
144
- color: #333;
145
- margin-right: 7px;
146
- text-decoration: none;
147
- text-align: center;
148
- }
149
- #tipue_search_foot_boxes li.current
150
- {
151
- padding: 9px 15px 10px 15px;
152
- background: #fff;
153
- border: 1px solid #dcdcdc;
154
- border-radius: 1px;
155
- color: #333;
156
- margin-right: 7px;
157
- text-align: center;
158
- }
159
- #tipue_search_foot_boxes li a:hover
160
- {
161
- border: 1px solid #ccc;
162
- background-color: #f3f3f3;
163
- }
@@ -1,379 +0,0 @@
1
-
2
- /*
3
- Tipue Search 3.1
4
- Copyright (c) 2013 Tipue
5
- Tipue Search is released under the MIT License
6
- http://www.tipue.com/search
7
- */
8
-
9
-
10
- (function($) {
11
-
12
- $.fn.tipuesearch = function(options) {
13
-
14
- var set = $.extend( {
15
-
16
- 'show' : 7,
17
- 'newWindow' : false,
18
- 'showURL' : true,
19
- 'minimumLength' : 3,
20
- 'descriptiveWords' : 25,
21
- 'highlightTerms' : true,
22
- 'highlightEveryTerm' : false,
23
- 'mode' : 'static',
24
- 'liveDescription' : '*',
25
- 'liveContent' : '*',
26
- 'contentLocation' : 'tipuesearch/tipuesearch_content.json'
27
-
28
- }, options);
29
- console.write("foo");
30
- return this.each(function() {
31
-
32
- var tipuesearch_in = {
33
- pages: []
34
- };
35
- $.ajaxSetup({
36
- async: false
37
- });
38
-
39
- if (set.mode == 'live')
40
- {
41
- for (var i = 0; i < tipuesearch_pages.length; i++)
42
- {
43
- $.get(tipuesearch_pages[i], '',
44
- function (html)
45
- {
46
- var cont = $(set.liveContent, html).text();
47
- cont = cont.replace(/\s+/g, ' ');
48
- var desc = $(set.liveDescription, html).text();
49
- desc = desc.replace(/\s+/g, ' ');
50
-
51
- var t_1 = html.toLowerCase().indexOf('<title>');
52
- var t_2 = html.toLowerCase().indexOf('</title>', t_1 + 7);
53
- if (t_1 != -1 && t_2 != -1)
54
- {
55
- var tit = html.slice(t_1 + 7, t_2);
56
- }
57
- else
58
- {
59
- var tit = 'No title';
60
- }
61
-
62
- tipuesearch_in.pages.push({
63
- "title": tit,
64
- "text": desc,
65
- "tags": cont,
66
- "loc": tipuesearch_pages[i]
67
- });
68
- }
69
- );
70
- }
71
- }
72
-
73
- if (set.mode == 'json')
74
- {
75
- $.getJSON(set.contentLocation,
76
- function(json)
77
- {
78
- tipuesearch_in = $.extend({}, json);
79
- }
80
- );
81
- }
82
-
83
- if (set.mode == 'static')
84
- {
85
- tipuesearch_in = $.extend({}, tipuesearch);
86
- }
87
-
88
- var tipue_search_w = '';
89
- if (set.newWindow)
90
- {
91
- tipue_search_w = ' target="_blank"';
92
- }
93
-
94
- function getURLP(name)
95
- {
96
- return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20')) || null;
97
- }
98
- if (getURLP('q'))
99
- {
100
- $('#tipue_search_input').val(getURLP('q'));
101
- getTipueSearch(0, true);
102
- }
103
-
104
- $('#tipue_search_button').click(function()
105
- {
106
- getTipueSearch(0, true);
107
- });
108
- $(this).keyup(function(event)
109
- {
110
- if(event.keyCode == '13')
111
- {
112
- getTipueSearch(0, true);
113
- }
114
- });
115
-
116
- function getTipueSearch(start, replace)
117
- {
118
- $('#tipue_search_content').hide();
119
- var out = '';
120
- var results = '';
121
- var show_replace = false;
122
- var show_stop = false;
123
-
124
- var d = $('#tipue_search_input').val().toLowerCase();
125
- d = $.trim(d);
126
- var d_w = d.split(' ');
127
- d = '';
128
- for (var i = 0; i < d_w.length; i++)
129
- {
130
- var a_w = true;
131
- for (var f = 0; f < tipuesearch_stop_words.length; f++)
132
- {
133
- if (d_w[i] == tipuesearch_stop_words[f])
134
- {
135
- a_w = false;
136
- show_stop = true;
137
- }
138
- }
139
- if (a_w)
140
- {
141
- d = d + ' ' + d_w[i];
142
- }
143
- }
144
- d = $.trim(d);
145
- d_w = d.split(' ');
146
-
147
- if (d.length >= set.minimumLength)
148
- {
149
- if (replace)
150
- {
151
- var d_r = d;
152
- for (var i = 0; i < d_w.length; i++)
153
- {
154
- for (var f = 0; f < tipuesearch_replace.words.length; f++)
155
- {
156
- if (d_w[i] == tipuesearch_replace.words[f].word)
157
- {
158
- d = d.replace(d_w[i], tipuesearch_replace.words[f].replace_with);
159
- show_replace = true;
160
- }
161
- }
162
- }
163
- d_w = d.split(' ');
164
- }
165
-
166
- var d_t = d;
167
- for (var i = 0; i < d_w.length; i++)
168
- {
169
- for (var f = 0; f < tipuesearch_stem.words.length; f++)
170
- {
171
- if (d_w[i] == tipuesearch_stem.words[f].word)
172
- {
173
- d_t = d_t + ' ' + tipuesearch_stem.words[f].stem;
174
- }
175
- }
176
- }
177
- d_w = d_t.split(' ');
178
-
179
- var c = 0;
180
- found = new Array();
181
- for (var i = 0; i < tipuesearch_in.pages.length; i++)
182
- {
183
- var score = 1000000000;
184
- var s_t = tipuesearch_in.pages[i].text;
185
- for (var f = 0; f < d_w.length; f++)
186
- {
187
- var pat = new RegExp(d_w[f], 'i');
188
- if (tipuesearch_in.pages[i].title.search(pat) != -1)
189
- {
190
- score -= (200000 - i);
191
- }
192
- if (tipuesearch_in.pages[i].text.search(pat) != -1)
193
- {
194
- score -= (150000 - i);
195
- }
196
-
197
- if (set.highlightTerms)
198
- {
199
- if (set.highlightEveryTerm)
200
- {
201
- var patr = new RegExp('(' + d_w[f] + ')', 'gi');
202
- }
203
- else
204
- {
205
- var patr = new RegExp('(' + d_w[f] + ')', 'i');
206
- }
207
- s_t = s_t.replace(patr, "<b>$1</b>");
208
- }
209
- if (tipuesearch_in.pages[i].tags.search(pat) != -1)
210
- {
211
- score -= (100000 - i);
212
- }
213
-
214
- }
215
- if (score < 1000000000)
216
- {
217
- found[c++] = score + '^' + tipuesearch_in.pages[i].title + '^' + s_t + '^' + tipuesearch_in.pages[i].loc;
218
- }
219
- }
220
-
221
- if (c != 0)
222
- {
223
- if (show_replace == 1)
224
- {
225
- out += '<div id="tipue_search_warning_head">Showing results for ' + d + '</div>';
226
- out += '<div id="tipue_search_warning">Search for <a href="javascript:void(0)" id="tipue_search_replaced">' + d_r + '</a></div>';
227
- }
228
- if (c == 1)
229
- {
230
- out += '<div id="tipue_search_results_count">1 result</div>';
231
- }
232
- else
233
- {
234
- c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
235
- out += '<div id="tipue_search_results_count">' + c_c + ' results</div>';
236
- }
237
-
238
- found.sort();
239
- var l_o = 0;
240
- for (var i = 0; i < found.length; i++)
241
- {
242
- var fo = found[i].split('^');
243
- if (l_o >= start && l_o < set.show + start)
244
- {
245
- out += '<div class="tipue_search_content_title"><a href="' + fo[3] + '"' + tipue_search_w + '>' + fo[1] + '</a></div>';
246
-
247
- var t = fo[2];
248
- var t_d = '';
249
- var t_w = t.split(' ');
250
- if (t_w.length < set.descriptiveWords)
251
- {
252
- t_d = t;
253
- }
254
- else
255
- {
256
- for (var f = 0; f < set.descriptiveWords; f++)
257
- {
258
- t_d += t_w[f] + ' ';
259
- }
260
- }
261
- t_d = $.trim(t_d);
262
- if (t_d.charAt(t_d.length - 1) != '.')
263
- {
264
- t_d += ' ...';
265
- }
266
- out += '<div class="tipue_search_content_text">' + t_d + '</div>';
267
-
268
- if (set.showURL)
269
- {
270
- out += '<div class="tipue_search_content_loc"><a href="' + fo[3] + '"' + tipue_search_w + '>' + fo[3] + '</a></div>';
271
- }
272
- }
273
- l_o++;
274
- }
275
-
276
- if (c > set.show)
277
- {
278
- var pages = Math.ceil(c / set.show);
279
- var page = (start / set.show);
280
- out += '<div id="tipue_search_foot"><ul id="tipue_search_foot_boxes">';
281
-
282
- if (start > 0)
283
- {
284
- out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (start - set.show) + '_' + replace + '">&#171; Prev</a></li>';
285
- }
286
-
287
- if (page <= 2)
288
- {
289
- var p_b = pages;
290
- if (pages > 3)
291
- {
292
- p_b = 3;
293
- }
294
- for (var f = 0; f < p_b; f++)
295
- {
296
- if (f == page)
297
- {
298
- out += '<li class="current">' + (f + 1) + '</li>';
299
- }
300
- else
301
- {
302
- out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';
303
- }
304
- }
305
- }
306
- else
307
- {
308
- var p_b = pages + 2;
309
- if (p_b > pages)
310
- {
311
- p_b = pages;
312
- }
313
- for (var f = page; f < p_b; f++)
314
- {
315
- if (f == page)
316
- {
317
- out += '<li class="current">' + (f + 1) + '</li>';
318
- }
319
- else
320
- {
321
- out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';
322
- }
323
- }
324
- }
325
-
326
- if (page + 1 != pages)
327
- {
328
- out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (start + set.show) + '_' + replace + '">Next &#187;</a></li>';
329
- }
330
-
331
- out += '</ul></div>';
332
- }
333
- }
334
- else
335
- {
336
- out += '<div id="tipue_search_warning_head">Nothing found</div>';
337
- }
338
- }
339
- else
340
- {
341
- if (show_stop)
342
- {
343
- out += '<div id="tipue_search_warning_head">Nothing found</div><div id="tipue_search_warning">Common words are largely ignored</div>';
344
- }
345
- else
346
- {
347
- out += '<div id="tipue_search_warning_head">Search too short</div>';
348
- if (set.minimumLength == 1)
349
- {
350
- out += '<div id="tipue_search_warning">Should be one character or more</div>';
351
- }
352
- else
353
- {
354
- out += '<div id="tipue_search_warning">Should be ' + set.minimumLength + ' characters or more</div>';
355
- }
356
- }
357
- }
358
-
359
- $('#tipue_search_content').html(out);
360
- $('#tipue_search_content').slideDown(200);
361
-
362
- $('#tipue_search_replaced').click(function()
363
- {
364
- getTipueSearch(0, false);
365
- });
366
-
367
- $('.tipue_search_foot_box').click(function()
368
- {
369
- var id_v = $(this).attr('id');
370
- var id_a = id_v.split('_');
371
-
372
- getTipueSearch(parseInt(id_a[0]), id_a[1]);
373
- });
374
- }
375
-
376
- });
377
- };
378
-
379
- })(jQuery);