added markdown (*.md) support

This commit is contained in:
Dooho Yi 2021-10-20 17:10:28 +09:00
parent a59d6d1fc1
commit 566f142a0c
5 changed files with 17 additions and 3 deletions

View file

@ -9,6 +9,7 @@ from PIL import Image
from distribusi.page_template import html_footer, html_head from distribusi.page_template import html_footer, html_head
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES
import re import re
import markdown
MIME_TYPE = magic.Magic(mime=True) MIME_TYPE = magic.Magic(mime=True)
PATTERN_TSTR = re.compile(r"(?P<tstring>(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})T(?P<hour>\d{2})(?P<minute>\d{2})(?P<second>\d{2})(?P<timezone>[+|-]\d{4}))_(?P<name>.+)") PATTERN_TSTR = re.compile(r"(?P<tstring>(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})T(?P<hour>\d{2})(?P<minute>\d{2})(?P<second>\d{2})(?P<timezone>[+|-]\d{4}))_(?P<name>.+)")
@ -155,6 +156,8 @@ def render_dir(args, root):
# what types of text files to expand # what types of text files to expand
a = '<section id="{}">{}</section>'.format(name, open(full_path).read()) a = '<section id="{}">{}</section>'.format(name, open(full_path).read())
#elif subtype in CODE_TYPES or name.endswith('.txt'): #elif subtype in CODE_TYPES or name.endswith('.txt'):
elif name.endswith('.md'):
a = '<section id="{}">{}</section>'.format(name, markdown.markdown(open(full_path).read()))
elif name.endswith('.txt'): elif name.endswith('.txt'):
#check - time string #check - time string
m = PATTERN_TSTR_TXT.search(name) m = PATTERN_TSTR_TXT.search(name)
@ -277,6 +280,8 @@ def distribusify(args, directory): # noqa
# what types of text files to expand # what types of text files to expand
a = '<section id="{}">{}</section>'.format(name, open(full_path).read()) a = '<section id="{}">{}</section>'.format(name, open(full_path).read())
#elif subtype in CODE_TYPES or name.endswith('.txt'): #elif subtype in CODE_TYPES or name.endswith('.txt'):
elif name.endswith('.md'):
a = '<section id="{}">{}</section>'.format(name, markdown.markdown(open(full_path).read()))
elif name.endswith('.txt'): elif name.endswith('.txt'):
#check - time string #check - time string
m = PATTERN_TSTR_TXT.search(name) m = PATTERN_TSTR_TXT.search(name)

View file

@ -1,2 +1,4 @@
pillow pillow
python-magic python-magic
markdown

2
run.sh
View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
python run.py -t -d ./data/ -nf -s styles/dark.css --no-hidden --no-underscore --unfolding -e .git python run.py -t -d ./data/ -s styles/white.css --no-hidden --no-underscore --unfolding -e .git

View file

@ -165,6 +165,13 @@ a:hover {
padding-left: 0; padding-left: 0;
} }
.plain .named {
display: block;
font-weight: 700;
border: unset;
color: rgba(127, 127, 127, 0.5);
}
time { time {
color: rgba(30, 30, 30, 0.3); color: rgba(30, 30, 30, 0.3);
} }

View file

@ -11,8 +11,8 @@ if command -v pyenv 1>/dev/null 2>&1; then
fi fi
eval "$(pyenv virtualenv-init -)" eval "$(pyenv virtualenv-init -)"
#load env for the proj. 'exp-dist' #load env for the proj. 'exp-dist-nc'
pyenv shell exp-dist pyenv shell exp-dist-nc
#change directory #change directory
cd /home/yunohost.app/syncthing/Sync/exp-dist-audiolog cd /home/yunohost.app/syncthing/Sync/exp-dist-audiolog