From 15053f4beea824f5747a1af4c022466a70095419 Mon Sep 17 00:00:00 2001 From: Deepak Khatri <deepaklorkhatri7@gmail.com> Date: Mon, 5 Feb 2024 18:49:46 +0530 Subject: [PATCH] Add PDF download button for proposals --- _templates/pdf.html | 10 ++++++---- conf.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/_templates/pdf.html b/_templates/pdf.html index 6e07b17..ea5f3f2 100644 --- a/_templates/pdf.html +++ b/_templates/pdf.html @@ -1,8 +1,10 @@ {% if pages_slug != "index" %} {% for proposal_name in proposals %} - {{pages_slug}} - <a class="btn btn-danger btn-sm btn-block" role="button" href="https://www.w3schools.com"> - {{proposal_name}}.pdf - </a> + {% if pagename == "proposals/"+proposal_name %} + <!-- TODO: Dynamically create custom link for every proposal PDF--> + <a class="btn btn-danger btn-sm btn-block text-light" role="button" href="https://git.beagleboard.org/gsoc/gsoc.beagleboard.io"> + {{proposal_name}}.pdf + </a> + {% endif %} {% endfor %} {% endif %} \ No newline at end of file diff --git a/conf.py b/conf.py index 7abc03a..e388fa2 100644 --- a/conf.py +++ b/conf.py @@ -10,7 +10,7 @@ import os import sys from pathlib import Path from typing import Any, Dict - +from os import walk import pydata_sphinx_theme from sphinx.application import Sphinx @@ -117,11 +117,19 @@ html_theme_options = { "footer_end": ["last-updated"], # "content_footer_items": ["last-updated"], "secondary_sidebar_items": { - "**": ["page-toc", "edit-this-page", "sourcelink"], - "proposals/template": ["page-toc", "edit-this-page", "sourcelink","pdf"] + "**": ["page-toc", "edit-this-page", "sourcelink","pdf"] } } +proposals = [] +proposal_filenames = next(walk("proposals"), (None, None, []))[2] +for proposal_filename in proposal_filenames: + proposal_filename = os.path.splitext(proposal_filename)[0] + if proposal_filename != "index": + proposals.append(proposal_filename) + +print(proposals) + html_context = { "display_gitlab": True, "gitlab_url": "https://openbeagle.org", @@ -137,7 +145,7 @@ html_context = { "edit_page_url_template": "{{ my_vcs_site }}{{ file_name }}", "edit_page_provider_name": "OpenBeagle", "my_vcs_site": "https://openbeagle.org/gsoc/gsoc.beagleboard.io/-/edit/main/", - "proposals":["template"] + "proposals":proposals } # -- Options for proposal PDF generation -- -- GitLab