Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: add page organized by date #326

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ root: readme
parts:
- caption: Contributing
chapters:
- file: contributing/index
- file: contributing/submit_app
- file: contributing/format
- file: contributing/index
- file: contributing/submit_app
- file: contributing/format

- caption: By tag
chapters:
Expand All @@ -22,11 +22,12 @@ parts:
chapters:
{license_toc}

# when adding new chapters here, don't forget to also add them to the scipts/generate_link_lists.py file
haesleinhuepf marked this conversation as resolved.
Show resolved Hide resolved
- caption: What's New
chapters:
{date_toc}


- caption: Appendix
chapters:
- file: statistics/readme
- file: export/readme
- file: imprint
- file: statistics/readme
haesleinhuepf marked this conversation as resolved.
Show resolved Hide resolved
- file: export/readme
- file: imprint
29 changes: 29 additions & 0 deletions scripts/generate_link_lists.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
def generate_by_publish_date(content, output_file):
haesleinhuepf marked this conversation as resolved.
Show resolved Hide resolved
"""Generates a markdown file organized by publish date for blog-like content organization."""
sorted_content = sorted(
content['resources'],
key=lambda x: str(x.get('publication_date', '0000-00-00')),
reverse=True
)

with open(output_file, 'w', encoding='utf-8') as file:
file.write("# What's New\n")
for entry in sorted_content:
name = entry.get('name', 'Untitled')
pub_date = entry.get('publication_date', 'No Date')
authors = entry.get('authors', 'Unknown')
description = entry.get('description', 'No description available.')
url = entry.get('url', '')

file.write(f"## {name} - {pub_date}\n")
file.write(f"*Authors:* {authors}\n")
file.write(f"*Published on:* {pub_date}\n\n")
file.write(f"{description}\n")
file.write(f"\n[Link to content]({url})\n")
file.write("\n---\n")

def main():
"""
When called from the terminal, this script goes through our yml files and generates .md files.
Expand Down Expand Up @@ -63,6 +87,11 @@ def main():
author_toc += " - file: " + filename + "\n"
replace_in_file(toc_file, "{author_toc}", author_toc)

# Generate the 'What's New' page with content sorted by publish date
haesleinhuepf marked this conversation as resolved.
Show resolved Hide resolved
date_toc = " - file: whats_new"
generate_by_publish_date(content, "docs/whats_new.md")
haesleinhuepf marked this conversation as resolved.
Show resolved Hide resolved
replace_in_file(toc_file, "{date_toc}", date_toc)

# go through all urls and detect duplicates
all_urls = collect_all(content, "url")
duplicate_found = False
Expand Down
Loading