madness 0.8.2 → 0.9.0
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 +4 -4
- data/README.md +22 -14
- data/app/public/css/main.css +2 -30
- data/app/public/css/main.css.map +42 -5
- data/app/styles/_manifest.scss +0 -1
- data/app/views/layout.slim +1 -7
- data/app/views/search.slim +3 -12
- data/lib/madness.rb +4 -1
- data/lib/madness/command_line.rb +0 -10
- data/lib/madness/docopt.txt +10 -19
- data/lib/madness/document.rb +43 -35
- data/lib/madness/navigation.rb +1 -1
- data/lib/madness/refinements/string_refinements.rb +3 -1
- data/lib/madness/search.rb +21 -53
- data/lib/madness/server.rb +0 -11
- data/lib/madness/server_base.rb +3 -13
- data/lib/madness/settings.rb +0 -2
- data/lib/madness/static.rb +2 -2
- data/lib/madness/table_of_contents.rb +2 -2
- data/lib/madness/templates/madness.yml +0 -2
- data/lib/madness/theme.rb +0 -8
- data/lib/madness/version.rb +1 -1
- metadata +14 -79
- 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: d3199e7003a86f77e67b7ff3baec33a2edd12538c5c09c703be48e8fe92ea9e1
|
4
|
+
data.tar.gz: 4415b0ba5c2d5b4666cee26f528e15f05de02e7c6de660ae674a2ed8edd97b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55e979365fb328a88e4794441c7c461c06f6f05297c1d2fc5c4eb5e43ea8f9d5aeefe53bcf12af751f493bcbf03d3824522914b158cff867c993f1f05b779a1
|
7
|
+
data.tar.gz: b5b46e4052ebd035859c95d66ab2f5ebc233beadd395c06e01e9621d6f9cd7e115ac677c0aa99205650b5bcdfa27524c2368bb060cfd16382d2b800e90b3a66f
|
data/README.md
CHANGED
@@ -61,7 +61,7 @@ searching for local, markdown based documentation directories.
|
|
61
61
|
- Configure with a configuration file or command arguments.
|
62
62
|
- Fully customizable theme.
|
63
63
|
- Automatic generation of navigation sidebar.
|
64
|
-
- Automatic generation of Table of Contents.
|
64
|
+
- Automatic generation of Table of Contents (site-wide and inline).
|
65
65
|
|
66
66
|
## Usage
|
67
67
|
|
@@ -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
|
|
@@ -179,8 +169,17 @@ will be automatically added based on the file name.
|
|
179
169
|
|
180
170
|
## Table of Contents Generation
|
181
171
|
|
182
|
-
|
183
|
-
|
172
|
+
### Site-wide
|
173
|
+
|
174
|
+
To generate a Table of Contents file for the entire site (for the directories
|
175
|
+
and files), run `madness --toc FILENAME`
|
176
|
+
|
177
|
+
### Inline
|
178
|
+
|
179
|
+
If you have long markdown documents, and you wish to add an inline Table of
|
180
|
+
Contents for them, simply add an HTML comment `<!-- TOC -->` where you want
|
181
|
+
the Table of Contents to be generated. The inserted list will only consider
|
182
|
+
H2 and H3 headings.
|
184
183
|
|
185
184
|
## Hidden Directories
|
186
185
|
|
@@ -239,6 +238,14 @@ option.
|
|
239
238
|
$ madness --theme my_theme
|
240
239
|
```
|
241
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
|
+
|
242
249
|
|
243
250
|
### Option 2: Change CSS only
|
244
251
|
|
@@ -291,4 +298,5 @@ For more information about the docker image, see:
|
|
291
298
|
[dockerfile]: https://github.com/DannyBen/docker-madness
|
292
299
|
[css]: app/public/css/main.css
|
293
300
|
[app]: app
|
301
|
+
[sasstool]: https://github.com/DannyBen/sasstool
|
294
302
|
|
data/app/public/css/main.css
CHANGED
@@ -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 {\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,IAAI;EAC1B,wBAAwB,EAAE,IAAI;EAC9B,KAAK,EAAE,IAAI;EAEX,WAAW,EAAE,mEAAmE;EAChF,SAAS,EAAE,IAAI;EACf,WAAW,EAAE,GAAG;EAChB,SAAS,EAAE,UAAU,GACtB;;AAED,AAAA,MAAM,EAAE,OAAO,CAAC;EACd,WAAW,EAAE,MAAM,GACpB;;AAED,AAAA,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;EACrB,UAAU,EAAE,GAAG;EACf,aAAa,EAAE,IAAI;EACnB,WAAW,EAAE,IAAI;EACjB,WAAW,EAAE,GAAG,GACjB;;AAED,AAAA,EAAE,CAAC;EACD,MAAM,EAAE,QAAQ;EAChB,cAAc,EAAE,KAAK;EACrB,SAAS,EAAE,MAAM;EACjB,WAAW,EAAE,GAAG;EAChB,aAAa,EAAE,cAAc,GAC9B;;AAED,AAAA,EAAE,CAAC;EACD,cAAc,EAAE,KAAK;EACrB,SAAS,EAAE,MAAM;EACjB,WAAW,EAAE,KAAK;EAClB,aAAa,EAAE,cA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F,gBAAgB,CAAC;IAChB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,MAAM,GACf"
|
7
44
|
}
|
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" 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.rb
CHANGED
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
@@ -16,17 +16,17 @@ Subcommands:
|
|
16
16
|
|
17
17
|
Parameters:
|
18
18
|
PATH:
|
19
|
-
Path to the markdown directory
|
20
|
-
(Config option: path)
|
19
|
+
Path to the markdown directory.
|
20
|
+
(Config option: path, default: .)
|
21
21
|
|
22
22
|
Options:
|
23
23
|
-p, --port NUMBER
|
24
|
-
Set server port number
|
25
|
-
(Config option: port)
|
24
|
+
Set server port number.
|
25
|
+
(Config option: port, default: 3000)
|
26
26
|
|
27
27
|
-b, --bind ADDRESS
|
28
|
-
Set server listen address
|
29
|
-
(Config option: bind)
|
28
|
+
Set server listen address.
|
29
|
+
(Config option: bind, default: 0.0.0.0)
|
30
30
|
|
31
31
|
--no-auto-h1
|
32
32
|
By default, if a markdown document does not start with an H1 caption,
|
@@ -60,32 +60,24 @@ 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)
|
78
70
|
|
79
71
|
--auth-realm REALM
|
80
|
-
The basic authentication realm
|
81
|
-
(Config option: auth_realm)
|
72
|
+
The basic authentication realm.
|
73
|
+
(Config option: auth_realm, default: Madness)
|
82
74
|
|
83
75
|
--open
|
84
76
|
Open the browser pointing at the madness webserver.
|
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,22 +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
|
-
add_anchor_ids
|
81
|
+
replace_toc_marker
|
82
|
+
prepend_h1 if config.auto_h1
|
83
|
+
add_anchor_ids
|
103
84
|
html = doc.to_html :UNSAFE
|
104
85
|
html = syntax_highlight(html) if config.highlighter
|
105
|
-
html = prepend_h1(html) if config.auto_h1
|
106
86
|
html
|
107
87
|
end
|
108
88
|
|
109
89
|
# Add anchors with IDs before all headers
|
110
|
-
def add_anchor_ids
|
90
|
+
def add_anchor_ids
|
111
91
|
doc.walk do |node|
|
112
92
|
if node.type == :header
|
113
93
|
anchor = CommonMarker::Node.new(:inline_html)
|
@@ -121,12 +101,40 @@ module Madness
|
|
121
101
|
end
|
122
102
|
end
|
123
103
|
|
124
|
-
#
|
125
|
-
def
|
126
|
-
|
127
|
-
html
|
104
|
+
# Replace <!-- TOC --> with a Table of Contents for the page
|
105
|
+
def replace_toc_marker
|
106
|
+
toc_marker = doc.find do |node|
|
107
|
+
node.type == :html and node.string_content.include? "<!-- TOC -->"
|
128
108
|
end
|
129
|
-
|
109
|
+
|
110
|
+
return unless toc_marker
|
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
|
118
|
+
toc = []
|
119
|
+
doc.walk do |node|
|
120
|
+
next unless node.type == :header
|
121
|
+
level = node.header_level
|
122
|
+
next unless level.between? 2, 3
|
123
|
+
text = node.first_child.string_content
|
124
|
+
spacer = " " * (level - 1)
|
125
|
+
toc << "#{spacer}- [#{text}](##{text.to_slug})"
|
126
|
+
end
|
127
|
+
|
128
|
+
toc = toc.join "\n"
|
129
|
+
CommonMarker.render_doc(toc).first_child
|
130
|
+
end
|
131
|
+
|
132
|
+
# If the document does not start with an H1 tag, add it.
|
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
|
130
138
|
end
|
131
139
|
|
132
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,44 @@
|
|
1
|
-
require 'ferret'
|
2
|
-
|
3
1
|
module Madness
|
4
2
|
class Search
|
5
3
|
include ServerHelper
|
6
|
-
include Ferret
|
7
|
-
include Ferret::Index
|
8
4
|
using StringRefinements
|
9
5
|
|
10
6
|
def initialize(path=nil)
|
11
7
|
@path = path || docroot
|
12
8
|
end
|
13
9
|
|
14
|
-
def
|
15
|
-
|
10
|
+
def index
|
11
|
+
@index ||= index!
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
def search(query)
|
15
|
+
query = query.downcase
|
16
|
+
result = {}
|
17
|
+
|
18
|
+
index.each do |file, content|
|
19
|
+
file = file.remove("#{@path}/")[0...-3]
|
20
|
+
url = file_url file
|
21
|
+
label = file_label file
|
22
|
+
next unless content.include? query
|
23
|
+
result[label] = url
|
26
24
|
end
|
27
25
|
|
28
|
-
|
29
|
-
index.close()
|
26
|
+
result
|
30
27
|
end
|
31
28
|
|
32
|
-
|
33
|
-
index = Index.new path: index_dir
|
29
|
+
private
|
34
30
|
|
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
|
-
}
|
31
|
+
def index!
|
32
|
+
results = {}
|
33
|
+
Dir["#{@path}/**/*.md"].sort.each do |file|
|
34
|
+
next if skip_index? file
|
35
|
+
filename = file_url(file.sub("#{@path}/", '')[0...-3]).downcase
|
36
|
+
content = File.read(file).downcase
|
37
|
+
results[file] = "#{filename} #{content}"
|
48
38
|
end
|
49
|
-
|
50
|
-
index.close()
|
51
39
|
results
|
52
40
|
end
|
53
41
|
|
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
42
|
# We are going to avoid indexing of README.md when there is also an
|
66
43
|
# index.md in the same directory, to keep behavior consistent with the
|
67
44
|
# display logic
|
@@ -74,15 +51,6 @@ module Madness
|
|
74
51
|
end
|
75
52
|
end
|
76
53
|
|
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
54
|
def file_label(filename)
|
87
55
|
filename
|
88
56
|
.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,9 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
# require 'sinatra/reloader'
|
2
2
|
require 'rack/ssl'
|
3
|
-
require 'sass'
|
4
|
-
require 'sass/plugin/rack'
|
5
3
|
require 'sinatra/base'
|
6
|
-
require 'sinatra/reloader'
|
7
4
|
require 'slim'
|
8
5
|
|
9
6
|
module Madness
|
@@ -15,23 +12,18 @@ module Madness
|
|
15
12
|
helpers ServerHelper
|
16
13
|
|
17
14
|
Slim::Engine.set_options pretty: true
|
18
|
-
use Sass::Plugin::Rack
|
19
15
|
use Rack::SSL if ENV['MADNESS_FORCE_SSL']
|
20
16
|
set :root, File.expand_path('../../', __dir__)
|
17
|
+
set :environment, ENV['MADNESS_ENV'] || :production
|
21
18
|
set :server, :puma
|
22
19
|
|
23
|
-
configure :development do
|
24
|
-
register Sinatra::Reloader
|
25
|
-
also_reload "#{__dir__}/*.rb"
|
26
|
-
end
|
27
|
-
|
28
20
|
# Since we cannot use any config values in the main body of the class,
|
29
21
|
# since they will be updated later, we need to set anything that relys
|
30
22
|
# on the config values just before running the server.
|
31
23
|
# The CommandLine class and the test suite should both call
|
32
24
|
# `Server.prepare` before calling Server.run!
|
33
25
|
def self.prepare
|
34
|
-
use Madness::Static, root: "#{config.path}/", :
|
26
|
+
use Madness::Static, root: "#{config.path}/", urls: %w[/], cascade: true
|
35
27
|
set :bind, config.bind
|
36
28
|
set :port, config.port
|
37
29
|
|
@@ -44,8 +36,6 @@ module Madness
|
|
44
36
|
|
45
37
|
set :views, theme.views_path
|
46
38
|
set :public_folder, theme.public_path
|
47
|
-
Sass::Plugin.options[:template_location] = theme.css_source_path
|
48
|
-
Sass::Plugin.options[:css_location] = theme.css_target_path
|
49
39
|
end
|
50
40
|
|
51
41
|
def self.set_basic_auth
|
data/lib/madness/settings.rb
CHANGED
data/lib/madness/static.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Madness
|
2
2
|
|
3
3
|
# The Madness::Static middleware delegates requests to
|
4
|
-
# Rack::
|
4
|
+
# Rack::Static middleware unless the request URI ends with .md
|
5
5
|
class Static
|
6
6
|
def initialize(app, options)
|
7
7
|
@app = app
|
8
|
-
@static =
|
8
|
+
@static = Rack::Static.new app, options
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
@@ -5,7 +5,7 @@ module Madness
|
|
5
5
|
|
6
6
|
attr_reader :dir
|
7
7
|
|
8
|
-
def initialize(dir=nil)
|
8
|
+
def initialize(dir = nil)
|
9
9
|
@dir = dir || docroot
|
10
10
|
end
|
11
11
|
|
@@ -20,7 +20,7 @@ module Madness
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def toc!(path=dir, indent=0)
|
23
|
+
def toc!(path = dir, indent = 0)
|
24
24
|
list = Directory.new(path).list
|
25
25
|
|
26
26
|
result = []
|
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.0
|
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: 2020-
|
11
|
+
date: 2020-12-31 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,28 +100,14 @@ dependencies:
|
|
128
100
|
requirements:
|
129
101
|
- - "~>"
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '4.0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rack-contrib
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '2.1'
|
103
|
+
version: '5.1'
|
146
104
|
type: :runtime
|
147
105
|
prerelease: false
|
148
106
|
version_requirements: !ruby/object:Gem::Requirement
|
149
107
|
requirements:
|
150
108
|
- - "~>"
|
151
109
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
110
|
+
version: '5.1'
|
153
111
|
- !ruby/object:Gem::Dependency
|
154
112
|
name: rack-ssl
|
155
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,20 +136,6 @@ dependencies:
|
|
178
136
|
- - "~>"
|
179
137
|
- !ruby/object:Gem::Version
|
180
138
|
version: '0.1'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: sass
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '3.7'
|
188
|
-
type: :runtime
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '3.7'
|
195
139
|
- !ruby/object:Gem::Dependency
|
196
140
|
name: sinatra
|
197
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,53 +157,47 @@ dependencies:
|
|
213
157
|
- !ruby/object:Gem::Version
|
214
158
|
version: 2.0.5
|
215
159
|
- !ruby/object:Gem::Dependency
|
216
|
-
name:
|
160
|
+
name: slim
|
217
161
|
requirement: !ruby/object:Gem::Requirement
|
218
162
|
requirements:
|
219
163
|
- - "~>"
|
220
164
|
- !ruby/object:Gem::Version
|
221
|
-
version: '
|
222
|
-
- - ">="
|
223
|
-
- !ruby/object:Gem::Version
|
224
|
-
version: 2.0.5
|
165
|
+
version: '4.0'
|
225
166
|
type: :runtime
|
226
167
|
prerelease: false
|
227
168
|
version_requirements: !ruby/object:Gem::Requirement
|
228
169
|
requirements:
|
229
170
|
- - "~>"
|
230
171
|
- !ruby/object:Gem::Version
|
231
|
-
version: '
|
232
|
-
- - ">="
|
233
|
-
- !ruby/object:Gem::Version
|
234
|
-
version: 2.0.5
|
172
|
+
version: '4.0'
|
235
173
|
- !ruby/object:Gem::Dependency
|
236
|
-
name:
|
174
|
+
name: extended_yaml
|
237
175
|
requirement: !ruby/object:Gem::Requirement
|
238
176
|
requirements:
|
239
177
|
- - "~>"
|
240
178
|
- !ruby/object:Gem::Version
|
241
|
-
version: '
|
179
|
+
version: '0.2'
|
242
180
|
type: :runtime
|
243
181
|
prerelease: false
|
244
182
|
version_requirements: !ruby/object:Gem::Requirement
|
245
183
|
requirements:
|
246
184
|
- - "~>"
|
247
185
|
- !ruby/object:Gem::Version
|
248
|
-
version: '
|
186
|
+
version: '0.2'
|
249
187
|
- !ruby/object:Gem::Dependency
|
250
|
-
name:
|
188
|
+
name: addressable
|
251
189
|
requirement: !ruby/object:Gem::Requirement
|
252
190
|
requirements:
|
253
191
|
- - "~>"
|
254
192
|
- !ruby/object:Gem::Version
|
255
|
-
version: '
|
193
|
+
version: '2.7'
|
256
194
|
type: :runtime
|
257
195
|
prerelease: false
|
258
196
|
version_requirements: !ruby/object:Gem::Requirement
|
259
197
|
requirements:
|
260
198
|
- - "~>"
|
261
199
|
- !ruby/object:Gem::Version
|
262
|
-
version: '
|
200
|
+
version: '2.7'
|
263
201
|
description: Start a markdown server in any directory
|
264
202
|
email: db@dannyben.com
|
265
203
|
executables:
|
@@ -276,13 +214,10 @@ files:
|
|
276
214
|
- app/public/fonts/fontello.ttf
|
277
215
|
- app/public/fonts/fontello.woff
|
278
216
|
- app/public/fonts/fontello.woff2
|
279
|
-
- app/public/js/autocomplete.js
|
280
217
|
- app/public/js/clipboard.js
|
281
218
|
- app/public/js/vendor/clipboard.min.js
|
282
|
-
- app/public/js/vendor/jquery.autocomplete-min.js
|
283
219
|
- app/public/js/vendor/jquery.min.js
|
284
220
|
- app/styles/_anchor.scss
|
285
|
-
- app/styles/_autocomplete.scss
|
286
221
|
- app/styles/_breadcrumbs.scss
|
287
222
|
- app/styles/_code.scss
|
288
223
|
- app/styles/_coderay.scss
|
@@ -347,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
347
282
|
- !ruby/object:Gem::Version
|
348
283
|
version: '0'
|
349
284
|
requirements: []
|
350
|
-
rubygems_version: 3.
|
285
|
+
rubygems_version: 3.2.3
|
351
286
|
signing_key:
|
352
287
|
specification_version: 4
|
353
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
|
-
}
|