From 79360758d692c02ad0817c370f9a6bd277336065 Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Wed, 13 Mar 2024 19:50:40 -0400 Subject: [PATCH 1/5] fix cite process raw date format --- _cite/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_cite/util.py b/_cite/util.py index 466a7d56f7..82e6ab6a75 100644 --- a/_cite/util.py +++ b/_cite/util.py @@ -7,7 +7,7 @@ import yaml from yaml.loader import SafeLoader from pathlib import Path -from datetime import datetime +from datetime import datetime, date as date_type from rich import print from diskcache import Cache @@ -95,6 +95,8 @@ def format_date(date): if isinstance(date, int): return datetime.fromtimestamp(date // 1000.0).strftime("%Y-%m-%d") + if isinstance(date, date_type): + return date.strftime("%Y-%m-%d") try: return datetime.strptime(date, "%Y-%m-%d").strftime("%Y-%m-%d") except Exception: From 6aa88eefa432b30b7902dd7a59dd6d964253835b Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Fri, 22 Mar 2024 22:39:04 -0400 Subject: [PATCH 2/5] echo to printf to fix url config write --- .docker/entrypoint.sh | 6 +++--- .github/workflows/build-site.yaml | 2 +- .github/workflows/first-time-setup.yaml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh index 77c697aa85..41271b22e3 100755 --- a/.docker/entrypoint.sh +++ b/.docker/entrypoint.sh @@ -1,10 +1,10 @@ #! /bin/bash # print folder contents for debugging -echo "Contents:" -echo "" +printf "Contents:" +printf "" ls -echo "" +printf "" # run cite process python3 _cite/cite.py diff --git a/.github/workflows/build-site.yaml b/.github/workflows/build-site.yaml index 6aa3e5a489..6194c83b5a 100644 --- a/.github/workflows/build-site.yaml +++ b/.github/workflows/build-site.yaml @@ -42,7 +42,7 @@ jobs: - name: Set root url run: | - echo "\n\nurl: ${{ steps.pages.outputs.origin }}" >> _config.yaml + printf "\n\nurl: ${{ steps.pages.outputs.origin }}" >> _config.yaml - name: Build live version of site run: | diff --git a/.github/workflows/first-time-setup.yaml b/.github/workflows/first-time-setup.yaml index 51d3273b0a..415e2842a0 100644 --- a/.github/workflows/first-time-setup.yaml +++ b/.github/workflows/first-time-setup.yaml @@ -41,7 +41,7 @@ jobs: run: touch .nojekyll - name: Make placeholder homepage - run: echo "Placeholder homepage" > index.html + run: printf "Placeholder homepage" > index.html - name: Commit changes to Pages branch uses: stefanzweifel/git-auto-commit-action@v5 @@ -70,12 +70,12 @@ jobs: run: | user="${{ github.repository_owner }}" description="An engaging 1-3 sentence description of your lab." - echo "USER=${user}" >> $GITHUB_ENV - echo "DESCRIPTION=${description}" >> $GITHUB_ENV + printf "USER=${user}" >> $GITHUB_ENV + printf "DESCRIPTION=${description}" >> $GITHUB_ENV - name: Personalize readme for user run: | - echo " + printf " # ${{ env.USER }}'s Website Visit **[website url](#)** 🚀 From d618c851e8fac4f1223b2485785fd9a488531283 Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Fri, 22 Mar 2024 22:52:35 -0400 Subject: [PATCH 3/5] update version --- CHANGELOG.md | 6 ++++++ CITATION.cff | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d702c3e8e1..7c945e4d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Reference: common-changelog.org +## 1.2.1 - 2024-03-26 + +### Changed + +- Minor bug fixes in cite process and sitemap generation. + ## 1.2.0 - 2024-03-08 ### Changed diff --git a/CITATION.cff b/CITATION.cff index dcb59dc43f..3274ff4b85 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,8 +1,8 @@ # citation metadata for the template itself title: "Lab Website Template" -version: 1.2.0 -date-released: 2024-03-08 +version: 1.2.1 +date-released: 2024-03-26 url: "https://github.com/greenelab/lab-website-template" authors: - family-names: "Rubinetti" From 26aae084cd512644b443580e69b19028c99ea181 Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Mon, 1 Apr 2024 15:32:43 -0400 Subject: [PATCH 4/5] review comments --- .docker/entrypoint.sh | 4 +--- CHANGELOG.md | 2 +- CITATION.cff | 2 +- _cite/util.py | 14 +++++++------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh index 41271b22e3..efe404765e 100755 --- a/.docker/entrypoint.sh +++ b/.docker/entrypoint.sh @@ -1,10 +1,8 @@ #! /bin/bash # print folder contents for debugging -printf "Contents:" -printf "" +printf "\n\nContents:\n\n" ls -printf "" # run cite process python3 _cite/cite.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c945e4d91..fb1f988eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Reference: common-changelog.org -## 1.2.1 - 2024-03-26 +## 1.2.1 - 2024-04-01 ### Changed diff --git a/CITATION.cff b/CITATION.cff index 3274ff4b85..4b875d4752 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ title: "Lab Website Template" version: 1.2.1 -date-released: 2024-03-26 +date-released: 2024-04-01 url: "https://github.com/greenelab/lab-website-template" authors: - family-names: "Rubinetti" diff --git a/_cite/util.py b/_cite/util.py index 82e6ab6a75..d9db4cf0aa 100644 --- a/_cite/util.py +++ b/_cite/util.py @@ -7,7 +7,7 @@ import yaml from yaml.loader import SafeLoader from pathlib import Path -from datetime import datetime, date as date_type +from datetime import date, datetime from rich import print from diskcache import Cache @@ -88,17 +88,17 @@ def list_of_dicts(data): return isinstance(data, list) and all(isinstance(entry, dict) for entry in data) -def format_date(date): +def format_date(_date): """ format date as YYYY-MM-DD, or no date if malformed """ - if isinstance(date, int): - return datetime.fromtimestamp(date // 1000.0).strftime("%Y-%m-%d") - if isinstance(date, date_type): - return date.strftime("%Y-%m-%d") + if isinstance(_date, int): + return datetime.fromtimestamp(_date // 1000.0).strftime("%Y-%m-%d") + if isinstance(_date, date) or isinstance(_date, datetime): + return _date.strftime("%Y-%m-%d") try: - return datetime.strptime(date, "%Y-%m-%d").strftime("%Y-%m-%d") + return datetime.strptime(_date, "%Y-%m-%d").strftime("%Y-%m-%d") except Exception: return "" From 88a9146eebe2f9e95a9517545875ed1632ed379b Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Mon, 1 Apr 2024 15:33:48 -0400 Subject: [PATCH 5/5] shorter syntax? --- _cite/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_cite/util.py b/_cite/util.py index d9db4cf0aa..904ff3329b 100644 --- a/_cite/util.py +++ b/_cite/util.py @@ -95,7 +95,7 @@ def format_date(_date): if isinstance(_date, int): return datetime.fromtimestamp(_date // 1000.0).strftime("%Y-%m-%d") - if isinstance(_date, date) or isinstance(_date, datetime): + if isinstance(_date, (date, datetime)): return _date.strftime("%Y-%m-%d") try: return datetime.strptime(_date, "%Y-%m-%d").strftime("%Y-%m-%d")