Chan Meng
commited on
Commit
·
8e118cf
1
Parent(s):
dd495a5
update
Browse files- .gitignore +2 -0
- GitHub README Profile Generator Development Guidelines.md +265 -0
- README模板.md +131 -0
- app.py +159 -2
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/venv
|
GitHub README Profile Generator Development Guidelines.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GitHub README Profile Generator Development Guidelines
|
| 2 |
+
|
| 3 |
+
## 1. Project Overview
|
| 4 |
+
|
| 5 |
+
### 1.1 Project Description
|
| 6 |
+
A Hugging Face Space application that helps users generate personalized GitHub README profiles through AI interaction and template customization.
|
| 7 |
+
|
| 8 |
+
### 1.2 Core Features
|
| 9 |
+
- AI-powered profile content generation
|
| 10 |
+
- Template-based README structure
|
| 11 |
+
- Interactive markdown preview
|
| 12 |
+
- Section-by-section copying
|
| 13 |
+
- Bulk markdown export
|
| 14 |
+
- Live preview of generated content
|
| 15 |
+
|
| 16 |
+
## 2. Technical Stack
|
| 17 |
+
|
| 18 |
+
### 2.1 Core Technologies
|
| 19 |
+
- Frontend Framework: Streamlit
|
| 20 |
+
- AI Model: LLaMA/BLOOM (Open Source LLM)
|
| 21 |
+
- Markdown Processing: Python-markdown
|
| 22 |
+
- Version Control: Git
|
| 23 |
+
|
| 24 |
+
### 2.2 Required Dependencies
|
| 25 |
+
```requirements.txt
|
| 26 |
+
streamlit>=1.24.0
|
| 27 |
+
python-markdown>=3.4.0
|
| 28 |
+
requests>=2.28.0
|
| 29 |
+
python-dotenv>=0.19.0
|
| 30 |
+
transformers>=4.30.0
|
| 31 |
+
torch>=2.0.0
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## 3. Project Structure
|
| 35 |
+
```
|
| 36 |
+
readme-profile-generator/
|
| 37 |
+
├── app.py # Main Streamlit application
|
| 38 |
+
├── src/
|
| 39 |
+
│ ├── ai/ # AI interaction modules
|
| 40 |
+
│ ├── components/ # UI components
|
| 41 |
+
│ ├── templates/ # README templates
|
| 42 |
+
│ └── utils/ # Helper functions
|
| 43 |
+
├── tests/ # Test files
|
| 44 |
+
├── .gitignore
|
| 45 |
+
├── requirements.txt
|
| 46 |
+
└── README.md
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
## 4. Development Phases
|
| 50 |
+
|
| 51 |
+
### Phase 1: MVP (Basic Foundation)
|
| 52 |
+
**Objective**: Create basic working prototype
|
| 53 |
+
|
| 54 |
+
**Features**:
|
| 55 |
+
1. Single-page Streamlit interface
|
| 56 |
+
2. Basic user input form
|
| 57 |
+
3. Simple markdown preview
|
| 58 |
+
4. Copy button for full content
|
| 59 |
+
|
| 60 |
+
**Testing Criteria**:
|
| 61 |
+
- UI renders correctly
|
| 62 |
+
- Form captures all basic information
|
| 63 |
+
- Preview displays formatted markdown
|
| 64 |
+
- Copy function works correctly
|
| 65 |
+
|
| 66 |
+
### Phase 2: AI Integration
|
| 67 |
+
**Objective**: Implement AI-powered content generation
|
| 68 |
+
|
| 69 |
+
**Features**:
|
| 70 |
+
1. AI model integration
|
| 71 |
+
2. Basic prompt engineering
|
| 72 |
+
3. Content suggestion system
|
| 73 |
+
4. Error handling for AI responses
|
| 74 |
+
|
| 75 |
+
**Testing Criteria**:
|
| 76 |
+
- AI responds within 5 seconds
|
| 77 |
+
- Generated content is relevant
|
| 78 |
+
- Error messages are clear
|
| 79 |
+
- Content format is valid markdown
|
| 80 |
+
|
| 81 |
+
### Phase 3: Template System
|
| 82 |
+
**Objective**: Add template selection and customization
|
| 83 |
+
|
| 84 |
+
**Features**:
|
| 85 |
+
1. Multiple template options
|
| 86 |
+
2. Template preview
|
| 87 |
+
3. Section customization
|
| 88 |
+
4. Template switching
|
| 89 |
+
|
| 90 |
+
**Testing Criteria**:
|
| 91 |
+
- All templates load correctly
|
| 92 |
+
- Preview updates instantly
|
| 93 |
+
- Customizations persist
|
| 94 |
+
- Templates maintain formatting
|
| 95 |
+
|
| 96 |
+
### Phase 4: Advanced Features
|
| 97 |
+
**Objective**: Implement section management and advanced copying
|
| 98 |
+
|
| 99 |
+
**Features**:
|
| 100 |
+
1. Section-by-section editing
|
| 101 |
+
2. Individual section copying
|
| 102 |
+
3. Bulk export options
|
| 103 |
+
4. Session management
|
| 104 |
+
|
| 105 |
+
**Testing Criteria**:
|
| 106 |
+
- Sections can be individually modified
|
| 107 |
+
- Copy functions work for all sections
|
| 108 |
+
- Export includes all content
|
| 109 |
+
- Sessions persist correctly
|
| 110 |
+
|
| 111 |
+
## 5. Coding Standards
|
| 112 |
+
|
| 113 |
+
### 5.1 Python Code Style
|
| 114 |
+
- Follow PEP 8 guidelines
|
| 115 |
+
- Use type hints
|
| 116 |
+
- Maximum line length: 88 characters
|
| 117 |
+
- Use descriptive variable names
|
| 118 |
+
|
| 119 |
+
### 5.2 File Organization
|
| 120 |
+
- One class per file
|
| 121 |
+
- Group related functionality in modules
|
| 122 |
+
- Keep files under 500 lines
|
| 123 |
+
- Use appropriate file naming conventions
|
| 124 |
+
|
| 125 |
+
### 5.3 Comments and Documentation
|
| 126 |
+
- Each function must have docstrings
|
| 127 |
+
- Complex logic requires inline comments
|
| 128 |
+
- Update README.md with new features
|
| 129 |
+
- Document all configuration options
|
| 130 |
+
|
| 131 |
+
## 6. Testing Guidelines
|
| 132 |
+
|
| 133 |
+
### 6.1 Testing Levels
|
| 134 |
+
1. Unit Testing
|
| 135 |
+
- Test individual functions
|
| 136 |
+
- Test UI components
|
| 137 |
+
- Test markdown generation
|
| 138 |
+
|
| 139 |
+
2. Integration Testing
|
| 140 |
+
- Test AI integration
|
| 141 |
+
- Test template system
|
| 142 |
+
- Test data flow
|
| 143 |
+
|
| 144 |
+
3. User Acceptance Testing
|
| 145 |
+
- Test full user workflows
|
| 146 |
+
- Test edge cases
|
| 147 |
+
- Test error scenarios
|
| 148 |
+
|
| 149 |
+
### 6.2 Test Cases Structure
|
| 150 |
+
```python
|
| 151 |
+
def test_feature():
|
| 152 |
+
# Setup
|
| 153 |
+
# Action
|
| 154 |
+
# Assert
|
| 155 |
+
# Cleanup
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
### 6.3 Testing Checklist
|
| 159 |
+
- [ ] All new functions have unit tests
|
| 160 |
+
- [ ] Integration tests pass
|
| 161 |
+
- [ ] UI renders correctly
|
| 162 |
+
- [ ] Error handling works
|
| 163 |
+
- [ ] Performance meets requirements
|
| 164 |
+
|
| 165 |
+
## 7. Deployment Guidelines
|
| 166 |
+
|
| 167 |
+
### 7.1 Pre-deployment Checklist
|
| 168 |
+
- [ ] All tests pass
|
| 169 |
+
- [ ] Dependencies are updated
|
| 170 |
+
- [ ] Environment variables are set
|
| 171 |
+
- [ ] Documentation is updated
|
| 172 |
+
|
| 173 |
+
### 7.2 Deployment Process
|
| 174 |
+
1. Update requirements.txt
|
| 175 |
+
2. Run full test suite
|
| 176 |
+
3. Update Space secrets if needed
|
| 177 |
+
4. Deploy to Hugging Face Space
|
| 178 |
+
5. Verify deployment
|
| 179 |
+
|
| 180 |
+
## 8. Version Control
|
| 181 |
+
|
| 182 |
+
### 8.1 Branch Strategy
|
| 183 |
+
- main: Production code
|
| 184 |
+
- develop: Development branch
|
| 185 |
+
- feature/*: New features
|
| 186 |
+
- bugfix/*: Bug fixes
|
| 187 |
+
|
| 188 |
+
### 8.2 Commit Guidelines
|
| 189 |
+
- Use descriptive commit messages
|
| 190 |
+
- Reference issue numbers
|
| 191 |
+
- Keep commits focused
|
| 192 |
+
- Follow conventional commits format
|
| 193 |
+
|
| 194 |
+
## 9. Performance Requirements
|
| 195 |
+
|
| 196 |
+
### 9.1 Response Times
|
| 197 |
+
- Page load: < 3 seconds
|
| 198 |
+
- AI response: < 5 seconds
|
| 199 |
+
- Preview update: < 1 second
|
| 200 |
+
- Copy operation: < 0.5 seconds
|
| 201 |
+
|
| 202 |
+
### 9.2 Resource Usage
|
| 203 |
+
- Memory usage < 512MB
|
| 204 |
+
- CPU usage < 70%
|
| 205 |
+
- Storage usage < 1GB
|
| 206 |
+
|
| 207 |
+
## 10. Error Handling
|
| 208 |
+
|
| 209 |
+
### 10.1 User Errors
|
| 210 |
+
- Display clear error messages
|
| 211 |
+
- Provide recovery suggestions
|
| 212 |
+
- Maintain data integrity
|
| 213 |
+
- Log user errors
|
| 214 |
+
|
| 215 |
+
### 10.2 System Errors
|
| 216 |
+
- Implement graceful degradation
|
| 217 |
+
- Log detailed error information
|
| 218 |
+
- Notify admin of critical errors
|
| 219 |
+
- Provide fallback options
|
| 220 |
+
|
| 221 |
+
## 11. Security Guidelines
|
| 222 |
+
|
| 223 |
+
### 11.1 User Data
|
| 224 |
+
- No sensitive data storage
|
| 225 |
+
- Clear data usage policies
|
| 226 |
+
- Implement rate limiting
|
| 227 |
+
- Sanitize user inputs
|
| 228 |
+
|
| 229 |
+
### 11.2 API Security
|
| 230 |
+
- Use environment variables
|
| 231 |
+
- Implement request validation
|
| 232 |
+
- Monitor API usage
|
| 233 |
+
- Handle token expiration
|
| 234 |
+
|
| 235 |
+
## 12. Maintenance
|
| 236 |
+
|
| 237 |
+
### 12.1 Regular Tasks
|
| 238 |
+
- Update dependencies monthly
|
| 239 |
+
- Review error logs weekly
|
| 240 |
+
- Backup configurations
|
| 241 |
+
- Monitor performance
|
| 242 |
+
|
| 243 |
+
### 12.2 Documentation
|
| 244 |
+
- Keep README updated
|
| 245 |
+
- Document API changes
|
| 246 |
+
- Update user guides
|
| 247 |
+
- Maintain changelog
|
| 248 |
+
|
| 249 |
+
## 13. Success Criteria
|
| 250 |
+
|
| 251 |
+
### 13.1 Functional Requirements
|
| 252 |
+
- All features work as specified
|
| 253 |
+
- No critical bugs
|
| 254 |
+
- Meets performance requirements
|
| 255 |
+
- Passes all test cases
|
| 256 |
+
|
| 257 |
+
### 13.2 User Experience
|
| 258 |
+
- Intuitive interface
|
| 259 |
+
- Clear feedback
|
| 260 |
+
- Responsive design
|
| 261 |
+
- Helpful error messages
|
| 262 |
+
|
| 263 |
+
---
|
| 264 |
+
|
| 265 |
+
**Note**: This document should be treated as a living document and updated as the project evolves. Each phase should be completed and thoroughly tested before moving to the next phase.
|
README模板.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+

|
| 2 |
+
|
| 3 |
+
<div align="center">
|
| 4 |
+
|
| 5 |
+
[]({{portfolio_link}})
|
| 6 |
+
[]({{linkedin_link}})
|
| 7 |
+
|
| 8 |
+
</div>
|
| 9 |
+
|
| 10 |
+
<details>
|
| 11 |
+
<summary><h2>🤞 My Promise</h2></summary>
|
| 12 |
+
|
| 13 |
+
```java
|
| 14 |
+
while (isAwake) {
|
| 15 |
+
{{daily_routine_1}}();
|
| 16 |
+
{{daily_routine_2}}();
|
| 17 |
+
{{daily_routine_3}}();
|
| 18 |
+
{{daily_routine_4}}();
|
| 19 |
+
}
|
| 20 |
+
```
|
| 21 |
+
</details>
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
|
| 25 |
+
<!-- Featured Projects Section -->
|
| 26 |
+
<table>
|
| 27 |
+
<tr>
|
| 28 |
+
<td width="50%">
|
| 29 |
+
<h3 align="center">{{project_1_name}}</h3>
|
| 30 |
+
<div align="center">
|
| 31 |
+
<a href="{{project_1_link}}" target="_blank">
|
| 32 |
+
<img src="{{project_1_image}}" width="50%" alt="{{project_1_name}}"/>
|
| 33 |
+
</a>
|
| 34 |
+
<br>
|
| 35 |
+
<br>
|
| 36 |
+
<p>
|
| 37 |
+
<a href="{{project_1_github}}" target="_blank">
|
| 38 |
+
<img src="https://img.shields.io/badge/View_on_GitHub-2ea44f?style=for-the-badge&logo=github"/>
|
| 39 |
+
</a>
|
| 40 |
+
<a href="{{project_1_live}}" target="_blank">
|
| 41 |
+
<img src="https://img.shields.io/badge/Live_Demo-brightgreen?style=for-the-badge&logo=vercel"/>
|
| 42 |
+
</a>
|
| 43 |
+
</p>
|
| 44 |
+
<p align="left">
|
| 45 |
+
• {{project_1_point_1}}<br>
|
| 46 |
+
• {{project_1_point_2}}<br>
|
| 47 |
+
• {{project_1_point_3}}
|
| 48 |
+
</p>
|
| 49 |
+
</div>
|
| 50 |
+
</td>
|
| 51 |
+
<td width="50%">
|
| 52 |
+
<h3 align="center">{{project_2_name}}</h3>
|
| 53 |
+
<div align="center">
|
| 54 |
+
<a href="{{project_2_link}}" target="_blank">
|
| 55 |
+
<img src="{{project_2_image}}" width="50%" alt="{{project_2_name}}"/>
|
| 56 |
+
</a>
|
| 57 |
+
<br>
|
| 58 |
+
<br>
|
| 59 |
+
<p>
|
| 60 |
+
<a href="{{project_2_github}}" target="_blank">
|
| 61 |
+
<img src="https://img.shields.io/badge/View_on_GitHub-2ea44f?style=for-the-badge&logo=github"/>
|
| 62 |
+
</a>
|
| 63 |
+
<a href="{{project_2_live}}" target="_blank">
|
| 64 |
+
<img src="https://img.shields.io/badge/Live_Demo-brightgreen?style=for-the-badge&logo=vercel"/>
|
| 65 |
+
</a>
|
| 66 |
+
</p>
|
| 67 |
+
<p align="left">
|
| 68 |
+
• {{project_2_point_1}}<br>
|
| 69 |
+
• {{project_2_point_2}}<br>
|
| 70 |
+
• {{project_2_point_3}}
|
| 71 |
+
</p>
|
| 72 |
+
</div>
|
| 73 |
+
</td>
|
| 74 |
+
</tr>
|
| 75 |
+
</table>
|
| 76 |
+
|
| 77 |
+

|
| 78 |
+
|
| 79 |
+
<details open>
|
| 80 |
+
<summary><h3>🎯 Core Skills</h3></summary>
|
| 81 |
+
|
| 82 |
+
{{core_skills_badges}}
|
| 83 |
+
|
| 84 |
+
</details>
|
| 85 |
+
|
| 86 |
+
<details>
|
| 87 |
+
<summary><h3>🌐 Frontend Development</h3></summary>
|
| 88 |
+
|
| 89 |
+
{{frontend_skills_badges}}
|
| 90 |
+
|
| 91 |
+
</details>
|
| 92 |
+
|
| 93 |
+
<details>
|
| 94 |
+
<summary><h3>🔙 Backend Development</h3></summary>
|
| 95 |
+
|
| 96 |
+
{{backend_skills_badges}}
|
| 97 |
+
|
| 98 |
+
</details>
|
| 99 |
+
|
| 100 |
+

|
| 101 |
+
|
| 102 |
+
<div align="center">
|
| 103 |
+
<img src="https://github-readme-stats.vercel.app/api?username={{github_username}}&show_icons=true&theme=graywhite" alt="GitHub Stats" height="170"/>
|
| 104 |
+
<img src="https://github-readme-stats.vercel.app/api/top-langs/?username={{github_username}}&layout=compact&theme=graywhite" alt="Top Languages" height="170"/>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<div align="center">
|
| 108 |
+
<img src="https://github-readme-streak-stats.herokuapp.com/?user={{github_username}}&theme=graywhite" alt="GitHub Streak" height="170"/>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
<h2 align="center">💡 Random Dev Quote</h2>
|
| 112 |
+
|
| 113 |
+
<div align="center">
|
| 114 |
+
<img src="https://quotes-github-readme.vercel.app/api?type=horizontal&theme=light" alt="Random Dev Quote"/>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+

|
| 118 |
+
|
| 119 |
+
<div align="center">
|
| 120 |
+
<p><i>{{footer_text}}</i></p>
|
| 121 |
+
<br>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
<div align="center">
|
| 125 |
+
|
| 126 |
+
[]({{portfolio_link}})
|
| 127 |
+
[]({{linkedin_link}})
|
| 128 |
+
|
| 129 |
+
</div>
|
| 130 |
+
|
| 131 |
+

|
app.py
CHANGED
|
@@ -1,4 +1,161 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import re
|
| 4 |
+
import urllib.parse
|
| 5 |
|
| 6 |
+
def load_template(template_path):
|
| 7 |
+
"""加载 README 模板文件"""
|
| 8 |
+
with open(template_path, 'r', encoding='utf-8') as f:
|
| 9 |
+
return f.read()
|
| 10 |
+
|
| 11 |
+
def get_template_variables(template_content):
|
| 12 |
+
"""从模板中提取所有变量"""
|
| 13 |
+
pattern = r'\{\{(\w+)\}\}'
|
| 14 |
+
return sorted(list(set(re.findall(pattern, template_content))))
|
| 15 |
+
|
| 16 |
+
def encode_url_safe(text):
|
| 17 |
+
"""将文本中的空格转换为 URL 安全的格式"""
|
| 18 |
+
return urllib.parse.quote(text).replace('+', '%20')
|
| 19 |
+
|
| 20 |
+
def replace_template_variables(template_content, variables_dict):
|
| 21 |
+
"""替换模板中的所有变量,对特定字段进行 URL 编码"""
|
| 22 |
+
url_encode_fields = ['full_name', 'bio'] # 需要 URL 编码的字段
|
| 23 |
+
|
| 24 |
+
for key, value in variables_dict.items():
|
| 25 |
+
if key in url_encode_fields and value:
|
| 26 |
+
# 对特定字段进行 URL 编码
|
| 27 |
+
encoded_value = encode_url_safe(value)
|
| 28 |
+
template_content = template_content.replace(f'{{{{{key}}}}}', encoded_value)
|
| 29 |
+
else:
|
| 30 |
+
# 其他字段正常替��
|
| 31 |
+
template_content = template_content.replace(f'{{{{{key}}}}}', value)
|
| 32 |
+
|
| 33 |
+
return template_content
|
| 34 |
+
|
| 35 |
+
def create_badge(text, color="blue"):
|
| 36 |
+
"""创建技能徽章
|
| 37 |
+
将空格替换为下划线,以确保徽章正确显示
|
| 38 |
+
"""
|
| 39 |
+
# 处理空格
|
| 40 |
+
text = text.strip()
|
| 41 |
+
badge_text = text.replace(" ", "_")
|
| 42 |
+
badge_logo = text.lower().replace(" ", "-") # logo 使用连字符
|
| 43 |
+
|
| 44 |
+
return f""
|
| 45 |
+
|
| 46 |
+
def process_skills(skills_text):
|
| 47 |
+
"""处理技能列表文本
|
| 48 |
+
分割文本并生成徽章
|
| 49 |
+
"""
|
| 50 |
+
if not skills_text:
|
| 51 |
+
return ""
|
| 52 |
+
|
| 53 |
+
# 分割技能并移除空白项
|
| 54 |
+
skills = [skill.strip() for skill in skills_text.split(",") if skill.strip()]
|
| 55 |
+
# 生成徽章
|
| 56 |
+
return " ".join([create_badge(skill) for skill in skills])
|
| 57 |
+
|
| 58 |
+
def main():
|
| 59 |
+
st.set_page_config(
|
| 60 |
+
page_title="GitHub README Profile Generator",
|
| 61 |
+
page_icon="📝",
|
| 62 |
+
layout="wide"
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
st.title("GitHub README Profile Generator")
|
| 66 |
+
st.markdown("### 生成你的个性化 GitHub Profile README")
|
| 67 |
+
|
| 68 |
+
# 加载默认模板
|
| 69 |
+
template_path = Path("README模板.md")
|
| 70 |
+
template_content = load_template(template_path)
|
| 71 |
+
|
| 72 |
+
# 创建两列布局
|
| 73 |
+
col1, col2 = st.columns([1, 1])
|
| 74 |
+
|
| 75 |
+
with col1:
|
| 76 |
+
st.subheader("基本信息")
|
| 77 |
+
|
| 78 |
+
# 基本信息表单
|
| 79 |
+
full_name = st.text_input("姓名", value="Chan Meng")
|
| 80 |
+
bio = st.text_input("个人简介", value="A minimalist")
|
| 81 |
+
github_username = st.text_input("GitHub 用户名", value="ChanMeng666")
|
| 82 |
+
|
| 83 |
+
# 社交链接
|
| 84 |
+
st.subheader("社交链接")
|
| 85 |
+
portfolio_link = st.text_input("作品集链接", value="https://chanmeng.live/")
|
| 86 |
+
linkedin_link = st.text_input("LinkedIn 链接", value="https://www.linkedin.com/in/chanmeng666/")
|
| 87 |
+
|
| 88 |
+
# 日常行为
|
| 89 |
+
st.subheader("日常行为")
|
| 90 |
+
daily_routine_1 = st.text_input("日常行为 1", value="code")
|
| 91 |
+
daily_routine_2 = st.text_input("日常行为 2", value="eat")
|
| 92 |
+
daily_routine_3 = st.text_input("日常行为 3", value="sleep")
|
| 93 |
+
daily_routine_4 = st.text_input("日常行为 4", value="repeat")
|
| 94 |
+
|
| 95 |
+
# 项目信息
|
| 96 |
+
st.subheader("项目 1")
|
| 97 |
+
project_1_name = st.text_input("项目 1 名称", value="My Awesome Project")
|
| 98 |
+
project_1_link = st.text_input("项目 1 链接", value="#")
|
| 99 |
+
project_1_image = st.text_input("项目 1 图片", value="/path/to/project1.png")
|
| 100 |
+
project_1_github = st.text_input("项目 1 GitHub", value="#")
|
| 101 |
+
project_1_live = st.text_input("项目 1 演示链接", value="#")
|
| 102 |
+
project_1_point_1 = st.text_input("项目 1 要点 1", value="Feature 1")
|
| 103 |
+
project_1_point_2 = st.text_input("项目 1 要点 2", value="Feature 2")
|
| 104 |
+
project_1_point_3 = st.text_input("项目 1 要点 3", value="Feature 3")
|
| 105 |
+
|
| 106 |
+
# 技能徽章
|
| 107 |
+
st.subheader("技能栈")
|
| 108 |
+
core_skills = st.text_area("核心技能 (用逗号分隔)",
|
| 109 |
+
value="React,Python,TypeScript,Machine Learning")
|
| 110 |
+
frontend_skills = st.text_area("前端技能 (用逗号分隔)",
|
| 111 |
+
value="HTML5,CSS3,JavaScript,React Native")
|
| 112 |
+
backend_skills = st.text_area("后端技能 (用逗号分隔)",
|
| 113 |
+
value="Node.js,MySQL,MongoDB")
|
| 114 |
+
|
| 115 |
+
# 生成徽章
|
| 116 |
+
core_skills_badges = process_skills(core_skills)
|
| 117 |
+
frontend_skills_badges = process_skills(frontend_skills)
|
| 118 |
+
backend_skills_badges = process_skills(backend_skills)
|
| 119 |
+
|
| 120 |
+
# 其他信息
|
| 121 |
+
st.subheader("其他信息")
|
| 122 |
+
footer_text = st.text_area("页脚文本", value="Thanks for visiting my GitHub profile! Feel free to connect or check out my projects.")
|
| 123 |
+
|
| 124 |
+
# 创建变量字典
|
| 125 |
+
variables = {
|
| 126 |
+
'full_name': full_name or '',
|
| 127 |
+
'bio': bio or '',
|
| 128 |
+
'github_username': github_username,
|
| 129 |
+
'portfolio_link': portfolio_link,
|
| 130 |
+
'linkedin_link': linkedin_link,
|
| 131 |
+
'daily_routine_1': daily_routine_1,
|
| 132 |
+
'daily_routine_2': daily_routine_2,
|
| 133 |
+
'daily_routine_3': daily_routine_3,
|
| 134 |
+
'daily_routine_4': daily_routine_4,
|
| 135 |
+
'project_1_name': project_1_name,
|
| 136 |
+
'project_1_link': project_1_link,
|
| 137 |
+
'project_1_image': project_1_image,
|
| 138 |
+
'project_1_github': project_1_github,
|
| 139 |
+
'project_1_live': project_1_live,
|
| 140 |
+
'project_1_point_1': project_1_point_1,
|
| 141 |
+
'project_1_point_2': project_1_point_2,
|
| 142 |
+
'project_1_point_3': project_1_point_3,
|
| 143 |
+
'core_skills_badges': core_skills_badges,
|
| 144 |
+
'frontend_skills_badges': frontend_skills_badges,
|
| 145 |
+
'backend_skills_badges': backend_skills_badges,
|
| 146 |
+
'footer_text': footer_text
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
# 生成预览内容
|
| 150 |
+
preview_content = replace_template_variables(template_content, variables)
|
| 151 |
+
|
| 152 |
+
with col2:
|
| 153 |
+
st.subheader("预览")
|
| 154 |
+
st.markdown(preview_content, unsafe_allow_html=True)
|
| 155 |
+
|
| 156 |
+
if st.button("复制全部内容"):
|
| 157 |
+
st.code(preview_content, language="markdown")
|
| 158 |
+
st.success("内容已复制到剪贴板!")
|
| 159 |
+
|
| 160 |
+
if __name__ == "__main__":
|
| 161 |
+
main()
|