mirror of
https://github.com/mustbeperfect/definitive-opensource.git
synced 2026-04-27 19:25:48 +02:00
Moved data files into static and dynamic
This commit is contained in:
@@ -41,13 +41,13 @@ def format_stars(n):
|
||||
|
||||
def generate_contents(platform="all"):
|
||||
|
||||
with open("source/data/categories.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/static/categories.json", "r", encoding="utf-8") as f:
|
||||
cat_data = json.load(f)
|
||||
with open("source/data/applications.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as f:
|
||||
app_data = json.load(f)
|
||||
with open("source/data/tags.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/static/tags.json", "r", encoding="utf-8") as f:
|
||||
tags_data = json.load(f)
|
||||
with open("source/data/platforms.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/static/platforms.json", "r", encoding="utf-8") as f:
|
||||
platforms_data = json.load(f)
|
||||
|
||||
categories = cat_data.get("categories", [])
|
||||
|
||||
@@ -2,7 +2,7 @@ import json
|
||||
|
||||
# Generates mainheader with dynamic project count
|
||||
def generate_mainheader():
|
||||
with open("source/data/applications.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
project_count = len(data.get("applications", []))
|
||||
|
||||
@@ -6,7 +6,7 @@ def slugify(name):
|
||||
|
||||
def generate_table_of_contents():
|
||||
# Load the categories JSON data
|
||||
with open("source/data/categories.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/static/categories.json", "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
categories = data.get("categories", [])
|
||||
subcategories = data.get("subcategories", [])
|
||||
|
||||
@@ -3,7 +3,7 @@ import requests
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
with open('source/data/applications.json', 'r') as f:
|
||||
with open('source/data/dynamic/applications.json', 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
|
||||
@@ -56,7 +56,7 @@ def update_application_data(app):
|
||||
for app in data['applications']:
|
||||
app = update_application_data(app)
|
||||
|
||||
with open('source/data/applications.json', 'w') as f:
|
||||
with open('source/data/dynamic/applications.json', 'w') as f:
|
||||
json.dump(data, f, indent=4)
|
||||
|
||||
print("Updated application data successfully!")
|
||||
|
||||
@@ -3,7 +3,7 @@ import json
|
||||
"""
|
||||
|
||||
# Load the JSON data from file
|
||||
with open("source/data/applications.json", "r", encoding="utf-8") as file:
|
||||
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as file:
|
||||
data = json.load(file)
|
||||
|
||||
# Convert all platform entries to lowercase
|
||||
@@ -12,7 +12,7 @@ for app in data.get("applications", []):
|
||||
app["platforms"] = [platform.lower() for platform in app["platforms"]]
|
||||
|
||||
# Write the modified data back to the file
|
||||
with open("source/data/applications.json", "w", encoding="utf-8") as file:
|
||||
with open("source/data/dynamic/applications.json", "w", encoding="utf-8") as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
print("All platform entries have been converted to lowercase.")
|
||||
@@ -20,7 +20,7 @@ print("All platform entries have been converted to lowercase.")
|
||||
|
||||
"""
|
||||
# Load the JSON file
|
||||
with open("source/data/applications.json", "r", encoding="utf-8") as file:
|
||||
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as file:
|
||||
data = json.load(file)
|
||||
|
||||
# Add "flags" and "stars" properties to each application
|
||||
@@ -28,14 +28,14 @@ for app in data.get("applications", []):
|
||||
app["homepage_url"] = ""
|
||||
|
||||
# Save the updated JSON back to the file
|
||||
with open("source/data/applications.json", "w", encoding="utf-8") as file:
|
||||
with open("source/data/dynamic/applications.json", "w", encoding="utf-8") as file:
|
||||
json.dump(data, file, indent=4, ensure_ascii=False)
|
||||
|
||||
print("Operation successful: applications.json updated")
|
||||
"""
|
||||
|
||||
# Load applications.json
|
||||
with open("source/data/applications.json", "r", encoding="utf-8") as f:
|
||||
with open("source/data/dynamic/applications.json", "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Platforms to check for
|
||||
@@ -58,5 +58,5 @@ for app in data.get("applications", []):
|
||||
app["tags"] = sorted(tags)
|
||||
|
||||
# Save the updated file
|
||||
with open("source/data/applications.json", "w", encoding="utf-8") as f:
|
||||
with open("source/data/dynamic/applications.json", "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
|
||||
Reference in New Issue
Block a user