madness 0.8.4 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -11
- data/app/public/css/main.css +3 -31
- data/app/public/css/main.css.map +42 -5
- data/app/styles/_anchor.scss +1 -1
- data/app/styles/_manifest.scss +0 -1
- data/app/views/layout.slim +1 -7
- data/app/views/search.slim +3 -12
- data/lib/madness/command_line.rb +0 -10
- data/lib/madness/docopt.txt +2 -11
- data/lib/madness/document.rb +25 -46
- data/lib/madness/navigation.rb +1 -1
- data/lib/madness/search.rb +27 -52
- data/lib/madness/server.rb +0 -11
- data/lib/madness/server_base.rb +1 -15
- data/lib/madness/settings.rb +0 -2
- data/lib/madness/templates/madness.yml +0 -2
- data/lib/madness/theme.rb +0 -8
- data/lib/madness/version.rb +1 -1
- metadata +5 -50
- data/app/public/js/autocomplete.js +0 -15
- data/app/public/js/vendor/jquery.autocomplete-min.js +0 -8
- data/app/styles/_autocomplete.scss +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6d1a2a1af740dbcace6dcf480bdb39bd070f1a2950d0bfdc75728ee99104cf
|
4
|
+
data.tar.gz: 4342dcc15681c42998f97736dda3d118c5062e295beae85e482ebf850e920977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d8c1f9366a41f91332e775c8c26d3a1994f4b13694a342a55c18a8cf99124f59257b3ce7f7ce1634c5759003dcfeb3a63f74f75ee1abaf835a30c9e83d68f9d
|
7
|
+
data.tar.gz: 7ed9cafc3418cdd966a55c2d0ba2fddee9e5e3bdae5c159e6caea8108d845d32a78ccdd77464469f8ff3cbdd70e70dac79e652e6001e980ea8662a3a0530ddee
|
data/README.md
CHANGED
@@ -124,8 +124,6 @@ auto_nav: true
|
|
124
124
|
highlighter: true
|
125
125
|
line_numbers: true
|
126
126
|
copy_code: true
|
127
|
-
index: false
|
128
|
-
search_limit: 100
|
129
127
|
dtoc: Table of Contents
|
130
128
|
theme: _theme
|
131
129
|
open: false
|
@@ -139,15 +137,7 @@ $ madness create config
|
|
139
137
|
|
140
138
|
## Search
|
141
139
|
|
142
|
-
Madness comes with a full text search page.
|
143
|
-
generate a search index by running `madness --index` or
|
144
|
-
`madness path/to/docs --index`.
|
145
|
-
|
146
|
-
This will create an `_index` sub folder, and will add a new search page
|
147
|
-
to your documentation server.
|
148
|
-
|
149
|
-
You will need to run this command from time to time, as your
|
150
|
-
documents change or new documents are added.
|
140
|
+
Madness comes with a full text search page.
|
151
141
|
|
152
142
|
## Images and Static Files
|
153
143
|
|
@@ -248,6 +238,14 @@ option.
|
|
248
238
|
$ madness --theme my_theme
|
249
239
|
```
|
250
240
|
|
241
|
+
Note that the generated theme contains the SCSS files in the `styles`
|
242
|
+
subfolder, and the rendered CSS files in the `public/css` subfolder.
|
243
|
+
|
244
|
+
If you wish to use the SCSS files, you will need to render them yourself
|
245
|
+
to the location of your theme styles (e.g. `public/css`) - you can use
|
246
|
+
any tool to do so, or if you do not have a preference, use
|
247
|
+
[SassTool][sasstool].
|
248
|
+
|
251
249
|
|
252
250
|
### Option 2: Change CSS only
|
253
251
|
|
@@ -300,4 +298,5 @@ For more information about the docker image, see:
|
|
300
298
|
[dockerfile]: https://github.com/DannyBen/docker-madness
|
301
299
|
[css]: app/public/css/main.css
|
302
300
|
[app]: app
|
301
|
+
[sasstool]: https://github.com/DannyBen/sasstool
|
303
302
|
|
data/app/public/css/main.css
CHANGED
@@ -70,7 +70,7 @@ a {
|
|
70
70
|
-webkit-text-decoration-skip: objects;
|
71
71
|
color: #4078c0;
|
72
72
|
text-decoration: none; }
|
73
|
-
a:active, a:hover {
|
73
|
+
a:active, a:hover, a:focus {
|
74
74
|
outline-width: 0;
|
75
75
|
text-decoration: underline; }
|
76
76
|
a:not([href]) {
|
@@ -273,6 +273,7 @@ nav {
|
|
273
273
|
src: url("../fonts/fontello.eot?68354463#iefix") format("embedded-opentype"), url("../fonts/fontello.woff2?68354463") format("woff2"), url("../fonts/fontello.woff?68354463") format("woff"), url("../fonts/fontello.ttf?68354463") format("truetype"), url("../fonts/fontello.svg?68354463#fontello") format("svg");
|
274
274
|
font-weight: normal;
|
275
275
|
font-style: normal; }
|
276
|
+
|
276
277
|
[class^="icon-"]:before, [class*=" icon-"]:before {
|
277
278
|
font-family: "fontello";
|
278
279
|
font-style: normal;
|
@@ -309,35 +310,6 @@ nav {
|
|
309
310
|
.icon-search:before {
|
310
311
|
content: '\e802'; }
|
311
312
|
|
312
|
-
.autocomplete-suggestions {
|
313
|
-
border: 1px solid #ccc;
|
314
|
-
background: #fff;
|
315
|
-
cursor: default;
|
316
|
-
overflow: auto; }
|
317
|
-
|
318
|
-
.autocomplete-suggestion {
|
319
|
-
padding: 5px 10px;
|
320
|
-
white-space: nowrap;
|
321
|
-
overflow: hidden; }
|
322
|
-
|
323
|
-
.autocomplete-no-suggestion {
|
324
|
-
padding: 2px 5px; }
|
325
|
-
|
326
|
-
.autocomplete-selected {
|
327
|
-
background: #ddd; }
|
328
|
-
|
329
|
-
.autocomplete-suggestions strong {
|
330
|
-
font-weight: bold; }
|
331
|
-
|
332
|
-
.autocomplete-group {
|
333
|
-
padding: 2px 5px; }
|
334
|
-
|
335
|
-
.autocomplete-group strong {
|
336
|
-
font-weight: bold;
|
337
|
-
color: #000;
|
338
|
-
display: block;
|
339
|
-
border-bottom: 1px solid #000; }
|
340
|
-
|
341
313
|
* {
|
342
314
|
box-sizing: border-box; }
|
343
315
|
|
@@ -379,4 +351,4 @@ body {
|
|
379
351
|
max-width: 980px;
|
380
352
|
margin: 0 auto; }
|
381
353
|
|
382
|
-
/*# sourceMappingURL=main.css.map */
|
354
|
+
/*# sourceMappingURL=main.css.map */
|
data/app/public/css/main.css.map
CHANGED
@@ -1,7 +1,44 @@
|
|
1
1
|
{
|
2
|
-
"version": 3,
|
3
|
-
"
|
4
|
-
"sources": [
|
5
|
-
"
|
6
|
-
"
|
2
|
+
"version": 3,
|
3
|
+
"file": "main.css",
|
4
|
+
"sources": [
|
5
|
+
"main.scss",
|
6
|
+
"_manifest.scss",
|
7
|
+
"_mixins.scss",
|
8
|
+
"_typography.scss",
|
9
|
+
"_table.scss",
|
10
|
+
"_anchor.scss",
|
11
|
+
"_list.scss",
|
12
|
+
"_code.scss",
|
13
|
+
"_coderay.scss",
|
14
|
+
"_image.scss",
|
15
|
+
"_line.scss",
|
16
|
+
"_keyboard.scss",
|
17
|
+
"_search.scss",
|
18
|
+
"_breadcrumbs.scss",
|
19
|
+
"_nav.scss",
|
20
|
+
"_icons.scss",
|
21
|
+
"_general.scss"
|
22
|
+
],
|
23
|
+
"sourcesContent": [
|
24
|
+
"@import \"manifest\";\n\nbody {\n max-width: 1300px;\n margin: 0 auto;\n}\n\n.main {\n padding: 0 20px 100px 20px;\n\n &:before, &:after {\n display: table;\n content: \"\";\n }\n\n &:after {\n // clear: both;\n }\n\n @include desktop {\n &.with-sidebar {\n min-height: 100vh;\n margin-left: 250px;\n }\n }\n \n &.without-sidebar {\n max-width: 980px;\n margin: 0 auto;\n }\n}\n\n",
|
25
|
+
"@import \"mixins\";\n\n@import \"typography\";\n@import \"table\";\n@import \"anchor\";\n@import \"list\";\n@import \"code\";\n@import \"coderay\";\n@import \"image\";\n@import \"line\";\n@import \"keyboard\";\n@import \"search\";\n@import \"breadcrumbs\";\n@import \"nav\";\n@import \"icons\";\n\n// Last\n@import \"general\";",
|
26
|
+
"// Mixins\n$breakpoint: 768px;\n\n@mixin mobile {\n\t@media only screen and (max-width: $breakpoint - 1) {\n\t\t@content;\n\t}\n}\n\n@mixin desktop {\n\t@media only screen and (min-width: $breakpoint) {\n\t\t@content;\n\t}\n}\n",
|
27
|
+
"body {\n -ms-text-size-adjust: 100%;\n -webkit-text-size-adjust: 100%;\n color: #333;\n // font-family: \"Helvetica Neue\", Helvetica, \"Segoe UI\", Arial, freesans, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n font-family: \"Segoe UI\", \"Helvetica Neue\", Helvetica,Arial, freesans, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n word-wrap: break-word;\n}\n\nstrong, .strong {\n font-weight: bolder;\n}\n\nh1, h2, h3, h4, h5, h6 {\n margin-top: 1em;\n margin-bottom: 16px;\n font-weight: bold;\n line-height: 1.4;\n}\n\nh1 {\n margin: 0.67em 0;\n padding-bottom: 0.3em;\n font-size: 2.25em;\n line-height: 1.2;\n border-bottom: 1px solid #eee;\n}\n\nh2 {\n padding-bottom: 0.3em;\n font-size: 1.75em;\n line-height: 1.225;\n border-bottom: 1px solid #eee;\n}\n\nh3 {\n font-size: 1.5em;\n line-height: 1.43;\n}\n\nh4 {\n font-size: 1.25em;\n}\n\nh5 {\n font-size: 1em;\n}\n\nh6 {\n font-size: 1em;\n color: #777;\n}\n\ncode, pre, kbd {\n font-family: Consolas, \"Liberation Mono\", Menlo, Courier, monospace;\n font-size: 1em;\n}\n",
|
28
|
+
"table {\n border-spacing: 0;\n border-collapse: collapse;\n\n display: block;\n width: 100%;\n overflow: auto;\n word-break: normal;\n word-break: keep-all;\n \n th {\n font-weight: bold;\n }\n\n th, td {\n padding: 6px 13px;\n border: 1px solid #ddd;\n }\n\n tr {\n background-color: #fff;\n border-top: 1px solid #ccc;\n }\n\n tr:nth-child(2n) {\n background-color: #f8f8f8;\n }\n}\n",
|
29
|
+
"a {\n -webkit-text-decoration-skip: objects;\n\n color: #4078c0;\n text-decoration: none;\n\n &:active, &:hover, &:focus {\n outline-width: 0;\n text-decoration: underline;\n }\n\n &:not([href]) {\n color: inherit;\n text-decoration: none;\n }\n}",
|
30
|
+
"ul, ol {\n margin-top: 0;\n margin-bottom: 0;\n\n padding-left: 2em;\n}\n\nol ol, ul ol {\n list-style-type: lower-roman;\n}\n\nul ul ol, ul ol ol, ol ul ol, ol ol ol {\n list-style-type: lower-alpha;\n}\n\nul ul, ul ol, ol ol, ol ul {\n margin-top: 0;\n margin-bottom: 0;\n}\n\ndd {\n margin-left: 0;\n}\n\ndl {\n padding: 0;\n\n dt {\n padding: 0;\n margin-top: 16px;\n font-size: 1em;\n font-style: italic;\n font-weight: bold;\n }\n\n dd {\n padding: 0 16px;\n margin-bottom: 16px;\n }\n}\n\nli>p {\n margin-top: 16px;\n}\n",
|
31
|
+
"code {\n padding: 0;\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n margin: 0;\n // font-size: 85%;\n background-color: #eee;\n border-radius: 3px;\n \n &:before, &:after {\n letter-spacing: -0.2em;\n content: \"\\00a0\";\n }\n}\n\npre {\n margin-left: 20px;\n // margin-top: 0;\n // margin-bottom: 0;\n\n // padding: 16px;\n overflow: auto;\n // font-size: 85%;\n line-height: 1.45;\n // background-color: #f7f7f7;\n // border-radius: 3px;\n word-wrap: normal;\n\n &>code {\n padding: 0;\n margin: 0;\n font-size: 100%;\n word-break: normal;\n white-space: pre;\n background: transparent;\n border: 0;\n }\n\n code {\n display: inline-block;\n max-width: initial;\n // padding: 10px;\n overflow: initial;\n line-height: inherit;\n word-wrap: normal;\n border: 0;\n // background: #eee;\n }\n\n code:before,\n code:after {\n content: normal;\n }\n}\n",
|
32
|
+
".clipboard-button {\n position: absolute;\n right: 0;\n font-size: 1.25em;\n opacity: 0.2;\n transition: opacity 0.3s;\n}\n\ntable.CodeRay:hover .clipboard-button {\n opacity: 1;\n transition: opacity 0.3s;\n}\n\ntable.CodeRay {\n position: relative;\n margin-bottom: 0;\n \n pre {\n margin-bottom: 0;\n }\n \n tr, td {\n border: 0;\n pre {\n margin-left: 0;\n }\n }\n\n td.line-numbers {\n background: #eee;\n padding: 4px; \n }\n\n td.code {\n }\n\n}\n",
|
33
|
+
"img {\n border-style: none;\n\n max-width: 100%;\n box-sizing: content-box;\n background-color: #fff;\n}\n",
|
34
|
+
"hr {\n box-sizing: content-box;\n // height: 0;\n overflow: visible;\n height: 0;\n // margin: 15px 0;\n overflow: hidden;\n // background: transparent;\n border: 0;\n border-bottom: 1px solid #ddd;\n\n height: 4px;\n padding: 0;\n margin: 16px 0;\n background-color: #e7e7e7;\n // border: 0 none;\n\n border-bottom-color: #eee;\n\n &::before {\n display: table;\n content: \"\";\n }\n &::after {\n display: table;\n clear: both;\n content: \"\";\n }\n}",
|
35
|
+
"kbd {\n display: inline-block;\n padding: 3px 5px;\n font-size: 11px;\n line-height: 10px;\n color: #555;\n vertical-align: middle;\n background-color: #fcfcfc;\n border: solid 1px #ccc;\n border-bottom-color: #bbb;\n border-radius: 3px;\n box-shadow: inset 0 -1px 0 #bbb;\n}\n\n",
|
36
|
+
".search-form {\n margin-bottom: 20px;\n margin-top: 20px;\n}\n\n.search-field {\n outline: none;\n padding: 8px 12px;\n font-size: 1.5em;\n width: 50%;\n min-width: 200px;\n width: 100%;\n\n border: #ccc 1px solid;\n border-radius: 3px;\n\n &:focus {\n border-color: #4078c0;\n }\n}\n",
|
37
|
+
".breadcrumbs {\n margin-top: 6px;\n border-bottom: 1px solid #ccc;\n a {\n display: inline-block;\n padding: 7px 0;\n }\n}\n",
|
38
|
+
"nav {\n @media print {\n display: none;\n }\n\n @include mobile {\n display: none;\n }\n\n // background: #eee;\n // border-right: 1px solid #ccc;\n\n height: 100vh;\n width: 250px;\n overflow-y: auto;\n position: fixed;\n\n .icon-bar {\n border-bottom: 1px dotted #ddd;\n }\n\n a.document, span.document, .caption {\n border-bottom: 1px dotted #ddd;\n // &:hover {\n // background: #e4e4e4;\n // }\n\n display: block;\n padding: 5px 20px 5px 30px;\n }\n\n a.icon {\n display: inline-block;\n font-size: 1.5em;\n width: 50%;\n padding: 3px 20px 3px 30px;\n &.wide {\n width: 100%\n }\n // &:hover {\n // background: #e4e4e4;\n // }\n }\n\n\n &:after {\n content: \"\";\n height: 90px;\n display: block;\n }\n}\n\n\n// Nicer sidebar scrollbars\n::-webkit-scrollbar {\n width: 6px;\n}\n::-webkit-scrollbar-thumb {\n background: #ddd;\n -webkit-border-radius: 3px;\n}\n",
|
39
|
+
"@font-face {\n font-family: 'fontello';\n src: url('../fonts/fontello.eot?68354463');\n src: url('../fonts/fontello.eot?68354463#iefix') format('embedded-opentype'),\n url('../fonts/fontello.woff2?68354463') format('woff2'),\n url('../fonts/fontello.woff?68354463') format('woff'),\n url('../fonts/fontello.ttf?68354463') format('truetype'),\n url('../fonts/fontello.svg?68354463#fontello') format('svg');\n font-weight: normal;\n font-style: normal;\n}\n \n[class^=\"icon-\"]:before, [class*=\" icon-\"]:before {\n font-family: \"fontello\";\n font-style: normal;\n font-weight: normal;\n speak: none;\n \n display: inline-block;\n text-decoration: inherit;\n width: 1em;\n margin-right: .2em;\n text-align: center;\n /* opacity: .8; */\n \n /* For safety - reset parent styles, that can break glyph codes*/\n font-variant: normal;\n text-transform: none;\n \n /* fix buttons height, for twitter bootstrap */\n line-height: 1em;\n \n /* Animation center compensation - margins should be symmetric */\n /* remove if not needed */\n margin-left: .2em;\n \n /* you can be more comfortable with increased icons size */\n /* font-size: 120%; */\n \n /* Font smoothing. That was taken from TWBS */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n \n /* Uncomment for 3D effect */\n /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */\n}\n \n.icon-export:before { content: '\\e800'; }\n.icon-home:before { content: '\\e801'; }\n.icon-search:before { content: '\\e802'; }\n",
|
40
|
+
"* {\n box-sizing: border-box;\n}\n\np {\n margin-top: 0;\n margin-bottom: 10px;\n}\n\nblockquote {\n margin: 0;\n padding: 0 15px;\n color: #777;\n border-left: 4px solid #ddd;\n\n &>:first-child {\n margin-top: 0;\n }\n\n &>:last-child {\n margin-bottom: 0;\n }\n}\n\np, blockquote, ul, ol, dl, table, pre {\n margin-top: 0;\n margin-bottom: 16px;\n}\n\n.quiet {\n color: #777;\n}\n"
|
41
|
+
],
|
42
|
+
"names": [],
|
43
|
+
"mappings": "AGAA,AAAA,IAAI,CAAC;EACH,oBAAoB,EAAE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ML,WAAW,CAAC;IACb,UAAU,EAAE,CAAC,GACd;EARH,AAUE,UAVQ,IAUL,UAAU,CAAC;IACZ,aAAa,EAAE,CAAC,GACjB;;AAGH,AAAA,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC;EACpC,UAAU,EAAE,CAAC;EACb,aAAa,EAAE,IAAI,GACpB;;AAED,AAAA,MAAM,CAAC;EACL,KAAK,EAAE,IAAI,GACZ;;AhB7BD,AAAA,IAAI,CAAC;EACH,SAAS,EAAE,MAAM;EACjB,MAAM,EAAE,MAAM,GACf;;AAED,AAAA,KAAK,CAAC;EACJ,OAAO,EAAE,iBAAiB,GAsB3B;EAvBD,AAGE,KAHG,CAGD,MAAM,EAHV,KAAK,CAGS,KAAK,CAAC;IAChB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,EAAE,GACZ;EEHF,MAAM,mCFUH;IAbJ,AAaI,KAbC,AAaA,aAAa,CAAC;MACb,UAAU,EAAE,KAAK;MACjB,WAAW,EAAE,KAAK,GACnB,EAAA;EAhBL,AAmBE,KAnBG,AAmBF,gBAAgB,CAAC;IAChB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,MAAM,GACf"
|
7
44
|
}
|
data/app/styles/_anchor.scss
CHANGED
data/app/styles/_manifest.scss
CHANGED
data/app/views/layout.slim
CHANGED
@@ -7,16 +7,10 @@ html
|
|
7
7
|
meta name="viewport" content="width=device-width, initial-scale=1"
|
8
8
|
link href='/css/main.css' rel='stylesheet' type='text/css'
|
9
9
|
|
10
|
-
- if nav.with_search? or config.copy_code
|
11
|
-
script src="/js/vendor/jquery.min.js"
|
12
|
-
|
13
10
|
- if config.copy_code
|
11
|
+
script src="/js/vendor/jquery.min.js"
|
14
12
|
script src="/js/vendor/clipboard.min.js"
|
15
13
|
script src="/js/clipboard.js"
|
16
14
|
|
17
|
-
- if nav.with_search?
|
18
|
-
script src="/js/vendor/jquery.autocomplete-min.js"
|
19
|
-
script src="/js/autocomplete.js"
|
20
|
-
|
21
15
|
body
|
22
16
|
== yield
|
data/app/views/search.slim
CHANGED
@@ -2,22 +2,13 @@
|
|
2
2
|
|
3
3
|
.main class=(config.sidebar ? 'with-sidebar' : 'without-sidebar')
|
4
4
|
form.search-form action="/_search" method="get"
|
5
|
-
input.search-field
|
5
|
+
input.search-field type="text" name="q" value="#{params[:q]}" placeholder="Search (use quotes for exact match)" autofocus=true
|
6
6
|
input type="submit" value="Search" style='display:none'
|
7
7
|
|
8
8
|
hr
|
9
9
|
|
10
10
|
- if results
|
11
|
-
- results.
|
11
|
+
- results.each do |label, url|
|
12
12
|
h4
|
13
|
-
=
|
14
|
-
= ". "
|
15
|
-
a href="#{result[:file]}" = result[:label]
|
16
|
-
|
17
|
-
ul
|
18
|
-
- if result[:highlights]
|
19
|
-
- result[:highlights].each do |highlight|
|
20
|
-
li.search-excerpt == highlight
|
21
|
-
- else
|
22
|
-
li.search-excerpt.quiet No excerpt
|
13
|
+
a href="#{url}" = label
|
23
14
|
|
data/lib/madness/command_line.rb
CHANGED
@@ -65,7 +65,6 @@ module Madness
|
|
65
65
|
config.port = args['--port'].to_i if args['--port']
|
66
66
|
config.bind = args['--bind'] if args['--bind']
|
67
67
|
config.toc = args['--toc'] if args['--toc']
|
68
|
-
config.search_limit = args['--search-limit'].to_i if args['--search-limit']
|
69
68
|
config.auth = args['--auth'] if args['--auth']
|
70
69
|
config.auth_realm = args['--auth-realm'] if args['--auth-realm']
|
71
70
|
|
@@ -75,7 +74,6 @@ module Madness
|
|
75
74
|
config.highlighter = false if args['--no-syntax']
|
76
75
|
config.line_numbers = false if args['--no-line-numbers']
|
77
76
|
config.copy_code = false if args['--no-copy-code']
|
78
|
-
config.index = true if args['--index']
|
79
77
|
config.open = true if args['--open']
|
80
78
|
|
81
79
|
config.theme = File.expand_path(args['--theme'], config.path) if args['--theme']
|
@@ -83,7 +81,6 @@ module Madness
|
|
83
81
|
|
84
82
|
# Generate index and toc, if requested by the user.
|
85
83
|
def generate_stuff
|
86
|
-
build_index if config.index
|
87
84
|
build_toc if config.toc
|
88
85
|
end
|
89
86
|
|
@@ -120,13 +117,6 @@ module Madness
|
|
120
117
|
say "-" * 60
|
121
118
|
end
|
122
119
|
|
123
|
-
# Build the search index
|
124
|
-
def build_index
|
125
|
-
search = Search.new
|
126
|
-
say_status :index, "generating #{search.index_dir}"
|
127
|
-
search.build_index
|
128
|
-
end
|
129
|
-
|
130
120
|
# Generate the table of contents file
|
131
121
|
def build_toc
|
132
122
|
say_status :toc, "generating #{config.toc}"
|
data/lib/madness/docopt.txt
CHANGED
@@ -60,18 +60,10 @@ Options:
|
|
60
60
|
documentation path.
|
61
61
|
(Config option: theme)
|
62
62
|
|
63
|
-
--index
|
64
|
-
Build or rebuild the index for the search page.
|
65
|
-
(Config option: index)
|
66
|
-
|
67
63
|
--toc FILE
|
68
64
|
Generate a table of contents file.
|
69
65
|
(Config option: toc)
|
70
66
|
|
71
|
-
--search-limit LIMIT
|
72
|
-
Maximum number of results to show on the search page [default: 100].
|
73
|
-
(Config option: search_limit)
|
74
|
-
|
75
67
|
--auth USER:PASS
|
76
68
|
Enable basic authentication.
|
77
69
|
(Config option: auth)
|
@@ -85,7 +77,7 @@ Options:
|
|
85
77
|
(Config option: open)
|
86
78
|
|
87
79
|
--and-quit
|
88
|
-
Quit instead of running the server. Useful with --
|
80
|
+
Quit instead of running the server. Useful with --toc.
|
89
81
|
|
90
82
|
Examples:
|
91
83
|
madness
|
@@ -93,8 +85,7 @@ Examples:
|
|
93
85
|
madness docs --no-auto-h1 -p 4567
|
94
86
|
madness docs --open
|
95
87
|
madness --no-sidebar --no-auto-nav
|
96
|
-
madness --
|
97
|
-
madness --toc "Table of Contents.md" --index --and-quit
|
88
|
+
madness --toc "Table of Contents.md" --and-quit
|
98
89
|
madness --auth user:secret --port 4000
|
99
90
|
madness --theme _mytheme
|
100
91
|
madness create config
|
data/lib/madness/document.rb
CHANGED
@@ -8,36 +8,13 @@ module Madness
|
|
8
8
|
include ServerHelper
|
9
9
|
using StringRefinements
|
10
10
|
|
11
|
-
attr_reader :base, :path
|
11
|
+
attr_reader :base, :path, :type, :file, :dir, :title
|
12
12
|
|
13
13
|
def initialize(path)
|
14
14
|
@path = path
|
15
15
|
@base = path.empty? ? docroot : "#{docroot}/#{path}"
|
16
16
|
@base.chomp! '/'
|
17
|
-
|
18
|
-
|
19
|
-
# Return :readme, :file or :empty
|
20
|
-
def type
|
21
|
-
set_base_attributes unless @type
|
22
|
-
@type
|
23
|
-
end
|
24
|
-
|
25
|
-
# Return the path to the actual markdown file
|
26
|
-
def file
|
27
|
-
set_base_attributes unless @file
|
28
|
-
@file
|
29
|
-
end
|
30
|
-
|
31
|
-
# Return the path to the document directory
|
32
|
-
def dir
|
33
|
-
set_base_attributes unless @dir
|
34
|
-
@dir
|
35
|
-
end
|
36
|
-
|
37
|
-
# Return the path to the document directory
|
38
|
-
def title
|
39
|
-
set_base_attributes unless @title
|
40
|
-
@title
|
17
|
+
set_base_attributes
|
41
18
|
end
|
42
19
|
|
43
20
|
# Return the HTML for that document
|
@@ -92,23 +69,25 @@ module Madness
|
|
92
69
|
@markdown ||= File.read file
|
93
70
|
end
|
94
71
|
|
72
|
+
def doc
|
73
|
+
@doc ||= CommonMarker.render_doc markdown, :DEFAULT, [:table]
|
74
|
+
end
|
75
|
+
|
95
76
|
# Convert markdown to HTML, with some additional processing:
|
96
77
|
# 1. Add anchors to headers
|
97
78
|
# 2. Syntax highilghting
|
98
79
|
# 3. Prepend H1 if needed
|
99
80
|
def markdown_to_html
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
add_anchor_ids doc
|
81
|
+
replace_toc_marker
|
82
|
+
prepend_h1 if config.auto_h1
|
83
|
+
add_anchor_ids
|
104
84
|
html = doc.to_html :UNSAFE
|
105
85
|
html = syntax_highlight(html) if config.highlighter
|
106
|
-
html = prepend_h1(html) if config.auto_h1
|
107
86
|
html
|
108
87
|
end
|
109
88
|
|
110
89
|
# Add anchors with IDs before all headers
|
111
|
-
def add_anchor_ids
|
90
|
+
def add_anchor_ids
|
112
91
|
doc.walk do |node|
|
113
92
|
if node.type == :header
|
114
93
|
anchor = CommonMarker::Node.new(:inline_html)
|
@@ -123,39 +102,39 @@ module Madness
|
|
123
102
|
end
|
124
103
|
|
125
104
|
# Replace <!-- TOC --> with a Table of Contents for the page
|
126
|
-
def replace_toc_marker
|
105
|
+
def replace_toc_marker
|
127
106
|
toc_marker = doc.find do |node|
|
128
107
|
node.type == :html and node.string_content.include? "<!-- TOC -->"
|
129
108
|
end
|
130
109
|
|
131
110
|
return unless toc_marker
|
132
111
|
|
112
|
+
toc_marker.insert_after document_toc
|
113
|
+
toc_marker.insert_after CommonMarker.render_doc("## Table of Contents").first_child
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns a UL object containing the document table of contents
|
117
|
+
def document_toc
|
133
118
|
toc = []
|
134
119
|
doc.walk do |node|
|
135
120
|
next unless node.type == :header
|
136
121
|
level = node.header_level
|
137
122
|
next unless level.between? 2, 3
|
138
123
|
text = node.first_child.string_content
|
139
|
-
|
140
|
-
|
141
|
-
toc << "- [#{text}](##{text.to_slug})"
|
142
|
-
else
|
143
|
-
toc << " - [#{text}](##{text.to_slug})"
|
144
|
-
end
|
124
|
+
spacer = " " * (level - 1)
|
125
|
+
toc << "#{spacer}- [#{text}](##{text.to_slug})"
|
145
126
|
end
|
146
127
|
|
147
128
|
toc = toc.join "\n"
|
148
|
-
|
149
|
-
toc_marker.insert_after toc.first_child
|
150
|
-
toc_marker.insert_after CommonMarker.render_doc("## Table of Contents").first_child
|
129
|
+
CommonMarker.render_doc(toc).first_child
|
151
130
|
end
|
152
131
|
|
153
132
|
# If the document does not start with an H1 tag, add it.
|
154
|
-
def prepend_h1
|
155
|
-
unless
|
156
|
-
|
157
|
-
|
158
|
-
|
133
|
+
def prepend_h1
|
134
|
+
return unless doc.first_child
|
135
|
+
return if doc.first_child.type == :header and doc.first_child.header_level == 1
|
136
|
+
h1 = CommonMarker.render_doc("# #{title}").first_child
|
137
|
+
doc.first_child.insert_before h1
|
159
138
|
end
|
160
139
|
|
161
140
|
# Apply syntax highlighting with CodeRay. This will parse for any
|
data/lib/madness/navigation.rb
CHANGED
data/lib/madness/search.rb
CHANGED
@@ -1,67 +1,51 @@
|
|
1
|
-
require '
|
1
|
+
require 'shellwords'
|
2
2
|
|
3
3
|
module Madness
|
4
4
|
class Search
|
5
5
|
include ServerHelper
|
6
|
-
include Ferret
|
7
|
-
include Ferret::Index
|
8
6
|
using StringRefinements
|
9
7
|
|
10
8
|
def initialize(path=nil)
|
11
9
|
@path = path || docroot
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
|
12
|
+
def index
|
13
|
+
@index ||= index!
|
16
14
|
end
|
17
15
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
def search(query)
|
17
|
+
query = query.downcase
|
18
|
+
words = Shellwords.split query
|
19
|
+
word_count = words.count
|
20
|
+
result = {}
|
21
|
+
return result if words.empty?
|
22
|
+
|
23
|
+
index.each do |file, content|
|
24
|
+
file = file.remove("#{@path}/")[0...-3]
|
25
|
+
url = file_url file
|
26
|
+
label = file_label file
|
27
|
+
found = 0
|
28
|
+
words.each { |word| found += 1 if content.include? word }
|
29
|
+
next unless found == word_count
|
30
|
+
result[label] = url
|
26
31
|
end
|
27
32
|
|
28
|
-
|
29
|
-
index.close()
|
33
|
+
result
|
30
34
|
end
|
31
35
|
|
32
|
-
|
33
|
-
index = Index.new path: index_dir
|
36
|
+
private
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
results << {
|
43
|
-
score: score,
|
44
|
-
file: file_url(filename),
|
45
|
-
label: file_label(filename),
|
46
|
-
highlights: highlights
|
47
|
-
}
|
38
|
+
def index!
|
39
|
+
results = {}
|
40
|
+
Dir["#{@path}/**/*.md"].sort.each do |file|
|
41
|
+
next if skip_index? file
|
42
|
+
filename = file_url(file.sub("#{@path}/", '')[0...-3]).downcase
|
43
|
+
content = File.read(file).downcase
|
44
|
+
results[file] = "#{filename} #{content}"
|
48
45
|
end
|
49
|
-
|
50
|
-
index.close()
|
51
46
|
results
|
52
47
|
end
|
53
48
|
|
54
|
-
def remove_index_dir
|
55
|
-
return unless Dir.exist? index_dir
|
56
|
-
FileUtils.rm_r index_dir
|
57
|
-
end
|
58
|
-
|
59
|
-
def index_dir
|
60
|
-
"#{@path}/_index"
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
49
|
# We are going to avoid indexing of README.md when there is also an
|
66
50
|
# index.md in the same directory, to keep behavior consistent with the
|
67
51
|
# display logic
|
@@ -74,15 +58,6 @@ module Madness
|
|
74
58
|
end
|
75
59
|
end
|
76
60
|
|
77
|
-
# This is poor-mans markdown strip.
|
78
|
-
# Convert to HTML, strip tags and return plain text suitable to act as
|
79
|
-
# the content for the search index.
|
80
|
-
def searchable_content(file)
|
81
|
-
content = File.read file
|
82
|
-
content = CommonMarker.render_html content
|
83
|
-
content.remove(/<\/?[^>]*>/).gsub("\n", " ")
|
84
|
-
end
|
85
|
-
|
86
61
|
def file_label(filename)
|
87
62
|
filename
|
88
63
|
.remove(/\/(index|README)$/)
|
data/lib/madness/server.rb
CHANGED
@@ -16,17 +16,6 @@ module Madness
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
get '/_search/autocomplete' do
|
20
|
-
query = params[:query]
|
21
|
-
return { suggestions: [] } if query.empty?
|
22
|
-
|
23
|
-
results = Search.new.search query
|
24
|
-
suggestions = results.map { |r| { value: r[:label], data: r[:file] } }
|
25
|
-
|
26
|
-
response = { suggestions: suggestions }
|
27
|
-
response.to_json
|
28
|
-
end
|
29
|
-
|
30
19
|
get '/*' do
|
31
20
|
path = params[:splat].first
|
32
21
|
|
data/lib/madness/server_base.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# require 'sinatra/reloader'
|
2
2
|
require 'rack/ssl'
|
3
|
-
require 'sass'
|
4
|
-
require 'sass/plugin/rack'
|
5
3
|
require 'sinatra/base'
|
6
4
|
require 'slim'
|
7
5
|
|
@@ -14,20 +12,10 @@ module Madness
|
|
14
12
|
helpers ServerHelper
|
15
13
|
|
16
14
|
Slim::Engine.set_options pretty: true
|
17
|
-
use Sass::Plugin::Rack
|
18
15
|
use Rack::SSL if ENV['MADNESS_FORCE_SSL']
|
19
16
|
set :root, File.expand_path('../../', __dir__)
|
20
|
-
set :server, :puma
|
21
17
|
set :environment, ENV['MADNESS_ENV'] || :production
|
22
|
-
|
23
|
-
# TODO: Uncomment when the upstream issue is resolved
|
24
|
-
# At this time, we cannot use reloader, since it prints deprecation
|
25
|
-
# warnings in Ruby 2.7
|
26
|
-
# ref: https://github.com/sinatra/sinatra/issues/1590
|
27
|
-
# configure :development do
|
28
|
-
# register Sinatra::Reloader
|
29
|
-
# also_reload "#{__dir__}/*.rb"
|
30
|
-
# end
|
18
|
+
set :server, :puma
|
31
19
|
|
32
20
|
# Since we cannot use any config values in the main body of the class,
|
33
21
|
# since they will be updated later, we need to set anything that relys
|
@@ -48,8 +36,6 @@ module Madness
|
|
48
36
|
|
49
37
|
set :views, theme.views_path
|
50
38
|
set :public_folder, theme.public_path
|
51
|
-
Sass::Plugin.options[:template_location] = theme.css_source_path
|
52
|
-
Sass::Plugin.options[:css_location] = theme.css_target_path
|
53
39
|
end
|
54
40
|
|
55
41
|
def self.set_basic_auth
|
data/lib/madness/settings.rb
CHANGED
data/lib/madness/theme.rb
CHANGED
@@ -14,14 +14,6 @@ module Madness
|
|
14
14
|
custom? ? "#{path}/public" : File.expand_path('../../app/public', __dir__)
|
15
15
|
end
|
16
16
|
|
17
|
-
def css_source_path
|
18
|
-
custom? ? "#{path}/styles" : 'app/styles'
|
19
|
-
end
|
20
|
-
|
21
|
-
def css_target_path
|
22
|
-
custom? ? "#{path}/public/css" : 'app/public/css'
|
23
|
-
end
|
24
|
-
|
25
17
|
def custom?
|
26
18
|
@custom ||= (path and Dir.exist? path)
|
27
19
|
end
|
data/lib/madness/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coderay
|
@@ -66,34 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.6'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: ferret
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.11'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.11'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: json
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2.1'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '2.1'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: naturally
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +100,14 @@ dependencies:
|
|
128
100
|
requirements:
|
129
101
|
- - "~>"
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
103
|
+
version: '5.1'
|
132
104
|
type: :runtime
|
133
105
|
prerelease: false
|
134
106
|
version_requirements: !ruby/object:Gem::Requirement
|
135
107
|
requirements:
|
136
108
|
- - "~>"
|
137
109
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
110
|
+
version: '5.1'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
112
|
name: rack-ssl
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,20 +136,6 @@ dependencies:
|
|
164
136
|
- - "~>"
|
165
137
|
- !ruby/object:Gem::Version
|
166
138
|
version: '0.1'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: sass
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '3.7'
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '3.7'
|
181
139
|
- !ruby/object:Gem::Dependency
|
182
140
|
name: sinatra
|
183
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -256,13 +214,10 @@ files:
|
|
256
214
|
- app/public/fonts/fontello.ttf
|
257
215
|
- app/public/fonts/fontello.woff
|
258
216
|
- app/public/fonts/fontello.woff2
|
259
|
-
- app/public/js/autocomplete.js
|
260
217
|
- app/public/js/clipboard.js
|
261
218
|
- app/public/js/vendor/clipboard.min.js
|
262
|
-
- app/public/js/vendor/jquery.autocomplete-min.js
|
263
219
|
- app/public/js/vendor/jquery.min.js
|
264
220
|
- app/styles/_anchor.scss
|
265
|
-
- app/styles/_autocomplete.scss
|
266
221
|
- app/styles/_breadcrumbs.scss
|
267
222
|
- app/styles/_code.scss
|
268
223
|
- app/styles/_coderay.scss
|
@@ -327,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
282
|
- !ruby/object:Gem::Version
|
328
283
|
version: '0'
|
329
284
|
requirements: []
|
330
|
-
rubygems_version: 3.
|
285
|
+
rubygems_version: 3.2.3
|
331
286
|
signing_key:
|
332
287
|
specification_version: 4
|
333
288
|
summary: Instant Markdown Server
|
@@ -1,15 +0,0 @@
|
|
1
|
-
$(function() {
|
2
|
-
$('.autocomplete').autocomplete({
|
3
|
-
serviceUrl: '/_search/autocomplete',
|
4
|
-
minChars: 2,
|
5
|
-
noCache: false,
|
6
|
-
preventBadQueries: false,
|
7
|
-
triggerSelectOnValidInput: false,
|
8
|
-
autoSelectFirst: false,
|
9
|
-
preserveInput: false,
|
10
|
-
showNoSuggestionNotice: true,
|
11
|
-
onSelect: function(suggestion) {
|
12
|
-
window.location = "/" + suggestion.data;
|
13
|
-
}
|
14
|
-
});
|
15
|
-
})
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Ajax Autocomplete for jQuery, version 1.2.21
|
3
|
-
* (c) 2014 Tomas Kirda
|
4
|
-
*
|
5
|
-
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
6
|
-
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
|
7
|
-
*/
|
8
|
-
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(a){"use strict";function b(c,d){var e=function(){},f=this,g={ajaxSettings:{},autoSelectFirst:!1,appendTo:document.body,serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:b.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:e,onSearchComplete:e,onSearchError:e,preserveInput:!1,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(a,b,c){return-1!==a.value.toLowerCase().indexOf(c)},paramName:"query",transformResult:function(b){return"string"==typeof b?a.parseJSON(b):b},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1};f.element=c,f.el=a(c),f.suggestions=[],f.badQueries=[],f.selectedIndex=-1,f.currentValue=f.element.value,f.intervalId=0,f.cachedResponse={},f.onChangeInterval=null,f.onChange=null,f.isLocal=!1,f.suggestionsContainer=null,f.noSuggestionsContainer=null,f.options=a.extend({},g,d),f.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},f.hint=null,f.hintValue="",f.selection=null,f.initialize(),f.setOptions(d)}var c=function(){return{escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(a){var b=document.createElement("div");return b.className=a,b.style.position="absolute",b.style.display="none",b}}}(),d={ESC:27,TAB:9,RETURN:13,LEFT:37,UP:38,RIGHT:39,DOWN:40};b.utils=c,a.Autocomplete=b,b.formatResult=function(a,b){var d=a.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),e="("+c.escapeRegExChars(b)+")";return d.replace(new RegExp(e,"gi"),"<strong>$1</strong>")},b.prototype={killerFn:null,initialize:function(){var c,d=this,e="."+d.classes.suggestion,f=d.classes.selected,g=d.options;d.element.setAttribute("autocomplete","off"),d.killerFn=function(b){0===a(b.target).closest("."+d.options.containerClass).length&&(d.killSuggestions(),d.disableKillerFn())},d.noSuggestionsContainer=a('<div class="autocomplete-no-suggestion"></div>').html(this.options.noSuggestionNotice).get(0),d.suggestionsContainer=b.utils.createNode(g.containerClass),c=a(d.suggestionsContainer),c.appendTo(g.appendTo),"auto"!==g.width&&c.width(g.width),c.on("mouseover.autocomplete",e,function(){d.activate(a(this).data("index"))}),c.on("mouseout.autocomplete",function(){d.selectedIndex=-1,c.children("."+f).removeClass(f)}),c.on("click.autocomplete",e,function(){d.select(a(this).data("index"))}),d.fixPositionCapture=function(){d.visible&&d.fixPosition()},a(window).on("resize.autocomplete",d.fixPositionCapture),d.el.on("keydown.autocomplete",function(a){d.onKeyPress(a)}),d.el.on("keyup.autocomplete",function(a){d.onKeyUp(a)}),d.el.on("blur.autocomplete",function(){d.onBlur()}),d.el.on("focus.autocomplete",function(){d.onFocus()}),d.el.on("change.autocomplete",function(a){d.onKeyUp(a)}),d.el.on("input.autocomplete",function(a){d.onKeyUp(a)})},onFocus:function(){var a=this;a.fixPosition(),0===a.options.minChars&&0===a.el.val().length&&a.onValueChange()},onBlur:function(){this.enableKillerFn()},abortAjax:function(){var a=this;a.currentRequest&&(a.currentRequest.abort(),a.currentRequest=null)},setOptions:function(b){var c=this,d=c.options;a.extend(d,b),c.isLocal=a.isArray(d.lookup),c.isLocal&&(d.lookup=c.verifySuggestionsFormat(d.lookup)),d.orientation=c.validateOrientation(d.orientation,"bottom"),a(c.suggestionsContainer).css({"max-height":d.maxHeight+"px",width:d.width+"px","z-index":d.zIndex})},clearCache:function(){this.cachedResponse={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var a=this;a.disabled=!0,clearInterval(a.onChangeInterval),a.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var b=this,c=a(b.suggestionsContainer),d=c.parent().get(0);if(d===document.body||b.options.forceFixPosition){var e=b.options.orientation,f=c.outerHeight(),g=b.el.outerHeight(),h=b.el.offset(),i={top:h.top,left:h.left};if("auto"===e){var j=a(window).height(),k=a(window).scrollTop(),l=-k+h.top-f,m=k+j-(h.top+g+f);e=Math.max(l,m)===l?"top":"bottom"}if(i.top+="top"===e?-f:g,d!==document.body){var n,o=c.css("opacity");b.visible||c.css("opacity",0).show(),n=c.offsetParent().offset(),i.top-=n.top,i.left-=n.left,b.visible||c.css("opacity",o).hide()}"auto"===b.options.width&&(i.width=b.el.outerWidth()-2+"px"),c.css(i)}},enableKillerFn:function(){var b=this;a(document).on("click.autocomplete",b.killerFn)},disableKillerFn:function(){var b=this;a(document).off("click.autocomplete",b.killerFn)},killSuggestions:function(){var a=this;a.stopKillSuggestions(),a.intervalId=window.setInterval(function(){a.hide(),a.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var a,b=this,c=b.el.val().length,d=b.element.selectionStart;return"number"==typeof d?d===c:document.selection?(a=document.selection.createRange(),a.moveStart("character",-c),c===a.text.length):!0},onKeyPress:function(a){var b=this;if(!b.disabled&&!b.visible&&a.which===d.DOWN&&b.currentValue)return void b.suggest();if(!b.disabled&&b.visible){switch(a.which){case d.ESC:b.el.val(b.currentValue),b.hide();break;case d.RIGHT:if(b.hint&&b.options.onHint&&b.isCursorAtEnd()){b.selectHint();break}return;case d.TAB:if(b.hint&&b.options.onHint)return void b.selectHint();if(-1===b.selectedIndex)return void b.hide();if(b.select(b.selectedIndex),b.options.tabDisabled===!1)return;break;case d.RETURN:if(-1===b.selectedIndex)return void b.hide();b.select(b.selectedIndex);break;case d.UP:b.moveUp();break;case d.DOWN:b.moveDown();break;default:return}a.stopImmediatePropagation(),a.preventDefault()}},onKeyUp:function(a){var b=this;if(!b.disabled){switch(a.which){case d.UP:case d.DOWN:return}clearInterval(b.onChangeInterval),b.currentValue!==b.el.val()&&(b.findBestHint(),b.options.deferRequestBy>0?b.onChangeInterval=setInterval(function(){b.onValueChange()},b.options.deferRequestBy):b.onValueChange())}},onValueChange:function(){var b=this,c=b.options,d=b.el.val(),e=b.getQuery(d);return b.selection&&b.currentValue!==e&&(b.selection=null,(c.onInvalidateSelection||a.noop).call(b.element)),clearInterval(b.onChangeInterval),b.currentValue=d,b.selectedIndex=-1,c.triggerSelectOnValidInput&&b.isExactMatch(e)?void b.select(0):void(e.length<c.minChars?b.hide():b.getSuggestions(e))},isExactMatch:function(a){var b=this.suggestions;return 1===b.length&&b[0].value.toLowerCase()===a.toLowerCase()},getQuery:function(b){var c,d=this.options.delimiter;return d?(c=b.split(d),a.trim(c[c.length-1])):b},getSuggestionsLocal:function(b){var c,d=this,e=d.options,f=b.toLowerCase(),g=e.lookupFilter,h=parseInt(e.lookupLimit,10);return c={suggestions:a.grep(e.lookup,function(a){return g(a,b,f)})},h&&c.suggestions.length>h&&(c.suggestions=c.suggestions.slice(0,h)),c},getSuggestions:function(b){var c,d,e,f,g=this,h=g.options,i=h.serviceUrl;if(h.params[h.paramName]=b,d=h.ignoreParams?null:h.params,h.onSearchStart.call(g.element,h.params)!==!1){if(a.isFunction(h.lookup))return void h.lookup(b,function(a){g.suggestions=a.suggestions,g.suggest(),h.onSearchComplete.call(g.element,b,a.suggestions)});g.isLocal?c=g.getSuggestionsLocal(b):(a.isFunction(i)&&(i=i.call(g.element,b)),e=i+"?"+a.param(d||{}),c=g.cachedResponse[e]),c&&a.isArray(c.suggestions)?(g.suggestions=c.suggestions,g.suggest(),h.onSearchComplete.call(g.element,b,c.suggestions)):g.isBadQuery(b)?h.onSearchComplete.call(g.element,b,[]):(g.abortAjax(),f={url:i,data:d,type:h.type,dataType:h.dataType},a.extend(f,h.ajaxSettings),g.currentRequest=a.ajax(f).done(function(a){var c;g.currentRequest=null,c=h.transformResult(a,b),g.processResponse(c,b,e),h.onSearchComplete.call(g.element,b,c.suggestions)}).fail(function(a,c,d){h.onSearchError.call(g.element,b,a,c,d)}))}},isBadQuery:function(a){if(!this.options.preventBadQueries)return!1;for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){var b=this,c=a(b.suggestionsContainer);a.isFunction(b.options.onHide)&&b.visible&&b.options.onHide.call(b.element,c),b.visible=!1,b.selectedIndex=-1,clearInterval(b.onChangeInterval),a(b.suggestionsContainer).hide(),b.signalHint(null)},suggest:function(){if(0===this.suggestions.length)return void(this.options.showNoSuggestionNotice?this.noSuggestions():this.hide());var b,c=this,d=c.options,e=d.groupBy,f=d.formatResult,g=c.getQuery(c.currentValue),h=c.classes.suggestion,i=c.classes.selected,j=a(c.suggestionsContainer),k=a(c.noSuggestionsContainer),l=d.beforeRender,m="",n=function(a){var c=a.data[e];return b===c?"":(b=c,'<div class="autocomplete-group"><strong>'+b+"</strong></div>")};return d.triggerSelectOnValidInput&&c.isExactMatch(g)?void c.select(0):(a.each(c.suggestions,function(a,b){e&&(m+=n(b,g,a)),m+='<div class="'+h+'" data-index="'+a+'">'+f(b,g)+"</div>"}),this.adjustContainerWidth(),k.detach(),j.html(m),a.isFunction(l)&&l.call(c.element,j),c.fixPosition(),j.show(),d.autoSelectFirst&&(c.selectedIndex=0,j.scrollTop(0),j.children("."+h).first().addClass(i)),c.visible=!0,void c.findBestHint())},noSuggestions:function(){var b=this,c=a(b.suggestionsContainer),d=a(b.noSuggestionsContainer);this.adjustContainerWidth(),d.detach(),c.empty(),c.append(d),b.fixPosition(),c.show(),b.visible=!0},adjustContainerWidth:function(){var b,c=this,d=c.options,e=a(c.suggestionsContainer);"auto"===d.width&&(b=c.el.outerWidth()-2,e.width(b>0?b:300))},findBestHint:function(){var b=this,c=b.el.val().toLowerCase(),d=null;c&&(a.each(b.suggestions,function(a,b){var e=0===b.value.toLowerCase().indexOf(c);return e&&(d=b),!e}),b.signalHint(d))},signalHint:function(b){var c="",d=this;b&&(c=d.currentValue+b.value.substr(d.currentValue.length)),d.hintValue!==c&&(d.hintValue=c,d.hint=b,(this.options.onHint||a.noop)(c))},verifySuggestionsFormat:function(b){return b.length&&"string"==typeof b[0]?a.map(b,function(a){return{value:a,data:null}}):b},validateOrientation:function(b,c){return b=a.trim(b||"").toLowerCase(),-1===a.inArray(b,["auto","bottom","top"])&&(b=c),b},processResponse:function(a,b,c){var d=this,e=d.options;a.suggestions=d.verifySuggestionsFormat(a.suggestions),e.noCache||(d.cachedResponse[c]=a,e.preventBadQueries&&0===a.suggestions.length&&d.badQueries.push(b)),b===d.getQuery(d.currentValue)&&(d.suggestions=a.suggestions,d.suggest())},activate:function(b){var c,d=this,e=d.classes.selected,f=a(d.suggestionsContainer),g=f.find("."+d.classes.suggestion);return f.find("."+e).removeClass(e),d.selectedIndex=b,-1!==d.selectedIndex&&g.length>d.selectedIndex?(c=g.get(d.selectedIndex),a(c).addClass(e),c):null},selectHint:function(){var b=this,c=a.inArray(b.hint,b.suggestions);b.select(c)},select:function(a){var b=this;b.hide(),b.onSelect(a)},moveUp:function(){var b=this;if(-1!==b.selectedIndex)return 0===b.selectedIndex?(a(b.suggestionsContainer).children().first().removeClass(b.classes.selected),b.selectedIndex=-1,b.el.val(b.currentValue),void b.findBestHint()):void b.adjustScroll(b.selectedIndex-1)},moveDown:function(){var a=this;a.selectedIndex!==a.suggestions.length-1&&a.adjustScroll(a.selectedIndex+1)},adjustScroll:function(b){var c=this,d=c.activate(b);if(d){var e,f,g,h=a(d).outerHeight();e=d.offsetTop,f=a(c.suggestionsContainer).scrollTop(),g=f+c.options.maxHeight-h,f>e?a(c.suggestionsContainer).scrollTop(e):e>g&&a(c.suggestionsContainer).scrollTop(e-c.options.maxHeight+h),c.options.preserveInput||c.el.val(c.getValue(c.suggestions[b].value)),c.signalHint(null)}},onSelect:function(b){var c=this,d=c.options.onSelect,e=c.suggestions[b];c.currentValue=c.getValue(e.value),c.currentValue===c.el.val()||c.options.preserveInput||c.el.val(c.currentValue),c.signalHint(null),c.suggestions=[],c.selection=e,a.isFunction(d)&&d.call(c.element,e)},getValue:function(a){var b,c,d=this,e=d.options.delimiter;return e?(b=d.currentValue,c=b.split(e),1===c.length?a:b.substr(0,b.length-c[c.length-1].length)+a):a},dispose:function(){var b=this;b.el.off(".autocomplete").removeData("autocomplete"),b.disableKillerFn(),a(window).off("resize.autocomplete",b.fixPositionCapture),a(b.suggestionsContainer).remove()}},a.fn.autocomplete=a.fn.devbridgeAutocomplete=function(c,d){var e="autocomplete";return 0===arguments.length?this.first().data(e):this.each(function(){var f=a(this),g=f.data(e);"string"==typeof c?g&&"function"==typeof g[c]&&g[c](d):(g&&g.dispose&&g.dispose(),g=new b(this,c),f.data(e,g))})}});
|
@@ -1,29 +0,0 @@
|
|
1
|
-
.autocomplete-suggestions {
|
2
|
-
border: 1px solid #ccc;
|
3
|
-
background: #fff;
|
4
|
-
cursor: default;
|
5
|
-
overflow: auto;
|
6
|
-
}
|
7
|
-
.autocomplete-suggestion {
|
8
|
-
padding: 5px 10px;
|
9
|
-
white-space: nowrap;
|
10
|
-
overflow: hidden;
|
11
|
-
}
|
12
|
-
.autocomplete-no-suggestion {
|
13
|
-
padding: 2px 5px;
|
14
|
-
}
|
15
|
-
.autocomplete-selected {
|
16
|
-
background: #ddd;
|
17
|
-
}
|
18
|
-
.autocomplete-suggestions strong {
|
19
|
-
font-weight: bold;
|
20
|
-
}
|
21
|
-
.autocomplete-group {
|
22
|
-
padding: 2px 5px;
|
23
|
-
}
|
24
|
-
.autocomplete-group strong {
|
25
|
-
font-weight: bold;
|
26
|
-
color: #000;
|
27
|
-
display: block;
|
28
|
-
border-bottom: 1px solid #000;
|
29
|
-
}
|