markita 4.1.230214 → 5.0.241001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +174 -230
- data/lib/markita/base.rb +9 -17
- data/lib/markita/config.rb +27 -5
- data/lib/markita/html.rb +3 -3
- data/lib/markita/markdown.rb +146 -169
- data/lib/markita/plug/favicon.rb +1 -1
- data/lib/markita/plug/highlight.rb +3 -2
- data/lib/markita/plug/login.rb +3 -3
- data/lib/markita.rb +10 -9
- metadata +60 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd3ec2273b3a06985b04dbcaa4e4cc190ad724b78a95614715bc940d762f0603
|
4
|
+
data.tar.gz: 45313726512a832f997d4ea3ac16e7be4839a448de674eeabfe62817ddd7128f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75a93470a33b67d868ed1fabac90b0d6a111f1f2c3e028534ffdc5ce434d8361103e8fa27249c4f34e347c3de57dc8806bd221351bc8abf75396ad9a1500f8bb
|
7
|
+
data.tar.gz: d1180313131e3487558c863cdd6817c401e37ddd36bc64ad1821eb082a11c432bed0f0eb055dc34a9bb75c68129a0a109e721bd4132efc072a6ca4583c2d655f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Markita
|
2
2
|
|
3
|
-
* [VERSION
|
3
|
+
* [VERSION 5.0.241001](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
|
|
@@ -49,197 +49,51 @@ Types:
|
|
49
49
|
```
|
50
50
|
## FEATURES
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
![In alt text say 100x100](/img/image.png)
|
80
|
-
|
81
|
-
### Image link
|
82
|
-
|
83
|
-
Markdown:
|
84
|
-
|
85
|
-
![Alt text](/img/image.png /href_to/page)
|
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].
|
196
|
-
|
197
|
-
### Lists: ordered, un-ordered, definitions
|
52
|
+
* `#` Headers with link anchors
|
53
|
+
* `>` Block-quotes nests up to level three
|
54
|
+
* ``` Code section highlighted by [Rouge](https://github.com/rouge-ruby/rouge)
|
55
|
+
* PRE-forms on text starting with four spaces
|
56
|
+
* Tables
|
57
|
+
* Script section pass through starts with `^<script` and ends with `^</script>`
|
58
|
+
* HTML pass through on `/^<.*>$/` lines
|
59
|
+
* And more...
|
60
|
+
|
61
|
+
### Horizontal rule with meta-data
|
62
|
+
|
63
|
+
* If `Title` is set via meta-data, the server will set the page's title to that
|
64
|
+
* One can use numbers to reference long URLs
|
65
|
+
```markdown
|
66
|
+
---
|
67
|
+
Title: Markita
|
68
|
+
1: https://github.com/carlosjhr64/markita
|
69
|
+
---
|
70
|
+
[Markita](1)
|
71
|
+
```
|
72
|
+
### Attributes
|
73
|
+
```markdown
|
74
|
+
{: style="color: blue;"}
|
75
|
+
You can set the attributes for most blocks.
|
76
|
+
```
|
77
|
+
### Lists
|
198
78
|
|
79
|
+
One can nest lists up to 3 levels:
|
80
|
+
```markdown
|
81
|
+
{: style="color: red;"}{: style="color: green;"}{: style="color: blue;"}
|
199
82
|
1. One
|
200
83
|
2. Two
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
<dt>Word</dt>
|
207
|
-
<dd>Definition of the word</dd>
|
208
|
-
<dt>Symbol</dt>
|
209
|
-
<dd>Usage for the symbol</dd>
|
210
|
-
</dl>
|
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
|
84
|
+
* ABC
|
85
|
+
- [ ] Empty ballot
|
86
|
+
- [x] Marked ballot
|
87
|
+
* XYZ
|
88
|
+
3. Three
|
241
89
|
```
|
242
|
-
|
90
|
+
### Definitions
|
91
|
+
```markdown
|
92
|
+
+ Word: Definition
|
93
|
+
+ Slang:
|
94
|
+
+ Define slang
|
95
|
+
```
|
96
|
+
### Code
|
243
97
|
|
244
98
|
```ruby
|
245
99
|
def wut
|
@@ -253,62 +107,152 @@ Markdown:
|
|
253
107
|
| ------: | ----: | :----: | :------------ |
|
254
108
|
| 1 | 1.0 | $ | The word |
|
255
109
|
| 1234 | 12.3 | & | On the street |
|
110
|
+
```markdown
|
111
|
+
| Integer | Float | Symbol | Word |
|
112
|
+
| ------: | ----: | :----: | :------------ |
|
113
|
+
| 1 | 1.0 | $ | The word |
|
114
|
+
| 1234 | 12.3 | & | On the street |
|
115
|
+
```
|
116
|
+
### Splits table
|
256
117
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
118
|
+
<table><tr><td>
|
119
|
+
<p> Top left </p>
|
120
|
+
</td><td>
|
121
|
+
<p> Top center </p>
|
122
|
+
</td><td>
|
123
|
+
<p> Top right </p>
|
124
|
+
</td></tr><tr><td>
|
125
|
+
<p> Middle left </p>
|
126
|
+
</td><td>
|
127
|
+
<p> Middle center </p>
|
128
|
+
</td><td>
|
129
|
+
<p> Middle left </p>
|
130
|
+
</td></tr><tr><td>
|
131
|
+
<p> Bottom left </p>
|
132
|
+
</td><td>
|
133
|
+
<p> Bottom center </p>
|
134
|
+
</td><td>
|
135
|
+
<p> Bottom right </p>
|
136
|
+
</td></tr></table>
|
270
137
|
|
138
|
+
```markdown
|
139
|
+
|:
|
140
|
+
Top left
|
141
|
+
|
|
142
|
+
Top center
|
143
|
+
|
|
144
|
+
Top right
|
145
|
+
:|:
|
146
|
+
Middle left
|
147
|
+
|
|
148
|
+
Middle center
|
149
|
+
|
|
150
|
+
Middle left
|
151
|
+
:|:
|
152
|
+
Bottom left
|
153
|
+
|
|
154
|
+
Bottom center
|
155
|
+
|
|
156
|
+
Bottom right
|
157
|
+
:|
|
158
|
+
```
|
159
|
+
### Image placement
|
160
|
+
```markdown
|
161
|
+
![:Centered Image:](/img/image.png)
|
162
|
+
![Left Floating:](/img/image.png)
|
163
|
+
![:Right Floating](/img/image.png)
|
164
|
+
Image centered above.
|
165
|
+
Image to the left.
|
166
|
+
Image to the right.
|
167
|
+
```
|
168
|
+
### Image size
|
169
|
+
```markdown
|
170
|
+
![In alt text say 100x100](/img/image.png)
|
171
|
+
```
|
172
|
+
### Image link
|
173
|
+
```markdown
|
174
|
+
![Alt text](/img/image.png /href_to/page)
|
175
|
+
```
|
271
176
|
### Embed text
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
!> /path-to/ascii_art.txt
|
276
|
-
|
177
|
+
```markdown
|
178
|
+
!> /path-to/ascii_art.txt
|
179
|
+
```
|
277
180
|
Useful for ASCII art.
|
278
181
|
Unless an `*.html` file, the text is embedded in `pre` tags.
|
279
182
|
Further more unless a `*.txt` file, the text is embedded in `code` tags.
|
280
183
|
|
281
|
-
###
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
184
|
+
### Footnotes
|
185
|
+
```markdown
|
186
|
+
There once was a man from Nantucket[^1]
|
187
|
+
Who kept all his cash[^2] in a bucket.
|
188
|
+
But his daughter, named Nan,
|
189
|
+
Ran away with a man
|
190
|
+
And as for the bucket, Natucket.[^3]
|
191
|
+
|
192
|
+
[^1]: Nantucket is an island in the U.S. state of Massachusetts.
|
193
|
+
[^2]: Cash is money in currency.
|
194
|
+
[^3]: Read as "Nan took it."
|
195
|
+
```
|
196
|
+
### Forms
|
197
|
+
```markdown
|
198
|
+
A get method form without submit button on single field:
|
199
|
+
! Google:[q] (https://www.google.com/search)
|
200
|
+
|
201
|
+
A post method form with a password field
|
202
|
+
and a submit button due to multiple fields.
|
203
|
+
Note the `*` in front of `pwd` marking it as a password field,
|
204
|
+
and the ending `!` marking the route as a post:
|
205
|
+
! Username:[user] Password:[*pwd] (/login.html)!
|
206
|
+
|
207
|
+
A multi-line form with default entry and hidden field:
|
208
|
+
! Name:[user] [status="active"] (/register.html)
|
209
|
+
! Address:[address]
|
210
|
+
! Code:[code="1234"]
|
211
|
+
|
212
|
+
A selection list:
|
213
|
+
! Color:[color="Red","White","Blue"]
|
214
|
+
```
|
215
|
+
### Template substitutions
|
216
|
+
```markdown
|
217
|
+
! template = "* [&query;](https://www.google.com/search?q=&QUERY;)"
|
218
|
+
! regx = /^\* (?<query>.*)$/
|
219
|
+
* Grumpy Cat
|
220
|
+
* It's over 9000!
|
221
|
+
```
|
222
|
+
Template clears after first non-match.
|
223
|
+
Note: on upcased keys, value is CGI escaped.
|
286
224
|
|
287
|
-
|
225
|
+
### Inline links, code, bold, italic, strikes, and underline
|
288
226
|
|
289
|
-
|
227
|
+
The <b>bold</b> and <i>italics</i> <s>strikes</s> at <u>underlined</u>,
|
228
|
+
while a [link to #Markita](#Markita)
|
229
|
+
sees the `~ code ~ "a*b*c"` to https://github.com.
|
230
|
+
```markdown
|
231
|
+
The *bold* and "italics" ~strikes~ at _underlined_,
|
232
|
+
while a [link to #Markita](#Markita)
|
233
|
+
sees the `~ code ~ "a*b*c"` to https://github.com.
|
234
|
+
```
|
235
|
+
### Entity escapes
|
290
236
|
|
291
|
-
|
237
|
+
When you want to escape the inline substitutions or HTML tags, use backslash:
|
292
238
|
|
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]
|
239
|
+
* \< \> \* \" \~ \` \& \; \\
|
298
240
|
|
299
|
-
|
300
|
-
[^2]: Cash is money in currency.
|
301
|
-
[^3]: Read as "Nan took it."
|
241
|
+
### Emojis
|
302
242
|
|
303
|
-
|
243
|
+
I :heart: to :laughing:!
|
244
|
+
```markdown
|
245
|
+
I :heart: to :laughing:!
|
246
|
+
```
|
247
|
+
### Superscript and subscript
|
304
248
|
|
305
|
-
|
249
|
+
This is <sup>superscript</sup> and this is <sub>subscript</sub>.
|
250
|
+
```markdown
|
251
|
+
This is \^(superscript) and this is \(subscript).
|
252
|
+
```
|
253
|
+
### It's all Ruby!
|
306
254
|
|
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.
|
255
|
+
Add your own custom features.
|
312
256
|
|
313
257
|
## HOW-TOs
|
314
258
|
|
@@ -351,7 +295,7 @@ $ GET https://raw.githubusercontent.com/carlosjhr64/markita/main/plug/todotxt.rb
|
|
351
295
|
```
|
352
296
|
## LICENSE
|
353
297
|
|
354
|
-
Copyright (c)
|
298
|
+
Copyright (c) 2024 CarlosJHR64
|
355
299
|
|
356
300
|
Permission is hereby granted, free of charge,
|
357
301
|
to any person obtaining a copy of this software and
|
data/lib/markita/base.rb
CHANGED
@@ -1,25 +1,17 @@
|
|
1
1
|
module Markita
|
2
2
|
class Base < Sinatra::Base
|
3
|
-
set bind: OPTIONS&.bind || '0.0.0.0'
|
4
|
-
set port: OPTIONS&.port || '8080'
|
5
3
|
set sessions: true
|
4
|
+
set bind: OPTIONS.bind || BIND
|
5
|
+
set port: OPTIONS.port || PORT
|
6
|
+
set server: SERVER
|
7
|
+
set server_settings: SERVER_SETTINGS if SERVER_SETTINGS
|
6
8
|
|
7
9
|
def self.run!
|
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
|
18
|
-
end
|
10
|
+
super {SERVER_CONFIG[_1]}
|
19
11
|
end
|
20
12
|
|
21
13
|
get PAGE_KEY do |key|
|
22
|
-
filepath = File.join ROOT, key+
|
14
|
+
filepath = File.join ROOT, key+MDX
|
23
15
|
raise Sinatra::NotFound unless File.exist? filepath
|
24
16
|
Markdown.new(key).filepath filepath
|
25
17
|
end
|
@@ -32,11 +24,11 @@ class Base < Sinatra::Base
|
|
32
24
|
end
|
33
25
|
|
34
26
|
get '/' do
|
35
|
-
filepath = File.join ROOT,
|
27
|
+
filepath = File.join ROOT, INDEX+MDX
|
36
28
|
if File.exist? filepath
|
37
|
-
Markdown.new(
|
29
|
+
Markdown.new(INDEX).filepath filepath
|
38
30
|
else
|
39
|
-
redirect '/about.html' unless OPTIONS
|
31
|
+
redirect '/about.html' unless OPTIONS.no_about
|
40
32
|
raise Sinatra::NotFound
|
41
33
|
end
|
42
34
|
end
|
data/lib/markita/config.rb
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
module Markita
|
2
|
-
OPTIONS ||= nil
|
3
|
-
|
4
2
|
HEADER_LINKS = ''
|
5
|
-
NAVIGATION
|
3
|
+
NAVIGATION = ''
|
4
|
+
|
5
|
+
BIND = '0.0.0.0'
|
6
|
+
PORT = '8080'
|
7
|
+
SERVER = 'webrick'
|
8
|
+
|
9
|
+
MDX = '.md'
|
10
|
+
INDEX = 'index'
|
6
11
|
|
7
|
-
ROOT = File.expand_path OPTIONS
|
12
|
+
ROOT = File.expand_path OPTIONS.root || '~/vimwiki'
|
8
13
|
raise 'Missing site root directory: '+ROOT unless File.directory? ROOT
|
9
|
-
|
14
|
+
|
15
|
+
SSL_CERTIFICATE = File.join(ROOT, '.cert.crt')
|
16
|
+
SSL_PRIVATE_KEY = File.join(ROOT, '.pkey.pem')
|
17
|
+
|
18
|
+
SERVER_SETTINGS = [SSL_CERTIFICATE, SSL_PRIVATE_KEY].all?{File.exist?_1} ?
|
19
|
+
{ SSLEnable: true,
|
20
|
+
SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE,
|
21
|
+
SSLCertificate: OpenSSL::X509::Certificate.new(File.read SSL_CERTIFICATE),
|
22
|
+
SSLPrivateKey: OpenSSL::PKey::RSA.new(File.read SSL_PRIVATE_KEY) } : nil
|
23
|
+
|
24
|
+
SERVER_CONFIG = lambda do |server|
|
25
|
+
puts "#{$0}-#{VERSION}"
|
26
|
+
puts "Sinatra-#{Sinatra::VERSION} using #{server.class}"
|
27
|
+
end
|
28
|
+
|
29
|
+
APPDIR = File.dirname __dir__, 2
|
10
30
|
APPDATA = File.join APPDIR, 'data'
|
31
|
+
|
11
32
|
PATH = lambda do |basename|
|
12
33
|
[ROOT, APPDATA].map{ File.join _1, basename}.detect{ File.exist? _1}
|
13
34
|
end
|
35
|
+
|
14
36
|
NOT_FOUND = File.read PATH['not_found.html']
|
15
37
|
|
16
38
|
EMOJIS = Hash[*File.read(PATH['emojis.tsv']).split(/\s+/)]
|
data/lib/markita/html.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Markita
|
2
2
|
module HTML
|
3
|
-
def self.header(
|
3
|
+
def self.header(title)
|
4
4
|
<<~HEADER
|
5
5
|
<!DOCTYPE html>
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
|
9
|
-
|
8
|
+
<title>#{title}</title>#{HEADER_LINKS}
|
9
|
+
</head>
|
10
10
|
<body>
|
11
11
|
HEADER
|
12
12
|
end
|