Spaces:
Sleeping
Sleeping
AtZa commited on
Upload 16 files
Browse files- app.py +45 -0
- content/projects.py +598 -0
- content/tutorials.py +901 -0
- instance/dify_learning.db +0 -0
- models.py +43 -0
- pyproject.toml +15 -0
- requirements.txt +8 -0
- routes.py +121 -0
- static/css/style.css +719 -0
- static/js/main.js +354 -0
- static/js/tutorial.js +596 -0
- templates/base.html +100 -0
- templates/index.html +150 -0
- templates/progress.html +158 -0
- templates/project.html +161 -0
- templates/tutorial.html +196 -0
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
from flask import Flask
|
| 5 |
+
from flask_sqlalchemy import SQLAlchemy
|
| 6 |
+
from sqlalchemy.orm import DeclarativeBase
|
| 7 |
+
from werkzeug.middleware.proxy_fix import ProxyFix
|
| 8 |
+
|
| 9 |
+
# Configure logging
|
| 10 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class Base(DeclarativeBase):
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
db = SQLAlchemy(model_class=Base)
|
| 18 |
+
|
| 19 |
+
# create the app
|
| 20 |
+
app = Flask(__name__)
|
| 21 |
+
app.secret_key = os.environ.get("SESSION_SECRET",
|
| 22 |
+
"dev-secret-key-change-in-production")
|
| 23 |
+
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
| 24 |
+
|
| 25 |
+
# configure the database, relative to the app instance folder
|
| 26 |
+
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get(
|
| 27 |
+
"DATABASE_URL", "sqlite:///dify_learning.db")
|
| 28 |
+
app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {
|
| 29 |
+
"pool_recycle": 300,
|
| 30 |
+
"pool_pre_ping": True,
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
# initialize the app with the extension
|
| 34 |
+
db.init_app(app)
|
| 35 |
+
|
| 36 |
+
# Import routes after app creation to avoid circular imports
|
| 37 |
+
from routes import *
|
| 38 |
+
|
| 39 |
+
with app.app_context():
|
| 40 |
+
# Make sure to import the models here or their tables won't be created
|
| 41 |
+
import models
|
| 42 |
+
db.create_all()
|
| 43 |
+
|
| 44 |
+
if __name__ == '__main__':
|
| 45 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|
content/projects.py
ADDED
|
@@ -0,0 +1,598 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Project content for the Dify AI Learning Platform
|
| 3 |
+
Real-world projects based on official Dify use cases and documentation
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
def get_all_projects():
|
| 7 |
+
"""Return all available hands-on projects"""
|
| 8 |
+
return [
|
| 9 |
+
{
|
| 10 |
+
'id': 1,
|
| 11 |
+
'title': 'AI Customer Service Bot',
|
| 12 |
+
'slug': 'ai-customer-service-bot',
|
| 13 |
+
'category': 'Customer Support',
|
| 14 |
+
'difficulty': 'beginner',
|
| 15 |
+
'difficulty_color': 'success',
|
| 16 |
+
'estimated_time': 45,
|
| 17 |
+
'description': 'Build an intelligent customer service bot that can answer questions from your product documentation and handle common support queries.',
|
| 18 |
+
'icon': 'headphones',
|
| 19 |
+
'outcomes': [
|
| 20 |
+
'A fully functional customer service chatbot',
|
| 21 |
+
'Knowledge base integration for product documentation',
|
| 22 |
+
'Automated response system for common queries',
|
| 23 |
+
'Escalation handling for complex issues'
|
| 24 |
+
],
|
| 25 |
+
'prerequisites': [
|
| 26 |
+
'Completed "Building Your First Chatbot" tutorial',
|
| 27 |
+
'Completed "Creating Knowledge Bases with RAG" tutorial',
|
| 28 |
+
'Basic understanding of customer service workflows'
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
'id': 2,
|
| 33 |
+
'title': 'AI Travel Consultant',
|
| 34 |
+
'slug': 'ai-travel-consultant',
|
| 35 |
+
'category': 'Travel & Tourism',
|
| 36 |
+
'difficulty': 'intermediate',
|
| 37 |
+
'difficulty_color': 'warning',
|
| 38 |
+
'estimated_time': 60,
|
| 39 |
+
'description': 'Create an AI agent that can plan travel itineraries, suggest accommodations, and find restaurants using external tools and APIs.',
|
| 40 |
+
'icon': 'map-pin',
|
| 41 |
+
'outcomes': [
|
| 42 |
+
'Intelligent travel planning agent',
|
| 43 |
+
'Integration with Wikipedia and Google Search',
|
| 44 |
+
'Dynamic itinerary generation',
|
| 45 |
+
'Hotel and restaurant recommendations with ratings'
|
| 46 |
+
],
|
| 47 |
+
'prerequisites': [
|
| 48 |
+
'Completed "Building AI Agents" tutorial',
|
| 49 |
+
'Completed "Tool Integration and APIs" tutorial',
|
| 50 |
+
'Understanding of AI agent workflows'
|
| 51 |
+
]
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
'id': 3,
|
| 55 |
+
'title': 'Document Analysis Assistant',
|
| 56 |
+
'slug': 'document-analysis-assistant',
|
| 57 |
+
'category': 'Document Processing',
|
| 58 |
+
'difficulty': 'intermediate',
|
| 59 |
+
'difficulty_color': 'warning',
|
| 60 |
+
'estimated_time': 55,
|
| 61 |
+
'description': 'Build an AI agent that can analyze documents, extract key information, and answer questions about document content.',
|
| 62 |
+
'icon': 'file-text',
|
| 63 |
+
'outcomes': [
|
| 64 |
+
'Document upload and processing system',
|
| 65 |
+
'AI-powered content analysis',
|
| 66 |
+
'Information extraction capabilities',
|
| 67 |
+
'Document Q&A functionality'
|
| 68 |
+
],
|
| 69 |
+
'prerequisites': [
|
| 70 |
+
'Completed "Creating Knowledge Bases with RAG" tutorial',
|
| 71 |
+
'Completed "Working with Files and Documents" tutorial',
|
| 72 |
+
'Understanding of document processing workflows'
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
'id': 4,
|
| 77 |
+
'title': 'Smart Recipe Generator',
|
| 78 |
+
'slug': 'smart-recipe-generator',
|
| 79 |
+
'category': 'Food & Lifestyle',
|
| 80 |
+
'difficulty': 'beginner',
|
| 81 |
+
'difficulty_color': 'success',
|
| 82 |
+
'estimated_time': 35,
|
| 83 |
+
'description': 'Create an AI agent that generates personalized recipes based on ingredients, dietary preferences, and cooking skills.',
|
| 84 |
+
'icon': 'chef-hat',
|
| 85 |
+
'outcomes': [
|
| 86 |
+
'Personalized recipe generation',
|
| 87 |
+
'Ingredient-based recipe suggestions',
|
| 88 |
+
'Dietary restriction handling',
|
| 89 |
+
'Cooking instruction optimization'
|
| 90 |
+
],
|
| 91 |
+
'prerequisites': [
|
| 92 |
+
'Completed "Building Your First Chatbot" tutorial',
|
| 93 |
+
'Basic understanding of conversational AI'
|
| 94 |
+
]
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
'id': 5,
|
| 98 |
+
'title': 'Investment Analysis Copilot',
|
| 99 |
+
'slug': 'investment-analysis-copilot',
|
| 100 |
+
'category': 'Finance',
|
| 101 |
+
'difficulty': 'advanced',
|
| 102 |
+
'difficulty_color': 'danger',
|
| 103 |
+
'estimated_time': 75,
|
| 104 |
+
'description': 'Build a sophisticated AI agent that analyzes stocks, provides market insights, and generates investment recommendations using financial APIs.',
|
| 105 |
+
'icon': 'trending-up',
|
| 106 |
+
'outcomes': [
|
| 107 |
+
'Real-time stock analysis system',
|
| 108 |
+
'Market trend analysis and insights',
|
| 109 |
+
'Investment recommendation engine',
|
| 110 |
+
'Risk assessment and portfolio suggestions'
|
| 111 |
+
],
|
| 112 |
+
'prerequisites': [
|
| 113 |
+
'Completed "Building AI Agents" tutorial',
|
| 114 |
+
'Completed "Tool Integration and APIs" tutorial',
|
| 115 |
+
'Understanding of financial markets and analysis'
|
| 116 |
+
]
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
'id': 6,
|
| 120 |
+
'title': 'Educational Quiz Bot',
|
| 121 |
+
'slug': 'educational-quiz-bot',
|
| 122 |
+
'category': 'Education',
|
| 123 |
+
'difficulty': 'intermediate',
|
| 124 |
+
'difficulty_color': 'warning',
|
| 125 |
+
'estimated_time': 40,
|
| 126 |
+
'description': 'Develop an interactive AI tutor that creates quizzes, provides explanations, and adapts to student learning patterns.',
|
| 127 |
+
'icon': 'graduation-cap',
|
| 128 |
+
'outcomes': [
|
| 129 |
+
'Adaptive quiz generation system',
|
| 130 |
+
'Personalized learning paths',
|
| 131 |
+
'Progress tracking and analytics',
|
| 132 |
+
'Interactive educational content'
|
| 133 |
+
],
|
| 134 |
+
'prerequisites': [
|
| 135 |
+
'Completed "Building Your First Chatbot" tutorial',
|
| 136 |
+
'Completed "Creating Knowledge Bases with RAG" tutorial',
|
| 137 |
+
'Understanding of educational workflows'
|
| 138 |
+
]
|
| 139 |
+
}
|
| 140 |
+
]
|
| 141 |
+
|
| 142 |
+
def get_project_content(slug):
|
| 143 |
+
"""Return detailed content for a specific project"""
|
| 144 |
+
projects = {
|
| 145 |
+
'ai-customer-service-bot': {
|
| 146 |
+
'id': 1,
|
| 147 |
+
'title': 'AI Customer Service Bot',
|
| 148 |
+
'category': 'Customer Support',
|
| 149 |
+
'difficulty': 'beginner',
|
| 150 |
+
'difficulty_color': 'success',
|
| 151 |
+
'estimated_time': 45,
|
| 152 |
+
'description': 'Build an intelligent customer service bot that can answer questions from your product documentation and handle common support queries.',
|
| 153 |
+
'icon': 'headphones',
|
| 154 |
+
'outcomes': [
|
| 155 |
+
'A fully functional customer service chatbot',
|
| 156 |
+
'Knowledge base integration for product documentation',
|
| 157 |
+
'Automated response system for common queries',
|
| 158 |
+
'Escalation handling for complex issues'
|
| 159 |
+
],
|
| 160 |
+
'prerequisites': [
|
| 161 |
+
'Completed "Building Your First Chatbot" tutorial',
|
| 162 |
+
'Completed "Creating Knowledge Bases with RAG" tutorial',
|
| 163 |
+
'Basic understanding of customer service workflows'
|
| 164 |
+
],
|
| 165 |
+
'overview': '''
|
| 166 |
+
<p>Customer service is evolving with AI-powered solutions that can handle routine inquiries 24/7. In this project, you'll build a comprehensive customer service bot that can:</p>
|
| 167 |
+
<ul>
|
| 168 |
+
<li>Answer questions from your product documentation using RAG</li>
|
| 169 |
+
<li>Handle common support queries with pre-trained responses</li>
|
| 170 |
+
<li>Escalate complex issues to human agents when needed</li>
|
| 171 |
+
<li>Track customer satisfaction and conversation quality</li>
|
| 172 |
+
</ul>
|
| 173 |
+
<p>This project demonstrates real-world application of AI in customer support, combining knowledge retrieval with intelligent conversation management.</p>
|
| 174 |
+
''',
|
| 175 |
+
'sections': [
|
| 176 |
+
{
|
| 177 |
+
'title': 'Setting Up Your Knowledge Base',
|
| 178 |
+
'content': '''
|
| 179 |
+
<p>Create a comprehensive knowledge base from your product documentation that will power your customer service bot's responses.</p>
|
| 180 |
+
''',
|
| 181 |
+
'steps': [
|
| 182 |
+
{
|
| 183 |
+
'title': 'Upload Product Documentation',
|
| 184 |
+
'content': '''
|
| 185 |
+
Upload your existing product documentation, FAQs, and support materials to Dify. The system will automatically process and chunk this content for optimal retrieval.
|
| 186 |
+
|
| 187 |
+
**What to Upload:**
|
| 188 |
+
- Product manuals and guides
|
| 189 |
+
- Frequently asked questions (FAQs)
|
| 190 |
+
- Troubleshooting documentation
|
| 191 |
+
- Policy documents (returns, warranties, etc.)
|
| 192 |
+
- Contact information and escalation procedures
|
| 193 |
+
|
| 194 |
+
**Best Practices:**
|
| 195 |
+
- Use clear, consistent formatting
|
| 196 |
+
- Include specific examples and scenarios
|
| 197 |
+
- Keep information current and accurate
|
| 198 |
+
- Organize content by topic or product line
|
| 199 |
+
''',
|
| 200 |
+
'tips': [
|
| 201 |
+
'Upload documents in PDF, TXT, or DOCX format for best results',
|
| 202 |
+
'Break large documents into smaller, focused sections',
|
| 203 |
+
'Include keywords customers commonly use'
|
| 204 |
+
]
|
| 205 |
+
}
|
| 206 |
+
]
|
| 207 |
+
}
|
| 208 |
+
]
|
| 209 |
+
},
|
| 210 |
+
|
| 211 |
+
'ai-travel-consultant': {
|
| 212 |
+
'id': 2,
|
| 213 |
+
'title': 'AI Travel Consultant',
|
| 214 |
+
'category': 'Travel & Tourism',
|
| 215 |
+
'difficulty': 'intermediate',
|
| 216 |
+
'difficulty_color': 'warning',
|
| 217 |
+
'estimated_time': 60,
|
| 218 |
+
'description': 'Create an AI agent that can plan travel itineraries, suggest accommodations, and find restaurants using external tools and APIs.',
|
| 219 |
+
'icon': 'map-pin',
|
| 220 |
+
'outcomes': [
|
| 221 |
+
'Intelligent travel planning agent',
|
| 222 |
+
'Integration with Wikipedia and Google Search',
|
| 223 |
+
'Dynamic itinerary generation',
|
| 224 |
+
'Hotel and restaurant recommendations with ratings'
|
| 225 |
+
],
|
| 226 |
+
'prerequisites': [
|
| 227 |
+
'Completed "Building AI Agents" tutorial',
|
| 228 |
+
'Completed "Tool Integration and APIs" tutorial',
|
| 229 |
+
'Understanding of AI agent workflows'
|
| 230 |
+
],
|
| 231 |
+
'overview': '''
|
| 232 |
+
<p>Travel planning involves researching destinations, finding accommodations, and creating itineraries. In this project, you'll build an AI travel consultant that can:</p>
|
| 233 |
+
<ul>
|
| 234 |
+
<li>Research destinations and provide detailed information</li>
|
| 235 |
+
<li>Plan day-by-day itineraries based on preferences</li>
|
| 236 |
+
<li>Find and recommend hotels with ratings and reviews</li>
|
| 237 |
+
<li>Suggest restaurants and local attractions</li>
|
| 238 |
+
</ul>
|
| 239 |
+
<p>This project showcases advanced AI agent capabilities with external tool integration and complex workflow orchestration.</p>
|
| 240 |
+
''',
|
| 241 |
+
'sections': [
|
| 242 |
+
{
|
| 243 |
+
'title': 'Configuring External Tools',
|
| 244 |
+
'content': '''
|
| 245 |
+
<p>Set up Wikipedia and Google Search integrations to provide your travel agent with access to real-time information about destinations, attractions, and travel recommendations.</p>
|
| 246 |
+
''',
|
| 247 |
+
'steps': [
|
| 248 |
+
{
|
| 249 |
+
'title': 'Configure Wikipedia Integration',
|
| 250 |
+
'content': '''
|
| 251 |
+
Add Wikipedia as a tool to your Dify agent to provide detailed information about destinations, landmarks, and cultural sites.
|
| 252 |
+
|
| 253 |
+
**Configuration Steps:**
|
| 254 |
+
1. Go to Tools section in your Dify workspace
|
| 255 |
+
2. Add "Wikipedia" from the available tools
|
| 256 |
+
3. Configure search parameters for travel-related queries
|
| 257 |
+
4. Test with sample destination searches
|
| 258 |
+
|
| 259 |
+
**Search Optimization:**
|
| 260 |
+
- Use specific place names and landmarks
|
| 261 |
+
- Include cultural and historical context
|
| 262 |
+
- Focus on tourist-relevant information
|
| 263 |
+
- Verify information accuracy and recency
|
| 264 |
+
''',
|
| 265 |
+
'tips': [
|
| 266 |
+
'Test Wikipedia searches with various destination formats',
|
| 267 |
+
'Combine multiple search terms for comprehensive results',
|
| 268 |
+
'Verify information from multiple sources when possible'
|
| 269 |
+
]
|
| 270 |
+
}
|
| 271 |
+
]
|
| 272 |
+
}
|
| 273 |
+
]
|
| 274 |
+
},
|
| 275 |
+
|
| 276 |
+
'document-analysis-assistant': {
|
| 277 |
+
'id': 3,
|
| 278 |
+
'title': 'Document Analysis Assistant',
|
| 279 |
+
'category': 'Document Processing',
|
| 280 |
+
'difficulty': 'intermediate',
|
| 281 |
+
'difficulty_color': 'warning',
|
| 282 |
+
'estimated_time': 55,
|
| 283 |
+
'description': 'Build an AI agent that can analyze documents, extract key information, and answer questions about document content.',
|
| 284 |
+
'icon': 'file-text',
|
| 285 |
+
'outcomes': [
|
| 286 |
+
'Document upload and processing system',
|
| 287 |
+
'AI-powered content analysis',
|
| 288 |
+
'Information extraction capabilities',
|
| 289 |
+
'Document Q&A functionality'
|
| 290 |
+
],
|
| 291 |
+
'prerequisites': [
|
| 292 |
+
'Completed "Creating Knowledge Bases with RAG" tutorial',
|
| 293 |
+
'Completed "Working with Files and Documents" tutorial',
|
| 294 |
+
'Understanding of document processing workflows'
|
| 295 |
+
],
|
| 296 |
+
'overview': '''
|
| 297 |
+
<p>Document analysis is crucial for businesses dealing with large volumes of text documents. In this project, you'll build an AI assistant that can:</p>
|
| 298 |
+
<ul>
|
| 299 |
+
<li>Process and analyze various document types</li>
|
| 300 |
+
<li>Extract key information and summarize content</li>
|
| 301 |
+
<li>Answer specific questions about document content</li>
|
| 302 |
+
<li>Identify patterns and insights across multiple documents</li>
|
| 303 |
+
</ul>
|
| 304 |
+
<p>This project demonstrates advanced document processing capabilities using AI, essential for legal, financial, and research applications.</p>
|
| 305 |
+
''',
|
| 306 |
+
'sections': [
|
| 307 |
+
{
|
| 308 |
+
'title': 'Document Processing Setup',
|
| 309 |
+
'content': '''
|
| 310 |
+
<p>Configure your document processing pipeline to handle various file formats and extract meaningful information from uploaded documents.</p>
|
| 311 |
+
''',
|
| 312 |
+
'steps': [
|
| 313 |
+
{
|
| 314 |
+
'title': 'Configure Document Upload',
|
| 315 |
+
'content': '''
|
| 316 |
+
Set up document upload capabilities in your Dify application to accept and process various file formats including PDFs, Word documents, and text files.
|
| 317 |
+
|
| 318 |
+
**Supported Formats:**
|
| 319 |
+
- PDF documents (.pdf)
|
| 320 |
+
- Microsoft Word documents (.docx, .doc)
|
| 321 |
+
- Plain text files (.txt)
|
| 322 |
+
- Rich text format (.rtf)
|
| 323 |
+
- Markdown files (.md)
|
| 324 |
+
|
| 325 |
+
**Processing Configuration:**
|
| 326 |
+
1. Enable file upload in your application settings
|
| 327 |
+
2. Set maximum file size limits (recommended: 10MB per file)
|
| 328 |
+
3. Configure document chunking for optimal processing
|
| 329 |
+
4. Enable OCR for scanned documents if needed
|
| 330 |
+
|
| 331 |
+
**Quality Optimization:**
|
| 332 |
+
- Ensure documents are well-formatted and readable
|
| 333 |
+
- Test with sample documents of each supported type
|
| 334 |
+
- Monitor processing time and adjust chunk sizes accordingly
|
| 335 |
+
''',
|
| 336 |
+
'tips': [
|
| 337 |
+
'Start with smaller documents to test processing capabilities',
|
| 338 |
+
'Use clear, well-structured documents for best results',
|
| 339 |
+
'Consider document security and privacy requirements'
|
| 340 |
+
]
|
| 341 |
+
}
|
| 342 |
+
]
|
| 343 |
+
}
|
| 344 |
+
]
|
| 345 |
+
},
|
| 346 |
+
|
| 347 |
+
'smart-recipe-generator': {
|
| 348 |
+
'id': 4,
|
| 349 |
+
'title': 'Smart Recipe Generator',
|
| 350 |
+
'category': 'Food & Lifestyle',
|
| 351 |
+
'difficulty': 'beginner',
|
| 352 |
+
'difficulty_color': 'success',
|
| 353 |
+
'estimated_time': 35,
|
| 354 |
+
'description': 'Create an AI agent that generates personalized recipes based on ingredients, dietary preferences, and cooking skills.',
|
| 355 |
+
'icon': 'chef-hat',
|
| 356 |
+
'outcomes': [
|
| 357 |
+
'Personalized recipe generation',
|
| 358 |
+
'Ingredient-based recipe suggestions',
|
| 359 |
+
'Dietary restriction handling',
|
| 360 |
+
'Cooking instruction optimization'
|
| 361 |
+
],
|
| 362 |
+
'prerequisites': [
|
| 363 |
+
'Completed "Building Your First Chatbot" tutorial',
|
| 364 |
+
'Basic understanding of conversational AI'
|
| 365 |
+
],
|
| 366 |
+
'overview': '''
|
| 367 |
+
<p>Cooking inspiration and meal planning can be enhanced with AI assistance. In this project, you'll build a smart recipe generator that can:</p>
|
| 368 |
+
<ul>
|
| 369 |
+
<li>Generate recipes based on available ingredients</li>
|
| 370 |
+
<li>Accommodate dietary restrictions and preferences</li>
|
| 371 |
+
<li>Adjust recipes based on cooking skill level</li>
|
| 372 |
+
<li>Provide step-by-step cooking instructions</li>
|
| 373 |
+
</ul>
|
| 374 |
+
<p>This project showcases creative AI applications in daily life, demonstrating how AI can assist with personal tasks and lifestyle decisions.</p>
|
| 375 |
+
''',
|
| 376 |
+
'sections': [
|
| 377 |
+
{
|
| 378 |
+
'title': 'Recipe Generation Logic',
|
| 379 |
+
'content': '''
|
| 380 |
+
<p>Design the core logic for generating personalized recipes based on user preferences, available ingredients, and dietary constraints.</p>
|
| 381 |
+
''',
|
| 382 |
+
'steps': [
|
| 383 |
+
{
|
| 384 |
+
'title': 'Create Recipe Prompt Template',
|
| 385 |
+
'content': '''
|
| 386 |
+
Design a comprehensive prompt template that will guide the AI in generating recipes that meet specific user requirements and preferences.
|
| 387 |
+
|
| 388 |
+
**Prompt Structure:**
|
| 389 |
+
```
|
| 390 |
+
You are a professional chef and recipe creator. Generate a recipe based on these requirements:
|
| 391 |
+
|
| 392 |
+
Ingredients Available: {ingredients}
|
| 393 |
+
Dietary Restrictions: {dietary_restrictions}
|
| 394 |
+
Cooking Skill Level: {skill_level}
|
| 395 |
+
Cuisine Preference: {cuisine_type}
|
| 396 |
+
Cooking Time Available: {time_limit}
|
| 397 |
+
|
| 398 |
+
Please provide:
|
| 399 |
+
1. Recipe name and brief description
|
| 400 |
+
2. Complete ingredient list with quantities
|
| 401 |
+
3. Step-by-step cooking instructions
|
| 402 |
+
4. Cooking tips and variations
|
| 403 |
+
5. Nutritional highlights
|
| 404 |
+
```
|
| 405 |
+
|
| 406 |
+
**Customization Variables:**
|
| 407 |
+
- Available ingredients (user input)
|
| 408 |
+
- Dietary restrictions (vegetarian, vegan, gluten-free, etc.)
|
| 409 |
+
- Skill level (beginner, intermediate, advanced)
|
| 410 |
+
- Cuisine preferences (Italian, Asian, Mexican, etc.)
|
| 411 |
+
- Time constraints (15 min, 30 min, 1 hour+)
|
| 412 |
+
''',
|
| 413 |
+
'tips': [
|
| 414 |
+
'Include specific quantity measurements in recipes',
|
| 415 |
+
'Provide alternative ingredients for flexibility',
|
| 416 |
+
'Add cooking tips for better results'
|
| 417 |
+
]
|
| 418 |
+
}
|
| 419 |
+
]
|
| 420 |
+
}
|
| 421 |
+
]
|
| 422 |
+
},
|
| 423 |
+
|
| 424 |
+
'investment-analysis-copilot': {
|
| 425 |
+
'id': 5,
|
| 426 |
+
'title': 'Investment Analysis Copilot',
|
| 427 |
+
'category': 'Finance',
|
| 428 |
+
'difficulty': 'advanced',
|
| 429 |
+
'difficulty_color': 'danger',
|
| 430 |
+
'estimated_time': 75,
|
| 431 |
+
'description': 'Build a sophisticated AI agent that analyzes stocks, provides market insights, and generates investment recommendations using financial APIs.',
|
| 432 |
+
'icon': 'trending-up',
|
| 433 |
+
'outcomes': [
|
| 434 |
+
'Real-time stock analysis system',
|
| 435 |
+
'Market trend analysis and insights',
|
| 436 |
+
'Investment recommendation engine',
|
| 437 |
+
'Risk assessment and portfolio suggestions'
|
| 438 |
+
],
|
| 439 |
+
'prerequisites': [
|
| 440 |
+
'Completed "Building AI Agents" tutorial',
|
| 441 |
+
'Completed "Tool Integration and APIs" tutorial',
|
| 442 |
+
'Understanding of financial markets and analysis'
|
| 443 |
+
],
|
| 444 |
+
'overview': '''
|
| 445 |
+
<p>Financial analysis requires processing vast amounts of data and making informed decisions. In this project, you'll build an AI investment copilot that can:</p>
|
| 446 |
+
<ul>
|
| 447 |
+
<li>Analyze individual stocks with real-time data</li>
|
| 448 |
+
<li>Provide comprehensive market trend analysis</li>
|
| 449 |
+
<li>Generate investment recommendations based on risk tolerance</li>
|
| 450 |
+
<li>Create portfolio suggestions and diversification advice</li>
|
| 451 |
+
</ul>
|
| 452 |
+
<p>This advanced project demonstrates professional-grade AI applications in finance, including API integration, data analysis, and risk assessment.</p>
|
| 453 |
+
''',
|
| 454 |
+
'sections': [
|
| 455 |
+
{
|
| 456 |
+
'title': 'Setting Up Financial Data Integration',
|
| 457 |
+
'content': '''
|
| 458 |
+
<p>Build connections to financial data sources and configure real-time market analysis capabilities.</p>
|
| 459 |
+
''',
|
| 460 |
+
'steps': [
|
| 461 |
+
{
|
| 462 |
+
'title': 'Configure Financial Data APIs',
|
| 463 |
+
'content': '''
|
| 464 |
+
Set up integration with financial data providers to access real-time stock prices, market data, and financial metrics for comprehensive analysis.
|
| 465 |
+
|
| 466 |
+
**Recommended Data Sources:**
|
| 467 |
+
- Alpha Vantage (free tier available)
|
| 468 |
+
- Yahoo Finance API
|
| 469 |
+
- Financial Modeling Prep
|
| 470 |
+
- IEX Cloud
|
| 471 |
+
|
| 472 |
+
**Key Data Points to Collect:**
|
| 473 |
+
- Current stock price and daily change
|
| 474 |
+
- Historical price data (1 year, 5 years)
|
| 475 |
+
- Financial ratios (P/E, P/B, ROE, etc.)
|
| 476 |
+
- Volume and market capitalization
|
| 477 |
+
- Dividend information and yield
|
| 478 |
+
- Analyst ratings and price targets
|
| 479 |
+
|
| 480 |
+
**API Configuration Steps:**
|
| 481 |
+
1. Choose your preferred financial data provider
|
| 482 |
+
2. Register for API access and obtain API keys
|
| 483 |
+
3. Configure API endpoints in Dify tools
|
| 484 |
+
4. Test data retrieval with sample stock symbols
|
| 485 |
+
5. Set up error handling for API rate limits
|
| 486 |
+
|
| 487 |
+
**Data Processing Tips:**
|
| 488 |
+
- Cache frequently requested data to reduce API calls
|
| 489 |
+
- Implement data validation and error handling
|
| 490 |
+
- Format financial data for clear presentation
|
| 491 |
+
- Consider real-time vs. delayed data requirements
|
| 492 |
+
''',
|
| 493 |
+
'tips': [
|
| 494 |
+
'Start with free API tiers to test functionality',
|
| 495 |
+
'Monitor API usage to avoid rate limits',
|
| 496 |
+
'Validate all financial data before analysis'
|
| 497 |
+
]
|
| 498 |
+
}
|
| 499 |
+
]
|
| 500 |
+
}
|
| 501 |
+
]
|
| 502 |
+
},
|
| 503 |
+
|
| 504 |
+
'educational-quiz-bot': {
|
| 505 |
+
'id': 6,
|
| 506 |
+
'title': 'Educational Quiz Bot',
|
| 507 |
+
'slug': 'educational-quiz-bot',
|
| 508 |
+
'category': 'Education',
|
| 509 |
+
'difficulty': 'intermediate',
|
| 510 |
+
'difficulty_color': 'warning',
|
| 511 |
+
'estimated_time': 40,
|
| 512 |
+
'description': 'Develop an interactive AI tutor that creates quizzes, provides explanations, and adapts to student learning patterns.',
|
| 513 |
+
'icon': 'graduation-cap',
|
| 514 |
+
'outcomes': [
|
| 515 |
+
'Adaptive quiz generation system',
|
| 516 |
+
'Personalized learning paths',
|
| 517 |
+
'Progress tracking and analytics',
|
| 518 |
+
'Interactive educational content'
|
| 519 |
+
],
|
| 520 |
+
'prerequisites': [
|
| 521 |
+
'Completed "Building Your First Chatbot" tutorial',
|
| 522 |
+
'Completed "Creating Knowledge Bases with RAG" tutorial',
|
| 523 |
+
'Understanding of educational workflows'
|
| 524 |
+
],
|
| 525 |
+
'overview': '''
|
| 526 |
+
<p>Educational technology benefits greatly from AI-powered personalization. In this project, you'll build an educational quiz bot that can:</p>
|
| 527 |
+
<ul>
|
| 528 |
+
<li>Generate quizzes on various topics and difficulty levels</li>
|
| 529 |
+
<li>Provide detailed explanations for answers</li>
|
| 530 |
+
<li>Adapt question difficulty based on student performance</li>
|
| 531 |
+
<li>Track learning progress and identify knowledge gaps</li>
|
| 532 |
+
</ul>
|
| 533 |
+
<p>This project demonstrates AI applications in education, showcasing adaptive learning and personalized instruction capabilities.</p>
|
| 534 |
+
''',
|
| 535 |
+
'sections': [
|
| 536 |
+
{
|
| 537 |
+
'title': 'Quiz Generation System',
|
| 538 |
+
'content': '''
|
| 539 |
+
<p>Design an intelligent quiz generation system that creates questions tailored to student learning objectives and performance levels.</p>
|
| 540 |
+
''',
|
| 541 |
+
'steps': [
|
| 542 |
+
{
|
| 543 |
+
'title': 'Create Dynamic Quiz Templates',
|
| 544 |
+
'content': '''
|
| 545 |
+
Develop flexible quiz templates that can generate questions across different subjects, difficulty levels, and question types.
|
| 546 |
+
|
| 547 |
+
**Question Types to Support:**
|
| 548 |
+
- Multiple choice questions
|
| 549 |
+
- True/False questions
|
| 550 |
+
- Fill-in-the-blank questions
|
| 551 |
+
- Short answer questions
|
| 552 |
+
- Essay questions (for advanced topics)
|
| 553 |
+
|
| 554 |
+
**Template Structure:**
|
| 555 |
+
```
|
| 556 |
+
Generate a {difficulty_level} {question_type} question about {topic}.
|
| 557 |
+
|
| 558 |
+
Requirements:
|
| 559 |
+
- Question should test {learning_objective}
|
| 560 |
+
- Include {num_options} answer choices (for multiple choice)
|
| 561 |
+
- Provide detailed explanation for correct answer
|
| 562 |
+
- Suggest common misconceptions to address
|
| 563 |
+
|
| 564 |
+
Format:
|
| 565 |
+
Question: [Your question here]
|
| 566 |
+
A) [Option 1]
|
| 567 |
+
B) [Option 2]
|
| 568 |
+
C) [Option 3]
|
| 569 |
+
D) [Option 4]
|
| 570 |
+
|
| 571 |
+
Correct Answer: [Letter and explanation]
|
| 572 |
+
Common Mistakes: [Address typical errors]
|
| 573 |
+
```
|
| 574 |
+
|
| 575 |
+
**Difficulty Adaptation:**
|
| 576 |
+
- Beginner: Basic recall and understanding
|
| 577 |
+
- Intermediate: Application and analysis
|
| 578 |
+
- Advanced: Synthesis and evaluation
|
| 579 |
+
|
| 580 |
+
**Learning Objectives:**
|
| 581 |
+
- Knowledge retention
|
| 582 |
+
- Concept application
|
| 583 |
+
- Problem-solving skills
|
| 584 |
+
- Critical thinking development
|
| 585 |
+
''',
|
| 586 |
+
'tips': [
|
| 587 |
+
'Include distractors that address common misconceptions',
|
| 588 |
+
'Provide detailed explanations for all answer choices',
|
| 589 |
+
'Vary question formats to maintain engagement'
|
| 590 |
+
]
|
| 591 |
+
}
|
| 592 |
+
]
|
| 593 |
+
}
|
| 594 |
+
]
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
return projects.get(slug)
|
content/tutorials.py
ADDED
|
@@ -0,0 +1,901 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Tutorial content for the Dify AI Learning Platform
|
| 3 |
+
Based on official Dify documentation and best practices
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
def get_all_tutorials():
|
| 7 |
+
"""Return all available tutorials in learning order"""
|
| 8 |
+
return [
|
| 9 |
+
{
|
| 10 |
+
'id': 1,
|
| 11 |
+
'title': 'Getting Started with Dify',
|
| 12 |
+
'slug': 'getting-started-with-dify',
|
| 13 |
+
'category': 'Fundamentals',
|
| 14 |
+
'difficulty': 'beginner',
|
| 15 |
+
'difficulty_color': 'success',
|
| 16 |
+
'order_index': 1,
|
| 17 |
+
'estimated_time': 15,
|
| 18 |
+
'description': 'Learn the basics of Dify AI platform, how to access it, and understand core concepts like LLMs, embeddings, and context windows.',
|
| 19 |
+
'total_steps': 4
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
'id': 2,
|
| 23 |
+
'title': 'Building Your First Chatbot',
|
| 24 |
+
'slug': 'building-your-first-chatbot',
|
| 25 |
+
'category': 'Chatbots',
|
| 26 |
+
'difficulty': 'beginner',
|
| 27 |
+
'difficulty_color': 'success',
|
| 28 |
+
'order_index': 2,
|
| 29 |
+
'estimated_time': 25,
|
| 30 |
+
'description': 'Create a simple AI chatbot using Dify\'s visual interface. Learn about prompts, models, and basic conversation flow.',
|
| 31 |
+
'total_steps': 6
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
'id': 3,
|
| 35 |
+
'title': 'Creating Knowledge Bases with RAG',
|
| 36 |
+
'slug': 'creating-knowledge-bases-rag',
|
| 37 |
+
'category': 'Knowledge Management',
|
| 38 |
+
'difficulty': 'intermediate',
|
| 39 |
+
'difficulty_color': 'warning',
|
| 40 |
+
'order_index': 3,
|
| 41 |
+
'estimated_time': 35,
|
| 42 |
+
'description': 'Build intelligent chatbots that can answer questions from your documents using Retrieval-Augmented Generation (RAG).',
|
| 43 |
+
'total_steps': 8
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
'id': 4,
|
| 47 |
+
'title': 'Mastering Prompt Engineering',
|
| 48 |
+
'slug': 'mastering-prompt-engineering',
|
| 49 |
+
'category': 'Prompt Engineering',
|
| 50 |
+
'difficulty': 'intermediate',
|
| 51 |
+
'difficulty_color': 'warning',
|
| 52 |
+
'order_index': 4,
|
| 53 |
+
'estimated_time': 30,
|
| 54 |
+
'description': 'Learn advanced prompt engineering techniques to get better results from your AI applications.',
|
| 55 |
+
'total_steps': 7
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
'id': 5,
|
| 59 |
+
'title': 'Building AI Agents',
|
| 60 |
+
'slug': 'building-ai-agents',
|
| 61 |
+
'category': 'AI Agents',
|
| 62 |
+
'difficulty': 'intermediate',
|
| 63 |
+
'difficulty_color': 'warning',
|
| 64 |
+
'order_index': 5,
|
| 65 |
+
'estimated_time': 40,
|
| 66 |
+
'description': 'Create intelligent AI agents that can use tools, make decisions, and handle complex multi-step tasks.',
|
| 67 |
+
'total_steps': 9
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
'id': 6,
|
| 71 |
+
'title': 'Workflow Orchestration',
|
| 72 |
+
'slug': 'workflow-orchestration',
|
| 73 |
+
'category': 'Workflows',
|
| 74 |
+
'difficulty': 'advanced',
|
| 75 |
+
'difficulty_color': 'danger',
|
| 76 |
+
'order_index': 6,
|
| 77 |
+
'estimated_time': 45,
|
| 78 |
+
'description': 'Master Dify\'s workflow system to create complex AI applications with conditional logic and parallel processing.',
|
| 79 |
+
'total_steps': 10
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
'id': 7,
|
| 83 |
+
'title': 'Tool Integration and APIs',
|
| 84 |
+
'slug': 'tool-integration-apis',
|
| 85 |
+
'category': 'Integration',
|
| 86 |
+
'difficulty': 'advanced',
|
| 87 |
+
'difficulty_color': 'danger',
|
| 88 |
+
'order_index': 7,
|
| 89 |
+
'estimated_time': 35,
|
| 90 |
+
'description': 'Connect your AI applications to external services and APIs to extend their capabilities.',
|
| 91 |
+
'total_steps': 8
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
'id': 8,
|
| 95 |
+
'title': 'Deployment and Monitoring',
|
| 96 |
+
'slug': 'deployment-monitoring',
|
| 97 |
+
'category': 'Operations',
|
| 98 |
+
'difficulty': 'advanced',
|
| 99 |
+
'difficulty_color': 'danger',
|
| 100 |
+
'order_index': 8,
|
| 101 |
+
'estimated_time': 30,
|
| 102 |
+
'description': 'Learn how to deploy your Dify applications to production and monitor their performance.',
|
| 103 |
+
'total_steps': 6
|
| 104 |
+
}
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
def get_tutorial_content(slug):
|
| 108 |
+
"""Return detailed content for a specific tutorial"""
|
| 109 |
+
tutorials = {
|
| 110 |
+
'getting-started-with-dify': {
|
| 111 |
+
'id': 1,
|
| 112 |
+
'title': 'Getting Started with Dify',
|
| 113 |
+
'category': 'Fundamentals',
|
| 114 |
+
'difficulty': 'beginner',
|
| 115 |
+
'difficulty_color': 'success',
|
| 116 |
+
'estimated_time': 15,
|
| 117 |
+
'description': 'Learn the basics of Dify AI platform, how to access it, and understand core concepts like LLMs, embeddings, and context windows.',
|
| 118 |
+
'steps': [
|
| 119 |
+
{
|
| 120 |
+
'title': 'What is Dify?',
|
| 121 |
+
'estimated_time': 3,
|
| 122 |
+
'content': '''
|
| 123 |
+
<p>Dify is an open-source, user-friendly LLMOps (Large Language Model Operations) platform designed to simplify and accelerate the development, deployment, and management of AI applications.</p>
|
| 124 |
+
|
| 125 |
+
<h4>Key Features:</h4>
|
| 126 |
+
<ul>
|
| 127 |
+
<li><strong>Visual AI Orchestration:</strong> Build AI applications using a drag-and-drop interface</li>
|
| 128 |
+
<li><strong>No-Code/Low-Code:</strong> Perfect for beginners with no programming experience</li>
|
| 129 |
+
<li><strong>RAG Engine:</strong> Built-in Retrieval-Augmented Generation for knowledge-based applications</li>
|
| 130 |
+
<li><strong>AI Agent Framework:</strong> Create intelligent agents that can use tools and make decisions</li>
|
| 131 |
+
<li><strong>Model Support:</strong> Works with all mainstream LLMs including GPT, Claude, and open-source models</li>
|
| 132 |
+
</ul>
|
| 133 |
+
|
| 134 |
+
<h4>Why Choose Dify?</h4>
|
| 135 |
+
<p>Unlike other AI tools that offer individual components, Dify provides a comprehensive, production-ready solution. Think of it as a well-designed scaffolding system that handles the complexity while you focus on creating innovative AI applications.</p>
|
| 136 |
+
''',
|
| 137 |
+
'tips': [
|
| 138 |
+
'Dify is completely open-source and free to use',
|
| 139 |
+
'You can use either the cloud version at dify.ai or deploy locally',
|
| 140 |
+
'No coding experience required to get started'
|
| 141 |
+
]
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
'title': 'Accessing Dify',
|
| 145 |
+
'estimated_time': 4,
|
| 146 |
+
'content': '''
|
| 147 |
+
<p>There are two ways to access Dify:</p>
|
| 148 |
+
|
| 149 |
+
<h4>Cloud Version (Recommended for Beginners)</h4>
|
| 150 |
+
<ol>
|
| 151 |
+
<li>Go to <a href="https://dify.ai" target="_blank">dify.ai</a></li>
|
| 152 |
+
<li>Sign up for a free account</li>
|
| 153 |
+
<li>Verify your email address</li>
|
| 154 |
+
<li>Start building immediately</li>
|
| 155 |
+
</ol>
|
| 156 |
+
<p>The cloud version includes free usage quotas for popular AI models, making it perfect for learning and experimentation.</p>
|
| 157 |
+
|
| 158 |
+
<h4>Local Installation (For Advanced Users)</h4>
|
| 159 |
+
<ol>
|
| 160 |
+
<li>Clone the repository from <a href="https://github.com/langgenius/dify" target="_blank">GitHub</a></li>
|
| 161 |
+
<li>Install Docker and Docker Compose</li>
|
| 162 |
+
<li>Run <code>docker compose up -d</code> in the dify/docker directory</li>
|
| 163 |
+
<li>Access at <code>http://localhost/install</code></li>
|
| 164 |
+
</ol>
|
| 165 |
+
''',
|
| 166 |
+
'tips': [
|
| 167 |
+
'Start with the cloud version for easier setup',
|
| 168 |
+
'Local installation gives you full control over data',
|
| 169 |
+
'Both versions have the same features and capabilities'
|
| 170 |
+
]
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
'title': 'Understanding Core Concepts',
|
| 174 |
+
'estimated_time': 5,
|
| 175 |
+
'content': '''
|
| 176 |
+
<p>Before building your first AI application, it's important to understand these key concepts:</p>
|
| 177 |
+
|
| 178 |
+
<h4>Large Language Models (LLMs)</h4>
|
| 179 |
+
<p>LLMs are AI models trained on vast amounts of text data. They can understand and generate human-like text. Popular LLMs include:</p>
|
| 180 |
+
<ul>
|
| 181 |
+
<li><strong>OpenAI GPT-4:</strong> Excellent for complex reasoning and creative tasks</li>
|
| 182 |
+
<li><strong>Claude:</strong> Great for analysis and following instructions</li>
|
| 183 |
+
<li><strong>Open-source models:</strong> Cost-effective alternatives for specific use cases</li>
|
| 184 |
+
</ul>
|
| 185 |
+
|
| 186 |
+
<h4>Context Window</h4>
|
| 187 |
+
<p>The context window is the amount of text an LLM can "see" and "remember" at once. A larger context window allows the model to consider more information when generating responses, leading to more accurate and coherent outputs.</p>
|
| 188 |
+
|
| 189 |
+
<h4>Embeddings</h4>
|
| 190 |
+
<p>Embeddings convert text into numerical vectors that capture semantic meaning. Similar texts have similar vectors, enabling AI to understand relationships between different pieces of content. This is crucial for search and retrieval functions.</p>
|
| 191 |
+
|
| 192 |
+
<h4>Tokens</h4>
|
| 193 |
+
<p>Tokens are the basic units that LLMs process - roughly equivalent to words or parts of words. Understanding tokens helps you manage costs and context limits.</p>
|
| 194 |
+
''',
|
| 195 |
+
'tips': [
|
| 196 |
+
'Different LLMs have different strengths - experiment to find the best fit',
|
| 197 |
+
'Larger context windows cost more but provide better results for complex tasks',
|
| 198 |
+
'Embeddings enable semantic search, not just keyword matching'
|
| 199 |
+
]
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
'title': 'Exploring the Dify Interface',
|
| 203 |
+
'estimated_time': 3,
|
| 204 |
+
'content': '''
|
| 205 |
+
<p>Once you're logged into Dify, you'll see a clean, intuitive dashboard with several key sections:</p>
|
| 206 |
+
|
| 207 |
+
<h4>Main Navigation</h4>
|
| 208 |
+
<ul>
|
| 209 |
+
<li><strong>Studio:</strong> Where you build and manage your AI applications</li>
|
| 210 |
+
<li><strong>Knowledge:</strong> Manage your knowledge bases and documents</li>
|
| 211 |
+
<li><strong>Tools:</strong> Configure external tools and integrations</li>
|
| 212 |
+
<li><strong>Datasets:</strong> Manage your training data and examples</li>
|
| 213 |
+
</ul>
|
| 214 |
+
|
| 215 |
+
<h4>Application Types</h4>
|
| 216 |
+
<p>Dify supports several types of AI applications:</p>
|
| 217 |
+
<ul>
|
| 218 |
+
<li><strong>Chatflow:</strong> Conversational applications with complex workflows</li>
|
| 219 |
+
<li><strong>Assistant:</strong> AI agents that can use tools and external services</li>
|
| 220 |
+
<li><strong>Completion:</strong> Text generation and completion applications</li>
|
| 221 |
+
</ul>
|
| 222 |
+
|
| 223 |
+
<h4>Quick Actions</h4>
|
| 224 |
+
<ul>
|
| 225 |
+
<li><strong>Create from Blank:</strong> Start with a clean slate</li>
|
| 226 |
+
<li><strong>Use Template:</strong> Begin with pre-built examples</li>
|
| 227 |
+
<li><strong>Import:</strong> Bring in existing configurations</li>
|
| 228 |
+
</ul>
|
| 229 |
+
''',
|
| 230 |
+
'tips': [
|
| 231 |
+
'Spend time exploring the interface before building your first app',
|
| 232 |
+
'Templates are great for learning best practices',
|
| 233 |
+
'The preview feature lets you test applications before publishing'
|
| 234 |
+
]
|
| 235 |
+
}
|
| 236 |
+
]
|
| 237 |
+
},
|
| 238 |
+
|
| 239 |
+
'building-your-first-chatbot': {
|
| 240 |
+
'id': 2,
|
| 241 |
+
'title': 'Building Your First Chatbot',
|
| 242 |
+
'category': 'Chatbots',
|
| 243 |
+
'difficulty': 'beginner',
|
| 244 |
+
'difficulty_color': 'success',
|
| 245 |
+
'estimated_time': 25,
|
| 246 |
+
'description': 'Create a simple AI chatbot using Dify\'s visual interface. Learn about prompts, models, and basic conversation flow.',
|
| 247 |
+
'steps': [
|
| 248 |
+
{
|
| 249 |
+
'title': 'Setting Up Your Model Provider',
|
| 250 |
+
'estimated_time': 5,
|
| 251 |
+
'content': '''
|
| 252 |
+
<p>Before creating your chatbot, you need to configure an AI model provider. Dify provides free usage quotas, but you'll eventually need your own API keys.</p>
|
| 253 |
+
|
| 254 |
+
<h4>Using the Free Quota</h4>
|
| 255 |
+
<p>New Dify users get:</p>
|
| 256 |
+
<ul>
|
| 257 |
+
<li>200 free OpenAI GPT messages</li>
|
| 258 |
+
<li>1000 free Anthropic Claude messages</li>
|
| 259 |
+
</ul>
|
| 260 |
+
|
| 261 |
+
<h4>Adding Your Own API Key</h4>
|
| 262 |
+
<ol>
|
| 263 |
+
<li>Go to Settings → Model Provider</li>
|
| 264 |
+
<li>Click on your preferred provider (e.g., OpenAI)</li>
|
| 265 |
+
<li>Click "Setup" and enter your API key</li>
|
| 266 |
+
<li>Test the connection and save</li>
|
| 267 |
+
</ol>
|
| 268 |
+
|
| 269 |
+
<h4>Getting API Keys</h4>
|
| 270 |
+
<ul>
|
| 271 |
+
<li><strong>OpenAI:</strong> Visit <a href="https://platform.openai.com/api-keys" target="_blank">platform.openai.com/api-keys</a></li>
|
| 272 |
+
<li><strong>Anthropic:</strong> Visit <a href="https://console.anthropic.com/" target="_blank">console.anthropic.com</a></li>
|
| 273 |
+
<li><strong>Other providers:</strong> Check their respective documentation</li>
|
| 274 |
+
</ul>
|
| 275 |
+
''',
|
| 276 |
+
'tips': [
|
| 277 |
+
'Start with the free quota to learn the basics',
|
| 278 |
+
'OpenAI GPT-4 is great for general-purpose chatbots',
|
| 279 |
+
'Keep your API keys secure and never share them publicly'
|
| 280 |
+
]
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
'title': 'Creating Your First Chatflow',
|
| 284 |
+
'estimated_time': 4,
|
| 285 |
+
'content': '''
|
| 286 |
+
<p>Let's create a simple chatbot that can have basic conversations with users.</p>
|
| 287 |
+
|
| 288 |
+
<h4>Step-by-Step Creation</h4>
|
| 289 |
+
<ol>
|
| 290 |
+
<li>Click <strong>"Create from Blank"</strong> in the Studio</li>
|
| 291 |
+
<li>Select <strong>"Chatflow"</strong> as the application type</li>
|
| 292 |
+
<li>Give your app a name (e.g., "My First Chatbot")</li>
|
| 293 |
+
<li>Click <strong>"Create"</strong></li>
|
| 294 |
+
</ol>
|
| 295 |
+
|
| 296 |
+
<h4>Understanding the Default Flow</h4>
|
| 297 |
+
<p>Your new chatflow will have three basic nodes:</p>
|
| 298 |
+
<ul>
|
| 299 |
+
<li><strong>Start Node:</strong> Triggers when a user sends a message</li>
|
| 300 |
+
<li><strong>LLM Node:</strong> Processes the user's message with AI</li>
|
| 301 |
+
<li><strong>Answer Node:</strong> Sends the response back to the user</li>
|
| 302 |
+
</ul>
|
| 303 |
+
|
| 304 |
+
<p>This simple flow creates a basic ChatGPT-like experience where users can ask questions and get AI-generated responses.</p>
|
| 305 |
+
''',
|
| 306 |
+
'interactive_demo': '''
|
| 307 |
+
<div class="demo-container" data-demo-type="workflow-builder">
|
| 308 |
+
Interactive workflow demo will appear here
|
| 309 |
+
</div>
|
| 310 |
+
''',
|
| 311 |
+
'tips': [
|
| 312 |
+
'The default three-node setup is perfect for simple conversational AI',
|
| 313 |
+
'You can always add more complexity later',
|
| 314 |
+
'Give your applications descriptive names for easy management'
|
| 315 |
+
]
|
| 316 |
+
},
|
| 317 |
+
{
|
| 318 |
+
'title': 'Configuring Your LLM',
|
| 319 |
+
'estimated_time': 6,
|
| 320 |
+
'content': '''
|
| 321 |
+
<p>The LLM node is the brain of your chatbot. Let's configure it properly.</p>
|
| 322 |
+
|
| 323 |
+
<h4>Selecting a Model</h4>
|
| 324 |
+
<ol>
|
| 325 |
+
<li>Click on the LLM node to open its settings</li>
|
| 326 |
+
<li>Choose your model (GPT-4 is recommended for beginners)</li>
|
| 327 |
+
<li>Adjust the temperature (0.7 is a good starting point)</li>
|
| 328 |
+
<li>Set the max tokens (1000-2000 for most conversations)</li>
|
| 329 |
+
</ol>
|
| 330 |
+
|
| 331 |
+
<h4>Model Parameters Explained</h4>
|
| 332 |
+
<ul>
|
| 333 |
+
<li><strong>Temperature (0-1):</strong> Controls creativity. Lower = more focused, Higher = more creative</li>
|
| 334 |
+
<li><strong>Max Tokens:</strong> Maximum length of the response</li>
|
| 335 |
+
<li><strong>Top P:</strong> Controls diversity of word choices</li>
|
| 336 |
+
<li><strong>Presence Penalty:</strong> Reduces repetitive responses</li>
|
| 337 |
+
</ul>
|
| 338 |
+
|
| 339 |
+
<h4>Writing Your First Prompt</h4>
|
| 340 |
+
<p>In the "Prompt" section, write instructions for your AI:</p>
|
| 341 |
+
<div class="code-example">
|
| 342 |
+
<pre><code>You are a helpful AI assistant. Your goal is to provide accurate, helpful, and friendly responses to users' questions.
|
| 343 |
+
|
| 344 |
+
Please follow these guidelines:
|
| 345 |
+
- Be conversational and approachable
|
| 346 |
+
- Provide clear and concise answers
|
| 347 |
+
- Ask clarifying questions when needed
|
| 348 |
+
- Admit when you don't know something
|
| 349 |
+
|
| 350 |
+
Respond to the user's message: {{sys.query}}</code></pre>
|
| 351 |
+
</div>
|
| 352 |
+
''',
|
| 353 |
+
'tips': [
|
| 354 |
+
'Start with a temperature of 0.7 for balanced responses',
|
| 355 |
+
'Clear prompts lead to better AI behavior',
|
| 356 |
+
'Use {{sys.query}} to reference the user\'s input'
|
| 357 |
+
]
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
'title': 'Testing Your Chatbot',
|
| 361 |
+
'estimated_time': 4,
|
| 362 |
+
'content': '''
|
| 363 |
+
<p>Before publishing, it's crucial to test your chatbot thoroughly.</p>
|
| 364 |
+
|
| 365 |
+
<h4>Using the Preview Feature</h4>
|
| 366 |
+
<ol>
|
| 367 |
+
<li>Click the <strong>"Preview"</strong> button in the top-right corner</li>
|
| 368 |
+
<li>A chat interface will open on the right side</li>
|
| 369 |
+
<li>Type a test message and press Enter</li>
|
| 370 |
+
<li>Observe the AI's response</li>
|
| 371 |
+
</ol>
|
| 372 |
+
|
| 373 |
+
<h4>Test Cases to Try</h4>
|
| 374 |
+
<ul>
|
| 375 |
+
<li><strong>Simple greeting:</strong> "Hello, how are you?"</li>
|
| 376 |
+
<li><strong>Question:</strong> "What is artificial intelligence?"</li>
|
| 377 |
+
<li><strong>Follow-up:</strong> Ask related questions to test conversation flow</li>
|
| 378 |
+
<li><strong>Edge cases:</strong> Empty messages, very long messages, special characters</li>
|
| 379 |
+
</ul>
|
| 380 |
+
|
| 381 |
+
<h4>Debugging Common Issues</h4>
|
| 382 |
+
<ul>
|
| 383 |
+
<li><strong>No response:</strong> Check your model provider setup</li>
|
| 384 |
+
<li><strong>Poor responses:</strong> Refine your prompt</li>
|
| 385 |
+
<li><strong>Too long/short:</strong> Adjust max tokens</li>
|
| 386 |
+
<li><strong>Too creative/rigid:</strong> Adjust temperature</li>
|
| 387 |
+
</ul>
|
| 388 |
+
''',
|
| 389 |
+
'interactive_demo': '''
|
| 390 |
+
<div class="demo-container" data-demo-type="chatbot-preview">
|
| 391 |
+
Interactive chatbot demo will appear here
|
| 392 |
+
</div>
|
| 393 |
+
''',
|
| 394 |
+
'tips': [
|
| 395 |
+
'Test with various types of questions and conversation styles',
|
| 396 |
+
'Pay attention to response quality and consistency',
|
| 397 |
+
'Make note of any improvements needed before publishing'
|
| 398 |
+
]
|
| 399 |
+
},
|
| 400 |
+
{
|
| 401 |
+
'title': 'Adding Personality and Features',
|
| 402 |
+
'estimated_time': 4,
|
| 403 |
+
'content': '''
|
| 404 |
+
<p>Make your chatbot more engaging by adding personality and useful features.</p>
|
| 405 |
+
|
| 406 |
+
<h4>Enhancing Your Prompt</h4>
|
| 407 |
+
<p>Add personality to your chatbot with a more detailed prompt:</p>
|
| 408 |
+
<div class="code-example">
|
| 409 |
+
<pre><code>You are Alex, a friendly and knowledgeable AI assistant with a passion for helping people learn and solve problems.
|
| 410 |
+
|
| 411 |
+
Your personality traits:
|
| 412 |
+
- Enthusiastic about technology and learning
|
| 413 |
+
- Patient and encouraging
|
| 414 |
+
- Uses occasional emojis to be more approachable
|
| 415 |
+
- Provides examples when explaining concepts
|
| 416 |
+
|
| 417 |
+
Your expertise includes:
|
| 418 |
+
- General knowledge and current events
|
| 419 |
+
- Technology and AI concepts
|
| 420 |
+
- Problem-solving strategies
|
| 421 |
+
- Creative thinking
|
| 422 |
+
|
| 423 |
+
Always aim to:
|
| 424 |
+
1. Understand the user's needs fully
|
| 425 |
+
2. Provide helpful and accurate information
|
| 426 |
+
3. Encourage further learning and exploration
|
| 427 |
+
4. Maintain a positive and supportive tone
|
| 428 |
+
|
| 429 |
+
User message: {{sys.query}}</code></pre>
|
| 430 |
+
</div>
|
| 431 |
+
|
| 432 |
+
<h4>Adding Features</h4>
|
| 433 |
+
<p>Click "Add Feature" to enable:</p>
|
| 434 |
+
<ul>
|
| 435 |
+
<li><strong>Opening Statement:</strong> Greet users when they start chatting</li>
|
| 436 |
+
<li><strong>Next Question Suggestions:</strong> Provide follow-up question ideas</li>
|
| 437 |
+
<li><strong>Speech to Text:</strong> Allow voice input</li>
|
| 438 |
+
<li><strong>Citation and Attribution:</strong> Show sources for responses</li>
|
| 439 |
+
</ul>
|
| 440 |
+
''',
|
| 441 |
+
'tips': [
|
| 442 |
+
'A good personality makes interactions more enjoyable',
|
| 443 |
+
'Opening statements set the right expectations',
|
| 444 |
+
'Question suggestions help users explore your chatbot\'s capabilities'
|
| 445 |
+
]
|
| 446 |
+
},
|
| 447 |
+
{
|
| 448 |
+
'title': 'Publishing and Sharing',
|
| 449 |
+
'estimated_time': 2,
|
| 450 |
+
'content': '''
|
| 451 |
+
<p>Once you're satisfied with your chatbot, it's time to publish and share it.</p>
|
| 452 |
+
|
| 453 |
+
<h4>Publishing Your Chatbot</h4>
|
| 454 |
+
<ol>
|
| 455 |
+
<li>Click the <strong>"Publish"</strong> button</li>
|
| 456 |
+
<li>Review your settings one final time</li>
|
| 457 |
+
<li>Click <strong>"Update"</strong> to make it live</li>
|
| 458 |
+
</ol>
|
| 459 |
+
|
| 460 |
+
<h4>Sharing Options</h4>
|
| 461 |
+
<p>After publishing, you can share your chatbot in several ways:</p>
|
| 462 |
+
<ul>
|
| 463 |
+
<li><strong>Public Link:</strong> Share a direct URL to your chatbot</li>
|
| 464 |
+
<li><strong>Embed Code:</strong> Add it to your website with HTML/iframe</li>
|
| 465 |
+
<li><strong>API Access:</strong> Integrate with your applications via REST API</li>
|
| 466 |
+
</ul>
|
| 467 |
+
|
| 468 |
+
<h4>Monitoring Usage</h4>
|
| 469 |
+
<p>Use the built-in analytics to track:</p>
|
| 470 |
+
<ul>
|
| 471 |
+
<li>Number of conversations</li>
|
| 472 |
+
<li>User satisfaction ratings</li>
|
| 473 |
+
<li>Most common questions</li>
|
| 474 |
+
<li>Response times and costs</li>
|
| 475 |
+
</ul>
|
| 476 |
+
|
| 477 |
+
<h4>Next Steps</h4>
|
| 478 |
+
<p>Congratulations! You've built your first AI chatbot. Consider:</p>
|
| 479 |
+
<ul>
|
| 480 |
+
<li>Gathering user feedback for improvements</li>
|
| 481 |
+
<li>Adding a knowledge base for specific topics</li>
|
| 482 |
+
<li>Creating more sophisticated workflows</li>
|
| 483 |
+
<li>Exploring AI agent capabilities</li>
|
| 484 |
+
</ul>
|
| 485 |
+
''',
|
| 486 |
+
'tips': [
|
| 487 |
+
'Test the published version to ensure everything works',
|
| 488 |
+
'Monitor usage patterns to identify improvement opportunities',
|
| 489 |
+
'Regular updates keep your chatbot relevant and useful'
|
| 490 |
+
]
|
| 491 |
+
}
|
| 492 |
+
]
|
| 493 |
+
},
|
| 494 |
+
|
| 495 |
+
'creating-knowledge-bases-rag': {
|
| 496 |
+
'id': 3,
|
| 497 |
+
'title': 'Creating Knowledge Bases with RAG',
|
| 498 |
+
'category': 'Knowledge Management',
|
| 499 |
+
'difficulty': 'intermediate',
|
| 500 |
+
'difficulty_color': 'warning',
|
| 501 |
+
'estimated_time': 35,
|
| 502 |
+
'description': 'Build intelligent chatbots that can answer questions from your documents using Retrieval-Augmented Generation (RAG).',
|
| 503 |
+
'steps': [
|
| 504 |
+
{
|
| 505 |
+
'title': 'Understanding RAG',
|
| 506 |
+
'estimated_time': 5,
|
| 507 |
+
'content': '''
|
| 508 |
+
<p>Retrieval-Augmented Generation (RAG) is a powerful technique that allows AI to access external knowledge sources to provide accurate, up-to-date information.</p>
|
| 509 |
+
|
| 510 |
+
<h4>How RAG Works</h4>
|
| 511 |
+
<ol>
|
| 512 |
+
<li><strong>Document Processing:</strong> Your documents are split into chunks and converted to embeddings</li>
|
| 513 |
+
<li><strong>Query Processing:</strong> User questions are also converted to embeddings</li>
|
| 514 |
+
<li><strong>Similarity Search:</strong> The system finds the most relevant document chunks</li>
|
| 515 |
+
<li><strong>Response Generation:</strong> The AI uses retrieved information to generate accurate answers</li>
|
| 516 |
+
</ol>
|
| 517 |
+
|
| 518 |
+
<h4>Benefits of RAG</h4>
|
| 519 |
+
<ul>
|
| 520 |
+
<li><strong>Accuracy:</strong> Reduces AI hallucinations by grounding responses in real data</li>
|
| 521 |
+
<li><strong>Current Information:</strong> Access to your latest documents and data</li>
|
| 522 |
+
<li><strong>Source Attribution:</strong> Can cite specific sources for transparency</li>
|
| 523 |
+
<li><strong>Cost Effective:</strong> More efficient than fine-tuning models</li>
|
| 524 |
+
</ul>
|
| 525 |
+
|
| 526 |
+
<h4>Use Cases</h4>
|
| 527 |
+
<ul>
|
| 528 |
+
<li>Customer support with product documentation</li>
|
| 529 |
+
<li>Internal knowledge sharing</li>
|
| 530 |
+
<li>Educational content delivery</li>
|
| 531 |
+
<li>Legal document analysis</li>
|
| 532 |
+
<li>Technical documentation assistance</li>
|
| 533 |
+
</ul>
|
| 534 |
+
''',
|
| 535 |
+
'tips': [
|
| 536 |
+
'RAG is perfect when you need AI to answer questions about specific content',
|
| 537 |
+
'Quality of your source documents directly impacts answer quality',
|
| 538 |
+
'RAG works best with well-structured, factual content'
|
| 539 |
+
]
|
| 540 |
+
},
|
| 541 |
+
{
|
| 542 |
+
'title': 'Creating Your First Knowledge Base',
|
| 543 |
+
'estimated_time': 6,
|
| 544 |
+
'content': '''
|
| 545 |
+
<p>Let's create a knowledge base from your documents that your AI can search and reference.</p>
|
| 546 |
+
|
| 547 |
+
<h4>Step-by-Step Knowledge Base Creation</h4>
|
| 548 |
+
<ol>
|
| 549 |
+
<li>Navigate to <strong>Knowledge</strong> in the main menu</li>
|
| 550 |
+
<li>Click <strong>"Create Knowledge"</strong></li>
|
| 551 |
+
<li>Give your knowledge base a descriptive name</li>
|
| 552 |
+
<li>Add a brief description of its contents</li>
|
| 553 |
+
<li>Click <strong>"Create"</strong></li>
|
| 554 |
+
</ol>
|
| 555 |
+
|
| 556 |
+
<h4>Supported Data Sources</h4>
|
| 557 |
+
<p>Dify supports multiple data sources:</p>
|
| 558 |
+
<ul>
|
| 559 |
+
<li><strong>Local Files:</strong> Upload PDFs, Word docs, text files, CSV, etc.</li>
|
| 560 |
+
<li><strong>Notion Pages:</strong> Sync directly from your Notion workspace</li>
|
| 561 |
+
<li><strong>Web Pages:</strong> Scrape content from websites using Jina or Firecrawl API</li>
|
| 562 |
+
<li><strong>Plain Text:</strong> Copy and paste content directly</li>
|
| 563 |
+
</ul>
|
| 564 |
+
|
| 565 |
+
<h4>File Requirements and Limits</h4>
|
| 566 |
+
<ul>
|
| 567 |
+
<li><strong>Supported formats:</strong> PDF, DOCX, TXT, MD, CSV, XLSX</li>
|
| 568 |
+
<li><strong>File size limit:</strong> Usually 15MB per file (varies by plan)</li>
|
| 569 |
+
<li><strong>Total size:</strong> Depends on your subscription tier</li>
|
| 570 |
+
<li><strong>Language support:</strong> Multi-language documents supported</li>
|
| 571 |
+
</ul>
|
| 572 |
+
''',
|
| 573 |
+
'tips': [
|
| 574 |
+
'Start with a small set of high-quality documents',
|
| 575 |
+
'Use descriptive names for easy management',
|
| 576 |
+
'Organize related content in the same knowledge base'
|
| 577 |
+
]
|
| 578 |
+
},
|
| 579 |
+
{
|
| 580 |
+
'title': 'Uploading and Processing Documents',
|
| 581 |
+
'estimated_time': 8,
|
| 582 |
+
'content': '''
|
| 583 |
+
<p>Now let's add documents to your knowledge base and configure how they're processed.</p>
|
| 584 |
+
|
| 585 |
+
<h4>Document Upload Process</h4>
|
| 586 |
+
<ol>
|
| 587 |
+
<li>Click <strong>"Add Document"</strong> in your knowledge base</li>
|
| 588 |
+
<li>Choose your upload method (File, Notion, Web scraping, or Text)</li>
|
| 589 |
+
<li>Select or upload your documents</li>
|
| 590 |
+
<li>Review the document preview</li>
|
| 591 |
+
<li>Configure processing settings</li>
|
| 592 |
+
</ol>
|
| 593 |
+
|
| 594 |
+
<h4>Chunking Configuration</h4>
|
| 595 |
+
<p>Documents are split into smaller chunks for better retrieval:</p>
|
| 596 |
+
<ul>
|
| 597 |
+
<li><strong>Automatic Chunking:</strong> Dify automatically splits by paragraphs</li>
|
| 598 |
+
<li><strong>Custom Rules:</strong> Set your own chunk size and overlap</li>
|
| 599 |
+
<li><strong>Chunk Size:</strong> 500-1000 characters is usually optimal</li>
|
| 600 |
+
<li><strong>Overlap:</strong> 50-100 characters to maintain context</li>
|
| 601 |
+
</ul>
|
| 602 |
+
|
| 603 |
+
<h4>Text Preprocessing Options</h4>
|
| 604 |
+
<ul>
|
| 605 |
+
<li><strong>Remove extra spaces:</strong> Clean up formatting</li>
|
| 606 |
+
<li><strong>Remove URLs:</strong> Filter out web links</li>
|
| 607 |
+
<li><strong>Remove email addresses:</strong> Protect privacy</li>
|
| 608 |
+
<li><strong>Custom preprocessing:</strong> Advanced filtering rules</li>
|
| 609 |
+
</ul>
|
| 610 |
+
|
| 611 |
+
<h4>Embedding Model Selection</h4>
|
| 612 |
+
<p>Choose the right embedding model for your content:</p>
|
| 613 |
+
<ul>
|
| 614 |
+
<li><strong>OpenAI text-embedding-3-small:</strong> Fast and cost-effective</li>
|
| 615 |
+
<li><strong>OpenAI text-embedding-3-large:</strong> Higher accuracy</li>
|
| 616 |
+
<li><strong>Cohere embed-english:</strong> Good for English content</li>
|
| 617 |
+
<li><strong>Cohere embed-multilingual:</strong> For multiple languages</li>
|
| 618 |
+
</ul>
|
| 619 |
+
''',
|
| 620 |
+
'code_example': '''
|
| 621 |
+
# Example document structure for optimal RAG performance:
|
| 622 |
+
|
| 623 |
+
## Product FAQ Document
|
| 624 |
+
|
| 625 |
+
### What is Product X?
|
| 626 |
+
Product X is a comprehensive solution for...
|
| 627 |
+
|
| 628 |
+
### How do I install Product X?
|
| 629 |
+
1. Download the installer from our website
|
| 630 |
+
2. Run the installer as administrator
|
| 631 |
+
3. Follow the setup wizard
|
| 632 |
+
|
| 633 |
+
### Troubleshooting Common Issues
|
| 634 |
+
**Issue:** Application won't start
|
| 635 |
+
**Solution:** Check system requirements and try running as administrator
|
| 636 |
+
''',
|
| 637 |
+
'tips': [
|
| 638 |
+
'Well-structured documents with clear headings work best',
|
| 639 |
+
'Keep chunk sizes moderate - too small loses context, too large reduces precision',
|
| 640 |
+
'Choose embedding models based on your primary language'
|
| 641 |
+
]
|
| 642 |
+
},
|
| 643 |
+
{
|
| 644 |
+
'title': 'Configuring Retrieval Settings',
|
| 645 |
+
'estimated_time': 5,
|
| 646 |
+
'content': '''
|
| 647 |
+
<p>Fine-tune how your knowledge base searches for and retrieves relevant information.</p>
|
| 648 |
+
|
| 649 |
+
<h4>Retrieval Methods</h4>
|
| 650 |
+
<ul>
|
| 651 |
+
<li><strong>Vector Retrieval:</strong> Finds semantically similar content using embeddings</li>
|
| 652 |
+
<li><strong>Full-Text Search:</strong> Traditional keyword-based search</li>
|
| 653 |
+
<li><strong>Hybrid Retrieval (Recommended):</strong> Combines both methods for best results</li>
|
| 654 |
+
</ul>
|
| 655 |
+
|
| 656 |
+
<h4>Hybrid Retrieval Configuration</h4>
|
| 657 |
+
<p>Adjust the balance between semantic and keyword search:</p>
|
| 658 |
+
<ul>
|
| 659 |
+
<li><strong>Semantic Weight (70%):</strong> Finds conceptually related content</li>
|
| 660 |
+
<li><strong>Keyword Weight (30%):</strong> Finds exact term matches</li>
|
| 661 |
+
<li><strong>Custom Weights:</strong> Adjust based on your content type</li>
|
| 662 |
+
</ul>
|
| 663 |
+
|
| 664 |
+
<h4>Reranking Models</h4>
|
| 665 |
+
<p>Improve retrieval accuracy with reranking:</p>
|
| 666 |
+
<ul>
|
| 667 |
+
<li><strong>Cohere Rerank:</strong> Reorders results for better relevance</li>
|
| 668 |
+
<li><strong>BGE Reranker:</strong> Open-source alternative</li>
|
| 669 |
+
<li><strong>No Reranking:</strong> Faster but potentially less accurate</li>
|
| 670 |
+
</ul>
|
| 671 |
+
|
| 672 |
+
<h4>Retrieval Parameters</h4>
|
| 673 |
+
<ul>
|
| 674 |
+
<li><strong>Top K:</strong> Number of chunks to retrieve (3-5 recommended)</li>
|
| 675 |
+
<li><strong>Score Threshold:</strong> Minimum similarity score for inclusion</li>
|
| 676 |
+
<li><strong>Max Tokens:</strong> Total token limit for retrieved content</li>
|
| 677 |
+
</ul>
|
| 678 |
+
''',
|
| 679 |
+
'tips': [
|
| 680 |
+
'Hybrid retrieval works best for most use cases',
|
| 681 |
+
'Start with 70% semantic, 30% keyword weighting',
|
| 682 |
+
'Use reranking for better accuracy when response quality matters most'
|
| 683 |
+
]
|
| 684 |
+
},
|
| 685 |
+
{
|
| 686 |
+
'title': 'Testing Your Knowledge Base',
|
| 687 |
+
'estimated_time': 4,
|
| 688 |
+
'content': '''
|
| 689 |
+
<p>Before integrating your knowledge base into an application, test its retrieval accuracy.</p>
|
| 690 |
+
|
| 691 |
+
<h4>Using the Recall Test</h4>
|
| 692 |
+
<ol>
|
| 693 |
+
<li>Go to your knowledge base settings</li>
|
| 694 |
+
<li>Click on the <strong>"Recall Test"</strong> tab</li>
|
| 695 |
+
<li>Enter test queries related to your content</li>
|
| 696 |
+
<li>Review the retrieved chunks and their relevance scores</li>
|
| 697 |
+
<li>Adjust settings if needed</li>
|
| 698 |
+
</ol>
|
| 699 |
+
|
| 700 |
+
<h4>Effective Test Queries</h4>
|
| 701 |
+
<ul>
|
| 702 |
+
<li><strong>Direct questions:</strong> "How do I reset my password?"</li>
|
| 703 |
+
<li><strong>Conceptual queries:</strong> "Security best practices"</li>
|
| 704 |
+
<li><strong>Specific terms:</strong> "API rate limits"</li>
|
| 705 |
+
<li><strong>Variations:</strong> Test different ways of asking the same thing</li>
|
| 706 |
+
</ul>
|
| 707 |
+
|
| 708 |
+
<h4>Evaluating Results</h4>
|
| 709 |
+
<p>Look for:</p>
|
| 710 |
+
<ul>
|
| 711 |
+
<li><strong>Relevance:</strong> Do retrieved chunks actually answer the question?</li>
|
| 712 |
+
<li><strong>Completeness:</strong> Is all necessary information retrieved?</li>
|
| 713 |
+
<li><strong>Ranking:</strong> Are the most relevant chunks ranked highest?</li>
|
| 714 |
+
<li><strong>Coverage:</strong> Can the system find information across all your documents?</li>
|
| 715 |
+
</ul>
|
| 716 |
+
|
| 717 |
+
<h4>Common Issues and Solutions</h4>
|
| 718 |
+
<ul>
|
| 719 |
+
<li><strong>Poor retrieval:</strong> Adjust chunk size or embedding model</li>
|
| 720 |
+
<li><strong>Irrelevant results:</strong> Increase score threshold</li>
|
| 721 |
+
<li><strong>Missing information:</strong> Check document quality and chunking</li>
|
| 722 |
+
<li><strong>Inconsistent results:</strong> Consider using reranking</li>
|
| 723 |
+
</ul>
|
| 724 |
+
''',
|
| 725 |
+
'tips': [
|
| 726 |
+
'Test with questions your actual users would ask',
|
| 727 |
+
'Document any query patterns that don\'t work well',
|
| 728 |
+
'Iterate on your settings based on test results'
|
| 729 |
+
]
|
| 730 |
+
},
|
| 731 |
+
{
|
| 732 |
+
'title': 'Building a RAG-Powered Chatbot',
|
| 733 |
+
'estimated_time': 5,
|
| 734 |
+
'content': '''
|
| 735 |
+
<p>Now let's create a chatbot that uses your knowledge base to answer questions accurately.</p>
|
| 736 |
+
|
| 737 |
+
<h4>Creating the Chatflow</h4>
|
| 738 |
+
<ol>
|
| 739 |
+
<li>Create a new Chatflow application</li>
|
| 740 |
+
<li>Keep the default Start → LLM → Answer flow</li>
|
| 741 |
+
<li>Click on the LLM node to configure it</li>
|
| 742 |
+
</ol>
|
| 743 |
+
|
| 744 |
+
<h4>Adding Your Knowledge Base</h4>
|
| 745 |
+
<ol>
|
| 746 |
+
<li>In the LLM node settings, find the <strong>"Context"</strong> section</li>
|
| 747 |
+
<li>Click <strong>"Add Knowledge"</strong></li>
|
| 748 |
+
<li>Select your knowledge base</li>
|
| 749 |
+
<li>Configure retrieval settings if needed</li>
|
| 750 |
+
</ol>
|
| 751 |
+
|
| 752 |
+
<h4>Crafting a RAG-Optimized Prompt</h4>
|
| 753 |
+
<div class="code-example">
|
| 754 |
+
<pre><code>You are a helpful assistant that answers questions based on the provided context.
|
| 755 |
+
|
| 756 |
+
Instructions:
|
| 757 |
+
1. Use the context information below to answer the user's question
|
| 758 |
+
2. If the context doesn't contain relevant information, say "I don't have information about that in my knowledge base"
|
| 759 |
+
3. Always cite specific parts of the context when possible
|
| 760 |
+
4. Be accurate and don't make up information not in the context
|
| 761 |
+
|
| 762 |
+
Context: {{#knowledge}}
|
| 763 |
+
|
| 764 |
+
User Question: {{sys.query}}
|
| 765 |
+
|
| 766 |
+
Please provide a helpful and accurate response based on the context above.</code></pre>
|
| 767 |
+
</div>
|
| 768 |
+
|
| 769 |
+
<h4>Advanced RAG Techniques</h4>
|
| 770 |
+
<ul>
|
| 771 |
+
<li><strong>Question Classification:</strong> Route different types of questions appropriately</li>
|
| 772 |
+
<li><strong>Multiple Knowledge Bases:</strong> Use different sources for different topics</li>
|
| 773 |
+
<li><strong>Fallback Strategies:</strong> Handle cases when no relevant information is found</li>
|
| 774 |
+
</ul>
|
| 775 |
+
''',
|
| 776 |
+
'tips': [
|
| 777 |
+
'Always instruct the AI to stay within the provided context',
|
| 778 |
+
'Enable citation features to show sources',
|
| 779 |
+
'Test with questions both inside and outside your knowledge base'
|
| 780 |
+
]
|
| 781 |
+
},
|
| 782 |
+
{
|
| 783 |
+
'title': 'Advanced RAG Workflows',
|
| 784 |
+
'estimated_time': 6,
|
| 785 |
+
'content': '''
|
| 786 |
+
<p>Create more sophisticated RAG applications with conditional logic and multiple knowledge sources.</p>
|
| 787 |
+
|
| 788 |
+
<h4>Question Classification Workflow</h4>
|
| 789 |
+
<p>Route different types of questions to appropriate knowledge bases:</p>
|
| 790 |
+
<ol>
|
| 791 |
+
<li>Add a <strong>Question Classifier</strong> node after Start</li>
|
| 792 |
+
<li>Define categories (e.g., "Product Info", "Technical Support", "Billing")</li>
|
| 793 |
+
<li>Connect different paths to different knowledge bases</li>
|
| 794 |
+
<li>Use conditional logic to route appropriately</li>
|
| 795 |
+
</ol>
|
| 796 |
+
|
| 797 |
+
<h4>Multi-Step RAG Process</h4>
|
| 798 |
+
<ol>
|
| 799 |
+
<li><strong>Initial Retrieval:</strong> Find relevant chunks</li>
|
| 800 |
+
<li><strong>Relevance Check:</strong> Evaluate if information is sufficient</li>
|
| 801 |
+
<li><strong>Follow-up Retrieval:</strong> Search additional sources if needed</li>
|
| 802 |
+
<li><strong>Response Generation:</strong> Synthesize all found information</li>
|
| 803 |
+
</ol>
|
| 804 |
+
|
| 805 |
+
<h4>Handling Edge Cases</h4>
|
| 806 |
+
<ul>
|
| 807 |
+
<li><strong>No Matches Found:</strong> Provide helpful guidance on how to rephrase</li>
|
| 808 |
+
<li><strong>Low Confidence:</strong> Ask clarifying questions</li>
|
| 809 |
+
<li><strong>Multiple Valid Answers:</strong> Present options clearly</li>
|
| 810 |
+
<li><strong>Outdated Information:</strong> Include disclaimers about data freshness</li>
|
| 811 |
+
</ul>
|
| 812 |
+
|
| 813 |
+
<div class="code-example">
|
| 814 |
+
<pre><code># Example multi-step RAG prompt
|
| 815 |
+
|
| 816 |
+
You are analyzing a user question in two steps:
|
| 817 |
+
|
| 818 |
+
Step 1: Evaluate if the retrieved context contains sufficient information
|
| 819 |
+
Context: {{#knowledge}}
|
| 820 |
+
Question: {{sys.query}}
|
| 821 |
+
|
| 822 |
+
If context is sufficient, respond with: SUFFICIENT
|
| 823 |
+
If context is insufficient, respond with: INSUFFICIENT - [reason]
|
| 824 |
+
|
| 825 |
+
Step 2 (only if sufficient): Provide a complete answer based on the context.</code></pre>
|
| 826 |
+
</div>
|
| 827 |
+
''',
|
| 828 |
+
'tips': [
|
| 829 |
+
'Question classification improves accuracy for diverse knowledge bases',
|
| 830 |
+
'Always have fallback options when retrieval fails',
|
| 831 |
+
'Consider the user experience when no good answers are found'
|
| 832 |
+
]
|
| 833 |
+
},
|
| 834 |
+
{
|
| 835 |
+
'title': 'Monitoring and Optimization',
|
| 836 |
+
'estimated_time': 6,
|
| 837 |
+
'content': '''
|
| 838 |
+
<p>Continuously improve your RAG system by monitoring performance and optimizing based on usage patterns.</p>
|
| 839 |
+
|
| 840 |
+
<h4>Key Metrics to Track</h4>
|
| 841 |
+
<ul>
|
| 842 |
+
<li><strong>Retrieval Accuracy:</strong> Percentage of queries with relevant results</li>
|
| 843 |
+
<li><strong>Response Quality:</strong> User satisfaction with answers</li>
|
| 844 |
+
<li><strong>Coverage:</strong> Percentage of questions that can be answered</li>
|
| 845 |
+
<li><strong>Response Time:</strong> Average time to generate answers</li>
|
| 846 |
+
<li><strong>Cost:</strong> Token usage for embeddings and generation</li>
|
| 847 |
+
</ul>
|
| 848 |
+
|
| 849 |
+
<h4>Optimization Strategies</h4>
|
| 850 |
+
<ul>
|
| 851 |
+
<li><strong>Document Quality:</strong> Improve source content structure and clarity</li>
|
| 852 |
+
<li><strong>Chunk Optimization:</strong> Adjust size and overlap based on performance</li>
|
| 853 |
+
<li><strong>Embedding Tuning:</strong> Experiment with different embedding models</li>
|
| 854 |
+
<li><strong>Prompt Refinement:</strong> Continuously improve instructions</li>
|
| 855 |
+
</ul>
|
| 856 |
+
|
| 857 |
+
<h4>Common Performance Issues</h4>
|
| 858 |
+
<ul>
|
| 859 |
+
<li><strong>Poor Retrieval:</strong>
|
| 860 |
+
<ul>
|
| 861 |
+
<li>Check document quality and structure</li>
|
| 862 |
+
<li>Adjust chunking strategy</li>
|
| 863 |
+
<li>Consider different embedding models</li>
|
| 864 |
+
</ul>
|
| 865 |
+
</li>
|
| 866 |
+
<li><strong>Slow Responses:</strong>
|
| 867 |
+
<ul>
|
| 868 |
+
<li>Optimize retrieval parameters</li>
|
| 869 |
+
<li>Use smaller, more focused knowledge bases</li>
|
| 870 |
+
<li>Consider caching frequent queries</li>
|
| 871 |
+
</ul>
|
| 872 |
+
</li>
|
| 873 |
+
<li><strong>High Costs:</strong>
|
| 874 |
+
<ul>
|
| 875 |
+
<li>Optimize chunk sizes to reduce token usage</li>
|
| 876 |
+
<li>Use more efficient embedding models</li>
|
| 877 |
+
<li>Implement query caching</li>
|
| 878 |
+
</ul>
|
| 879 |
+
</li>
|
| 880 |
+
</ul>
|
| 881 |
+
|
| 882 |
+
<h4>Best Practices for Production</h4>
|
| 883 |
+
<ul>
|
| 884 |
+
<li><strong>Regular Updates:</strong> Keep knowledge bases current</li>
|
| 885 |
+
<li><strong>Quality Control:</strong> Review and curate content regularly</li>
|
| 886 |
+
<li><strong>User Feedback:</strong> Collect and act on user ratings</li>
|
| 887 |
+
<li><strong>A/B Testing:</strong> Test different configurations</li>
|
| 888 |
+
<li><strong>Backup Strategies:</strong> Maintain multiple knowledge sources</li>
|
| 889 |
+
</ul>
|
| 890 |
+
''',
|
| 891 |
+
'tips': [
|
| 892 |
+
'Monitor real user queries to identify content gaps',
|
| 893 |
+
'Regularly review and update your knowledge base content',
|
| 894 |
+
'Use analytics to identify the most common query patterns'
|
| 895 |
+
]
|
| 896 |
+
}
|
| 897 |
+
]
|
| 898 |
+
}
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
return tutorials.get(slug)
|
instance/dify_learning.db
ADDED
|
Binary file (36.9 kB). View file
|
|
|
models.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app import db
|
| 2 |
+
from datetime import datetime
|
| 3 |
+
|
| 4 |
+
class User(db.Model):
|
| 5 |
+
id = db.Column(db.Integer, primary_key=True)
|
| 6 |
+
username = db.Column(db.String(64), unique=True, nullable=False)
|
| 7 |
+
email = db.Column(db.String(120), unique=True, nullable=False)
|
| 8 |
+
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
| 9 |
+
|
| 10 |
+
# Relationship with progress
|
| 11 |
+
progress_entries = db.relationship('Progress', backref='user', lazy=True)
|
| 12 |
+
|
| 13 |
+
class Tutorial(db.Model):
|
| 14 |
+
id = db.Column(db.Integer, primary_key=True)
|
| 15 |
+
title = db.Column(db.String(200), nullable=False)
|
| 16 |
+
slug = db.Column(db.String(100), unique=True, nullable=False)
|
| 17 |
+
category = db.Column(db.String(50), nullable=False)
|
| 18 |
+
difficulty = db.Column(db.String(20), nullable=False) # beginner, intermediate, advanced
|
| 19 |
+
order_index = db.Column(db.Integer, nullable=False)
|
| 20 |
+
estimated_time = db.Column(db.Integer) # in minutes
|
| 21 |
+
description = db.Column(db.Text)
|
| 22 |
+
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
| 23 |
+
|
| 24 |
+
class Progress(db.Model):
|
| 25 |
+
id = db.Column(db.Integer, primary_key=True)
|
| 26 |
+
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
| 27 |
+
tutorial_id = db.Column(db.Integer, db.ForeignKey('tutorial.id'), nullable=False)
|
| 28 |
+
completed = db.Column(db.Boolean, default=False)
|
| 29 |
+
current_step = db.Column(db.Integer, default=0)
|
| 30 |
+
completion_date = db.Column(db.DateTime)
|
| 31 |
+
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
| 32 |
+
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
| 33 |
+
|
| 34 |
+
class Project(db.Model):
|
| 35 |
+
id = db.Column(db.Integer, primary_key=True)
|
| 36 |
+
title = db.Column(db.String(200), nullable=False)
|
| 37 |
+
slug = db.Column(db.String(100), unique=True, nullable=False)
|
| 38 |
+
category = db.Column(db.String(50), nullable=False)
|
| 39 |
+
difficulty = db.Column(db.String(20), nullable=False)
|
| 40 |
+
description = db.Column(db.Text)
|
| 41 |
+
estimated_time = db.Column(db.Integer) # in minutes
|
| 42 |
+
prerequisites = db.Column(db.Text) # JSON string of tutorial IDs
|
| 43 |
+
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
pyproject.toml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "repl-nix-workspace"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
requires-python = ">=3.11"
|
| 6 |
+
dependencies = [
|
| 7 |
+
"email-validator>=2.2.0",
|
| 8 |
+
"flask>=3.1.1",
|
| 9 |
+
"flask-sqlalchemy>=3.1.1",
|
| 10 |
+
"gunicorn>=23.0.0",
|
| 11 |
+
"markdown>=3.8.1",
|
| 12 |
+
"psycopg2-binary>=2.9.10",
|
| 13 |
+
"sqlalchemy>=2.0.41",
|
| 14 |
+
"werkzeug>=3.1.3",
|
| 15 |
+
]
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
sqlalchemy
|
| 3 |
+
werkzeug
|
| 4 |
+
psycopg2-binary
|
| 5 |
+
markdown
|
| 6 |
+
flask-sqlalchemy
|
| 7 |
+
email-validator
|
| 8 |
+
gunicorn
|
routes.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import render_template, request, jsonify, session, redirect, url_for
|
| 2 |
+
from app import app, db
|
| 3 |
+
from models import User, Tutorial, Progress, Project
|
| 4 |
+
from content.tutorials import get_tutorial_content, get_all_tutorials
|
| 5 |
+
from content.projects import get_project_content, get_all_projects
|
| 6 |
+
import json
|
| 7 |
+
import markdown
|
| 8 |
+
|
| 9 |
+
@app.route('/')
|
| 10 |
+
def index():
|
| 11 |
+
tutorials = get_all_tutorials()
|
| 12 |
+
projects = get_all_projects()
|
| 13 |
+
|
| 14 |
+
# Get user progress if logged in
|
| 15 |
+
user_progress = {}
|
| 16 |
+
if 'user_id' in session:
|
| 17 |
+
user_id = session['user_id']
|
| 18 |
+
progress_records = Progress.query.filter_by(user_id=user_id).all()
|
| 19 |
+
user_progress = {p.tutorial_id: p for p in progress_records}
|
| 20 |
+
|
| 21 |
+
return render_template('index.html',
|
| 22 |
+
tutorials=tutorials,
|
| 23 |
+
projects=projects,
|
| 24 |
+
user_progress=user_progress)
|
| 25 |
+
|
| 26 |
+
@app.route('/tutorial/<slug>')
|
| 27 |
+
def tutorial(slug):
|
| 28 |
+
tutorial_data = get_tutorial_content(slug)
|
| 29 |
+
if not tutorial_data:
|
| 30 |
+
return "Tutorial not found", 404
|
| 31 |
+
|
| 32 |
+
# Get or create progress for this tutorial
|
| 33 |
+
user_progress = None
|
| 34 |
+
if 'user_id' in session:
|
| 35 |
+
user_id = session['user_id']
|
| 36 |
+
tutorial_id = tutorial_data.get('id', 0)
|
| 37 |
+
user_progress = Progress.query.filter_by(
|
| 38 |
+
user_id=user_id,
|
| 39 |
+
tutorial_id=tutorial_id
|
| 40 |
+
).first()
|
| 41 |
+
|
| 42 |
+
if not user_progress:
|
| 43 |
+
user_progress = Progress(
|
| 44 |
+
user_id=user_id,
|
| 45 |
+
tutorial_id=tutorial_id,
|
| 46 |
+
current_step=0
|
| 47 |
+
)
|
| 48 |
+
db.session.add(user_progress)
|
| 49 |
+
db.session.commit()
|
| 50 |
+
|
| 51 |
+
return render_template('tutorial.html',
|
| 52 |
+
tutorial=tutorial_data,
|
| 53 |
+
user_progress=user_progress)
|
| 54 |
+
|
| 55 |
+
@app.route('/project/<slug>')
|
| 56 |
+
def project(slug):
|
| 57 |
+
project_data = get_project_content(slug)
|
| 58 |
+
if not project_data:
|
| 59 |
+
return "Project not found", 404
|
| 60 |
+
|
| 61 |
+
# Convert markdown content to HTML for proper display
|
| 62 |
+
if project_data.get('sections'):
|
| 63 |
+
for section in project_data['sections']:
|
| 64 |
+
if section.get('steps'):
|
| 65 |
+
for step in section['steps']:
|
| 66 |
+
if step.get('content'):
|
| 67 |
+
# Convert markdown to HTML with proper formatting
|
| 68 |
+
step['content'] = markdown.markdown(step['content'], extensions=['extra', 'nl2br'])
|
| 69 |
+
|
| 70 |
+
return render_template('project.html', project=project_data)
|
| 71 |
+
|
| 72 |
+
@app.route('/progress')
|
| 73 |
+
def progress():
|
| 74 |
+
if 'user_id' not in session:
|
| 75 |
+
return redirect(url_for('login'))
|
| 76 |
+
|
| 77 |
+
user_id = session['user_id']
|
| 78 |
+
user = User.query.get(user_id)
|
| 79 |
+
progress_records = Progress.query.filter_by(user_id=user_id).all()
|
| 80 |
+
|
| 81 |
+
tutorials = get_all_tutorials()
|
| 82 |
+
progress_data = []
|
| 83 |
+
|
| 84 |
+
for tutorial in tutorials:
|
| 85 |
+
progress_record = next((p for p in progress_records if p.tutorial_id == tutorial['id']), None)
|
| 86 |
+
progress_data.append({
|
| 87 |
+
'tutorial': tutorial,
|
| 88 |
+
'progress': progress_record
|
| 89 |
+
})
|
| 90 |
+
|
| 91 |
+
return render_template('progress.html',
|
| 92 |
+
user=user,
|
| 93 |
+
progress_data=progress_data)
|
| 94 |
+
|
| 95 |
+
@app.route('/api/progress/update', methods=['POST'])
|
| 96 |
+
def update_progress():
|
| 97 |
+
# Progress tracking disabled - return success without saving
|
| 98 |
+
return jsonify({'success': True})
|
| 99 |
+
|
| 100 |
+
@app.route('/login')
|
| 101 |
+
def login():
|
| 102 |
+
# Simple session-based login for demo
|
| 103 |
+
if 'user_id' not in session:
|
| 104 |
+
# Create or get demo user
|
| 105 |
+
demo_user = User.query.filter_by(username='demo_user').first()
|
| 106 |
+
if not demo_user:
|
| 107 |
+
demo_user = User(
|
| 108 |
+
username='demo_user',
|
| 109 |
+
email='demo@example.com'
|
| 110 |
+
)
|
| 111 |
+
db.session.add(demo_user)
|
| 112 |
+
db.session.commit()
|
| 113 |
+
|
| 114 |
+
session['user_id'] = demo_user.id
|
| 115 |
+
|
| 116 |
+
return redirect(url_for('index'))
|
| 117 |
+
|
| 118 |
+
@app.route('/logout')
|
| 119 |
+
def logout():
|
| 120 |
+
session.pop('user_id', None)
|
| 121 |
+
return redirect(url_for('index'))
|
static/css/style.css
ADDED
|
@@ -0,0 +1,719 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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5 |
+
--info-color: #17a2b8;
|
| 6 |
+
--warning-color: #ffc107;
|
| 7 |
+
--danger-color: #dc3545;
|
| 8 |
+
--light-color: #f8f9fa;
|
| 9 |
+
--dark-color: #343a40;
|
| 10 |
+
|
| 11 |
+
--beginner-color: #28a745;
|
| 12 |
+
--intermediate-color: #ffc107;
|
| 13 |
+
--advanced-color: #dc3545;
|
| 14 |
+
|
| 15 |
+
--border-radius: 8px;
|
| 16 |
+
--box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
| 17 |
+
--transition: all 0.3s ease;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/* Global Styles */
|
| 21 |
+
body {
|
| 22 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 23 |
+
line-height: 1.6;
|
| 24 |
+
color: #333;
|
| 25 |
+
background-color: #f8f9fa;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.main-content {
|
| 29 |
+
margin-top: 76px; /* Account for fixed navbar */
|
| 30 |
+
min-height: calc(100vh - 76px);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/* Typography */
|
| 34 |
+
.section-title {
|
| 35 |
+
font-size: 2rem;
|
| 36 |
+
font-weight: 600;
|
| 37 |
+
color: var(--dark-color);
|
| 38 |
+
margin-bottom: 0.5rem;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.section-subtitle {
|
| 42 |
+
color: var(--secondary-color);
|
| 43 |
+
font-size: 1.1rem;
|
| 44 |
+
margin-bottom: 2rem;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.page-title {
|
| 48 |
+
font-size: 2.5rem;
|
| 49 |
+
font-weight: 700;
|
| 50 |
+
color: var(--primary-color);
|
| 51 |
+
margin-bottom: 0.5rem;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.page-subtitle {
|
| 55 |
+
color: var(--secondary-color);
|
| 56 |
+
font-size: 1.2rem;
|
| 57 |
+
margin-bottom: 2rem;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/* Hero Section */
|
| 61 |
+
.hero-section {
|
| 62 |
+
background: linear-gradient(135deg, var(--primary-color), #0056b3);
|
| 63 |
+
color: white;
|
| 64 |
+
padding: 4rem 2rem;
|
| 65 |
+
border-radius: var(--border-radius);
|
| 66 |
+
margin-bottom: 3rem;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.hero-stats {
|
| 70 |
+
margin-top: 2rem;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.stat-item {
|
| 74 |
+
padding: 1rem;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.stat-number {
|
| 78 |
+
font-size: 2.5rem;
|
| 79 |
+
font-weight: 700;
|
| 80 |
+
margin: 0;
|
| 81 |
+
color: white;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.stat-label {
|
| 85 |
+
margin: 0;
|
| 86 |
+
opacity: 0.9;
|
| 87 |
+
font-size: 0.9rem;
|
| 88 |
+
text-transform: uppercase;
|
| 89 |
+
letter-spacing: 1px;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/* Learning Path */
|
| 93 |
+
.learning-path {
|
| 94 |
+
position: relative;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.path-item {
|
| 98 |
+
display: flex;
|
| 99 |
+
align-items: flex-start;
|
| 100 |
+
margin-bottom: 2rem;
|
| 101 |
+
position: relative;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.path-item::before {
|
| 105 |
+
content: '';
|
| 106 |
+
position: absolute;
|
| 107 |
+
left: 20px;
|
| 108 |
+
top: 60px;
|
| 109 |
+
bottom: -20px;
|
| 110 |
+
width: 2px;
|
| 111 |
+
background: #e9ecef;
|
| 112 |
+
z-index: 1;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.path-item:last-child::before {
|
| 116 |
+
display: none;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.path-number {
|
| 120 |
+
width: 40px;
|
| 121 |
+
height: 40px;
|
| 122 |
+
background: var(--primary-color);
|
| 123 |
+
color: white;
|
| 124 |
+
border-radius: 50%;
|
| 125 |
+
display: flex;
|
| 126 |
+
align-items: center;
|
| 127 |
+
justify-content: center;
|
| 128 |
+
font-weight: 600;
|
| 129 |
+
margin-right: 1.5rem;
|
| 130 |
+
position: relative;
|
| 131 |
+
z-index: 2;
|
| 132 |
+
flex-shrink: 0;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.path-content {
|
| 136 |
+
flex: 1;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/* Cards */
|
| 140 |
+
.tutorial-card, .project-card {
|
| 141 |
+
border: none;
|
| 142 |
+
box-shadow: var(--box-shadow);
|
| 143 |
+
transition: var(--transition);
|
| 144 |
+
border-radius: var(--border-radius);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.tutorial-card:hover, .project-card:hover {
|
| 148 |
+
transform: translateY(-2px);
|
| 149 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.tutorial-progress {
|
| 153 |
+
position: relative;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.progress-circle {
|
| 157 |
+
width: 40px;
|
| 158 |
+
height: 40px;
|
| 159 |
+
border-radius: 50%;
|
| 160 |
+
display: flex;
|
| 161 |
+
align-items: center;
|
| 162 |
+
justify-content: center;
|
| 163 |
+
font-size: 12px;
|
| 164 |
+
font-weight: 600;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.progress-circle.completed {
|
| 168 |
+
background: var(--success-color);
|
| 169 |
+
color: white;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.progress-circle.in-progress {
|
| 173 |
+
background: var(--warning-color);
|
| 174 |
+
color: white;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.progress-circle.not-started {
|
| 178 |
+
background: var(--light-color);
|
| 179 |
+
color: var(--secondary-color);
|
| 180 |
+
border: 2px solid #dee2e6;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/* Difficulty Badges */
|
| 184 |
+
.bg-beginner { background-color: var(--beginner-color) !important; }
|
| 185 |
+
.bg-intermediate { background-color: var(--warning-color) !important; }
|
| 186 |
+
.bg-advanced { background-color: var(--danger-color) !important; }
|
| 187 |
+
|
| 188 |
+
/* Project Cards */
|
| 189 |
+
.project-icon {
|
| 190 |
+
width: 60px;
|
| 191 |
+
height: 60px;
|
| 192 |
+
background: var(--primary-color);
|
| 193 |
+
border-radius: var(--border-radius);
|
| 194 |
+
display: flex;
|
| 195 |
+
align-items: center;
|
| 196 |
+
justify-content: center;
|
| 197 |
+
color: white;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.project-icon i {
|
| 201 |
+
width: 30px;
|
| 202 |
+
height: 30px;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
.project-meta {
|
| 206 |
+
display: flex;
|
| 207 |
+
align-items: center;
|
| 208 |
+
flex-wrap: wrap;
|
| 209 |
+
gap: 0.5rem;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
/* Features Section */
|
| 213 |
+
.features-section {
|
| 214 |
+
background: white;
|
| 215 |
+
padding: 3rem 2rem;
|
| 216 |
+
border-radius: var(--border-radius);
|
| 217 |
+
box-shadow: var(--box-shadow);
|
| 218 |
+
margin-top: 3rem;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.feature-item {
|
| 222 |
+
padding: 2rem 1rem;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
.feature-icon {
|
| 226 |
+
width: 80px;
|
| 227 |
+
height: 80px;
|
| 228 |
+
background: linear-gradient(135deg, var(--primary-color), #0056b3);
|
| 229 |
+
border-radius: 50%;
|
| 230 |
+
display: flex;
|
| 231 |
+
align-items: center;
|
| 232 |
+
justify-content: center;
|
| 233 |
+
margin: 0 auto 1.5rem;
|
| 234 |
+
color: white;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.feature-icon i {
|
| 238 |
+
width: 32px;
|
| 239 |
+
height: 32px;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/* Tutorial Page Styles */
|
| 243 |
+
.tutorial-sidebar {
|
| 244 |
+
background: white;
|
| 245 |
+
padding: 1.5rem;
|
| 246 |
+
border-radius: var(--border-radius);
|
| 247 |
+
box-shadow: var(--box-shadow);
|
| 248 |
+
top: 100px;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.tutorial-nav .nav-link {
|
| 252 |
+
border-radius: var(--border-radius);
|
| 253 |
+
color: var(--dark-color);
|
| 254 |
+
padding: 0.75rem 1rem;
|
| 255 |
+
margin-bottom: 0.25rem;
|
| 256 |
+
display: flex;
|
| 257 |
+
align-items: center;
|
| 258 |
+
transition: var(--transition);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.tutorial-nav .nav-link:hover {
|
| 262 |
+
background-color: var(--light-color);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
.tutorial-nav .nav-link.active {
|
| 266 |
+
background-color: var(--primary-color);
|
| 267 |
+
color: white;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.step-number {
|
| 271 |
+
display: inline-flex;
|
| 272 |
+
align-items: center;
|
| 273 |
+
justify-content: center;
|
| 274 |
+
width: 24px;
|
| 275 |
+
height: 24px;
|
| 276 |
+
background: var(--light-color);
|
| 277 |
+
border-radius: 50%;
|
| 278 |
+
font-size: 12px;
|
| 279 |
+
font-weight: 600;
|
| 280 |
+
margin-right: 0.75rem;
|
| 281 |
+
color: var(--secondary-color);
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.tutorial-nav .nav-link.active .step-number {
|
| 285 |
+
background: rgba(255,255,255,0.2);
|
| 286 |
+
color: white;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
/* Tutorial Content */
|
| 290 |
+
.tutorial-header {
|
| 291 |
+
background: white;
|
| 292 |
+
padding: 2rem;
|
| 293 |
+
border-radius: var(--border-radius);
|
| 294 |
+
box-shadow: var(--box-shadow);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.tutorial-title {
|
| 298 |
+
font-size: 2.5rem;
|
| 299 |
+
font-weight: 700;
|
| 300 |
+
color: var(--dark-color);
|
| 301 |
+
margin-bottom: 1rem;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.tutorial-meta {
|
| 305 |
+
display: flex;
|
| 306 |
+
align-items: center;
|
| 307 |
+
flex-wrap: wrap;
|
| 308 |
+
gap: 1rem;
|
| 309 |
+
margin-bottom: 1rem;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
.tutorial-step {
|
| 313 |
+
background: white;
|
| 314 |
+
padding: 2rem;
|
| 315 |
+
border-radius: var(--border-radius);
|
| 316 |
+
box-shadow: var(--box-shadow);
|
| 317 |
+
margin-bottom: 2rem;
|
| 318 |
+
display: none;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
.tutorial-step.active {
|
| 322 |
+
display: block;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
.step-header {
|
| 326 |
+
display: flex;
|
| 327 |
+
justify-content: between;
|
| 328 |
+
align-items: center;
|
| 329 |
+
margin-bottom: 1.5rem;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
.step-title {
|
| 333 |
+
font-size: 1.8rem;
|
| 334 |
+
font-weight: 600;
|
| 335 |
+
color: var(--dark-color);
|
| 336 |
+
display: flex;
|
| 337 |
+
align-items: center;
|
| 338 |
+
flex: 1;
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
.step-number-badge {
|
| 342 |
+
display: inline-flex;
|
| 343 |
+
align-items: center;
|
| 344 |
+
justify-content: center;
|
| 345 |
+
width: 32px;
|
| 346 |
+
height: 32px;
|
| 347 |
+
background: var(--primary-color);
|
| 348 |
+
color: white;
|
| 349 |
+
border-radius: 50%;
|
| 350 |
+
font-size: 14px;
|
| 351 |
+
font-weight: 600;
|
| 352 |
+
margin-right: 1rem;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
.step-time {
|
| 356 |
+
color: var(--secondary-color);
|
| 357 |
+
font-size: 0.9rem;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
.step-content {
|
| 361 |
+
font-size: 1.1rem;
|
| 362 |
+
line-height: 1.8;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
.step-content h3 {
|
| 366 |
+
color: var(--dark-color);
|
| 367 |
+
margin-top: 2rem;
|
| 368 |
+
margin-bottom: 1rem;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
.step-content h4 {
|
| 372 |
+
color: var(--dark-color);
|
| 373 |
+
margin-top: 1.5rem;
|
| 374 |
+
margin-bottom: 0.75rem;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
.code-example {
|
| 378 |
+
background: #f8f9fa;
|
| 379 |
+
border: 1px solid #e9ecef;
|
| 380 |
+
border-radius: var(--border-radius);
|
| 381 |
+
padding: 1.5rem;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
.code-example pre {
|
| 385 |
+
margin: 0;
|
| 386 |
+
font-size: 0.9rem;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.interactive-demo {
|
| 390 |
+
border: 2px dashed #dee2e6;
|
| 391 |
+
border-radius: var(--border-radius);
|
| 392 |
+
padding: 1.5rem;
|
| 393 |
+
background: #f8f9fa;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
.demo-container {
|
| 397 |
+
background: white;
|
| 398 |
+
padding: 1rem;
|
| 399 |
+
border-radius: var(--border-radius);
|
| 400 |
+
border: 1px solid #dee2e6;
|
| 401 |
+
min-height: 200px;
|
| 402 |
+
display: flex;
|
| 403 |
+
align-items: center;
|
| 404 |
+
justify-content: center;
|
| 405 |
+
color: var(--secondary-color);
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
/* Project Page Styles */
|
| 409 |
+
.project-info-card {
|
| 410 |
+
top: 100px;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
.project-info-card .large-icon {
|
| 414 |
+
width: 48px;
|
| 415 |
+
height: 48px;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
.detail-item {
|
| 419 |
+
display: flex;
|
| 420 |
+
justify-content: space-between;
|
| 421 |
+
align-items: center;
|
| 422 |
+
padding: 0.5rem 0;
|
| 423 |
+
border-bottom: 1px solid #f1f3f4;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
.detail-item:last-child {
|
| 427 |
+
border-bottom: none;
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
.project-content {
|
| 431 |
+
background: white;
|
| 432 |
+
padding: 2rem;
|
| 433 |
+
border-radius: var(--border-radius);
|
| 434 |
+
box-shadow: var(--box-shadow);
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
.project-section {
|
| 438 |
+
margin-bottom: 3rem;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
.project-section h2 {
|
| 442 |
+
color: var(--dark-color);
|
| 443 |
+
font-weight: 600;
|
| 444 |
+
margin-bottom: 1.5rem;
|
| 445 |
+
padding-bottom: 0.5rem;
|
| 446 |
+
border-bottom: 2px solid var(--primary-color);
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
.project-steps {
|
| 450 |
+
margin-top: 2rem;
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
.project-step {
|
| 454 |
+
background: #f8f9fa;
|
| 455 |
+
border-radius: var(--border-radius);
|
| 456 |
+
padding: 1.5rem;
|
| 457 |
+
margin-bottom: 1.5rem;
|
| 458 |
+
border-left: 4px solid var(--primary-color);
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
.project-step .step-header h4 {
|
| 462 |
+
color: var(--dark-color);
|
| 463 |
+
margin-bottom: 1rem;
|
| 464 |
+
display: flex;
|
| 465 |
+
align-items: center;
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
.project-step .step-number {
|
| 469 |
+
display: inline-flex;
|
| 470 |
+
align-items: center;
|
| 471 |
+
justify-content: center;
|
| 472 |
+
width: 28px;
|
| 473 |
+
height: 28px;
|
| 474 |
+
background: var(--primary-color);
|
| 475 |
+
color: white;
|
| 476 |
+
border-radius: 50%;
|
| 477 |
+
font-size: 12px;
|
| 478 |
+
font-weight: 600;
|
| 479 |
+
margin-right: 1rem;
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
.code-block {
|
| 483 |
+
background: #2d3748;
|
| 484 |
+
color: #e2e8f0;
|
| 485 |
+
border-radius: var(--border-radius);
|
| 486 |
+
padding: 1.5rem;
|
| 487 |
+
overflow-x: auto;
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
.code-block pre {
|
| 491 |
+
margin: 0;
|
| 492 |
+
font-family: 'Monaco', 'Menlo', monospace;
|
| 493 |
+
font-size: 0.9rem;
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
/* Progress Page Styles */
|
| 497 |
+
.stats-card {
|
| 498 |
+
border: none;
|
| 499 |
+
box-shadow: var(--box-shadow);
|
| 500 |
+
transition: var(--transition);
|
| 501 |
+
border-radius: var(--border-radius);
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
.stats-card:hover {
|
| 505 |
+
transform: translateY(-2px);
|
| 506 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
.stats-icon {
|
| 510 |
+
width: 60px;
|
| 511 |
+
height: 60px;
|
| 512 |
+
background: var(--primary-color);
|
| 513 |
+
border-radius: 50%;
|
| 514 |
+
display: flex;
|
| 515 |
+
align-items: center;
|
| 516 |
+
justify-content: center;
|
| 517 |
+
margin: 0 auto 1rem;
|
| 518 |
+
color: white;
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
.stats-number {
|
| 522 |
+
font-size: 2rem;
|
| 523 |
+
font-weight: 700;
|
| 524 |
+
color: var(--primary-color);
|
| 525 |
+
margin: 0;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
.stats-label {
|
| 529 |
+
color: var(--secondary-color);
|
| 530 |
+
font-size: 0.9rem;
|
| 531 |
+
text-transform: uppercase;
|
| 532 |
+
letter-spacing: 1px;
|
| 533 |
+
margin: 0;
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.progress-timeline {
|
| 537 |
+
position: relative;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
.progress-item {
|
| 541 |
+
display: flex;
|
| 542 |
+
align-items: flex-start;
|
| 543 |
+
margin-bottom: 2rem;
|
| 544 |
+
position: relative;
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
.progress-item::before {
|
| 548 |
+
content: '';
|
| 549 |
+
position: absolute;
|
| 550 |
+
left: 20px;
|
| 551 |
+
top: 60px;
|
| 552 |
+
bottom: -20px;
|
| 553 |
+
width: 2px;
|
| 554 |
+
background: #e9ecef;
|
| 555 |
+
z-index: 1;
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
.progress-item:last-child::before {
|
| 559 |
+
display: none;
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
.progress-marker {
|
| 563 |
+
margin-right: 1.5rem;
|
| 564 |
+
position: relative;
|
| 565 |
+
z-index: 2;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
.marker {
|
| 569 |
+
width: 40px;
|
| 570 |
+
height: 40px;
|
| 571 |
+
border-radius: 50%;
|
| 572 |
+
display: flex;
|
| 573 |
+
align-items: center;
|
| 574 |
+
justify-content: center;
|
| 575 |
+
font-size: 12px;
|
| 576 |
+
font-weight: 600;
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
.marker.completed {
|
| 580 |
+
background: var(--success-color);
|
| 581 |
+
color: white;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
.marker.in-progress {
|
| 585 |
+
background: var(--warning-color);
|
| 586 |
+
color: white;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
.marker.not-started {
|
| 590 |
+
background: var(--light-color);
|
| 591 |
+
color: var(--secondary-color);
|
| 592 |
+
border: 2px solid #dee2e6;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
.progress-content {
|
| 596 |
+
flex: 1;
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
.progress-actions {
|
| 600 |
+
display: flex;
|
| 601 |
+
gap: 0.5rem;
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
.tutorial-progress {
|
| 605 |
+
margin-top: 1rem;
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
.tutorial-progress .progress {
|
| 609 |
+
height: 6px;
|
| 610 |
+
margin-bottom: 0.5rem;
|
| 611 |
+
}
|
| 612 |
+
|
| 613 |
+
/* Responsive Design */
|
| 614 |
+
@media (max-width: 768px) {
|
| 615 |
+
.main-content {
|
| 616 |
+
margin-top: 60px;
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
.hero-section {
|
| 620 |
+
padding: 2rem 1rem;
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
.stat-number {
|
| 624 |
+
font-size: 2rem;
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
.section-title {
|
| 628 |
+
font-size: 1.75rem;
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
.page-title {
|
| 632 |
+
font-size: 2rem;
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
.tutorial-sidebar {
|
| 636 |
+
position: static !important;
|
| 637 |
+
margin-bottom: 2rem;
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
.path-item {
|
| 641 |
+
flex-direction: column;
|
| 642 |
+
align-items: center;
|
| 643 |
+
text-align: center;
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
.path-item::before {
|
| 647 |
+
display: none;
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
.path-number {
|
| 651 |
+
margin-bottom: 1rem;
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
.tutorial-meta, .project-meta {
|
| 655 |
+
flex-direction: column;
|
| 656 |
+
align-items: flex-start;
|
| 657 |
+
gap: 0.5rem;
|
| 658 |
+
}
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
/* Animation Classes */
|
| 662 |
+
.fade-in {
|
| 663 |
+
animation: fadeIn 0.5s ease-in;
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
@keyframes fadeIn {
|
| 667 |
+
from { opacity: 0; transform: translateY(20px); }
|
| 668 |
+
to { opacity: 1; transform: translateY(0); }
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
.slide-in-left {
|
| 672 |
+
animation: slideInLeft 0.5s ease-out;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
@keyframes slideInLeft {
|
| 676 |
+
from { opacity: 0; transform: translateX(-30px); }
|
| 677 |
+
to { opacity: 1; transform: translateX(0); }
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
/* Utility Classes */
|
| 681 |
+
.text-gradient {
|
| 682 |
+
background: linear-gradient(135deg, var(--primary-color), #0056b3);
|
| 683 |
+
-webkit-background-clip: text;
|
| 684 |
+
-webkit-text-fill-color: transparent;
|
| 685 |
+
background-clip: text;
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
.border-gradient {
|
| 689 |
+
border: 2px solid;
|
| 690 |
+
border-image: linear-gradient(135deg, var(--primary-color), #0056b3) 1;
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
/* Dark mode support */
|
| 694 |
+
@media (prefers-color-scheme: dark) {
|
| 695 |
+
:root {
|
| 696 |
+
--light-color: #343a40;
|
| 697 |
+
--dark-color: #f8f9fa;
|
| 698 |
+
}
|
| 699 |
+
|
| 700 |
+
body {
|
| 701 |
+
background-color: #1a1a1a;
|
| 702 |
+
color: #f8f9fa;
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
.tutorial-sidebar,
|
| 706 |
+
.tutorial-header,
|
| 707 |
+
.tutorial-step,
|
| 708 |
+
.project-content,
|
| 709 |
+
.features-section {
|
| 710 |
+
background: #2d3748;
|
| 711 |
+
color: #f8f9fa;
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
.card {
|
| 715 |
+
background: #2d3748;
|
| 716 |
+
color: #f8f9fa;
|
| 717 |
+
border-color: #4a5568;
|
| 718 |
+
}
|
| 719 |
+
}
|
static/js/main.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Main JavaScript functionality for the Dify Learning Platform
|
| 2 |
+
|
| 3 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 4 |
+
// Initialize tooltips
|
| 5 |
+
initializeTooltips();
|
| 6 |
+
|
| 7 |
+
// Initialize animations
|
| 8 |
+
initializeAnimations();
|
| 9 |
+
|
| 10 |
+
// Initialize progress tracking
|
| 11 |
+
initializeProgressTracking();
|
| 12 |
+
|
| 13 |
+
// Initialize search functionality
|
| 14 |
+
initializeSearch();
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Initialize Bootstrap tooltips
|
| 19 |
+
*/
|
| 20 |
+
function initializeTooltips() {
|
| 21 |
+
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
|
| 22 |
+
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
| 23 |
+
return new bootstrap.Tooltip(tooltipTriggerEl);
|
| 24 |
+
});
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Initialize scroll animations
|
| 29 |
+
*/
|
| 30 |
+
function initializeAnimations() {
|
| 31 |
+
// Fade in elements on scroll
|
| 32 |
+
const observerOptions = {
|
| 33 |
+
threshold: 0.1,
|
| 34 |
+
rootMargin: '0px 0px -50px 0px'
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
const observer = new IntersectionObserver(function(entries) {
|
| 38 |
+
entries.forEach(entry => {
|
| 39 |
+
if (entry.isIntersecting) {
|
| 40 |
+
entry.target.classList.add('fade-in');
|
| 41 |
+
}
|
| 42 |
+
});
|
| 43 |
+
}, observerOptions);
|
| 44 |
+
|
| 45 |
+
// Observe elements for animation
|
| 46 |
+
document.querySelectorAll('.tutorial-card, .project-card, .feature-item').forEach(el => {
|
| 47 |
+
observer.observe(el);
|
| 48 |
+
});
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Initialize progress tracking
|
| 53 |
+
*/
|
| 54 |
+
function initializeProgressTracking() {
|
| 55 |
+
// Track page views
|
| 56 |
+
trackPageView();
|
| 57 |
+
|
| 58 |
+
// Track tutorial interactions
|
| 59 |
+
document.querySelectorAll('.tutorial-card .btn').forEach(btn => {
|
| 60 |
+
btn.addEventListener('click', function(e) {
|
| 61 |
+
const tutorialTitle = this.closest('.tutorial-card').querySelector('.card-title').textContent;
|
| 62 |
+
trackEvent('tutorial_started', { tutorial: tutorialTitle });
|
| 63 |
+
});
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
// Track project interactions
|
| 67 |
+
document.querySelectorAll('.project-card .btn').forEach(btn => {
|
| 68 |
+
btn.addEventListener('click', function(e) {
|
| 69 |
+
const projectTitle = this.closest('.project-card').querySelector('.card-title').textContent;
|
| 70 |
+
trackEvent('project_started', { project: projectTitle });
|
| 71 |
+
});
|
| 72 |
+
});
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* Initialize search functionality
|
| 77 |
+
*/
|
| 78 |
+
function initializeSearch() {
|
| 79 |
+
const searchInput = document.getElementById('search-input');
|
| 80 |
+
if (searchInput) {
|
| 81 |
+
searchInput.addEventListener('input', debounce(handleSearch, 300));
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Handle search functionality
|
| 87 |
+
*/
|
| 88 |
+
function handleSearch(event) {
|
| 89 |
+
const query = event.target.value.toLowerCase().trim();
|
| 90 |
+
const tutorials = document.querySelectorAll('.tutorial-card');
|
| 91 |
+
const projects = document.querySelectorAll('.project-card');
|
| 92 |
+
|
| 93 |
+
// Filter tutorials
|
| 94 |
+
tutorials.forEach(card => {
|
| 95 |
+
const title = card.querySelector('.card-title').textContent.toLowerCase();
|
| 96 |
+
const description = card.querySelector('.card-text').textContent.toLowerCase();
|
| 97 |
+
const isVisible = title.includes(query) || description.includes(query) || query === '';
|
| 98 |
+
|
| 99 |
+
card.closest('.path-item, .col-md-6, .col-lg-4')?.style.setProperty('display', isVisible ? '' : 'none');
|
| 100 |
+
});
|
| 101 |
+
|
| 102 |
+
// Filter projects
|
| 103 |
+
projects.forEach(card => {
|
| 104 |
+
const title = card.querySelector('.card-title').textContent.toLowerCase();
|
| 105 |
+
const description = card.querySelector('.card-text').textContent.toLowerCase();
|
| 106 |
+
const isVisible = title.includes(query) || description.includes(query) || query === '';
|
| 107 |
+
|
| 108 |
+
card.closest('.col-md-6, .col-lg-4')?.style.setProperty('display', isVisible ? '' : 'none');
|
| 109 |
+
});
|
| 110 |
+
|
| 111 |
+
// Show/hide sections based on results
|
| 112 |
+
updateSearchResults(query);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Update search results display
|
| 117 |
+
*/
|
| 118 |
+
function updateSearchResults(query) {
|
| 119 |
+
const tutorialSection = document.querySelector('.learning-path');
|
| 120 |
+
const projectSection = document.querySelector('#projects');
|
| 121 |
+
|
| 122 |
+
if (query) {
|
| 123 |
+
const visibleTutorials = document.querySelectorAll('.tutorial-card:not([style*="display: none"])');
|
| 124 |
+
const visibleProjects = document.querySelectorAll('.project-card:not([style*="display: none"])');
|
| 125 |
+
|
| 126 |
+
// Show no results message if needed
|
| 127 |
+
if (visibleTutorials.length === 0 && visibleProjects.length === 0) {
|
| 128 |
+
showNoResultsMessage();
|
| 129 |
+
} else {
|
| 130 |
+
hideNoResultsMessage();
|
| 131 |
+
}
|
| 132 |
+
} else {
|
| 133 |
+
hideNoResultsMessage();
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Show no results message
|
| 139 |
+
*/
|
| 140 |
+
function showNoResultsMessage() {
|
| 141 |
+
let noResultsMsg = document.getElementById('no-results-message');
|
| 142 |
+
if (!noResultsMsg) {
|
| 143 |
+
noResultsMsg = document.createElement('div');
|
| 144 |
+
noResultsMsg.id = 'no-results-message';
|
| 145 |
+
noResultsMsg.className = 'alert alert-info text-center';
|
| 146 |
+
noResultsMsg.innerHTML = `
|
| 147 |
+
<i data-feather="search" class="me-2"></i>
|
| 148 |
+
No tutorials or projects found matching your search.
|
| 149 |
+
`;
|
| 150 |
+
document.querySelector('.container').appendChild(noResultsMsg);
|
| 151 |
+
feather.replace();
|
| 152 |
+
}
|
| 153 |
+
noResultsMsg.style.display = 'block';
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Hide no results message
|
| 158 |
+
*/
|
| 159 |
+
function hideNoResultsMessage() {
|
| 160 |
+
const noResultsMsg = document.getElementById('no-results-message');
|
| 161 |
+
if (noResultsMsg) {
|
| 162 |
+
noResultsMsg.style.display = 'none';
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Track page views for analytics
|
| 168 |
+
*/
|
| 169 |
+
function trackPageView() {
|
| 170 |
+
const pageData = {
|
| 171 |
+
page: window.location.pathname,
|
| 172 |
+
title: document.title,
|
| 173 |
+
timestamp: new Date().toISOString()
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
// Store in localStorage for demo purposes
|
| 177 |
+
const visits = JSON.parse(localStorage.getItem('dify_visits') || '[]');
|
| 178 |
+
visits.push(pageData);
|
| 179 |
+
localStorage.setItem('dify_visits', JSON.stringify(visits.slice(-100))); // Keep last 100 visits
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Track custom events
|
| 184 |
+
*/
|
| 185 |
+
function trackEvent(eventName, eventData = {}) {
|
| 186 |
+
const event = {
|
| 187 |
+
name: eventName,
|
| 188 |
+
data: eventData,
|
| 189 |
+
timestamp: new Date().toISOString(),
|
| 190 |
+
page: window.location.pathname
|
| 191 |
+
};
|
| 192 |
+
|
| 193 |
+
// Store in localStorage for demo purposes
|
| 194 |
+
const events = JSON.parse(localStorage.getItem('dify_events') || '[]');
|
| 195 |
+
events.push(event);
|
| 196 |
+
localStorage.setItem('dify_events', JSON.stringify(events.slice(-100))); // Keep last 100 events
|
| 197 |
+
|
| 198 |
+
console.log('Event tracked:', event);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Utility function to debounce function calls
|
| 203 |
+
*/
|
| 204 |
+
function debounce(func, wait) {
|
| 205 |
+
let timeout;
|
| 206 |
+
return function(...args) {
|
| 207 |
+
const later = () => {
|
| 208 |
+
clearTimeout(timeout);
|
| 209 |
+
func.apply(this, args);
|
| 210 |
+
};
|
| 211 |
+
clearTimeout(timeout);
|
| 212 |
+
timeout = setTimeout(later, wait);
|
| 213 |
+
};
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* Smooth scroll to element
|
| 218 |
+
*/
|
| 219 |
+
function smoothScrollTo(element, offset = 80) {
|
| 220 |
+
const targetPosition = element.offsetTop - offset;
|
| 221 |
+
window.scrollTo({
|
| 222 |
+
top: targetPosition,
|
| 223 |
+
behavior: 'smooth'
|
| 224 |
+
});
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Show loading spinner
|
| 229 |
+
*/
|
| 230 |
+
function showLoader(container) {
|
| 231 |
+
const loader = document.createElement('div');
|
| 232 |
+
loader.className = 'text-center py-4';
|
| 233 |
+
loader.innerHTML = `
|
| 234 |
+
<div class="spinner-border text-primary" role="status">
|
| 235 |
+
<span class="visually-hidden">Loading...</span>
|
| 236 |
+
</div>
|
| 237 |
+
`;
|
| 238 |
+
container.appendChild(loader);
|
| 239 |
+
return loader;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* Hide loading spinner
|
| 244 |
+
*/
|
| 245 |
+
function hideLoader(loader) {
|
| 246 |
+
if (loader && loader.parentNode) {
|
| 247 |
+
loader.parentNode.removeChild(loader);
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
/**
|
| 252 |
+
* Show toast notification
|
| 253 |
+
*/
|
| 254 |
+
function showToast(message, type = 'info') {
|
| 255 |
+
const toast = document.createElement('div');
|
| 256 |
+
toast.className = `toast align-items-center text-white bg-${type} border-0`;
|
| 257 |
+
toast.setAttribute('role', 'alert');
|
| 258 |
+
toast.setAttribute('aria-live', 'assertive');
|
| 259 |
+
toast.setAttribute('aria-atomic', 'true');
|
| 260 |
+
|
| 261 |
+
toast.innerHTML = `
|
| 262 |
+
<div class="d-flex">
|
| 263 |
+
<div class="toast-body">
|
| 264 |
+
${message}
|
| 265 |
+
</div>
|
| 266 |
+
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
|
| 267 |
+
</div>
|
| 268 |
+
`;
|
| 269 |
+
|
| 270 |
+
// Add to toast container or create one
|
| 271 |
+
let toastContainer = document.getElementById('toast-container');
|
| 272 |
+
if (!toastContainer) {
|
| 273 |
+
toastContainer = document.createElement('div');
|
| 274 |
+
toastContainer.id = 'toast-container';
|
| 275 |
+
toastContainer.className = 'toast-container position-fixed top-0 end-0 p-3';
|
| 276 |
+
toastContainer.style.zIndex = '9999';
|
| 277 |
+
document.body.appendChild(toastContainer);
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
toastContainer.appendChild(toast);
|
| 281 |
+
|
| 282 |
+
// Initialize and show toast
|
| 283 |
+
const bsToast = new bootstrap.Toast(toast);
|
| 284 |
+
bsToast.show();
|
| 285 |
+
|
| 286 |
+
// Remove from DOM after hiding
|
| 287 |
+
toast.addEventListener('hidden.bs.toast', () => {
|
| 288 |
+
toast.remove();
|
| 289 |
+
});
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
/**
|
| 293 |
+
* Copy text to clipboard
|
| 294 |
+
*/
|
| 295 |
+
async function copyToClipboard(text) {
|
| 296 |
+
try {
|
| 297 |
+
await navigator.clipboard.writeText(text);
|
| 298 |
+
showToast('Copied to clipboard!', 'success');
|
| 299 |
+
} catch (err) {
|
| 300 |
+
console.error('Failed to copy:', err);
|
| 301 |
+
showToast('Failed to copy to clipboard', 'danger');
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* Format time duration
|
| 307 |
+
*/
|
| 308 |
+
function formatDuration(minutes) {
|
| 309 |
+
if (minutes < 60) {
|
| 310 |
+
return `${minutes} min`;
|
| 311 |
+
} else {
|
| 312 |
+
const hours = Math.floor(minutes / 60);
|
| 313 |
+
const remainingMinutes = minutes % 60;
|
| 314 |
+
return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
/**
|
| 319 |
+
* Calculate reading time for content
|
| 320 |
+
*/
|
| 321 |
+
function calculateReadingTime(text, wordsPerMinute = 200) {
|
| 322 |
+
const wordCount = text.split(/\s+/).length;
|
| 323 |
+
const minutes = Math.ceil(wordCount / wordsPerMinute);
|
| 324 |
+
return Math.max(1, minutes);
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
/**
|
| 328 |
+
* Initialize progress bars with animation
|
| 329 |
+
*/
|
| 330 |
+
function animateProgressBar(progressBar, targetWidth) {
|
| 331 |
+
let currentWidth = 0;
|
| 332 |
+
const increment = targetWidth / 20;
|
| 333 |
+
const interval = setInterval(() => {
|
| 334 |
+
currentWidth += increment;
|
| 335 |
+
if (currentWidth >= targetWidth) {
|
| 336 |
+
currentWidth = targetWidth;
|
| 337 |
+
clearInterval(interval);
|
| 338 |
+
}
|
| 339 |
+
progressBar.style.width = `${currentWidth}%`;
|
| 340 |
+
}, 50);
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
// Export functions for use in other scripts
|
| 344 |
+
window.DifyLearning = {
|
| 345 |
+
trackEvent,
|
| 346 |
+
showToast,
|
| 347 |
+
copyToClipboard,
|
| 348 |
+
formatDuration,
|
| 349 |
+
calculateReadingTime,
|
| 350 |
+
smoothScrollTo,
|
| 351 |
+
showLoader,
|
| 352 |
+
hideLoader,
|
| 353 |
+
animateProgressBar
|
| 354 |
+
};
|
static/js/tutorial.js
ADDED
|
@@ -0,0 +1,596 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Tutorial-specific JavaScript functionality
|
| 2 |
+
|
| 3 |
+
let currentTutorial = null;
|
| 4 |
+
let currentStep = 0;
|
| 5 |
+
let totalSteps = 0;
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* Initialize tutorial functionality
|
| 9 |
+
*/
|
| 10 |
+
function initializeTutorial(tutorialData) {
|
| 11 |
+
currentTutorial = tutorialData;
|
| 12 |
+
currentStep = tutorialData.currentStep || 0;
|
| 13 |
+
totalSteps = tutorialData.totalSteps;
|
| 14 |
+
|
| 15 |
+
setupTutorialNavigation();
|
| 16 |
+
setupStepTracking();
|
| 17 |
+
setupKeyboardNavigation();
|
| 18 |
+
updateProgress();
|
| 19 |
+
|
| 20 |
+
// Show the current step
|
| 21 |
+
showStep(currentStep);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Setup tutorial navigation
|
| 26 |
+
*/
|
| 27 |
+
function setupTutorialNavigation() {
|
| 28 |
+
// Step navigation links
|
| 29 |
+
document.querySelectorAll('.step-nav-link').forEach(link => {
|
| 30 |
+
link.addEventListener('click', function(e) {
|
| 31 |
+
e.preventDefault();
|
| 32 |
+
const stepIndex = parseInt(this.dataset.step);
|
| 33 |
+
navigateToStep(stepIndex);
|
| 34 |
+
});
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
// Next/Previous buttons
|
| 38 |
+
document.querySelectorAll('[onclick*="navigateToStep"]').forEach(btn => {
|
| 39 |
+
btn.addEventListener('click', function(e) {
|
| 40 |
+
e.preventDefault();
|
| 41 |
+
const match = this.getAttribute('onclick').match(/navigateToStep\((\d+)\)/);
|
| 42 |
+
if (match) {
|
| 43 |
+
navigateToStep(parseInt(match[1]));
|
| 44 |
+
}
|
| 45 |
+
});
|
| 46 |
+
});
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Setup step tracking
|
| 51 |
+
*/
|
| 52 |
+
function setupStepTracking() {
|
| 53 |
+
// Track time spent on each step
|
| 54 |
+
let stepStartTime = Date.now();
|
| 55 |
+
|
| 56 |
+
window.addEventListener('beforeunload', () => {
|
| 57 |
+
const timeSpent = Math.floor((Date.now() - stepStartTime) / 1000);
|
| 58 |
+
trackStepTime(currentStep, timeSpent);
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
// Track step completion
|
| 62 |
+
document.addEventListener('visibilitychange', () => {
|
| 63 |
+
if (document.hidden) {
|
| 64 |
+
const timeSpent = Math.floor((Date.now() - stepStartTime) / 1000);
|
| 65 |
+
trackStepTime(currentStep, timeSpent);
|
| 66 |
+
} else {
|
| 67 |
+
stepStartTime = Date.now();
|
| 68 |
+
}
|
| 69 |
+
});
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Setup keyboard navigation
|
| 74 |
+
*/
|
| 75 |
+
function setupKeyboardNavigation() {
|
| 76 |
+
document.addEventListener('keydown', function(e) {
|
| 77 |
+
// Only handle keyboard navigation when tutorial content is focused
|
| 78 |
+
if (!document.querySelector('.tutorial-content').contains(document.activeElement)) {
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
switch(e.key) {
|
| 83 |
+
case 'ArrowLeft':
|
| 84 |
+
if (currentStep > 0) {
|
| 85 |
+
e.preventDefault();
|
| 86 |
+
navigateToStep(currentStep - 1);
|
| 87 |
+
}
|
| 88 |
+
break;
|
| 89 |
+
case 'ArrowRight':
|
| 90 |
+
if (currentStep < totalSteps - 1) {
|
| 91 |
+
e.preventDefault();
|
| 92 |
+
navigateToStep(currentStep + 1);
|
| 93 |
+
}
|
| 94 |
+
break;
|
| 95 |
+
case 'Home':
|
| 96 |
+
e.preventDefault();
|
| 97 |
+
navigateToStep(0);
|
| 98 |
+
break;
|
| 99 |
+
case 'End':
|
| 100 |
+
e.preventDefault();
|
| 101 |
+
navigateToStep(totalSteps - 1);
|
| 102 |
+
break;
|
| 103 |
+
}
|
| 104 |
+
});
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Navigate to a specific step
|
| 109 |
+
*/
|
| 110 |
+
function navigateToStep(stepIndex) {
|
| 111 |
+
if (stepIndex < 0 || stepIndex >= totalSteps) {
|
| 112 |
+
return;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// Hide current step
|
| 116 |
+
const currentStepElement = document.querySelector(`#step-${currentStep}`);
|
| 117 |
+
if (currentStepElement) {
|
| 118 |
+
currentStepElement.classList.remove('active');
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
// Update step navigation
|
| 122 |
+
document.querySelectorAll('.step-nav-link').forEach(link => {
|
| 123 |
+
link.classList.remove('active');
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
// Show new step
|
| 127 |
+
currentStep = stepIndex;
|
| 128 |
+
showStep(currentStep);
|
| 129 |
+
|
| 130 |
+
// Update navigation
|
| 131 |
+
const newNavLink = document.querySelector(`[data-step="${currentStep}"]`);
|
| 132 |
+
if (newNavLink) {
|
| 133 |
+
newNavLink.classList.add('active');
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
// Update progress
|
| 137 |
+
updateProgress();
|
| 138 |
+
|
| 139 |
+
// Save progress
|
| 140 |
+
saveProgress();
|
| 141 |
+
|
| 142 |
+
// Track step view
|
| 143 |
+
window.DifyLearning?.trackEvent('tutorial_step_viewed', {
|
| 144 |
+
tutorial_id: currentTutorial.id,
|
| 145 |
+
step: currentStep + 1,
|
| 146 |
+
step_title: document.querySelector(`#step-${currentStep} .step-title`)?.textContent
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
// Scroll to top of content
|
| 150 |
+
const tutorialContent = document.querySelector('.tutorial-content');
|
| 151 |
+
if (tutorialContent) {
|
| 152 |
+
tutorialContent.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Show a specific step
|
| 158 |
+
*/
|
| 159 |
+
function showStep(stepIndex) {
|
| 160 |
+
// Hide all steps
|
| 161 |
+
document.querySelectorAll('.tutorial-step').forEach(step => {
|
| 162 |
+
step.classList.remove('active');
|
| 163 |
+
});
|
| 164 |
+
|
| 165 |
+
// Show target step
|
| 166 |
+
const targetStep = document.querySelector(`#step-${stepIndex}`);
|
| 167 |
+
if (targetStep) {
|
| 168 |
+
targetStep.classList.add('active');
|
| 169 |
+
|
| 170 |
+
// Initialize any interactive elements in this step
|
| 171 |
+
initializeStepElements(targetStep);
|
| 172 |
+
|
| 173 |
+
// Add fade-in animation
|
| 174 |
+
targetStep.classList.add('fade-in');
|
| 175 |
+
|
| 176 |
+
// Update step counter
|
| 177 |
+
updateStepCounter(stepIndex + 1);
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Initialize interactive elements in a step
|
| 183 |
+
*/
|
| 184 |
+
function initializeStepElements(stepElement) {
|
| 185 |
+
// Initialize code examples with syntax highlighting
|
| 186 |
+
const codeBlocks = stepElement.querySelectorAll('pre code');
|
| 187 |
+
codeBlocks.forEach(block => {
|
| 188 |
+
// Add copy button
|
| 189 |
+
addCopyButton(block);
|
| 190 |
+
|
| 191 |
+
// Add line numbers if needed
|
| 192 |
+
if (block.textContent.split('\n').length > 5) {
|
| 193 |
+
addLineNumbers(block);
|
| 194 |
+
}
|
| 195 |
+
});
|
| 196 |
+
|
| 197 |
+
// Initialize interactive demos
|
| 198 |
+
const demos = stepElement.querySelectorAll('.interactive-demo');
|
| 199 |
+
demos.forEach(demo => {
|
| 200 |
+
initializeDemo(demo);
|
| 201 |
+
});
|
| 202 |
+
|
| 203 |
+
// Initialize tooltips for this step
|
| 204 |
+
const tooltips = stepElement.querySelectorAll('[data-bs-toggle="tooltip"]');
|
| 205 |
+
tooltips.forEach(tooltip => {
|
| 206 |
+
new bootstrap.Tooltip(tooltip);
|
| 207 |
+
});
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Add copy button to code blocks
|
| 212 |
+
*/
|
| 213 |
+
function addCopyButton(codeBlock) {
|
| 214 |
+
if (codeBlock.querySelector('.copy-button')) {
|
| 215 |
+
return; // Already has copy button
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
const copyButton = document.createElement('button');
|
| 219 |
+
copyButton.className = 'btn btn-sm btn-outline-secondary copy-button position-absolute top-0 end-0 m-2';
|
| 220 |
+
copyButton.innerHTML = '<i data-feather="copy"></i>';
|
| 221 |
+
copyButton.title = 'Copy code';
|
| 222 |
+
|
| 223 |
+
copyButton.addEventListener('click', async () => {
|
| 224 |
+
try {
|
| 225 |
+
await navigator.clipboard.writeText(codeBlock.textContent);
|
| 226 |
+
copyButton.innerHTML = '<i data-feather="check"></i>';
|
| 227 |
+
copyButton.classList.add('btn-success');
|
| 228 |
+
copyButton.classList.remove('btn-outline-secondary');
|
| 229 |
+
|
| 230 |
+
setTimeout(() => {
|
| 231 |
+
copyButton.innerHTML = '<i data-feather="copy"></i>';
|
| 232 |
+
copyButton.classList.remove('btn-success');
|
| 233 |
+
copyButton.classList.add('btn-outline-secondary');
|
| 234 |
+
feather.replace();
|
| 235 |
+
}, 2000);
|
| 236 |
+
|
| 237 |
+
window.DifyLearning?.showToast('Code copied to clipboard!', 'success');
|
| 238 |
+
} catch (err) {
|
| 239 |
+
window.DifyLearning?.showToast('Failed to copy code', 'danger');
|
| 240 |
+
}
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
// Make parent relative positioned
|
| 244 |
+
const pre = codeBlock.closest('pre');
|
| 245 |
+
if (pre) {
|
| 246 |
+
pre.style.position = 'relative';
|
| 247 |
+
pre.appendChild(copyButton);
|
| 248 |
+
feather.replace();
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* Add line numbers to code blocks
|
| 254 |
+
*/
|
| 255 |
+
function addLineNumbers(codeBlock) {
|
| 256 |
+
const lines = codeBlock.textContent.split('\n');
|
| 257 |
+
const lineNumbers = lines.map((_, index) => index + 1).join('\n');
|
| 258 |
+
|
| 259 |
+
const lineNumbersElement = document.createElement('pre');
|
| 260 |
+
lineNumbersElement.className = 'line-numbers';
|
| 261 |
+
lineNumbersElement.textContent = lineNumbers;
|
| 262 |
+
lineNumbersElement.style.cssText = `
|
| 263 |
+
position: absolute;
|
| 264 |
+
left: 0;
|
| 265 |
+
top: 0;
|
| 266 |
+
padding: 1rem 0.5rem;
|
| 267 |
+
background: #f1f3f4;
|
| 268 |
+
color: #666;
|
| 269 |
+
font-size: 0.8rem;
|
| 270 |
+
border-right: 1px solid #ddd;
|
| 271 |
+
user-select: none;
|
| 272 |
+
width: 3rem;
|
| 273 |
+
text-align: right;
|
| 274 |
+
`;
|
| 275 |
+
|
| 276 |
+
const pre = codeBlock.closest('pre');
|
| 277 |
+
if (pre) {
|
| 278 |
+
pre.style.position = 'relative';
|
| 279 |
+
pre.style.paddingLeft = '4rem';
|
| 280 |
+
pre.appendChild(lineNumbersElement);
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
/**
|
| 285 |
+
* Initialize interactive demos
|
| 286 |
+
*/
|
| 287 |
+
function initializeDemo(demoElement) {
|
| 288 |
+
const demoType = demoElement.dataset.demoType;
|
| 289 |
+
|
| 290 |
+
switch(demoType) {
|
| 291 |
+
case 'workflow-builder':
|
| 292 |
+
initializeWorkflowDemo(demoElement);
|
| 293 |
+
break;
|
| 294 |
+
case 'chatbot-preview':
|
| 295 |
+
initializeChatbotDemo(demoElement);
|
| 296 |
+
break;
|
| 297 |
+
case 'agent-configuration':
|
| 298 |
+
initializeAgentDemo(demoElement);
|
| 299 |
+
break;
|
| 300 |
+
default:
|
| 301 |
+
// Generic demo initialization
|
| 302 |
+
demoElement.innerHTML = `
|
| 303 |
+
<div class="demo-placeholder">
|
| 304 |
+
<i data-feather="play-circle" class="large-icon text-primary mb-2"></i>
|
| 305 |
+
<p>Interactive Demo</p>
|
| 306 |
+
<button class="btn btn-primary btn-sm">Try It</button>
|
| 307 |
+
</div>
|
| 308 |
+
`;
|
| 309 |
+
feather.replace();
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* Initialize workflow builder demo
|
| 315 |
+
*/
|
| 316 |
+
function initializeWorkflowDemo(element) {
|
| 317 |
+
element.innerHTML = `
|
| 318 |
+
<div class="workflow-demo">
|
| 319 |
+
<div class="workflow-canvas">
|
| 320 |
+
<div class="workflow-node start-node">
|
| 321 |
+
<i data-feather="play"></i>
|
| 322 |
+
<span>Start</span>
|
| 323 |
+
</div>
|
| 324 |
+
<div class="workflow-arrow">→</div>
|
| 325 |
+
<div class="workflow-node llm-node">
|
| 326 |
+
<i data-feather="cpu"></i>
|
| 327 |
+
<span>LLM</span>
|
| 328 |
+
</div>
|
| 329 |
+
<div class="workflow-arrow">→</div>
|
| 330 |
+
<div class="workflow-node end-node">
|
| 331 |
+
<i data-feather="message-circle"></i>
|
| 332 |
+
<span>Response</span>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
<div class="workflow-controls mt-3">
|
| 336 |
+
<button class="btn btn-sm btn-primary" onclick="addWorkflowNode(this)">
|
| 337 |
+
<i data-feather="plus"></i> Add Node
|
| 338 |
+
</button>
|
| 339 |
+
</div>
|
| 340 |
+
</div>
|
| 341 |
+
`;
|
| 342 |
+
feather.replace();
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
/**
|
| 346 |
+
* Initialize chatbot demo
|
| 347 |
+
*/
|
| 348 |
+
function initializeChatbotDemo(element) {
|
| 349 |
+
element.innerHTML = `
|
| 350 |
+
<div class="chatbot-demo">
|
| 351 |
+
<div class="chat-window">
|
| 352 |
+
<div class="chat-messages" id="demo-chat-messages">
|
| 353 |
+
<div class="message bot-message">
|
| 354 |
+
<div class="message-content">
|
| 355 |
+
Hello! I'm your Dify AI assistant. How can I help you today?
|
| 356 |
+
</div>
|
| 357 |
+
</div>
|
| 358 |
+
</div>
|
| 359 |
+
<div class="chat-input">
|
| 360 |
+
<input type="text" class="form-control" placeholder="Type your message..."
|
| 361 |
+
onkeypress="handleDemoChatInput(event)">
|
| 362 |
+
<button class="btn btn-primary" onclick="sendDemoMessage()">
|
| 363 |
+
<i data-feather="send"></i>
|
| 364 |
+
</button>
|
| 365 |
+
</div>
|
| 366 |
+
</div>
|
| 367 |
+
</div>
|
| 368 |
+
`;
|
| 369 |
+
feather.replace();
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
/**
|
| 373 |
+
* Handle demo chat input
|
| 374 |
+
*/
|
| 375 |
+
function handleDemoChatInput(event) {
|
| 376 |
+
if (event.key === 'Enter') {
|
| 377 |
+
sendDemoMessage();
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* Send demo message
|
| 383 |
+
*/
|
| 384 |
+
function sendDemoMessage() {
|
| 385 |
+
const input = event.target.closest('.chat-input').querySelector('input');
|
| 386 |
+
const message = input.value.trim();
|
| 387 |
+
|
| 388 |
+
if (!message) return;
|
| 389 |
+
|
| 390 |
+
const messagesContainer = document.getElementById('demo-chat-messages');
|
| 391 |
+
|
| 392 |
+
// Add user message
|
| 393 |
+
const userMessage = document.createElement('div');
|
| 394 |
+
userMessage.className = 'message user-message';
|
| 395 |
+
userMessage.innerHTML = `<div class="message-content">${message}</div>`;
|
| 396 |
+
messagesContainer.appendChild(userMessage);
|
| 397 |
+
|
| 398 |
+
// Clear input
|
| 399 |
+
input.value = '';
|
| 400 |
+
|
| 401 |
+
// Simulate bot response
|
| 402 |
+
setTimeout(() => {
|
| 403 |
+
const botMessage = document.createElement('div');
|
| 404 |
+
botMessage.className = 'message bot-message';
|
| 405 |
+
botMessage.innerHTML = `
|
| 406 |
+
<div class="message-content">
|
| 407 |
+
That's a great question about Dify! This is a demo response showing how your chatbot would interact with users.
|
| 408 |
+
</div>
|
| 409 |
+
`;
|
| 410 |
+
messagesContainer.appendChild(botMessage);
|
| 411 |
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
| 412 |
+
}, 1000);
|
| 413 |
+
|
| 414 |
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
/**
|
| 418 |
+
* Update progress display
|
| 419 |
+
*/
|
| 420 |
+
function updateProgress() {
|
| 421 |
+
// Update progress bar
|
| 422 |
+
const progressBar = document.getElementById('tutorial-progress-bar');
|
| 423 |
+
if (progressBar) {
|
| 424 |
+
const percentage = ((currentStep + 1) / totalSteps) * 100;
|
| 425 |
+
window.DifyLearning?.animateProgressBar(progressBar, percentage);
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
// Update step counter
|
| 429 |
+
updateStepCounter(currentStep + 1);
|
| 430 |
+
|
| 431 |
+
// Update sidebar navigation
|
| 432 |
+
updateSidebarNavigation();
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
/**
|
| 436 |
+
* Update step counter
|
| 437 |
+
*/
|
| 438 |
+
function updateStepCounter(stepNumber) {
|
| 439 |
+
const counter = document.getElementById('current-step');
|
| 440 |
+
if (counter) {
|
| 441 |
+
counter.textContent = stepNumber;
|
| 442 |
+
}
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
* Update sidebar navigation
|
| 447 |
+
*/
|
| 448 |
+
function updateSidebarNavigation() {
|
| 449 |
+
document.querySelectorAll('.step-nav-link').forEach((link, index) => {
|
| 450 |
+
link.classList.remove('active');
|
| 451 |
+
|
| 452 |
+
if (index === currentStep) {
|
| 453 |
+
link.classList.add('active');
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
// Remove completed indicators (checkmarks disabled)
|
| 457 |
+
const existingCheck = link.querySelector('i[data-feather="check"]');
|
| 458 |
+
if (existingCheck) {
|
| 459 |
+
existingCheck.remove();
|
| 460 |
+
}
|
| 461 |
+
});
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
/**
|
| 465 |
+
* Save progress to server
|
| 466 |
+
*/
|
| 467 |
+
async function saveProgress() {
|
| 468 |
+
if (!currentTutorial) return;
|
| 469 |
+
|
| 470 |
+
try {
|
| 471 |
+
const response = await fetch('/api/progress/update', {
|
| 472 |
+
method: 'POST',
|
| 473 |
+
headers: {
|
| 474 |
+
'Content-Type': 'application/json',
|
| 475 |
+
},
|
| 476 |
+
body: JSON.stringify({
|
| 477 |
+
tutorial_id: currentTutorial.id,
|
| 478 |
+
current_step: currentStep,
|
| 479 |
+
completed: false
|
| 480 |
+
})
|
| 481 |
+
});
|
| 482 |
+
|
| 483 |
+
if (!response.ok) {
|
| 484 |
+
throw new Error('Failed to save progress');
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
} catch (error) {
|
| 488 |
+
console.error('Error saving progress:', error);
|
| 489 |
+
// Show error message to user
|
| 490 |
+
window.DifyLearning?.showToast('Failed to save progress', 'warning');
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
/**
|
| 495 |
+
* Complete tutorial
|
| 496 |
+
*/
|
| 497 |
+
async function completeTutorial() {
|
| 498 |
+
if (!currentTutorial) return;
|
| 499 |
+
|
| 500 |
+
try {
|
| 501 |
+
const response = await fetch('/api/progress/update', {
|
| 502 |
+
method: 'POST',
|
| 503 |
+
headers: {
|
| 504 |
+
'Content-Type': 'application/json',
|
| 505 |
+
},
|
| 506 |
+
body: JSON.stringify({
|
| 507 |
+
tutorial_id: currentTutorial.id,
|
| 508 |
+
current_step: totalSteps - 1,
|
| 509 |
+
completed: true
|
| 510 |
+
})
|
| 511 |
+
});
|
| 512 |
+
|
| 513 |
+
if (response.ok) {
|
| 514 |
+
// Track completion
|
| 515 |
+
window.DifyLearning?.trackEvent('tutorial_completed', {
|
| 516 |
+
tutorial_id: currentTutorial.id,
|
| 517 |
+
total_steps: totalSteps,
|
| 518 |
+
completion_time: new Date().toISOString()
|
| 519 |
+
});
|
| 520 |
+
|
| 521 |
+
// Show completion modal
|
| 522 |
+
const modal = new bootstrap.Modal(document.getElementById('completionModal'));
|
| 523 |
+
modal.show();
|
| 524 |
+
|
| 525 |
+
// Update UI to show completion
|
| 526 |
+
document.querySelectorAll('.progress-circle').forEach(circle => {
|
| 527 |
+
circle.className = 'progress-circle completed';
|
| 528 |
+
circle.innerHTML = '<i data-feather="check"></i>';
|
| 529 |
+
});
|
| 530 |
+
feather.replace();
|
| 531 |
+
|
| 532 |
+
} else {
|
| 533 |
+
throw new Error('Failed to complete tutorial');
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
} catch (error) {
|
| 537 |
+
console.error('Error completing tutorial:', error);
|
| 538 |
+
window.DifyLearning?.showToast('Failed to save completion status', 'warning');
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
/**
|
| 543 |
+
* Track time spent on step
|
| 544 |
+
*/
|
| 545 |
+
function trackStepTime(stepIndex, seconds) {
|
| 546 |
+
if (seconds < 5) return; // Ignore very short durations
|
| 547 |
+
|
| 548 |
+
const stepData = {
|
| 549 |
+
tutorial_id: currentTutorial?.id,
|
| 550 |
+
step: stepIndex + 1,
|
| 551 |
+
time_spent: seconds
|
| 552 |
+
};
|
| 553 |
+
|
| 554 |
+
// Store locally for analytics
|
| 555 |
+
const stepTimes = JSON.parse(localStorage.getItem('dify_step_times') || '[]');
|
| 556 |
+
stepTimes.push({
|
| 557 |
+
...stepData,
|
| 558 |
+
timestamp: new Date().toISOString()
|
| 559 |
+
});
|
| 560 |
+
localStorage.setItem('dify_step_times', JSON.stringify(stepTimes.slice(-1000)));
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
/**
|
| 564 |
+
* Add workflow node (demo function)
|
| 565 |
+
*/
|
| 566 |
+
function addWorkflowNode(button) {
|
| 567 |
+
const canvas = button.closest('.workflow-demo').querySelector('.workflow-canvas');
|
| 568 |
+
const newNode = document.createElement('div');
|
| 569 |
+
newNode.className = 'workflow-node';
|
| 570 |
+
newNode.innerHTML = `
|
| 571 |
+
<i data-feather="settings"></i>
|
| 572 |
+
<span>New Node</span>
|
| 573 |
+
`;
|
| 574 |
+
|
| 575 |
+
// Add arrow before new node
|
| 576 |
+
const arrow = document.createElement('div');
|
| 577 |
+
arrow.className = 'workflow-arrow';
|
| 578 |
+
arrow.textContent = '→';
|
| 579 |
+
|
| 580 |
+
// Insert before end node
|
| 581 |
+
const endNode = canvas.querySelector('.end-node');
|
| 582 |
+
canvas.insertBefore(arrow, endNode);
|
| 583 |
+
canvas.insertBefore(newNode, endNode);
|
| 584 |
+
|
| 585 |
+
feather.replace();
|
| 586 |
+
|
| 587 |
+
// Show success message
|
| 588 |
+
window.DifyLearning?.showToast('Node added to workflow!', 'success');
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
// Make functions available globally
|
| 592 |
+
window.navigateToStep = navigateToStep;
|
| 593 |
+
window.completeTutorial = completeTutorial;
|
| 594 |
+
window.handleDemoChatInput = handleDemoChatInput;
|
| 595 |
+
window.sendDemoMessage = sendDemoMessage;
|
| 596 |
+
window.addWorkflowNode = addWorkflowNode;
|
templates/base.html
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>{% block title %}Dify AI Learning Platform{% endblock %}</title>
|
| 7 |
+
|
| 8 |
+
<!-- Bootstrap CSS -->
|
| 9 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 10 |
+
<!-- Feather Icons -->
|
| 11 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 12 |
+
<!-- Custom CSS -->
|
| 13 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
| 14 |
+
|
| 15 |
+
{% block extra_head %}{% endblock %}
|
| 16 |
+
</head>
|
| 17 |
+
<body>
|
| 18 |
+
<!-- Navigation -->
|
| 19 |
+
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
|
| 20 |
+
<div class="container">
|
| 21 |
+
<a class="navbar-brand" href="{{ url_for('index') }}">
|
| 22 |
+
<i data-feather="book-open" class="me-2"></i>
|
| 23 |
+
Dify AI Learning
|
| 24 |
+
</a>
|
| 25 |
+
|
| 26 |
+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
| 27 |
+
<span class="navbar-toggler-icon"></span>
|
| 28 |
+
</button>
|
| 29 |
+
|
| 30 |
+
<div class="collapse navbar-collapse" id="navbarNav">
|
| 31 |
+
<ul class="navbar-nav me-auto">
|
| 32 |
+
<li class="nav-item">
|
| 33 |
+
<a class="nav-link" href="{{ url_for('index') }}">
|
| 34 |
+
<i data-feather="home" class="me-1"></i>Home
|
| 35 |
+
</a>
|
| 36 |
+
</li>
|
| 37 |
+
<li class="nav-item">
|
| 38 |
+
<a class="nav-link" href="{{ url_for('progress') }}">
|
| 39 |
+
<i data-feather="trending-up" class="me-1"></i>Progress
|
| 40 |
+
</a>
|
| 41 |
+
</li>
|
| 42 |
+
</ul>
|
| 43 |
+
|
| 44 |
+
<ul class="navbar-nav">
|
| 45 |
+
{% if session.user_id %}
|
| 46 |
+
<li class="nav-item">
|
| 47 |
+
<a class="nav-link" href="{{ url_for('logout') }}">
|
| 48 |
+
<i data-feather="log-out" class="me-1"></i>Logout
|
| 49 |
+
</a>
|
| 50 |
+
</li>
|
| 51 |
+
{% else %}
|
| 52 |
+
<li class="nav-item">
|
| 53 |
+
<a class="nav-link" href="{{ url_for('login') }}">
|
| 54 |
+
<i data-feather="log-in" class="me-1"></i>Login
|
| 55 |
+
</a>
|
| 56 |
+
</li>
|
| 57 |
+
{% endif %}
|
| 58 |
+
</ul>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
</nav>
|
| 62 |
+
|
| 63 |
+
<!-- Main Content -->
|
| 64 |
+
<main class="main-content">
|
| 65 |
+
{% block content %}{% endblock %}
|
| 66 |
+
</main>
|
| 67 |
+
|
| 68 |
+
<!-- Footer -->
|
| 69 |
+
<footer class="bg-dark text-light py-4 mt-5">
|
| 70 |
+
<div class="container">
|
| 71 |
+
<div class="row">
|
| 72 |
+
<div class="col-md-6">
|
| 73 |
+
<h5>Dify AI Learning Platform</h5>
|
| 74 |
+
<p>Master Dify AI with our comprehensive tutorials and hands-on projects.</p>
|
| 75 |
+
</div>
|
| 76 |
+
<div class="col-md-6">
|
| 77 |
+
<h5>Resources</h5>
|
| 78 |
+
<ul class="list-unstyled">
|
| 79 |
+
<li><a href="https://docs.dify.ai/" target="_blank" class="text-light">Official Documentation</a></li>
|
| 80 |
+
<li><a href="https://github.com/langgenius/dify" target="_blank" class="text-light">GitHub Repository</a></li>
|
| 81 |
+
<li><a href="https://dify.ai/" target="_blank" class="text-light">Dify.ai Cloud</a></li>
|
| 82 |
+
</ul>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
</footer>
|
| 87 |
+
|
| 88 |
+
<!-- Bootstrap JS -->
|
| 89 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
| 90 |
+
<!-- Custom JS -->
|
| 91 |
+
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
| 92 |
+
|
| 93 |
+
{% block extra_scripts %}{% endblock %}
|
| 94 |
+
|
| 95 |
+
<script>
|
| 96 |
+
// Initialize Feather icons
|
| 97 |
+
feather.replace();
|
| 98 |
+
</script>
|
| 99 |
+
</body>
|
| 100 |
+
</html>
|
templates/index.html
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
|
| 3 |
+
{% block content %}
|
| 4 |
+
<div class="container py-5">
|
| 5 |
+
<!-- Hero Section -->
|
| 6 |
+
<div class="hero-section text-center mb-5">
|
| 7 |
+
<h1 class="display-4 fw-bold mb-3">Master Dify AI</h1>
|
| 8 |
+
<p class="lead mb-4">Learn to build powerful AI applications with our comprehensive, step-by-step tutorials designed for beginners</p>
|
| 9 |
+
<div class="hero-stats row justify-content-center">
|
| 10 |
+
<div class="col-md-2 col-4">
|
| 11 |
+
<div class="stat-item">
|
| 12 |
+
<h3 class="stat-number">{{ tutorials|length }}</h3>
|
| 13 |
+
<p class="stat-label">Tutorials</p>
|
| 14 |
+
</div>
|
| 15 |
+
</div>
|
| 16 |
+
<div class="col-md-2 col-4">
|
| 17 |
+
<div class="stat-item">
|
| 18 |
+
<h3 class="stat-number">{{ projects|length }}</h3>
|
| 19 |
+
<p class="stat-label">Projects</p>
|
| 20 |
+
</div>
|
| 21 |
+
</div>
|
| 22 |
+
<div class="col-md-2 col-4">
|
| 23 |
+
<div class="stat-item">
|
| 24 |
+
<h3 class="stat-number">0</h3>
|
| 25 |
+
<p class="stat-label">Coding Req.</p>
|
| 26 |
+
</div>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<!-- Learning Path -->
|
| 32 |
+
<section class="mb-5">
|
| 33 |
+
<h2 class="section-title">
|
| 34 |
+
<i data-feather="map" class="me-2"></i>
|
| 35 |
+
Learning Path
|
| 36 |
+
</h2>
|
| 37 |
+
<p class="section-subtitle">Follow our structured learning path to master Dify AI from basics to advanced topics</p>
|
| 38 |
+
|
| 39 |
+
<div class="learning-path">
|
| 40 |
+
{% for tutorial in tutorials %}
|
| 41 |
+
<div class="path-item">
|
| 42 |
+
<div class="path-number">{{ loop.index }}</div>
|
| 43 |
+
<div class="path-content">
|
| 44 |
+
<div class="card tutorial-card">
|
| 45 |
+
<div class="card-body">
|
| 46 |
+
<div class="d-flex justify-content-between align-items-start">
|
| 47 |
+
<div>
|
| 48 |
+
<h5 class="card-title">{{ tutorial.title }}</h5>
|
| 49 |
+
<p class="card-text">{{ tutorial.description }}</p>
|
| 50 |
+
<div class="tutorial-meta">
|
| 51 |
+
<span class="badge bg-{{ tutorial.difficulty_color }}">{{ tutorial.difficulty }}</span>
|
| 52 |
+
<span class="text-muted ms-2">
|
| 53 |
+
<i data-feather="clock" class="small me-1"></i>
|
| 54 |
+
{{ tutorial.estimated_time }} min
|
| 55 |
+
</span>
|
| 56 |
+
</div>
|
| 57 |
+
</div>
|
| 58 |
+
<div class="tutorial-progress">
|
| 59 |
+
<div class="progress-circle not-started">
|
| 60 |
+
<i data-feather="play"></i>
|
| 61 |
+
</div>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
<div class="mt-3">
|
| 65 |
+
<a href="{{ url_for('tutorial', slug=tutorial.slug) }}" class="btn btn-primary">
|
| 66 |
+
Start Tutorial
|
| 67 |
+
</a>
|
| 68 |
+
</div>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
</div>
|
| 72 |
+
</div>
|
| 73 |
+
{% endfor %}
|
| 74 |
+
</div>
|
| 75 |
+
</section>
|
| 76 |
+
|
| 77 |
+
<!-- Hands-on Projects -->
|
| 78 |
+
<section class="mb-5">
|
| 79 |
+
<h2 class="section-title">
|
| 80 |
+
<i data-feather="code" class="me-2"></i>
|
| 81 |
+
Hands-on Projects
|
| 82 |
+
</h2>
|
| 83 |
+
<p class="section-subtitle">Apply your knowledge with real-world projects</p>
|
| 84 |
+
|
| 85 |
+
<div class="row">
|
| 86 |
+
{% for project in projects %}
|
| 87 |
+
<div class="col-md-6 col-lg-4 mb-4">
|
| 88 |
+
<div class="card project-card h-100">
|
| 89 |
+
<div class="card-body">
|
| 90 |
+
<div class="project-icon mb-3">
|
| 91 |
+
<i data-feather="{{ project.icon }}"></i>
|
| 92 |
+
</div>
|
| 93 |
+
<h5 class="card-title">{{ project.title }}</h5>
|
| 94 |
+
<p class="card-text">{{ project.description }}</p>
|
| 95 |
+
<div class="project-meta mb-3">
|
| 96 |
+
<span class="badge bg-{{ project.difficulty_color }}">{{ project.difficulty }}</span>
|
| 97 |
+
<span class="text-muted ms-2">
|
| 98 |
+
<i data-feather="clock" class="small me-1"></i>
|
| 99 |
+
{{ project.estimated_time }} min
|
| 100 |
+
</span>
|
| 101 |
+
</div>
|
| 102 |
+
<a href="{{ url_for('project', slug=project.slug) }}" class="btn btn-outline-primary">
|
| 103 |
+
Start Project
|
| 104 |
+
</a>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
{% endfor %}
|
| 109 |
+
</div>
|
| 110 |
+
</section>
|
| 111 |
+
|
| 112 |
+
<!-- Features -->
|
| 113 |
+
<section class="features-section">
|
| 114 |
+
<h2 class="section-title text-center">
|
| 115 |
+
<i data-feather="star" class="me-2"></i>
|
| 116 |
+
Why Choose Our Platform?
|
| 117 |
+
</h2>
|
| 118 |
+
|
| 119 |
+
<div class="row mt-4">
|
| 120 |
+
<div class="col-md-4 mb-4">
|
| 121 |
+
<div class="feature-item text-center">
|
| 122 |
+
<div class="feature-icon">
|
| 123 |
+
<i data-feather="users"></i>
|
| 124 |
+
</div>
|
| 125 |
+
<h4>Beginner Friendly</h4>
|
| 126 |
+
<p>No coding experience required. Learn Dify AI with visual, step-by-step tutorials.</p>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
<div class="col-md-4 mb-4">
|
| 130 |
+
<div class="feature-item text-center">
|
| 131 |
+
<div class="feature-icon">
|
| 132 |
+
<i data-feather="trending-up"></i>
|
| 133 |
+
</div>
|
| 134 |
+
<h4>Progress Tracking</h4>
|
| 135 |
+
<p>Track your learning progress and see how far you've come in your AI journey.</p>
|
| 136 |
+
</div>
|
| 137 |
+
</div>
|
| 138 |
+
<div class="col-md-4 mb-4">
|
| 139 |
+
<div class="feature-item text-center">
|
| 140 |
+
<div class="feature-icon">
|
| 141 |
+
<i data-feather="play-circle"></i>
|
| 142 |
+
</div>
|
| 143 |
+
<h4>Interactive Learning</h4>
|
| 144 |
+
<p>Learn by doing with interactive tutorials and real-world project examples.</p>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
</section>
|
| 149 |
+
</div>
|
| 150 |
+
{% endblock %}
|
templates/progress.html
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
|
| 3 |
+
{% block title %}Learning Progress - Dify AI Learning{% endblock %}
|
| 4 |
+
|
| 5 |
+
{% block content %}
|
| 6 |
+
<div class="container py-4">
|
| 7 |
+
<div class="row">
|
| 8 |
+
<div class="col-12">
|
| 9 |
+
<h1 class="page-title">
|
| 10 |
+
<i data-feather="trending-up" class="me-2"></i>
|
| 11 |
+
Your Learning Progress
|
| 12 |
+
</h1>
|
| 13 |
+
<p class="page-subtitle">Track your journey through Dify AI mastery</p>
|
| 14 |
+
</div>
|
| 15 |
+
</div>
|
| 16 |
+
|
| 17 |
+
<!-- Progress Overview -->
|
| 18 |
+
<div class="row mb-5">
|
| 19 |
+
<div class="col-md-3 col-6 mb-3">
|
| 20 |
+
<div class="card stats-card">
|
| 21 |
+
<div class="card-body text-center">
|
| 22 |
+
<div class="stats-icon">
|
| 23 |
+
<i data-feather="book-open"></i>
|
| 24 |
+
</div>
|
| 25 |
+
<h3 class="stats-number">{{ progress_data|selectattr('progress')|list|length }}</h3>
|
| 26 |
+
<p class="stats-label">Started</p>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
<div class="col-md-3 col-6 mb-3">
|
| 31 |
+
<div class="card stats-card">
|
| 32 |
+
<div class="card-body text-center">
|
| 33 |
+
<div class="stats-icon">
|
| 34 |
+
<i data-feather="check-circle"></i>
|
| 35 |
+
</div>
|
| 36 |
+
<h3 class="stats-number">{{ progress_data|selectattr('progress.completed')|list|length }}</h3>
|
| 37 |
+
<p class="stats-label">Completed</p>
|
| 38 |
+
</div>
|
| 39 |
+
</div>
|
| 40 |
+
</div>
|
| 41 |
+
<div class="col-md-3 col-6 mb-3">
|
| 42 |
+
<div class="card stats-card">
|
| 43 |
+
<div class="card-body text-center">
|
| 44 |
+
<div class="stats-icon">
|
| 45 |
+
<i data-feather="play-circle"></i>
|
| 46 |
+
</div>
|
| 47 |
+
<h3 class="stats-number">{{ progress_data|rejectattr('progress')|list|length }}</h3>
|
| 48 |
+
<p class="stats-label">Not Started</p>
|
| 49 |
+
</div>
|
| 50 |
+
</div>
|
| 51 |
+
</div>
|
| 52 |
+
<div class="col-md-3 col-6 mb-3">
|
| 53 |
+
<div class="card stats-card">
|
| 54 |
+
<div class="card-body text-center">
|
| 55 |
+
<div class="stats-icon">
|
| 56 |
+
<i data-feather="clock"></i>
|
| 57 |
+
</div>
|
| 58 |
+
<h3 class="stats-number">
|
| 59 |
+
{{ (progress_data|selectattr('progress.completed')|map(attribute='tutorial.estimated_time')|sum) or 0 }}
|
| 60 |
+
</h3>
|
| 61 |
+
<p class="stats-label">Minutes Learned</p>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
<!-- Progress Timeline -->
|
| 68 |
+
<div class="row">
|
| 69 |
+
<div class="col-12">
|
| 70 |
+
<h2 class="section-title">
|
| 71 |
+
<i data-feather="list" class="me-2"></i>
|
| 72 |
+
Tutorial Progress
|
| 73 |
+
</h2>
|
| 74 |
+
|
| 75 |
+
<div class="progress-timeline">
|
| 76 |
+
{% for item in progress_data %}
|
| 77 |
+
<div class="progress-item">
|
| 78 |
+
<div class="progress-marker">
|
| 79 |
+
{% if item.progress and item.progress.completed %}
|
| 80 |
+
<div class="marker completed">
|
| 81 |
+
<i data-feather="check"></i>
|
| 82 |
+
</div>
|
| 83 |
+
{% elif item.progress %}
|
| 84 |
+
<div class="marker in-progress">
|
| 85 |
+
<span>{{ item.progress.current_step + 1 }}</span>
|
| 86 |
+
</div>
|
| 87 |
+
{% else %}
|
| 88 |
+
<div class="marker not-started">
|
| 89 |
+
<i data-feather="circle"></i>
|
| 90 |
+
</div>
|
| 91 |
+
{% endif %}
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<div class="progress-content">
|
| 95 |
+
<div class="card">
|
| 96 |
+
<div class="card-body">
|
| 97 |
+
<div class="d-flex justify-content-between align-items-start">
|
| 98 |
+
<div>
|
| 99 |
+
<h5 class="card-title">{{ item.tutorial.title }}</h5>
|
| 100 |
+
<p class="card-text">{{ item.tutorial.description }}</p>
|
| 101 |
+
<div class="tutorial-meta">
|
| 102 |
+
<span class="badge bg-{{ item.tutorial.difficulty_color }}">
|
| 103 |
+
{{ item.tutorial.difficulty }}
|
| 104 |
+
</span>
|
| 105 |
+
<span class="text-muted ms-2">
|
| 106 |
+
<i data-feather="clock" class="small me-1"></i>
|
| 107 |
+
{{ item.tutorial.estimated_time }} min
|
| 108 |
+
</span>
|
| 109 |
+
{% if item.progress and item.progress.completed %}
|
| 110 |
+
<span class="text-success ms-2">
|
| 111 |
+
<i data-feather="calendar" class="small me-1"></i>
|
| 112 |
+
Completed {{ item.progress.completion_date.strftime('%b %d') }}
|
| 113 |
+
</span>
|
| 114 |
+
{% endif %}
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
<div class="progress-actions">
|
| 118 |
+
{% if item.progress and item.progress.completed %}
|
| 119 |
+
<a href="{{ url_for('tutorial', slug=item.tutorial.slug) }}"
|
| 120 |
+
class="btn btn-outline-primary btn-sm">
|
| 121 |
+
Review
|
| 122 |
+
</a>
|
| 123 |
+
{% elif item.progress %}
|
| 124 |
+
<a href="{{ url_for('tutorial', slug=item.tutorial.slug) }}"
|
| 125 |
+
class="btn btn-primary btn-sm">
|
| 126 |
+
Continue
|
| 127 |
+
</a>
|
| 128 |
+
{% else %}
|
| 129 |
+
<a href="{{ url_for('tutorial', slug=item.tutorial.slug) }}"
|
| 130 |
+
class="btn btn-outline-primary btn-sm">
|
| 131 |
+
Start
|
| 132 |
+
</a>
|
| 133 |
+
{% endif %}
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
{% if item.progress and not item.progress.completed %}
|
| 138 |
+
<div class="tutorial-progress mt-3">
|
| 139 |
+
<div class="progress">
|
| 140 |
+
<div class="progress-bar" role="progressbar"
|
| 141 |
+
style="width: {{ (item.progress.current_step / item.tutorial.total_steps * 100)|round }}%">
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
<small class="text-muted">
|
| 145 |
+
Step {{ item.progress.current_step + 1 }} of {{ item.tutorial.total_steps }}
|
| 146 |
+
</small>
|
| 147 |
+
</div>
|
| 148 |
+
{% endif %}
|
| 149 |
+
</div>
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
{% endfor %}
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
{% endblock %}
|
templates/project.html
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
|
| 3 |
+
{% block title %}{{ project.title }} - Dify AI Learning{% endblock %}
|
| 4 |
+
|
| 5 |
+
{% block content %}
|
| 6 |
+
<div class="container py-4">
|
| 7 |
+
<div class="row">
|
| 8 |
+
<!-- Project Info Sidebar -->
|
| 9 |
+
<div class="col-lg-4">
|
| 10 |
+
<div class="project-info-card sticky-top">
|
| 11 |
+
<div class="card">
|
| 12 |
+
<div class="card-body">
|
| 13 |
+
<div class="project-icon mb-3">
|
| 14 |
+
<i data-feather="{{ project.icon }}" class="large-icon"></i>
|
| 15 |
+
</div>
|
| 16 |
+
<h5 class="card-title">{{ project.title }}</h5>
|
| 17 |
+
<p class="card-text">{{ project.description }}</p>
|
| 18 |
+
|
| 19 |
+
<div class="project-details">
|
| 20 |
+
<div class="detail-item">
|
| 21 |
+
<strong>Difficulty:</strong>
|
| 22 |
+
<span class="badge bg-{{ project.difficulty_color }}">{{ project.difficulty }}</span>
|
| 23 |
+
</div>
|
| 24 |
+
<div class="detail-item">
|
| 25 |
+
<strong>Duration:</strong>
|
| 26 |
+
<span><i data-feather="clock" class="small me-1"></i>{{ project.estimated_time }} minutes</span>
|
| 27 |
+
</div>
|
| 28 |
+
<div class="detail-item">
|
| 29 |
+
<strong>Category:</strong>
|
| 30 |
+
<span>{{ project.category }}</span>
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
{% if project.prerequisites %}
|
| 35 |
+
<div class="prerequisites mt-3">
|
| 36 |
+
<h6>Prerequisites:</h6>
|
| 37 |
+
<ul class="small">
|
| 38 |
+
{% for prereq in project.prerequisites %}
|
| 39 |
+
<li>{{ prereq }}</li>
|
| 40 |
+
{% endfor %}
|
| 41 |
+
</ul>
|
| 42 |
+
</div>
|
| 43 |
+
{% endif %}
|
| 44 |
+
|
| 45 |
+
<div class="project-resources mt-3">
|
| 46 |
+
<h6>What You'll Build:</h6>
|
| 47 |
+
<ul class="small">
|
| 48 |
+
{% for outcome in project.outcomes %}
|
| 49 |
+
<li>{{ outcome }}</li>
|
| 50 |
+
{% endfor %}
|
| 51 |
+
</ul>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
</div>
|
| 57 |
+
|
| 58 |
+
<!-- Project Content -->
|
| 59 |
+
<div class="col-lg-8">
|
| 60 |
+
<nav aria-label="breadcrumb">
|
| 61 |
+
<ol class="breadcrumb">
|
| 62 |
+
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">Home</a></li>
|
| 63 |
+
<li class="breadcrumb-item active">{{ project.title }}</li>
|
| 64 |
+
</ol>
|
| 65 |
+
</nav>
|
| 66 |
+
|
| 67 |
+
<div class="project-content">
|
| 68 |
+
<h1 class="project-title">{{ project.title }}</h1>
|
| 69 |
+
|
| 70 |
+
<!-- Project Overview -->
|
| 71 |
+
<section class="project-section">
|
| 72 |
+
<h2>Project Overview</h2>
|
| 73 |
+
<div class="project-overview">
|
| 74 |
+
{{ project.overview|safe }}
|
| 75 |
+
</div>
|
| 76 |
+
</section>
|
| 77 |
+
|
| 78 |
+
<!-- Project Steps -->
|
| 79 |
+
{% for section in project.sections %}
|
| 80 |
+
<section class="project-section">
|
| 81 |
+
<h2>{{ section.title }}</h2>
|
| 82 |
+
<div class="section-content">
|
| 83 |
+
{{ section.content|safe }}
|
| 84 |
+
|
| 85 |
+
{% if section.steps %}
|
| 86 |
+
<div class="project-steps">
|
| 87 |
+
{% for step in section.steps %}
|
| 88 |
+
<div class="project-step">
|
| 89 |
+
<div class="step-header">
|
| 90 |
+
<h4>
|
| 91 |
+
<span class="step-number">{{ loop.index }}</span>
|
| 92 |
+
{{ step.title }}
|
| 93 |
+
</h4>
|
| 94 |
+
</div>
|
| 95 |
+
<div class="step-content">
|
| 96 |
+
{{ step.content|safe }}
|
| 97 |
+
|
| 98 |
+
{% if step.code %}
|
| 99 |
+
<div class="code-block mt-3">
|
| 100 |
+
<h6>Configuration:</h6>
|
| 101 |
+
<pre><code>{{ step.code }}</code></pre>
|
| 102 |
+
</div>
|
| 103 |
+
{% endif %}
|
| 104 |
+
|
| 105 |
+
{% if step.screenshot %}
|
| 106 |
+
<div class="screenshot mt-3">
|
| 107 |
+
<img src="{{ step.screenshot }}" alt="{{ step.title }}" class="img-fluid rounded border">
|
| 108 |
+
</div>
|
| 109 |
+
{% endif %}
|
| 110 |
+
|
| 111 |
+
{% if step.tips %}
|
| 112 |
+
<div class="alert alert-info mt-3">
|
| 113 |
+
<h6><i data-feather="lightbulb" class="me-2"></i>Tips:</h6>
|
| 114 |
+
<ul class="mb-0">
|
| 115 |
+
{% for tip in step.tips %}
|
| 116 |
+
<li>{{ tip }}</li>
|
| 117 |
+
{% endfor %}
|
| 118 |
+
</ul>
|
| 119 |
+
</div>
|
| 120 |
+
{% endif %}
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
{% endfor %}
|
| 124 |
+
</div>
|
| 125 |
+
{% endif %}
|
| 126 |
+
</div>
|
| 127 |
+
</section>
|
| 128 |
+
{% endfor %}
|
| 129 |
+
|
| 130 |
+
<!-- Next Steps -->
|
| 131 |
+
<section class="project-section">
|
| 132 |
+
<h2>Next Steps</h2>
|
| 133 |
+
<div class="next-steps">
|
| 134 |
+
<p>Congratulations on completing this project! Here are some suggestions for what to do next:</p>
|
| 135 |
+
<div class="row">
|
| 136 |
+
<div class="col-md-6">
|
| 137 |
+
<div class="card">
|
| 138 |
+
<div class="card-body">
|
| 139 |
+
<h5><i data-feather="arrow-right" class="me-2"></i>Try Another Project</h5>
|
| 140 |
+
<p>Apply your skills to a different type of AI application</p>
|
| 141 |
+
<a href="{{ url_for('index') }}#projects" class="btn btn-outline-primary">Browse Projects</a>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
<div class="col-md-6">
|
| 146 |
+
<div class="card">
|
| 147 |
+
<div class="card-body">
|
| 148 |
+
<h5><i data-feather="book" class="me-2"></i>Learn More</h5>
|
| 149 |
+
<p>Dive deeper into advanced Dify features and techniques</p>
|
| 150 |
+
<a href="{{ url_for('index') }}#tutorials" class="btn btn-outline-primary">View Tutorials</a>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
</section>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
{% endblock %}
|
templates/tutorial.html
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
|
| 3 |
+
{% block title %}{{ tutorial.title }} - Dify AI Learning{% endblock %}
|
| 4 |
+
|
| 5 |
+
{% block extra_head %}
|
| 6 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='js/tutorial.js') }}">
|
| 7 |
+
{% endblock %}
|
| 8 |
+
|
| 9 |
+
{% block content %}
|
| 10 |
+
<div class="container py-4">
|
| 11 |
+
<div class="row">
|
| 12 |
+
<!-- Sidebar Navigation -->
|
| 13 |
+
<div class="col-lg-3">
|
| 14 |
+
<div class="tutorial-sidebar sticky-top">
|
| 15 |
+
<div class="tutorial-progress-info mb-4">
|
| 16 |
+
<h6 class="text-muted">Tutorial Progress</h6>
|
| 17 |
+
<div class="progress mb-2">
|
| 18 |
+
<div class="progress-bar" role="progressbar"
|
| 19 |
+
style="width: {{ ((user_progress.current_step if user_progress else 0) / tutorial.steps|length * 100)|round }}%"
|
| 20 |
+
id="tutorial-progress-bar">
|
| 21 |
+
</div>
|
| 22 |
+
</div>
|
| 23 |
+
<small class="text-muted">
|
| 24 |
+
Step <span id="current-step">{{ user_progress.current_step + 1 if user_progress else 1 }}</span>
|
| 25 |
+
of {{ tutorial.steps|length }}
|
| 26 |
+
</small>
|
| 27 |
+
</div>
|
| 28 |
+
|
| 29 |
+
<nav class="tutorial-nav">
|
| 30 |
+
<h6 class="text-muted mb-3">Steps</h6>
|
| 31 |
+
<ul class="nav nav-pills flex-column" id="tutorial-steps-nav">
|
| 32 |
+
{% for step in tutorial.steps %}
|
| 33 |
+
<li class="nav-item">
|
| 34 |
+
<a class="nav-link step-nav-link {% if loop.index0 == (user_progress.current_step if user_progress else 0) %}active{% endif %}"
|
| 35 |
+
href="#step-{{ loop.index0 }}"
|
| 36 |
+
data-step="{{ loop.index0 }}">
|
| 37 |
+
<span class="step-number">{{ loop.index }}</span>
|
| 38 |
+
{{ step.title }}
|
| 39 |
+
|
| 40 |
+
</a>
|
| 41 |
+
</li>
|
| 42 |
+
{% endfor %}
|
| 43 |
+
</ul>
|
| 44 |
+
</nav>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<!-- Main Content -->
|
| 49 |
+
<div class="col-lg-9">
|
| 50 |
+
<!-- Tutorial Header -->
|
| 51 |
+
<div class="tutorial-header mb-4">
|
| 52 |
+
<nav aria-label="breadcrumb">
|
| 53 |
+
<ol class="breadcrumb">
|
| 54 |
+
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">Home</a></li>
|
| 55 |
+
<li class="breadcrumb-item active">{{ tutorial.title }}</li>
|
| 56 |
+
</ol>
|
| 57 |
+
</nav>
|
| 58 |
+
|
| 59 |
+
<h1 class="tutorial-title">{{ tutorial.title }}</h1>
|
| 60 |
+
<div class="tutorial-meta">
|
| 61 |
+
<span class="badge bg-{{ tutorial.difficulty_color }} me-2">{{ tutorial.difficulty }}</span>
|
| 62 |
+
<span class="text-muted">
|
| 63 |
+
<i data-feather="clock" class="small me-1"></i>
|
| 64 |
+
{{ tutorial.estimated_time }} minutes
|
| 65 |
+
</span>
|
| 66 |
+
<span class="text-muted ms-3">
|
| 67 |
+
<i data-feather="bookmark" class="small me-1"></i>
|
| 68 |
+
{{ tutorial.category }}
|
| 69 |
+
</span>
|
| 70 |
+
</div>
|
| 71 |
+
<p class="tutorial-description mt-3">{{ tutorial.description }}</p>
|
| 72 |
+
</div>
|
| 73 |
+
|
| 74 |
+
<!-- Tutorial Steps -->
|
| 75 |
+
<div class="tutorial-content">
|
| 76 |
+
{% for step in tutorial.steps %}
|
| 77 |
+
<div class="tutorial-step {% if loop.index0 == (user_progress.current_step if user_progress else 0) %}active{% endif %}"
|
| 78 |
+
id="step-{{ loop.index0 }}"
|
| 79 |
+
data-step="{{ loop.index0 }}">
|
| 80 |
+
|
| 81 |
+
<div class="step-header">
|
| 82 |
+
<h2 class="step-title">
|
| 83 |
+
<span class="step-number-badge">{{ loop.index }}</span>
|
| 84 |
+
{{ step.title }}
|
| 85 |
+
</h2>
|
| 86 |
+
{% if step.estimated_time %}
|
| 87 |
+
<span class="step-time">
|
| 88 |
+
<i data-feather="clock" class="small me-1"></i>
|
| 89 |
+
{{ step.estimated_time }} min
|
| 90 |
+
</span>
|
| 91 |
+
{% endif %}
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<div class="step-content">
|
| 95 |
+
{{ step.content|safe }}
|
| 96 |
+
|
| 97 |
+
{% if step.code_example %}
|
| 98 |
+
<div class="code-example mt-4">
|
| 99 |
+
<h6>Example:</h6>
|
| 100 |
+
<pre><code>{{ step.code_example }}</code></pre>
|
| 101 |
+
</div>
|
| 102 |
+
{% endif %}
|
| 103 |
+
|
| 104 |
+
{% if step.interactive_demo %}
|
| 105 |
+
<div class="interactive-demo mt-4">
|
| 106 |
+
<h6>Interactive Demo:</h6>
|
| 107 |
+
<div class="demo-container">
|
| 108 |
+
{{ step.interactive_demo|safe }}
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
+
{% endif %}
|
| 112 |
+
|
| 113 |
+
{% if step.tips %}
|
| 114 |
+
<div class="alert alert-info mt-4">
|
| 115 |
+
<h6><i data-feather="lightbulb" class="me-2"></i>Tips:</h6>
|
| 116 |
+
<ul class="mb-0">
|
| 117 |
+
{% for tip in step.tips %}
|
| 118 |
+
<li>{{ tip }}</li>
|
| 119 |
+
{% endfor %}
|
| 120 |
+
</ul>
|
| 121 |
+
</div>
|
| 122 |
+
{% endif %}
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
+
<!-- Step Navigation -->
|
| 126 |
+
<div class="step-navigation mt-4 pt-4 border-top">
|
| 127 |
+
<div class="d-flex justify-content-between">
|
| 128 |
+
<div>
|
| 129 |
+
{% if loop.index0 > 0 %}
|
| 130 |
+
<button class="btn btn-outline-secondary"
|
| 131 |
+
onclick="navigateToStep({{ loop.index0 - 1 }})">
|
| 132 |
+
<i data-feather="chevron-left" class="me-1"></i>
|
| 133 |
+
Previous
|
| 134 |
+
</button>
|
| 135 |
+
{% endif %}
|
| 136 |
+
</div>
|
| 137 |
+
<div>
|
| 138 |
+
{% if loop.index0 < tutorial.steps|length - 1 %}
|
| 139 |
+
<button class="btn btn-primary"
|
| 140 |
+
onclick="navigateToStep({{ loop.index0 + 1 }})">
|
| 141 |
+
Next
|
| 142 |
+
<i data-feather="chevron-right" class="ms-1"></i>
|
| 143 |
+
</button>
|
| 144 |
+
{% else %}
|
| 145 |
+
<button class="btn btn-success" onclick="completeTutorial()">
|
| 146 |
+
<i data-feather="check" class="me-1"></i>
|
| 147 |
+
Complete Tutorial
|
| 148 |
+
</button>
|
| 149 |
+
{% endif %}
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
</div>
|
| 154 |
+
{% endfor %}
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
|
| 160 |
+
<!-- Tutorial completion modal -->
|
| 161 |
+
<div class="modal fade" id="completionModal" tabindex="-1">
|
| 162 |
+
<div class="modal-dialog">
|
| 163 |
+
<div class="modal-content">
|
| 164 |
+
<div class="modal-header">
|
| 165 |
+
<h5 class="modal-title">
|
| 166 |
+
<i data-feather="award" class="me-2"></i>
|
| 167 |
+
Congratulations!
|
| 168 |
+
</h5>
|
| 169 |
+
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
| 170 |
+
</div>
|
| 171 |
+
<div class="modal-body">
|
| 172 |
+
<p>You've successfully completed <strong>{{ tutorial.title }}</strong>!</p>
|
| 173 |
+
<p>You're ready to move on to the next tutorial or try a hands-on project.</p>
|
| 174 |
+
</div>
|
| 175 |
+
<div class="modal-footer">
|
| 176 |
+
<a href="{{ url_for('index') }}" class="btn btn-primary">Back to Home</a>
|
| 177 |
+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Continue Learning</button>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
{% endblock %}
|
| 183 |
+
|
| 184 |
+
{% block extra_scripts %}
|
| 185 |
+
<script src="{{ url_for('static', filename='js/tutorial.js') }}"></script>
|
| 186 |
+
<script>
|
| 187 |
+
// Initialize tutorial with current progress
|
| 188 |
+
const tutorialData = {
|
| 189 |
+
id: {{ tutorial.id }},
|
| 190 |
+
totalSteps: {{ tutorial.steps|length }},
|
| 191 |
+
currentStep: {{ user_progress.current_step if user_progress else 0 }}
|
| 192 |
+
};
|
| 193 |
+
|
| 194 |
+
initializeTutorial(tutorialData);
|
| 195 |
+
</script>
|
| 196 |
+
{% endblock %}
|