diff options
Diffstat (limited to 'megapixels/app/site')
| -rw-r--r-- | megapixels/app/site/builder.py | 2 | ||||
| -rw-r--r-- | megapixels/app/site/loader.py | 2 | ||||
| -rw-r--r-- | megapixels/app/site/parser.py | 22 |
3 files changed, 25 insertions, 1 deletions
diff --git a/megapixels/app/site/builder.py b/megapixels/app/site/builder.py index 603d4788..55a85b0f 100644 --- a/megapixels/app/site/builder.py +++ b/megapixels/app/site/builder.py @@ -57,7 +57,7 @@ def build_page(fn, research_posts, datasets): s3.sync_directory(dirname, s3_dir, metadata) content = parser.parse_markdown(metadata, sections, s3_path, skip_h1=skip_h1) - + html = template.render( metadata=metadata, content=content, diff --git a/megapixels/app/site/loader.py b/megapixels/app/site/loader.py index a544333b..779f68ba 100644 --- a/megapixels/app/site/loader.py +++ b/megapixels/app/site/loader.py @@ -85,6 +85,8 @@ def parse_metadata(fn, sections): metadata['meta'] = load_json(dataset_path) if not metadata['meta']: print("Bad metadata? {}".format(dataset_path)) + elif 'datasets' in fn: + print("/!\\ {} does not exist!".format(dataset_path)) if 'meta' not in metadata or not metadata['meta']: # dude metadata['meta'] = {} diff --git a/megapixels/app/site/parser.py b/megapixels/app/site/parser.py index 00470e4b..06c45f41 100644 --- a/megapixels/app/site/parser.py +++ b/megapixels/app/site/parser.py @@ -27,6 +27,7 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False): current_group = [] footnotes = [] in_stats = False + in_columns = False in_footnotes = False ignoring = False @@ -50,6 +51,7 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False): footnotes.append(section) elif ignoring: continue + elif '### statistics' in section.lower() or '### sidebar' in section.lower(): if len(current_group): groups.append(format_section(current_group, s3_path)) @@ -64,6 +66,26 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False): if 'end sidebar' not in section.lower(): current_group.append(section) in_stats = False + + elif '=== columns' in section.lower(): + if len(current_group): + groups.append(format_section(current_group, s3_path)) + current_group = [] + in_columns = True + column_partz = section.split(' ') + if len(column_partz) == 3: + column_count = column_partz[2] + else: + column_count = "N" + groups.append("<section><div class='columns columns-{}'>".format(column_count)) + elif in_columns is True and '===' in section: + groups.append(format_section(current_group, s3_path, type='column', tag='div')) + current_group = [] + if 'end columns' in section: + groups.append("</div></section>") + in_columns = False + current_group = [] + elif section.strip().startswith('{% include'): groups.append(format_section(current_group, s3_path)) current_group = [] |
