markita 3.0.210907 → 3.3.210918

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8176e09462f3a78f7e10600cef156aff9d32ed892c97366d242bf299e87adf5e
4
- data.tar.gz: '0864ffe280f23e7d15b196aef1226a14f7b3443c0ebf4a142667187550665ab9'
3
+ metadata.gz: 00f2378d6afe1f1ed2251e78d0e413305cc3a2616da3dfeccfe3446faac0712c
4
+ data.tar.gz: 8d099fe74a6bd50829c1a09f9bbc492893113c868dc4731cd41bd4380d19cbe5
5
5
  SHA512:
6
- metadata.gz: 16135591f2eb1d7446be0337c0ba7b51624834f169f219c1a0a534d88f263dec04da18e8b8e05f5c4d4998b8d9a96aaf437e53d1d0858b36aab19948f10985bc
7
- data.tar.gz: ecfc73bc0f9e13e216a1b5e9682bbfdc93a9aada53b3aaa49e19c529324b37a9afeb06761349a2ce4dda10c1bfeb4852d4bc705ff137f488451117afb3eb2612
6
+ metadata.gz: 0d13c5e56db469e15a3d5b11048cb1f70b3ffae0f02dec77b02edef36b47d8393218f66755fa5619c2755861e163b1c4d3d05edba9f55f06d44f1c61366ee239
7
+ data.tar.gz: 958c7442e49d7efd39bc9c99d843c788c0f5e1e29ca87e5965816f04fff8a61494ccc1acaa2b855e9ce543edc6b9a4b1e505043159d494a8f9820bd0d4461b02
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Markita
2
2
 
3
- * [VERSION 3.0.210907](https://github.com/carlosjhr64/markita/releases)
3
+ * [VERSION 3.3.210918](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
 
@@ -23,18 +23,20 @@ Options:
23
23
  --root=DIRECTORY ~/vimwiki
24
24
  --bind=BIND 0.0.0.0
25
25
  --port=PORT 8080
26
+ --theme=THEME base16.light
26
27
  --allowed=IPS
27
28
  --no_about
28
29
  --no_favicon
29
30
  --no_highlight
31
+ --no_navigation
30
32
  --no_login
31
33
  --no_plugs
32
34
  Types:
33
35
  DIRECTORY /^~?[\/\w\.]+$/
34
36
  BIND /^[\w\.]+$/
35
37
  PORT /^\d+$/
36
- THEME /^[\w\.]+$/
37
38
  IPS /^[\d\.\,]+$/
39
+ THEME /^[\w\.]+$/
38
40
  # NOTE:
39
41
  # Assuming site is in ~/vimwiki,
40
42
  # when ~/vimwiki/.valid-id is set with a sha256sum of a password,
@@ -62,11 +64,23 @@ Markdown:
62
64
  ![Left Floating ](/img/image.png)
63
65
  ![ Right Floating](/img/image.png)
64
66
  Image centered above.
65
- Image to the left.
67
+ Image to the left with width and height set.
66
68
  Image to the right.
67
69
  And set a HR bar below.
68
70
  ---
69
71
 
72
+ ### Image size
73
+
74
+ Markdown:
75
+
76
+ ![In alt text say 100x100](/img/image.png)
77
+
78
+ ### Image link
79
+
80
+ Markdown:
81
+
82
+ ![Alt text](/img/image.png /href_to/page)
83
+
70
84
  ### Forms
71
85
 
72
86
  Markdown:
@@ -83,6 +97,9 @@ Markdown:
83
97
  ! Address:[address]
84
98
  ! Code:[code="1234"]
85
99
 
100
+ A selection list:
101
+ ! Color:[color="Red","White","Blue"]
102
+
86
103
  ### Template substitutions
87
104
 
88
105
  Markdown:
@@ -284,12 +301,11 @@ Markdown:
284
301
  $ # Assuming ~/vimwiki is your site's root...
285
302
  $ echo -n '<SitePasswordHere>' | sha256sum | grep -o '^\w*' > ~/vimwiki/.valid-id
286
303
  ```
287
- ### Set site custom favicon, css, not found page, and login form and fail page:
304
+ ### Set site custom favicon, not found page, and login form and fail page:
288
305
  ```console
289
306
  $ # Assuming ~/vimwiki is your site's root...
290
307
  $ # Note that you'll have to restart the server on any change to these:
291
308
  $ cp /path-to/custom/favicon.ico ~/vimwiki/favicon.ico
292
- $ cp /path-to/custom/highlight.css ~/vimwiki/highlight.css
293
309
  $ cp /path-to/custom/not_found.html ~/vimwiki/not_found.html
294
310
  $ cp /path-to/custom/login_form.html ~/vimwiki/login_form.html
295
311
  $ cp /path-to/custom/login_fail.html ~/vimwiki/login_fail.html
data/bin/markita CHANGED
@@ -9,18 +9,20 @@ Options:
9
9
  --root=DIRECTORY \t ~/vimwiki
10
10
  --bind=BIND \t 0.0.0.0
11
11
  --port=PORT \t 8080
12
+ --theme=THEME \t base16.light
12
13
  --allowed=IPS
13
14
  --no_about
14
15
  --no_favicon
15
16
  --no_highlight
17
+ --no_navigation
16
18
  --no_login
17
19
  --no_plugs
18
20
  Types:
19
21
  DIRECTORY /^~?[\\/\\w\\.]+$/
20
22
  BIND /^[\\w\\.]+$/
21
23
  PORT /^\\d+$/
22
- THEME /^[\\w\\.]+$/
23
24
  IPS /^[\\d\\.\\,]+$/
25
+ THEME /^[\\w\\.]+$/
24
26
  # NOTE:
25
27
  # Assuming site is in ~/vimwiki,
26
28
  # when ~/vimwiki/.valid-id is set with a sha256sum of a password,
@@ -2,6 +2,7 @@ module Markita
2
2
  OPTIONS ||= nil
3
3
 
4
4
  HEADER_LINKS = ''
5
+ NAVIGATION = ''
5
6
 
6
7
  ROOT = File.expand_path OPTIONS&.root || '~/vimwiki'
7
8
  raise "Missing site root directory: "+ROOT unless File.directory? ROOT
data/lib/markita/html.rb CHANGED
@@ -11,6 +11,10 @@ module HTML
11
11
  HEADER
12
12
  end
13
13
 
14
+ def HTML.navigation
15
+ NAVIGATION
16
+ end
17
+
14
18
  def HTML.footer
15
19
  <<~FOOTER
16
20
  </body>
@@ -9,11 +9,13 @@ class Markdown
9
9
  end
10
10
 
11
11
  def start
12
- @line,@html,@opt = HTML.header(@title),'',{}
12
+ @html << HTML.header(@title)
13
+ @line = HTML.navigation
13
14
  end
14
15
 
15
16
  def finish
16
17
  @html << HTML.footer
18
+ @line = nil
17
19
  end
18
20
 
19
21
  def default
@@ -21,8 +23,12 @@ class Markdown
21
23
  @line = @file.gets
22
24
  end
23
25
 
26
+ def init(fh)
27
+ @file,@html,@opt = Preprocess.new(fh),'',{}
28
+ end
29
+
24
30
  def parse(fh)
25
- @file = Preprocess.new(fh)
31
+ init(fh)
26
32
  start
27
33
  while @line
28
34
  PARSERS.detect{method(_1).call} or default
@@ -93,12 +99,12 @@ class Markdown
93
99
  string = Markdown.tag(entry, CODEx, CODE) do |entry|
94
100
  Markdown.tag(entry, Ax, A) do |entry|
95
101
  Markdown.tag(entry, URLx, URL) do |entry|
96
- string = Markdown.tag(entry, Bx, B)
97
- string = Markdown.tag(string, Ix, I)
98
- string = Markdown.tag(string, Sx, S)
99
- string = Markdown.tag(string, Ux, U)
100
- string = Markdown.tag(string, FOOTNOTEx, FOOTNOTE)
101
- Markdown.tag(string, EMOJIx, EMOJI)
102
+ entry = Markdown.tag(entry, EMOJIx, EMOJI)
103
+ entry = Markdown.tag(entry, Bx, B)
104
+ entry = Markdown.tag(entry, Ix, I)
105
+ entry = Markdown.tag(entry, Sx, S)
106
+ entry = Markdown.tag(entry, Ux, U)
107
+ entry = Markdown.tag(entry, FOOTNOTEx, FOOTNOTE)
102
108
  end
103
109
  end
104
110
  end
@@ -115,15 +121,20 @@ class Markdown
115
121
  end
116
122
 
117
123
  # Ordered list
118
- ORDERED = /^\d+. (.*)$/
124
+ ORDERED = /^( {0,3})\d+\. (\S.*)$/
119
125
  PARSERS << :ordered
120
- def ordered
121
- md = ORDERED.match(@line) or return false
126
+ def ordered(md=ORDERED.match(@line), level=0)
127
+ return false unless md
122
128
  @html << "<ol#{@opt[:attributes]}>\n"
123
129
  @opt.delete(:attributes)
124
- while md
125
- @html << " <li>#{INLINE[md[1]]}</li>\n"
126
- md = (@line=@file.gets)&.match ORDERED
130
+ while md and level==md[1].length
131
+ @html << " <li>#{INLINE[md[2]]}</li>\n"
132
+ if md = (@line=@file.gets)&.match(ORDERED)
133
+ if level < md[1].length
134
+ ordered(md, md[1].length)
135
+ md = @line&.match(ORDERED)
136
+ end
137
+ end
127
138
  end
128
139
  @html << "</ol>\n"
129
140
  true
@@ -145,15 +156,20 @@ class Markdown
145
156
  end
146
157
 
147
158
  # Unordered list
148
- UNORDERED = /^[*] (.*)$/
159
+ UNORDERED = /^( {0,3})[*] (\S.*)$/
149
160
  PARSERS << :unordered
150
- def unordered
151
- md = UNORDERED.match(@line) or return false
161
+ def unordered(md=UNORDERED.match(@line), level=0)
162
+ return false unless md
152
163
  @html << "<ul#{@opt[:attributes]}>\n"
153
164
  @opt.delete(:attributes)
154
- while md
155
- @html << " <li>#{INLINE[md[1]]}</li>\n"
156
- md = (@line=@file.gets)&.match UNORDERED
165
+ while md and level==md[1].length
166
+ @html << " <li>#{INLINE[md[2]]}</li>\n"
167
+ if md = (@line=@file.gets)&.match(UNORDERED)
168
+ if level < md[1].length
169
+ unordered(md, md[1].length)
170
+ md = @line&.match(UNORDERED)
171
+ end
172
+ end
157
173
  end
158
174
  @html << "</ul>\n"
159
175
  true
@@ -332,7 +348,7 @@ class Markdown
332
348
  PARSERS << :images
333
349
  def images
334
350
  md = IMAGES.match(@line) or return false
335
- alt,src=md[1],md[2]
351
+ alt,src,href=md[1],*md[2].strip.split(/\s+/,2)
336
352
  style = ' '
337
353
  case alt
338
354
  when /^ .* $/
@@ -342,14 +358,21 @@ class Markdown
342
358
  when /^ /
343
359
  style = %Q( style="float:right;" )
344
360
  end
361
+ if /(\d+)x(\d+)/.match alt
362
+ style << %Q(width="#{$1}" height="#{$2}" )
363
+ end
364
+ @html << %Q(<a href="#{href}">\n) if href
345
365
  @html << %Q(<img src="#{src}"#{style}alt="#{alt.strip}"#{@opt[:attributes]}>\n)
366
+ @html << %Q(</a>\n) if href
346
367
  @opt.delete(:attributes)
347
368
  @line = @file.gets
348
369
  true
349
370
  end
350
371
 
351
372
  # Forms
352
- FORMS = /^!( (\w+:)?\[\*?\w+(="[^"]*")?\])+/
373
+ FIELD = '(\w+:)?\[(\*)?(\w+)(=("[^"]+")(,"[^"]+")*)?\]'
374
+ FIELDS = Regexp.new FIELD
375
+ FORMS = Regexp.new "^!( #{FIELD})+"
353
376
  PARSERS << :forms
354
377
  def forms
355
378
  md = FORMS.match(@line) or return false
@@ -359,16 +382,26 @@ class Markdown
359
382
  while md
360
383
  n += 1
361
384
  form << ' <br>' if n > 1
362
- @line.scan(/(\w+:)?\[(\*)?(\w+)(="[^"]*")?\]/).each do |field, pwd, name, value|
385
+ @line.scan(FIELDS).each do |field, pwd, name, value|
363
386
  method ||= ' method="post"' if pwd
364
387
  field &&= field[0...-1]
365
388
  value &&= value[2...-1]
366
389
  if field
367
- fields += 1
368
390
  type = (pwd)? 'password' : 'text'
369
391
  if value
370
- form << %Q{ #{field}:<input type="#{type}" name="#{name}" value="#{value}">}
392
+ if (values = value.split('","')).length > 1
393
+ form << %Q(#{field}:<select name="#{name}">)
394
+ values.each do |value|
395
+ fields += 1
396
+ form << %Q( <option value="#{value}">#{value}</option>)
397
+ end
398
+ form << "</select>"
399
+ else
400
+ fields += 1
401
+ form << %Q{ #{field}:<input type="#{type}" name="#{name}" value="#{value}">}
402
+ end
371
403
  else
404
+ fields += 1
372
405
  form << %Q{ #{field}:<input type="#{type}" name="#{name}">}
373
406
  end
374
407
  elsif name=='submit'
@@ -1,5 +1,5 @@
1
1
  module Markita
2
- class Base < Sinatra::Base
2
+ class Base
3
3
  HEADER_LINKS << %Q( <link rel="icon" type="image/x-icon" href="/favicon.ico">\n)
4
4
  module Favicon
5
5
  ICO = File.read PATH['favicon.ico']
@@ -1,8 +1,10 @@
1
1
  module Markita
2
- class Base < Sinatra::Base
2
+ class Base
3
3
  HEADER_LINKS << %Q( <link rel="stylesheet" href="/highlight.css" type="text/css">\n)
4
4
  module Highlight
5
- CSS = File.read PATH['highlight.css']
5
+ theme = OPTIONS&.theme || 'base16.light'
6
+ CSS = Rouge::Theme.find(theme)&.render(scope: '.highlight')
7
+ raise "Can't find Rouge Theme "+theme unless CSS
6
8
  end
7
9
 
8
10
  get '/highlight.css' do
@@ -0,0 +1,3 @@
1
+ module Markita
2
+ NAVIGATION << %Q(![ Navigation](/favicon.ico /index)\n)
3
+ end
data/lib/markita.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Markita
2
- VERSION = '3.0.210907'
2
+ VERSION = '3.3.210918'
3
3
 
4
4
  def self.run!
5
5
  # Standard libraries
@@ -18,6 +18,7 @@ module Markita
18
18
  # Plugs
19
19
  require_relative 'markita/plug/favicon.rb' unless OPTIONS&.no_favicon
20
20
  require_relative 'markita/plug/highlight.rb' unless OPTIONS&.no_highlight
21
+ require_relative 'markita/plug/navigation.rb' unless OPTIONS&.no_navigation
21
22
  require_relative 'markita/plug/login.rb' unless OPTIONS&.no_login
22
23
  require_relative 'markita/plug/about.rb' unless OPTIONS&.no_about
23
24
  require_relative 'markita/plug/plugs.rb' unless OPTIONS&.no_plugs
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markita
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.210907
4
+ version: 3.3.210918
5
5
  platform: ruby
6
6
  authors:
7
7
  - CarlosJHR64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-07 00:00:00.000000000 Z
11
+ date: 2021-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: help_parser
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '8.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 7.0.200907
22
+ version: 8.0.210917
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '7.0'
29
+ version: '8.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 7.0.200907
32
+ version: 8.0.210917
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rouge
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '3.26'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 3.26.0
42
+ version: 3.26.1
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '3.26'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 3.26.0
52
+ version: 3.26.1
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: sinatra
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +104,6 @@ files:
104
104
  - bin/markita
105
105
  - data/emojis.tsv
106
106
  - data/favicon.ico
107
- - data/highlight.css
108
107
  - data/login_failed.html
109
108
  - data/login_form.html
110
109
  - data/not_found.html
@@ -117,6 +116,7 @@ files:
117
116
  - lib/markita/plug/favicon.rb
118
117
  - lib/markita/plug/highlight.rb
119
118
  - lib/markita/plug/login.rb
119
+ - lib/markita/plug/navigation.rb
120
120
  - lib/markita/plug/plugs.rb
121
121
  - lib/markita/preprocess.rb
122
122
  homepage: https://github.com/carlosjhr64/markita
data/data/highlight.css DELETED
@@ -1,81 +0,0 @@
1
- /* Ruby Gem Rouge's base16.light */
2
- .highlight table td { padding: 5px; }
3
- .highlight table pre { margin: 0; }
4
- .highlight, .highlight .w {
5
- color: #303030;
6
- }
7
- .highlight .err {
8
- color: #151515;
9
- background-color: #ac4142;
10
- }
11
- .highlight .c, .highlight .ch, .highlight .cd, .highlight .cm, .highlight .cpf, .highlight .c1, .highlight .cs {
12
- color: #505050;
13
- }
14
- .highlight .cp {
15
- color: #f4bf75;
16
- }
17
- .highlight .nt {
18
- color: #f4bf75;
19
- }
20
- .highlight .o, .highlight .ow {
21
- color: #d0d0d0;
22
- }
23
- .highlight .p, .highlight .pi {
24
- color: #d0d0d0;
25
- }
26
- .highlight .gi {
27
- color: #90a959;
28
- }
29
- .highlight .gd {
30
- color: #ac4142;
31
- }
32
- .highlight .gh {
33
- color: #6a9fb5;
34
- background-color: #151515;
35
- font-weight: bold;
36
- }
37
- .highlight .k, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv {
38
- color: #aa759f;
39
- }
40
- .highlight .kc {
41
- color: #d28445;
42
- }
43
- .highlight .kt {
44
- color: #d28445;
45
- }
46
- .highlight .kd {
47
- color: #d28445;
48
- }
49
- .highlight .s, .highlight .sb, .highlight .sc, .highlight .dl, .highlight .sd, .highlight .s2, .highlight .sh, .highlight .sx, .highlight .s1 {
50
- color: #90a959;
51
- }
52
- .highlight .sa {
53
- color: #aa759f;
54
- }
55
- .highlight .sr {
56
- color: #75b5aa;
57
- }
58
- .highlight .si {
59
- color: #8f5536;
60
- }
61
- .highlight .se {
62
- color: #8f5536;
63
- }
64
- .highlight .nn {
65
- color: #f4bf75;
66
- }
67
- .highlight .nc {
68
- color: #f4bf75;
69
- }
70
- .highlight .no {
71
- color: #f4bf75;
72
- }
73
- .highlight .na {
74
- color: #6a9fb5;
75
- }
76
- .highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo, .highlight .mx {
77
- color: #90a959;
78
- }
79
- .highlight .ss {
80
- color: #90a959;
81
- }