Skip to content

Commit

Permalink
indexer finished
Browse files Browse the repository at this point in the history
  • Loading branch information
CJavierSaldana committed Sep 8, 2024
1 parent 904d749 commit 2bc2bef
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 30 deletions.
28 changes: 2 additions & 26 deletions .github/workflows/update-directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,8 @@ jobs:

- name: Update DIRECTORY.md
run: |
pip install pyyaml
python - <<EOF
import os
import yaml
def update_directory():
directory_path = 'directory'
clones = []
for filename in os.listdir(directory_path):
if filename.endswith('.yml'):
with open(os.path.join(directory_path, filename), 'r') as file:
clone_data = yaml.safe_load(file)
clones.append(clone_data)
with open('DIRECTORY.md', 'w') as directory_file:
directory_file.write("# Directory of Clones\n\n")
directory_file.write("| Name | Description | Repository Link |\n")
directory_file.write("|------|-------------|------------------|\n")
for clone in clones:
directory_file.write(f"| {clone['name']} | {clone['description']} | [{clone['name']}]({clone['repo_link']}) |\n")
if __name__ == "__main__":
update_directory()
EOF
pip install pyyaml requests
python3 indexer.py
- name: Commit changes
run: |
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ To begin your journey with clone-me:
1. **Fork the Template**: Start by forking the `clone-me` repository.
2. **Customize Your Clone**: Populate your `me`folder with your knowledge, experiences, and methodologies.
3. **Organize Your Content**: Use the core categories (see below) to structure your information.
4. **Share and Collaborate**: Make your repository public and engage with the community.
4. **Add Your Profile**: Create a YAML file in the `directory` folder (e.g., `@yourusername.yaml`) with your profile information.
5. **Share and Collaborate**: Make your repository public and engage with the community.

For detailed instructions, check out our [Beginner's Guide](link-to-guide).
For detailed instructions, check out our [Beginner's Guide](docs/beginners-guide.md).

## Core Categories

Expand Down
5 changes: 5 additions & 0 deletions directory/@cjaviersaldana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: Carlos Javier Saldana
description: Indomitable Developer | AI Strategist | Space Visionary | Tech Entrepreneur | Founder of PahVenture | Commander of the Future
github_username: cjaviersaldana
x_username: cjaviersaldana
website: https://cjaviersaldana.com
15 changes: 13 additions & 2 deletions docs/beginners-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ Welcome to the clone-me project! This guide will help you get started with creat
1. Fork the Template
2. Customize Your Clone
3. Organize Your Content
4. Share and Collaborate
4. Add Your Profile
5. Share and Collaborate

(Expand on each step with more detailed instructions)
### 1. Fork the Template
// ... existing instructions ...

### 2. Customize Your Clone
// ... existing instructions ...

### 3. Organize Your Content
// ... existing instructions ...

### 4. Add Your Profile
Create a YAML file in the `directory` folder with your GitHub username as the filename (e.g., `@yourusername.yaml`). Include the following information:

## Tips for Success

Expand Down
3 changes: 3 additions & 0 deletions docs/content-structure-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ clone-me/
7. Regular Review and Refactoring
- Schedule periodic reviews of your content structure to ensure it remains organized and relevant as your knowledge grows.

8. Profile Information
- Create a YAML file in the `directory` folder (e.g., `@yourusername.yaml`) with your profile information for automatic indexing.

By following these guidelines and adapting the structure to your specific needs, you'll create a well-organized and easily navigable clone-me repository that effectively showcases your knowledge and expertise.
50 changes: 50 additions & 0 deletions indexer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import yaml
import requests

def sanitize_text(text):
"""Sanitize text to avoid breaking Markdown table."""
return text.replace('|', '&#124;').replace('\n', ' ').strip()

def update_directory():
directory_path = 'directory'
clones = []

for filename in os.listdir(directory_path):
if filename.startswith('@') and filename.endswith('.yaml'):
with open(os.path.join(directory_path, filename), 'r') as file:
clone_data = yaml.safe_load(file)
if 'github_username' in clone_data:
try:
github_api_url = f"https://api.github.com/users/{clone_data['github_username']}"
response = requests.get(github_api_url)

if response.status_code == 200:
user_data = response.json()
clone_data['github'] = clone_data.get('github', {})
clone_data['github'].update({
'avatar_url': user_data.get('avatar_url'),
'public_repos': user_data.get('public_repos'),
'followers': user_data.get('followers')
})
else:
raise Exception(f"Error occurred while fetching GitHub data: {response.status_code}")
except ImportError:
raise Exception("Warning: 'requests' library not installed. Skipping GitHub API validation.")
except Exception as e:
raise Exception(f"Error occurred while fetching GitHub data: {str(e)}")
clones.append(clone_data)

with open('DIRECTORY.md', 'w') as directory_file:
directory_file.write("# Directory of Clones\n\n")
directory_file.write("| Name | GitHub | X | Description |\n")
directory_file.write("|------|--------|---|-------------|\n")
for clone in clones:
name = sanitize_text(clone['name'])
github = sanitize_text(clone.get('github_username', 'N/A'))
x = sanitize_text(clone.get('x_username', 'N/A'))
desc = sanitize_text(clone['description'])[:200]
directory_file.write(f"| {name} | [{github}](https://github.com/{github}) | [{x}](https://twitter.com/{x}) | {desc} |\n")

if __name__ == "__main__":
update_directory()

0 comments on commit 2bc2bef

Please sign in to comment.