diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-12-15 22:14:17 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-12-15 22:14:17 +0100 |
| commit | 898e6cdf8df0993f853b748d4e8a9c269fad0294 (patch) | |
| tree | 484f02ce7fa3066cb0c1934d612b0e64ec46e3d5 /megapixels | |
| parent | b1e7dc570fe25749a2e1b02c9e859df6588b4660 (diff) | |
inject applet payload
Diffstat (limited to 'megapixels')
| -rw-r--r-- | megapixels/app/settings/app_cfg.py | 2 | ||||
| -rw-r--r-- | megapixels/app/site/builder.py | 4 | ||||
| -rw-r--r-- | megapixels/app/site/parser.py | 15 | ||||
| -rw-r--r-- | megapixels/commands/site/build.py | 2 |
4 files changed, 14 insertions, 9 deletions
diff --git a/megapixels/app/settings/app_cfg.py b/megapixels/app/settings/app_cfg.py index a18e5875..d25936e6 100644 --- a/megapixels/app/settings/app_cfg.py +++ b/megapixels/app/settings/app_cfg.py @@ -75,10 +75,10 @@ FP_FONT = join(DIR_ASSETS, 'font') # ----------------------------------------------------------------------------- DIR_COMMANDS_CV = 'commands/cv' DIR_COMMANDS_ADMIN = 'commands/admin' -DIR_COMMANDS_SITE = 'commands/site' DIR_COMMANDS_DATASETS = 'commands/datasets' DIR_COMMANDS_FAISS = 'commands/faiss' DIR_COMMANDS_MISC = 'commands/misc' +DIR_COMMANDS_SITE = 'commands/site' # ----------------------------------------------------------------------------- # Filesystem settings diff --git a/megapixels/app/site/builder.py b/megapixels/app/site/builder.py index df609f60..42e25768 100644 --- a/megapixels/app/site/builder.py +++ b/megapixels/app/site/builder.py @@ -6,8 +6,8 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape import app.settings.app_cfg as cfg -import app.builder.s3 as s3 -import app.builder.parser as parser +import app.site.s3 as s3 +import app.site.parser as parser env = Environment( loader=FileSystemLoader(cfg.DIR_SITE_TEMPLATES), diff --git a/megapixels/app/site/parser.py b/megapixels/app/site/parser.py index add3f386..d78cc402 100644 --- a/megapixels/app/site/parser.py +++ b/megapixels/app/site/parser.py @@ -1,10 +1,11 @@ import os import re import glob +import simplejson as json import mistune import app.settings.app_cfg as cfg -import app.builder.s3 as s3 +import app.site.s3 as s3 renderer = mistune.Renderer(escape=False) markdown = mistune.Markdown(renderer=renderer) @@ -45,14 +46,18 @@ def format_metadata(section): def format_applet(section): payload = section.replace('```', '').strip().split('\n') + applet = {} if ': ' in payload[0]: command, opt = payload[0].split(': ') else: command = payload[0] opt = None - if command == 'load_file': - return "<section><div class='applet'>{}</div></section>" - + applet['command'] = command + if opt: + applet['opt'] = opt + if command == 'load file': + applet['fields'] = payload[1] + return "<section><div class='applet' data-payload='{}'></div></section>".format(json.dumps(applet)) def parse_markdown(sections, s3_path, skip_h1=False): groups = [] @@ -60,7 +65,7 @@ def parse_markdown(sections, s3_path, skip_h1=False): for section in sections: if skip_h1 and section.startswith('# '): continue - elif section.startsWith('```'): + elif section.startswith('```'): groups.append(format_section(current_group, s3_path)) groups.append(format_applet(section)) current_group = [] diff --git a/megapixels/commands/site/build.py b/megapixels/commands/site/build.py index fc4fb302..0a76a9ac 100644 --- a/megapixels/commands/site/build.py +++ b/megapixels/commands/site/build.py @@ -4,7 +4,7 @@ Build the static site import click -from app.builder.builder import build_site +from app.site.builder import build_site @click.command() @click.pass_context |
