markita 4.1.230214 → 6.0.250327
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 +194 -237
- data/bin/markita +16 -19
- data/lib/markita/base.rb +37 -38
- data/lib/markita/config.rb +41 -10
- data/lib/markita/html.rb +35 -20
- data/lib/markita/markdown/attributes.rb +23 -0
- data/lib/markita/markdown/blockquote.rb +41 -0
- data/lib/markita/markdown/code.rb +44 -0
- data/lib/markita/markdown/code_block.rb +29 -0
- data/lib/markita/markdown/definitions.rb +42 -0
- data/lib/markita/markdown/embed.rb +63 -0
- data/lib/markita/markdown/empty.rb +22 -0
- data/lib/markita/markdown/fold.rb +39 -0
- data/lib/markita/markdown/footnotes.rb +28 -0
- data/lib/markita/markdown/form.rb +125 -0
- data/lib/markita/markdown/heading.rb +33 -0
- data/lib/markita/markdown/horizontal_rule.rb +25 -0
- data/lib/markita/markdown/image.rb +60 -0
- data/lib/markita/markdown/inline.rb +123 -0
- data/lib/markita/markdown/list.rb +65 -0
- data/lib/markita/markdown/markup.rb +23 -0
- data/lib/markita/markdown/script.rb +28 -0
- data/lib/markita/markdown/split.rb +38 -0
- data/lib/markita/markdown/table.rb +52 -0
- data/lib/markita/markdown.rb +51 -498
- data/lib/markita/plug/about.rb +28 -17
- data/lib/markita/plug/favicon.rb +14 -10
- data/lib/markita/plug/highlight.rb +18 -12
- data/lib/markita/plug/login.rb +35 -28
- data/lib/markita/plug/navigation.rb +4 -1
- data/lib/markita/plug/plugs.rb +7 -1
- data/lib/markita/plug/readme.rb +8 -4
- data/lib/markita/preprocess.rb +52 -23
- data/lib/markita/refinement.rb +21 -0
- data/lib/markita/requires.rb +29 -0
- data/lib/markita.rb +15 -24
- metadata +52 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed48aca2238e0b8ac390519ddc7d4c0e8e5e6f798b87a7654da9454f5f92cd3
|
4
|
+
data.tar.gz: bfec77d804b3e803c282e4581c6ac7008a716ad0c2d91c2e9dca170b9ecb987a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4feb3c5ba26177dc86f27ab90599c120a3d0631f24d5919d28efacb39edd7bbdb5d6a76d9eb28ee852ec0b0bfdfc41ea3097b82f1bdc29d533686f95756bb13f
|
7
|
+
data.tar.gz: b8dfe46d0853061fe8d7d8a666e1c102b249a12cd3ad26558b05ebe5893d899b03add66fe8d9da41fd984e27e7d158cb0b69d1967e7fe365f703c2e2ba74ae20
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Markita
|
2
2
|
|
3
|
-
* [VERSION
|
3
|
+
* [VERSION 6.0.250327](https://github.com/carlosjhr64/markita/releases)
|
4
4
|
* [github](https://www.github.com/carlosjhr64/markita)
|
5
5
|
* [rubygems](https://rubygems.org/gems/markita)
|
6
6
|
|
@@ -25,221 +25,78 @@ Options:
|
|
25
25
|
--port=PORT 8080
|
26
26
|
--theme=THEME base16.light
|
27
27
|
--allowed=IPS
|
28
|
-
--
|
29
|
-
--no_favicon
|
30
|
-
--no_highlight
|
31
|
-
--no_login
|
32
|
-
--no_navigation
|
33
|
-
--no_plugs
|
34
|
-
--no_readme
|
35
|
-
Exclusive:
|
36
|
-
no_login allowed
|
28
|
+
--no=PLUGS
|
37
29
|
Types:
|
38
30
|
DIRECTORY /^~?[\/\w\.]+$/
|
39
31
|
BIND /^[\w\.]+$/
|
40
32
|
PORT /^\d+$/
|
41
33
|
IPS /^[\d\.\,]+$/
|
42
34
|
THEME /^[\w\.]+$/
|
35
|
+
PLUGS /^[\w\,]+$/
|
43
36
|
# NOTE:
|
44
37
|
# Assuming site is in ~/vimwiki,
|
45
38
|
# when ~/vimwiki/.valid-id is set with a sha256sum of a password,
|
46
39
|
# that password will restrict the site.
|
47
40
|
# Allowed IPs bypass the need for site password
|
48
41
|
# when the site is accessed from those locations.
|
42
|
+
# You can use the --no option to list plugins to disable.
|
49
43
|
```
|
50
44
|
## FEATURES
|
51
45
|
|
52
|
-
|
46
|
+
* `#` Headers with link anchors
|
47
|
+
* `>` Block-quotes nests up to level three
|
48
|
+
* ``` Code section highlighted by [Rouge](https://github.com/rouge-ruby/rouge)
|
49
|
+
* PRE-forms on text starting with four spaces
|
50
|
+
* Tables
|
51
|
+
* Script section pass through starts with `^<script` and ends with `^</script>`
|
52
|
+
* HTML pass through on `/^<.*>$/` lines
|
53
|
+
* And more...
|
53
54
|
|
54
|
-
-
|
55
|
-
- [x] Marked ballot
|
56
|
-
|
57
|
-
Markdown:
|
58
|
-
|
59
|
-
- [ ] Empty ballot
|
60
|
-
- [x] Marked ballot
|
61
|
-
|
62
|
-
### Image placement
|
63
|
-
|
64
|
-
Markdown:
|
65
|
-
|
66
|
-

|
67
|
-

|
68
|
-

|
69
|
-
Image centered above.
|
70
|
-
Image to the left.
|
71
|
-
Image to the right.
|
72
|
-
And set a HR bar below.
|
73
|
-
---
|
74
|
-
|
75
|
-
### Image size
|
76
|
-
|
77
|
-
Markdown:
|
78
|
-
|
79
|
-

|
80
|
-
|
81
|
-
### Image link
|
82
|
-
|
83
|
-
Markdown:
|
84
|
-
|
85
|
-

|
86
|
-
|
87
|
-
### Forms
|
88
|
-
|
89
|
-
Markdown:
|
90
|
-
|
91
|
-
A get method form without submit button on single field:
|
92
|
-
! Google:[q] (https://www.google.com/search)
|
93
|
-
|
94
|
-
A post method form with a password field
|
95
|
-
and a submit button due to multiple fields.
|
96
|
-
Note the `*` in front of `pwd` marking it as a password field,
|
97
|
-
and the ending `!` marking the route as a post:
|
98
|
-
! Username:[user] Password:[*pwd] (/login.html)!
|
99
|
-
|
100
|
-
A multi-line form with default entry and hidden field:
|
101
|
-
! Name:[user] [status="active"] (/register.html)
|
102
|
-
! Address:[address]
|
103
|
-
! Code:[code="1234"]
|
104
|
-
|
105
|
-
A selection list:
|
106
|
-
! Color:[color="Red","White","Blue"]
|
107
|
-
|
108
|
-
### Template substitutions
|
109
|
-
|
110
|
-
Markdown:
|
111
|
-
|
112
|
-
! template = "* [&query;](https://www.google.com/search?q=&QUERY;)"
|
113
|
-
! regx = /^\* (?<query>.*)$/
|
114
|
-
* Grumpy Cat
|
115
|
-
* It's over 9000!
|
116
|
-
|
117
|
-
Template clears after first non-match.
|
118
|
-
Note: on upcased keys, value is CGI escaped.
|
119
|
-
|
120
|
-
### Split table
|
121
|
-
|
122
|
-
<table><tr><td>
|
123
|
-
<p>
|
124
|
-
Top left
|
125
|
-
</p>
|
126
|
-
</td><td>
|
127
|
-
<p>
|
128
|
-
Top center
|
129
|
-
</p>
|
130
|
-
</td><td>
|
131
|
-
<p>
|
132
|
-
Top right
|
133
|
-
</p>
|
134
|
-
</td></tr><tr><td>
|
135
|
-
<p>
|
136
|
-
Middle left
|
137
|
-
</p>
|
138
|
-
</td><td>
|
139
|
-
<p>
|
140
|
-
Middle center
|
141
|
-
</p>
|
142
|
-
</td><td>
|
143
|
-
<p>
|
144
|
-
Middle left
|
145
|
-
</p>
|
146
|
-
</td></tr><tr><td>
|
147
|
-
<p>
|
148
|
-
Bottom left
|
149
|
-
</p>
|
150
|
-
</td><td>
|
151
|
-
<p>
|
152
|
-
Bottom center
|
153
|
-
</p>
|
154
|
-
</td><td>
|
155
|
-
<p>
|
156
|
-
Bottom right
|
157
|
-
</p>
|
158
|
-
</td></tr></table>
|
159
|
-
|
160
|
-
Markdown:
|
161
|
-
|
162
|
-
|:
|
163
|
-
Top left
|
164
|
-
|
|
165
|
-
Top center
|
166
|
-
|
|
167
|
-
Top right
|
168
|
-
:|:
|
169
|
-
Middle left
|
170
|
-
|
|
171
|
-
Middle center
|
172
|
-
|
|
173
|
-
Middle left
|
174
|
-
:|:
|
175
|
-
Bottom left
|
176
|
-
|
|
177
|
-
Bottom center
|
178
|
-
|
|
179
|
-
Bottom right
|
180
|
-
:|
|
181
|
-
|
182
|
-
### Inline links, code, bold, italic, strikes, and underline
|
183
|
-
|
184
|
-
<p>
|
185
|
-
The <b>bold</b> and <i>italics</i> <s>strikes</s> at <u>underlined</u>, while a
|
186
|
-
<a href="#Markita">link to #Markita</a>
|
187
|
-
sees the <code>~ code ~ "a*b*c"</code> to
|
188
|
-
<a href="https://github.com">https://github.com</a>.
|
189
|
-
</p>
|
190
|
-
|
191
|
-
Markdown:
|
192
|
-
|
193
|
-
The *bold* and "italics" ~strikes~ at _underlined_,
|
194
|
-
while a [link to #Markita](#Markita)
|
195
|
-
sees the `~ code ~ "a*b*c"` to [https://github.com].
|
55
|
+
### Meta-data
|
196
56
|
|
197
|
-
|
57
|
+
* `$key` substitution to its metadata value in text
|
58
|
+
* If `Title` is set via meta-data, Javascript will set the page's title to that
|
59
|
+
* One can use numbers to reference long URLs
|
60
|
+
```markdown
|
61
|
+
--- # The hashtag disambiguates the horizontal rule(legal YAML comment).
|
62
|
+
Title: Markita
|
63
|
+
1: https://github.com/carlosjhr64/markita
|
64
|
+
name: Don Quixote de la Mancha
|
65
|
+
# You can also add to attributes here:
|
66
|
+
attributes: style="color: darkgreen;"
|
67
|
+
... # The end marker is needed to end the fold
|
68
|
+
[Markita](1)
|
69
|
+
Your name is $name.
|
70
|
+
```
|
71
|
+
### Horizontal rule
|
72
|
+
```markdown
|
73
|
+
---
|
74
|
+
```
|
75
|
+
### Attributes
|
76
|
+
```markdown
|
77
|
+
{: style="color: blue;"}
|
78
|
+
You can set the attributes for most blocks.
|
79
|
+
```
|
80
|
+
### Lists
|
198
81
|
|
82
|
+
One can nest lists up to 3 levels:
|
83
|
+
```markdown
|
84
|
+
{: style="color: red;"}{: style="color: green;"}{: style="color: blue;"}
|
199
85
|
1. One
|
200
86
|
2. Two
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
Markdown:
|
213
|
-
|
214
|
-
1. One
|
215
|
-
2. Two
|
216
|
-
|
217
|
-
* Point A
|
218
|
-
* Point B
|
219
|
-
|
220
|
-
+ Word: Definition of the word
|
221
|
-
+ Symbol:
|
222
|
-
+ Usage for the symbol
|
223
|
-
|
224
|
-
### Block-quote
|
225
|
-
|
226
|
-
Like Hamlet says...
|
227
|
-
> To be or not to be...
|
228
|
-
> That is the question!
|
229
|
-
|
230
|
-
Markdown:
|
231
|
-
|
232
|
-
Like Hamlet says...
|
233
|
-
> To be or not to be...
|
234
|
-
> That is the question!
|
235
|
-
|
236
|
-
### Code
|
237
|
-
```ruby
|
238
|
-
def wut
|
239
|
-
puts "Wut?"
|
240
|
-
end
|
87
|
+
* ABC
|
88
|
+
- [ ] Empty ballot
|
89
|
+
- [x] Marked ballot
|
90
|
+
* XYZ
|
91
|
+
3. Three
|
92
|
+
```
|
93
|
+
### Definitions
|
94
|
+
```markdown
|
95
|
+
+ Word: Definition
|
96
|
+
+ Slang:
|
97
|
+
+ Define slang
|
241
98
|
```
|
242
|
-
|
99
|
+
### Code
|
243
100
|
|
244
101
|
```ruby
|
245
102
|
def wut
|
@@ -253,62 +110,162 @@ Markdown:
|
|
253
110
|
| ------: | ----: | :----: | :------------ |
|
254
111
|
| 1 | 1.0 | $ | The word |
|
255
112
|
| 1234 | 12.3 | & | On the street |
|
113
|
+
```markdown
|
114
|
+
| Integer | Float | Symbol | Word |
|
115
|
+
| ------: | ----: | :----: | :------------ |
|
116
|
+
| 1 | 1.0 | $ | The word |
|
117
|
+
| 1234 | 12.3 | & | On the street |
|
118
|
+
```
|
119
|
+
### Splits table
|
256
120
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
121
|
+
<table><tr><td>
|
122
|
+
<p> Top left </p>
|
123
|
+
</td><td>
|
124
|
+
<p> Top center </p>
|
125
|
+
</td><td>
|
126
|
+
<p> Top right </p>
|
127
|
+
</td></tr><tr><td>
|
128
|
+
<p> Middle left </p>
|
129
|
+
</td><td>
|
130
|
+
<p> Middle center </p>
|
131
|
+
</td><td>
|
132
|
+
<p> Middle left </p>
|
133
|
+
</td></tr><tr><td>
|
134
|
+
<p> Bottom left </p>
|
135
|
+
</td><td>
|
136
|
+
<p> Bottom center </p>
|
137
|
+
</td><td>
|
138
|
+
<p> Bottom right </p>
|
139
|
+
</td></tr></table>
|
270
140
|
|
141
|
+
```markdown
|
142
|
+
|:
|
143
|
+
Top left
|
144
|
+
|
|
145
|
+
Top center
|
146
|
+
|
|
147
|
+
Top right
|
148
|
+
:|:
|
149
|
+
Middle left
|
150
|
+
|
|
151
|
+
Middle center
|
152
|
+
|
|
153
|
+
Middle left
|
154
|
+
:|:
|
155
|
+
Bottom left
|
156
|
+
|
|
157
|
+
Bottom center
|
158
|
+
|
|
159
|
+
Bottom right
|
160
|
+
:|
|
161
|
+
```
|
162
|
+
### Image placement
|
163
|
+
```markdown
|
164
|
+

|
165
|
+

|
166
|
+

|
167
|
+
Image centered above.
|
168
|
+
Image to the left.
|
169
|
+
Image to the right.
|
170
|
+
```
|
171
|
+
### Image size
|
172
|
+
```markdown
|
173
|
+

|
174
|
+
```
|
175
|
+
### Image link
|
176
|
+
```markdown
|
177
|
+

|
178
|
+
```
|
271
179
|
### Embed text
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
!> /path-to/ascii_art.txt
|
276
|
-
|
180
|
+
```markdown
|
181
|
+
!> /path-to/ascii_art.txt
|
182
|
+
```
|
277
183
|
Useful for ASCII art.
|
278
184
|
Unless an `*.html` file, the text is embedded in `pre` tags.
|
279
185
|
Further more unless a `*.txt` file, the text is embedded in `code` tags.
|
280
186
|
|
281
|
-
###
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
187
|
+
### Footnotes
|
188
|
+
```markdown
|
189
|
+
There once was a man from Nantucket[^1]
|
190
|
+
Who kept all his cash[^2] in a bucket.
|
191
|
+
But his daughter, named Nan,
|
192
|
+
Ran away with a man
|
193
|
+
And as for the bucket, Natucket.[^3]
|
194
|
+
|
195
|
+
[^1]: Nantucket is an island in the U.S. state of Massachusetts.
|
196
|
+
[^2]: Cash is money in currency.
|
197
|
+
[^3]: Read as "Nan took it."
|
198
|
+
```
|
199
|
+
### Forms
|
200
|
+
```markdown
|
201
|
+
A get method form without submit button on single field:
|
202
|
+
! Google:[q] (https://www.google.com/search)
|
203
|
+
|
204
|
+
A post method form with a password field
|
205
|
+
and a submit button due to multiple fields.
|
206
|
+
Note the `*` in front of `pwd` marking it as a password field,
|
207
|
+
and the ending `!` marking the route as a post:
|
208
|
+
! Username:[user] Password:[*pwd] (/login.html)!
|
209
|
+
|
210
|
+
A multi-line form with default entry and hidden field:
|
211
|
+
! Name:[user] [status="active"] (/register.html)
|
212
|
+
! Address:[address]
|
213
|
+
! Code:[code="1234"]
|
214
|
+
|
215
|
+
A selection list:
|
216
|
+
! Color:[color="Red","White","Blue"]
|
217
|
+
|
218
|
+
A submit button:
|
219
|
+
! [submit="Go!"]
|
220
|
+
```
|
221
|
+
### Template substitutions
|
222
|
+
```markdown
|
223
|
+
! regx = /^This (?<word>\w+)/
|
224
|
+
This cat is a pussy&word;.
|
225
|
+
|
226
|
+
! template = "* [&query;](https://www.google.com/search?q=&QUERY;)"
|
227
|
+
! regx = /^\* (?<query>.*)$/
|
228
|
+
* Grumpy Cat
|
229
|
+
* It's over 9000!
|
230
|
+
```
|
231
|
+
Template clears after first non-match.
|
232
|
+
Note: on upcased keys, value is CGI escaped.
|
286
233
|
|
287
|
-
|
234
|
+
### Inline links, code, bold, italic, strikes, and underline
|
288
235
|
|
289
|
-
|
236
|
+
The <b>bold</b> and <i>italics</i> <s>strikes</s> at <u>underlined</u>,
|
237
|
+
while a [link to #Markita](#Markita)
|
238
|
+
sees the `~ code ~ "a*b*c"` to https://github.com.
|
239
|
+
```markdown
|
240
|
+
The *bold* and "italics" ~strikes~ at _underlined_,
|
241
|
+
while a [link to #Markita](#Markita)
|
242
|
+
sees the `~ code ~ "a*b*c"` to https://github.com.
|
243
|
+
```
|
244
|
+
The inline links with optional title have the following syntax(with no double quotes):
|
245
|
+
```markdown
|
246
|
+
[link text](link title)
|
247
|
+
```
|
248
|
+
### Entity escapes
|
290
249
|
|
291
|
-
|
250
|
+
When you want to escape the inline substitutions or HTML tags, use backslash:
|
292
251
|
|
293
|
-
|
294
|
-
Who kept all his cash[^2] in a bucket.
|
295
|
-
But his daughter, named Nan,
|
296
|
-
Ran away with a man
|
297
|
-
And as for the bucket, Natucket.[^3]
|
252
|
+
* \< \> \* \" \~ \` \& \; \\
|
298
253
|
|
299
|
-
|
300
|
-
[^2]: Cash is money in currency.
|
301
|
-
[^3]: Read as "Nan took it."
|
254
|
+
### Emojis
|
302
255
|
|
303
|
-
|
256
|
+
I :heart: to :laughing:!
|
257
|
+
```markdown
|
258
|
+
I :heart: to :laughing:!
|
259
|
+
```
|
260
|
+
### Superscript and subscript
|
304
261
|
|
305
|
-
|
262
|
+
This is <sup>superscript</sup> and this is <sub>subscript</sub>.
|
263
|
+
```markdown
|
264
|
+
This is \^(superscript) and this is \(subscript).
|
265
|
+
```
|
266
|
+
### It's all Ruby!
|
306
267
|
|
307
|
-
|
308
|
-
Title: The Title You Want For Your Page
|
309
|
-
1: https://way.to/create/ref/links
|
310
|
-
---
|
311
|
-
You can now [link](1) with a reference number.
|
268
|
+
Add your own custom features.
|
312
269
|
|
313
270
|
## HOW-TOs
|
314
271
|
|
@@ -351,7 +308,7 @@ $ GET https://raw.githubusercontent.com/carlosjhr64/markita/main/plug/todotxt.rb
|
|
351
308
|
```
|
352
309
|
## LICENSE
|
353
310
|
|
354
|
-
Copyright (c)
|
311
|
+
Copyright (c) 2025 CarlosJHR64
|
355
312
|
|
356
313
|
Permission is hereby granted, free of charge,
|
357
314
|
to any person obtaining a copy of this software and
|
data/bin/markita
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'help_parser'
|
3
5
|
require 'markita'
|
4
6
|
|
@@ -11,38 +13,33 @@ OPTIONS = HelpParser[Markita::VERSION, <<~HELP]
|
|
11
13
|
--port=PORT \t 8080
|
12
14
|
--theme=THEME \t base16.light
|
13
15
|
--allowed=IPS
|
14
|
-
--
|
15
|
-
--no_favicon
|
16
|
-
--no_highlight
|
17
|
-
--no_login
|
18
|
-
--no_navigation
|
19
|
-
--no_plugs
|
20
|
-
--no_readme
|
21
|
-
Exclusive:
|
22
|
-
no_login allowed
|
16
|
+
--no=PLUGS
|
23
17
|
Types:
|
24
18
|
DIRECTORY /^~?[\\/\\w\\.]+$/
|
25
19
|
BIND /^[\\w\\.]+$/
|
26
20
|
PORT /^\\d+$/
|
27
21
|
IPS /^[\\d\\.\\,]+$/
|
28
22
|
THEME /^[\\w\\.]+$/
|
23
|
+
PLUGS /^[\\w\\,]+$/
|
29
24
|
# NOTE:
|
30
25
|
# Assuming site is in ~/vimwiki,
|
31
26
|
# when ~/vimwiki/.valid-id is set with a sha256sum of a password,
|
32
27
|
# that password will restrict the site.
|
33
28
|
# Allowed IPs bypass the need for site password
|
34
29
|
# when the site is accessed from those locations.
|
30
|
+
# You can use the --no option to list plugins to disable.
|
35
31
|
HELP
|
36
32
|
begin
|
33
|
+
Markita.no.concat OPTIONS.no.split(',').map(&:to_sym) if OPTIONS.no?
|
37
34
|
Markita.run!
|
38
|
-
rescue LoadError
|
39
|
-
HelpParser::REDTTY["#{
|
40
|
-
exit 72
|
41
|
-
rescue RuntimeError
|
42
|
-
HelpParser::REDTTY["#{
|
43
|
-
exit 65
|
44
|
-
rescue
|
45
|
-
warn
|
46
|
-
HelpParser::REDTTY["#{
|
47
|
-
exit 70
|
35
|
+
rescue LoadError => e
|
36
|
+
HelpParser::REDTTY["#{e.class}: #{e.message}"]
|
37
|
+
exit 72 # EX_OSFILE
|
38
|
+
rescue RuntimeError => e
|
39
|
+
HelpParser::REDTTY["#{e.class}: #{e.message}"]
|
40
|
+
exit 65 # EX_DATAERR: generic runtime error raised, usually due to user error.
|
41
|
+
rescue StandardError => e
|
42
|
+
warn e.backtrace
|
43
|
+
HelpParser::REDTTY["#{e.class}: #{e.message}"]
|
44
|
+
exit 70 # EX_SOFTWARE
|
48
45
|
end
|
data/lib/markita/base.rb
CHANGED
@@ -1,48 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Markita namespace
|
1
4
|
module Markita
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
# Base class of the Sinatra Markita application
|
6
|
+
class Base < Sinatra::Base
|
7
|
+
set sessions: true
|
8
|
+
set bind: BIND
|
9
|
+
set port: PORT
|
10
|
+
set server: SERVER
|
11
|
+
set server_settings: SERVER_SETTINGS if SERVER_SETTINGS
|
6
12
|
|
7
|
-
|
8
|
-
|
9
|
-
super do |server|
|
10
|
-
if ['.cert.crt', '.pkey.pem'].all?{ File.exist? File.join(ROOT, _1)}
|
11
|
-
server.ssl = true
|
12
|
-
server.ssl_options = {
|
13
|
-
:cert_chain_file => File.join(ROOT, '.cert.crt'),
|
14
|
-
:private_key_file => File.join(ROOT, '.pkey.pem'),
|
15
|
-
:verify_peer => false,
|
16
|
-
}
|
17
|
-
end
|
13
|
+
def self.run!
|
14
|
+
super { SERVER_CONFIG[it] }
|
18
15
|
end
|
19
|
-
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Markdown.new(key).filepath filepath
|
25
|
-
end
|
17
|
+
get PAGE_KEY do |key|
|
18
|
+
filepath = File.join ROOT, key + MDX
|
19
|
+
raise Sinatra::NotFound unless File.exist? filepath
|
26
20
|
|
27
|
-
|
28
|
-
|
29
|
-
(filepath=File.join ROOT, path) &&
|
30
|
-
File.exist?(filepath)
|
31
|
-
send_file filepath
|
32
|
-
end
|
21
|
+
Markdown.new(key).filepath filepath
|
22
|
+
end
|
33
23
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
24
|
+
# For the server to send a static file, the request may only specify a path
|
25
|
+
# (no query string) and the file must exist... Else, it passes.
|
26
|
+
get SEND_FILE do |path|
|
27
|
+
pass unless params.length == 1 &&
|
28
|
+
(filepath = File.join ROOT, path) &&
|
29
|
+
File.exist?(filepath)
|
30
|
+
send_file filepath
|
31
|
+
end
|
32
|
+
|
33
|
+
get '/' do
|
34
|
+
filepath = File.join ROOT, INDEX + MDX
|
35
|
+
if File.exist? filepath
|
36
|
+
Markdown.new(INDEX).filepath filepath
|
37
|
+
else
|
38
|
+
redirect '/about.html' unless Markita.no.include? :about
|
39
|
+
raise Sinatra::NotFound
|
40
|
+
end
|
41
41
|
end
|
42
|
-
end
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
not_found do
|
44
|
+
NOT_FOUND
|
45
|
+
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
end
|