From f7b653b6a0b0c47edde52f49f92d2550280d0987 Mon Sep 17 00:00:00 2001 From: Thomas Camlong <49837342+ajnart@users.noreply.github.com> Date: Thu, 26 May 2022 13:38:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Rework=20the=20python=20script?= =?UTF-8?q?=20(#105)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/update_readme.yml | 5 +- TEMPLATE.md | 59 +++++++++++++++++++ generate_readme.py | 90 +++++++---------------------- 3 files changed, 82 insertions(+), 72 deletions(-) create mode 100644 TEMPLATE.md diff --git a/.github/workflows/update_readme.yml b/.github/workflows/update_readme.yml index 3cdb014..996e772 100644 --- a/.github/workflows/update_readme.yml +++ b/.github/workflows/update_readme.yml @@ -3,9 +3,6 @@ name: Update Readme on: push: workflow_dispatch: - schedule: - - cron: '0 0 * * *' - jobs: build: runs-on: ubuntu-latest @@ -31,6 +28,6 @@ jobs: git config --global user.email "readmebot@walkx.org" git config --global user.name "Readme Bot" git add -A - git commit -m "✨ feat(add): Update Readme" || exit 0 + git commit -m ":octocat: Update Readme" || exit 0 git push diff --git a/TEMPLATE.md b/TEMPLATE.md new file mode 100644 index 0000000..fa4ed3d --- /dev/null +++ b/TEMPLATE.md @@ -0,0 +1,59 @@ +

+

Dashboard Icons

+ +

+ Dashboard Icons for your selfhosted services. +
+ Get icons » +
+
+ +

+ +# Table of Contents +- [Table of Contents](#table-of-contents) +- [Getting Started](#getting-started) + - [Dashboards](#dashboards) + - [Installation](#installation) +- [Icons](#icons) +- [Legal](#legal) + + +# Getting Started + +## Dashboards + +There's multiple Dashboards available. Here are some of the popular ones. + +- [Dashy*](https://github.com/Lissy93/dashy) +- [Homer Dashboard](https://github.com/bastienwirtz/homer) +- [Heimdall](https://github.com/linuxserver/Heimdall) +- [Organizr(v2)](https://github.com/causefx/Organizr) +- [Flame](https://github.com/pawelmalak/flame) +- [SUI](https://github.com/jeroenpardon/sui) + +## Installation +_*Dashy natively supports all icons in this repo, and is synced automatically. (Clicking [this link](https://github.com/Lissy93/dashy/blob/master/docs/icons.md#home-lab-icons) will take you to the docs that explain how to use the integration.)_ + +To download an icon, simple `Right click > Save image`. + +For non-desktop operating systems, or people that prefer to use terminal. +```sh +$ curl https://raw.githubusercontent.com/walkxhub/dashboard-icons/master/png/example.png > example.png +``` +or +```sh +$ wget https://raw.githubusercontent.com/walkxhub/dashboard-icons/master/png/example.png - O example.png +``` + +# Icons + + + + + +# Legal +(Almost) All product names, trademarks and registered trademarks in the images in this repository, are property of their respective owners. All images in this repository are used by the users of the Dashboard Icons project for identification purposes only. + +The use of these names, trademarks and brands appearing in these image files, do not imply endorsement. + diff --git a/generate_readme.py b/generate_readme.py index af28cb3..7204bb4 100644 --- a/generate_readme.py +++ b/generate_readme.py @@ -1,78 +1,32 @@ import pathlib from pathlib import Path + root = pathlib.Path(__file__).parent.resolve() -readme_path = root / 'README.md' +template_path = root / "TEMPLATE.md" +readme_path = root / "README.md" def generate_img_tag(file): return f'{file.stem}' -if __name__ == "__main__": - imgs = sorted(Path("./png").glob("*.png")) - img_tags = [generate_img_tag(x) for x in imgs] +imgs = sorted(Path("./png").glob("*.png")) +img_tags = [generate_img_tag(x) for x in imgs] +line_number = 0 - with open(readme_path, "wt", encoding="UTF-8") as f: - f.write("

\n") - f.write("

Dashboard Icons

\n") - f.write("\n") - f.write("

\n") - f.write(" Dashboard Icons for your selfhosted services.\n") - f.write("
\n") - f.write( - " Get icons » \n") - f.write("
\n") - f.write("
\n") - f.write( - " \n") - f.write("

\n") - f.write("\n") - f.write("# Table of Contents\n") - f.write("- [Table of Contents](#table-of-contents)\n") - f.write("- [Getting Started](#getting-started)\n") - f.write(" - [Dashboards](#dashboards)\n") - f.write(" - [Installation](#installation)\n") - f.write("- [Icons](#icons)\n") - f.write("- [Legal](#legal)\n") - f.write("\n") - f.write("\n") - f.write("# Getting Started\n") - f.write("\n") - f.write("## Dashboards\n") - f.write("\n") - f.write( - "There's multiple Dashboards available. Here are some of the popular ones.\n") - f.write("\n") - f.write("- [Dashy*](https://github.com/Lissy93/dashy)\n") - f.write( - "- [Homer Dashboard](https://github.com/bastienwirtz/homer)\n") - f.write("- [Heimdall](https://github.com/linuxserver/Heimdall)\n") - f.write("- [Organizr(v2)](https://github.com/causefx/Organizr)\n") - f.write("- [Flame](https://github.com/pawelmalak/flame)\n") - f.write("- [SUI](https://github.com/jeroenpardon/sui)\n") - f.write("\n") - f.write("## Installation\n") - f.write( - "_*Dashy natively supports all icons in this repo, and is synced automatically. (Clicking [this link](https://github.com/Lissy93/dashy/blob/master/docs/icons.md#home-lab-icons) will take you to the docs that explain how to use the integration.)_\n") - f.write("\n") - f.write("To download an icon, simple `Right click > Save image`.\n") - f.write("\n") - f.write( - "For non-desktop operating systems, or people that prefer to use terminal.\n") - f.write("```sh\n") - f.write("$ curl https://raw.githubusercontent.com/walkxhub/dashboard-icons/master/png/example.png > example.png\n") - f.write("```\n") - f.write("or\n") - f.write("```sh\n") - f.write("$ wget https://raw.githubusercontent.com/walkxhub/dashboard-icons/master/png/example.png - O example.png\n") - f.write("```\n") - f.write("\n") - f.write("\n") - f.write("# Icons\n") - f.write(" ".join(img_tags)) - f.write("\n\n") - f.write("\n") - f.write("# Legal\n") - f.write("(Almost) All product names, trademarks and registered trademarks in the images in this repository, are property of their respective owners. All images in this repository are used by the users of the Dashboard Icons project for identification purposes only.\n") - f.write("\n") - f.write("The use of these names, trademarks and brands appearing in these image files, do not imply endorsement.\n") +# Read the template file +with open(template_path, "r", encoding="UTF-8") as f: + lines = f.readlines() +# Find the line that starts with "" +for line in lines: + if line.startswith(""): + line_number = lines.index(line) + break +# Insert the icons after the line +lines.insert(line_number + 1, "\n".join(img_tags)) +# Write the new file +with open(readme_path, "w", encoding="UTF-8") as f: + f.write("".join(lines)) + f.write("\n") +print("Done!") +print("Please commit the new README.md file.")