Added tags, createdAt, updatedAt properties (#561)

* add new properties on submit theme

* New GitHub Action for updating `updatedAt`

* change rebuild_themes.py to update tags for color themes

* Adding GitHub Action for updating all theme.json files (temporary)

* Applying corrected themes.json file

* fix: forgot to commit changes

* Update theme.json metadata

* Deleting actions not needed for merge

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
TheRealMG 2024-10-12 02:23:29 -05:00 committed by GitHub
parent 1d26f953a6
commit ab50f51b95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 1240 additions and 64 deletions

View file

@ -72,11 +72,16 @@ def main():
theme_colors_output = os.path.join(theme_folder, "chrome.css")
colors = write_colors(theme_colors_file, theme_colors_output)
if "isDarkMode" in colors:
theme_data["isDarkMode"] = colors["isDarkMode"]
if "tags" not in theme_data:
theme_data["tags"] = []
theme_data["isColorTheme"] = True
# Add 'color theme' tag if colors.json is present
theme_data["tags"].append("color theme")
# Add 'dark' tag if colors.json specifies dark mode
if "isDarkMode" in colors and colors["isDarkMode"]:
theme_data["tags"].append("dark")
themes_data[theme] = theme_data
with open(THEMES_DATA_FILE, "w") as f:
@ -106,4 +111,4 @@ def main():
if __name__ == "__main__":
main()
main()

View file

@ -2,6 +2,7 @@ import os
import re
import argparse
import json
import time
import uuid
import sys
import requests
@ -352,6 +353,9 @@ Just joking, you can do whatever you want. You're the boss.
"image": get_static_asset(theme_id, IMAGE_FILE),
"author": author,
"version": "1.0.0",
"tags": [],
"createdAt": time.strftime("%Y-%m-%d"),
"updatedAt": time.strftime("%Y-%m-%d"),
}
os.makedirs(f"themes/{theme_id}")
@ -388,4 +392,4 @@ Just joking, you can do whatever you want. You're the boss.
if __name__ == "__main__":
main()
main()

View file

@ -0,0 +1,41 @@
import json
import time
import os
import sys
def panic(message: str):
print(message, file=sys.stderr)
exit(1)
def update_theme_date(theme_path):
theme_file = os.path.join(theme_path, "theme.json")
if not os.path.exists(theme_file):
panic(f"{theme_file} not found.")
# Load the theme JSON data
with open(theme_file, "r") as f:
try:
theme_data = json.load(f)
except json.JSONDecodeError as e:
panic("Error reading theme.json: " + str(e))
# Update the `updatedAt` field to the current date
theme_data["updatedAt"] = time.strftime("%Y-%m-%d")
# Write the changes back to theme.json
with open(theme_file, "w") as f:
json.dump(theme_data, f, indent=2)
print(f"Updated `updatedAt` for {theme_path} to {theme_data['updatedAt']}")
if __name__ == "__main__":
# Make sure the script is run with the theme path as an argument
if len(sys.argv) != 2:
panic("Usage: update_theme_date.py <path_to_theme_directory>")
theme_path = sys.argv[1]
update_theme_date(theme_path)