diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-02 20:28:26 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-02 20:28:26 +0200 |
| commit | f871619d7fedbf973c249ad6e16c0fcf7e819cf8 (patch) | |
| tree | 93bcdeb6ffb45b12580a7890b0cc1d88ce977a32 /tools | |
| parent | e326e848dc9e065af2cb4a324e3ebcf98ad9fb33 (diff) | |
| download | mitjafelicijan.com-f871619d7fedbf973c249ad6e16c0fcf7e819cf8.tar.gz | |
Update
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/fossil-projects.sh | 17 | ||||
| -rw-r--r-- | tools/github-projects.py (renamed from tools/projects.py) | 19 |
2 files changed, 21 insertions, 15 deletions
diff --git a/tools/fossil-projects.sh b/tools/fossil-projects.sh new file mode 100644 index 0000000..bb6e673 --- /dev/null +++ b/tools/fossil-projects.sh | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | set -xe | ||
| 2 | |||
| 3 | OUT=../content/pages/projects.fossil.md.part | ||
| 4 | |||
| 5 | echo -e "## Fossil repositories\n" > $OUT | ||
| 6 | |||
| 7 | find ~/Projects/ -type f -name "*.fossil" -not -path "*/website/*" | while read -r file; do | ||
| 8 | cp $file ../static/projects/ | ||
| 9 | done | ||
| 10 | |||
| 11 | find ../static/projects/ -type f -name "*.fossil" | while read -r file; do | ||
| 12 | base=$(basename "$file") | ||
| 13 | size=$(stat -c %s "$file" | numfmt --to=iec) | ||
| 14 | modified_date=$(stat -c %Y "$file") | ||
| 15 | formatted_date=$(date -d @"$modified_date" +"%Y-%m-%d %H:%M:%S") | ||
| 16 | echo -e "- [$base](/projects/$base)<br><small>Size: $size, Modified: $formatted_date</small>" >> $OUT | ||
| 17 | done | ||
diff --git a/tools/projects.py b/tools/github-projects.py index 65cea8d..e2afe95 100644 --- a/tools/projects.py +++ b/tools/github-projects.py | |||
| @@ -12,17 +12,11 @@ headers = { | |||
| 12 | "Accept": "application/vnd.github.v3+json" | 12 | "Accept": "application/vnd.github.v3+json" |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | |||
| 16 | def generate_markdown_file(include_repositories): | 15 | def generate_markdown_file(include_repositories): |
| 17 | file = open("../content/pages/projects.md", "w") | 16 | file = open("../content/pages/projects.github.md.part", "w") |
| 18 | 17 | ||
| 19 | file.write("---\n") | 18 | file.write(DOUBLE_NL) |
| 20 | file.write("title: Personal projects\n") | 19 | file.write("## GitHub repositories") |
| 21 | file.write("date: 2024-10-21T12:00:00+02:00\n") | ||
| 22 | file.write("url: projects.html\n") | ||
| 23 | file.write("type: page\n") | ||
| 24 | file.write("draft: false\n") | ||
| 25 | file.write("---") | ||
| 26 | file.write(DOUBLE_NL) | 20 | file.write(DOUBLE_NL) |
| 27 | 21 | ||
| 28 | file.write("<div class='project-list'>") | 22 | file.write("<div class='project-list'>") |
| @@ -76,8 +70,6 @@ def generate_markdown_file(include_repositories): | |||
| 76 | 70 | ||
| 77 | file.close() | 71 | file.close() |
| 78 | 72 | ||
| 79 | |||
| 80 | |||
| 81 | def download_tarball(url, filepath): | 73 | def download_tarball(url, filepath): |
| 82 | with requests.get(url, stream=True, timeout=30) as response: | 74 | with requests.get(url, stream=True, timeout=30) as response: |
| 83 | response.raise_for_status() | 75 | response.raise_for_status() |
| @@ -86,7 +78,6 @@ def download_tarball(url, filepath): | |||
| 86 | for chunk in response.iter_content(chunk_size=8192): | 78 | for chunk in response.iter_content(chunk_size=8192): |
| 87 | file.write(chunk) | 79 | file.write(chunk) |
| 88 | 80 | ||
| 89 | |||
| 90 | def assert_rate_limit(response): | 81 | def assert_rate_limit(response): |
| 91 | rate_limit_limit = int(response.headers.get("x-ratelimit-limit")) | 82 | rate_limit_limit = int(response.headers.get("x-ratelimit-limit")) |
| 92 | rate_limit_remaining = int(response.headers.get("x-ratelimit-remaining")) | 83 | rate_limit_remaining = int(response.headers.get("x-ratelimit-remaining")) |
| @@ -97,7 +88,6 @@ def assert_rate_limit(response): | |||
| 97 | if rate_limit_remaining == 0: | 88 | if rate_limit_remaining == 0: |
| 98 | sys.exit(1) | 89 | sys.exit(1) |
| 99 | 90 | ||
| 100 | |||
| 101 | def fetch_github_data(): | 91 | def fetch_github_data(): |
| 102 | include_repositories = [] | 92 | include_repositories = [] |
| 103 | print(headers) | 93 | print(headers) |
| @@ -136,7 +126,6 @@ def fetch_github_data(): | |||
| 136 | 126 | ||
| 137 | return include_repositories | 127 | return include_repositories |
| 138 | 128 | ||
| 139 | |||
| 140 | include_repositories = fetch_github_data() | 129 | include_repositories = fetch_github_data() |
| 141 | 130 | ||
| 142 | # with open("out.json", "w") as json_file: | 131 | # with open("out.json", "w") as json_file: |
