Markita
DESCRIPTION
A Sinatra Markdown server.
With many extra non-standard features.
INSTALL
$ gem install markita
HELP
$ markita --help
Usage:
markita [:options+]
Options:
--root=DIRECTORY ~/vimwiki
--bind=BIND 0.0.0.0
--port=PORT 8080
--theme=THEME base16.light
--allowed=IPS
--no_about
--no_favicon
--no_highlight
--no_login
--no_navigation
--no_plugs
--no_readme
Exclusive:
no_login allowed
Types:
DIRECTORY /^~?[\/\w\.]+$/
BIND /^[\w\.]+$/
PORT /^\d+$/
IPS /^[\d\.\,]+$/
THEME /^[\w\.]+$/
# NOTE:
# Assuming site is in ~/vimwiki,
# when ~/vimwiki/.valid-id is set with a sha256sum of a password,
# that password will restrict the site.
# Allowed IPs bypass the need for site password
# when the site is accessed from those locations.
FEATURES
-
#
Headers with link anchors -
>
Block-quotes nests up to level three - ``` Code section highlighted by Rouge
- PRE-forms on text starting with four spaces
- Tables
- Script section pass through starts with
^<script
and ends with^</script>
- HTML pass through on
/^<.*>$/
lines - And more...
Horizontal rule with meta-data
- If
Title
is set via meta-data, the server will set the page's title to that - One can use numbers to reference long URLs
---
Title: Markita
1: https://github.com/carlosjhr64/markita
---
[Markita](1)
Attributes
{: style="color: blue;"}
You can set the attributes for most blocks.
Lists
One can nest lists up to 3 levels:
{: style="color: red;"}{: style="color: green;"}{: style="color: blue;"}
1. One
2. Two
* ABC
- [ ] Empty ballot
- [x] Marked ballot
* XYZ
3. Three
Definitions
+ Word: Definition
+ Slang:
+ Define slang
Code
```ruby
def wut
puts "Wut?"
end
```
Tables
Integer | Float | Symbol | Word |
---|---|---|---|
1 | 1.0 | $ | The word |
1234 | 12.3 | & | On the street |
| Integer | Float | Symbol | Word |
| ------: | ----: | :----: | :------------ |
| 1 | 1.0 | $ | The word |
| 1234 | 12.3 | & | On the street |
Splits table
Top left |
Top center |
Top right |
Middle left |
Middle center |
Middle left |
Bottom left |
Bottom center |
Bottom right |
|:
Top left
|
Top center
|
Top right
:|:
Middle left
|
Middle center
|
Middle left
:|:
Bottom left
|
Bottom center
|
Bottom right
:|
Image placement
![:Centered Image:](/img/image.png)
![Left Floating:](/img/image.png)
![:Right Floating](/img/image.png)
Image centered above.
Image to the left.
Image to the right.
Image size
![In alt text say 100x100](/img/image.png)
Image link
![Alt text](/img/image.png /href_to/page)
Embed text
!> /path-to/ascii_art.txt
Useful for ASCII art.
Unless an *.html
file, the text is embedded in pre
tags.
Further more unless a *.txt
file, the text is embedded in code
tags.
Footnotes
There once was a man from Nantucket[^1]
Who kept all his cash[^2] in a bucket.
But his daughter, named Nan,
Ran away with a man
And as for the bucket, Natucket.[^3]
[^1]: Nantucket is an island in the U.S. state of Massachusetts.
[^2]: Cash is money in currency.
[^3]: Read as "Nan took it."
Forms
A get method form without submit button on single field:
! Google:[q] (https://www.google.com/search)
A post method form with a password field
and a submit button due to multiple fields.
Note the `*` in front of `pwd` marking it as a password field,
and the ending `!` marking the route as a post:
! Username:[user] Password:[*pwd] (/login.html)!
A multi-line form with default entry and hidden field:
! Name:[user] [status="active"] (/register.html)
! Address:[address]
! Code:[code="1234"]
A selection list:
! Color:[color="Red","White","Blue"]
Template substitutions
! template = "* [&query;](https://www.google.com/search?q=&QUERY;)"
! regx = /^\* (?<query>.*)$/
* Grumpy Cat
* It's over 9000!
Template clears after first non-match. Note: on upcased keys, value is CGI escaped.
Inline links, code, bold, italic, strikes, and underline
The bold and italics strikes at underlined,
while a link to #Markita
sees the ~ code ~ "a*b*c"
to https://github.com.
The *bold* and "italics" ~strikes~ at _underlined_,
while a [link to #Markita](#Markita)
sees the `~ code ~ "a*b*c"` to https://github.com.
Entity escapes
When you want to escape the inline substitutions or HTML tags, use backslash:
- \< \> \* \" \~ \` \& \; \\
Emojis
I ❤️ to 😆!
I :heart: to :laughing:!
Superscript and subscript
This is superscript and this is subscript.
This is \^(superscript) and this is \(subscript).
It's all Ruby!
Add your own custom features.
HOW-TOs
Set site password:
$ # Assuming ~/vimwiki is your site's root...
$ echo -n '<SitePasswordHere>' | sha256sum | grep -o '^\w*' > ~/vimwiki/.valid-id
Set site custom favicon, not found page, and login form and fail page:
$ # Assuming ~/vimwiki is your site's root...
$ # Note that you'll have to restart the server on any change to these:
$ cp /path-to/custom/favicon.ico ~/vimwiki/favicon.ico
$ cp /path-to/custom/not_found.html ~/vimwiki/not_found.html
$ cp /path-to/custom/login_form.html ~/vimwiki/login_form.html
$ cp /path-to/custom/login_fail.html ~/vimwiki/login_fail.html
Run site in https:
$ # Assuming ~/vimwiki is your site's root...
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout pkey.pem -out cert.crt
$ # Stuff happens... Answer all the dumb questions... then:
$ mv cert.crt ~/vimwiki/.cert.crt
$ mv pkey.pem ~/vimwiki/.pkey.pem
Allow localhost to bypass password:
$ # Assuming ~/vimwiki with a site password set...
$ markita --allowed=127.0.0.1
./bin/markita-1.0.210826
== Sinatra (v2.1.0) has taken the stage on 8080 for development with backup from Thin
Adding plugs
$ # Assuming ~/vimwiki
$ mkdir ~/viwiki/plug
$ # Then copy (or create) your plug there.
$ # For example:
$ GET https://raw.githubusercontent.com/carlosjhr64/markita/main/plug/todotxt.rb > ~/vimwiki/plug/todotxt.rb
LICENSE
Copyright (c) 2024 CarlosJHR64
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.