diff --git a/.fuse_hidden00011cee00000003 b/.fuse_hidden00011cee00000003 new file mode 100644 index 0000000..fbd2d2e --- /dev/null +++ b/.fuse_hidden00011cee00000003 @@ -0,0 +1,53 @@ + + + + + + My LinkTree + + + + lemmy.cif.su +code.cif.su + + + youtube icon + YouTube + + + + + \ No newline at end of file diff --git a/generate.py b/generate.py new file mode 100644 index 0000000..45346a6 --- /dev/null +++ b/generate.py @@ -0,0 +1,66 @@ +import json + +def load_social_media_data(): + # Load social media data from JSON file + with open("./templates/sites.json", "r") as file: + return json.load(file) + +def detect_platform(link, social_media_data): + # Detect the platform from the link + for platform in social_media_data: + if platform in link: + return platform + return None + +def generate_html(links, social_media_data): + # Read the template file + with open("./templates/template.html", "r") as file: + template = file.read() + + # Generate button elements for each link + buttons = "" + for link in links: + platform = detect_platform(link, social_media_data) + if platform: + icon_url = social_media_data[platform]["icon"] + platform_name = social_media_data[platform]["name"] + buttons += f''' + + {platform} icon + {platform_name} + \n + ''' + else: + # If the platform is not recognized, use the domain name as the button text + domain = link.split("//")[-1].split("/")[0] # Extract domain from link + buttons += f'{domain}\n' + + # Replace the placeholder with the generated buttons + template = template.replace("{links}", buttons) + + # Save the new HTML file + output_file = "./generated/visicard.html" + with open(output_file, "w") as file: + file.write(template) + + print(f"Your Linktree '{output_file}' has been generated successfully!") + +if __name__ == "__main__": + # Load social media data + social_media_data = load_social_media_data() + + # Ask the user how many links they want to add + try: + num_links = int(input("How many links do you want to add? ")) + except ValueError: + print("Please enter a valid number.") + exit() + + # Ask the user for each link + links = [] + for i in range(1, num_links + 1): + link = input(f"Please enter Link {i}: ") + links.append(link) + + # Generate the HTML file + generate_html(links, social_media_data) \ No newline at end of file diff --git a/templates/sites.json b/templates/sites.json new file mode 100644 index 0000000..4efeccc --- /dev/null +++ b/templates/sites.json @@ -0,0 +1,26 @@ +{ + "youtube": { + "icon": "https://example.com/icons/youtube.svg", + "name": "YouTube" + }, + "twitter": { + "icon": "https://example.com/icons/twitter.svg", + "name": "Twitter" + }, + "github": { + "icon": "https://example.com/icons/github.svg", + "name": "GitHub" + }, + "instagram": { + "icon": "https://example.com/icons/instagram.svg", + "name": "Instagram" + }, + "linkedin": { + "icon": "https://example.com/icons/linkedin.svg", + "name": "LinkedIn" + }, + "facebook": { + "icon": "https://example.com/icons/facebook.svg", + "name": "Facebook" + } +} \ No newline at end of file diff --git a/templates/template.html b/templates/template.html new file mode 100644 index 0000000..fbc475a --- /dev/null +++ b/templates/template.html @@ -0,0 +1,45 @@ + + + + + + My LinkTree + + + + {links} + + \ No newline at end of file