daviszhen commited on
Commit
b8e3da3
·
verified ·
1 Parent(s): 09d879f

if user choose file filter - code only, it gives supported code file extensions like *.cpp,*.h,etc.

Browse files
Files changed (4) hide show
  1. README.md +8 -5
  2. index.html +99 -19
  3. script.js +94 -0
  4. style.css +67 -18
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Codecanvas Github Repo Render Wizard
3
- emoji: 🐢
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: CodeCanvas - GitHub Repo Render Wizard 🎨
3
+ colorFrom: yellow
4
+ colorTo: green
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
index.html CHANGED
@@ -1,19 +1,99 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>CodeCanvas - GitHub Repo Render Wizard</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ </head>
12
+ <body class="bg-gray-50 min-h-screen">
13
+ <custom-navbar></custom-navbar>
14
+
15
+ <main class="container mx-auto px-4 py-12">
16
+ <div class="max-w-4xl mx-auto">
17
+ <div class="text-center mb-12">
18
+ <h1 class="text-4xl font-bold text-gray-800 mb-4">CodeCanvas</h1>
19
+ <p class="text-xl text-gray-600">Transform GitHub repositories into beautiful documentation</p>
20
+ </div>
21
+
22
+ <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
23
+ <div class="mb-6">
24
+ <label for="repo-url" class="block text-sm font-medium text-gray-700 mb-2">GitHub Repository URL</label>
25
+ <div class="flex">
26
+ <input type="text" id="repo-url" class="flex-grow px-4 py-3 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="https://github.com/username/repository">
27
+ <button id="fetch-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-r-lg transition duration-200 flex items-center">
28
+ <i data-feather="download" class="mr-2"></i> Fetch
29
+ </button>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
34
+ <div>
35
+ <label class="block text-sm font-medium text-gray-700 mb-2">File Filter</label>
36
+ <select id="file-filter" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
37
+ <option value="all">All Files</option>
38
+ <option value="code">Code Only (.js, .py, .java, etc)</option>
39
+ <option value="docs">Documentation Only (.md, .txt)</option>
40
+ <option value="custom">Custom Filter</option>
41
+ </select>
42
+ </div>
43
+
44
+ <div>
45
+ <label class="block text-sm font-medium text-gray-700 mb-2">Template</label>
46
+ <select id="template" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
47
+ <option value="default">Default</option>
48
+ <option value="documentation">Documentation</option>
49
+ <option value="portfolio">Portfolio</option>
50
+ <option value="minimal">Minimal</option>
51
+ </select>
52
+ </div>
53
+
54
+ <div>
55
+ <label class="block text-sm font-medium text-gray-700 mb-2">Theme</label>
56
+ <select id="theme" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
57
+ <option value="light">Light</option>
58
+ <option value="dark">Dark</option>
59
+ <option value="solarized">Solarized</option>
60
+ <option value="monokai">Monokai</option>
61
+ </select>
62
+ </div>
63
+ </div>
64
+ </div>
65
+
66
+ <div id="preview-section" class="hidden bg-white rounded-xl shadow-lg p-8">
67
+ <div class="flex justify-between items-center mb-6">
68
+ <h2 class="text-2xl font-semibold text-gray-800">Preview</h2>
69
+ <div class="flex space-x-3">
70
+ <button id="download-btn" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg transition duration-200 flex items-center">
71
+ <i data-feather="download" class="mr-2"></i> Download
72
+ </button>
73
+ <button id="deploy-btn" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg transition duration-200 flex items-center">
74
+ <i data-feather="upload" class="mr-2"></i> Deploy
75
+ </button>
76
+ </div>
77
+ </div>
78
+
79
+ <div id="preview-content" class="border border-gray-200 rounded-lg p-6 min-h-[400px]">
80
+ <div class="text-center py-20 text-gray-400">
81
+ <i data-feather="code" class="w-12 h-12 mx-auto mb-4"></i>
82
+ <p>Your rendered content will appear here</p>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </main>
88
+
89
+ <custom-footer></custom-footer>
90
+
91
+ <script src="components/navbar.js"></script>
92
+ <script src="components/footer.js"></script>
93
+ <script src="script.js"></script>
94
+ <script>
95
+ feather.replace();
96
+ </script>
97
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
98
+ </body>
99
+ </html>
script.js ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const fetchBtn = document.getElementById('fetch-btn');
3
+ const repoUrlInput = document.getElementById('repo-url');
4
+ const fileFilterSelect = document.getElementById('file-filter');
5
+ const templateSelect = document.getElementById('template');
6
+ const themeSelect = document.getElementById('theme');
7
+ const previewSection = document.getElementById('preview-section');
8
+ const previewContent = document.getElementById('preview-content');
9
+ const downloadBtn = document.getElementById('download-btn');
10
+ const deployBtn = document.getElementById('deploy-btn');
11
+ fetchBtn.addEventListener('click', async function() {
12
+ const repoUrl = repoUrlInput.value.trim();
13
+ const fileFilter = fileFilterSelect.value;
14
+
15
+ if (!repoUrl) {
16
+ showAlert('Please enter a GitHub repository URL', 'error');
17
+ return;
18
+ }
19
+
20
+ // Validate GitHub URL
21
+ if (!isValidGitHubUrl(repoUrl)) {
22
+ showAlert('Please enter a valid GitHub repository URL', 'error');
23
+ return;
24
+ }
25
+
26
+ // Show supported extensions for code filter
27
+ if (fileFilter === 'code') {
28
+ showAlert('Filtering for code files only: .js, .ts, .py, .java, .cpp, .h, .c, .cs, .go, .rb, .php, .swift, .kt, .rs, .sh', 'info');
29
+ }
30
+ // Show loading state
31
+ fetchBtn.disabled = true;
32
+ fetchBtn.innerHTML = '<span class="loading-spinner"></span> Processing...';
33
+
34
+ try {
35
+ // Simulate API call (in a real app, you would call your backend here)
36
+ await simulateApiCall();
37
+
38
+ // Show preview section
39
+ previewSection.classList.remove('hidden');
40
+
41
+ // Generate sample preview (in a real app, this would be the actual rendered content)
42
+ generateSamplePreview();
43
+
44
+ showAlert('Repository fetched successfully!', 'success');
45
+ } catch (error) {
46
+ showAlert('Error fetching repository: ' + error.message, 'error');
47
+ } finally {
48
+ // Reset button state
49
+ fetchBtn.disabled = false;
50
+ fetchBtn.innerHTML = '<i data-feather="download" class="mr-2"></i> Fetch';
51
+ feather.replace();
52
+ }
53
+ });
54
+
55
+ downloadBtn.addEventListener('click', function() {
56
+ showAlert('Download started!', 'success');
57
+ // In a real app, this would trigger the download
58
+ });
59
+
60
+ deployBtn.addEventListener('click', function() {
61
+ showAlert('Deployment initiated!', 'success');
62
+ // In a real app, this would trigger the deployment
63
+ });
64
+
65
+ function isValidGitHubUrl(url) {
66
+ const pattern = /^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+(\/)?$/;
67
+ return pattern.test(url);
68
+ }
69
+
70
+ function simulateApiCall() {
71
+ return new Promise((resolve) => {
72
+ setTimeout(resolve, 1500);
73
+ });
74
+ }
75
+ function generateSamplePreview() {
76
+ const template = templateSelect.value;
77
+ const theme = themeSelect.value;
78
+ const fileFilter = fileFilterSelect.value;
79
+ // Apply theme class to preview
80
+ previewContent.className = 'border border-gray-200 rounded-lg p-6 min-h-[400px]';
81
+ if (theme === 'dark') {
82
+ previewContent.classList.add('bg-gray-800', 'text-gray-100');
83
+ } else if (theme === 'solarized') {
84
+ previewContent.classList.add('bg-[#fdf6e3]', 'text-[#657b83]');
85
+ } else if (theme === 'monokai') {
86
+ previewContent.classList.add('bg-[#272822]', 'text-[#f8f8f2]');
87
+ }
88
+
89
+ // Generate sample content based on template
90
+ let content = '';
91
+ if (template === 'default') {
92
+ content = `
93
+ <h1 class="text-2xl font-bold mb-4">Sample Repository</h1>
94
+ <p class="mb-4">This is a sample preview of how your
style.css CHANGED
@@ -1,28 +1,77 @@
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
 
 
28
  }
 
 
 
 
 
 
 
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
2
+
3
  body {
4
+ font-family: 'Inter', sans-serif;
5
+ }
6
+
7
+ /* Custom scrollbar */
8
+ ::-webkit-scrollbar {
9
+ width: 8px;
10
+ height: 8px;
11
+ }
12
+
13
+ ::-webkit-scrollbar-track {
14
+ background: #f1f1f1;
15
+ border-radius: 10px;
16
+ }
17
+
18
+ ::-webkit-scrollbar-thumb {
19
+ background: #888;
20
+ border-radius: 10px;
21
+ }
22
+
23
+ ::-webkit-scrollbar-thumb:hover {
24
+ background: #555;
25
+ }
26
+
27
+ /* Animation for buttons */
28
+ button {
29
+ transition: all 0.2s ease-in-out;
30
+ }
31
+
32
+ /* Loading spinner */
33
+ .loading-spinner {
34
+ display: inline-block;
35
+ width: 20px;
36
+ height: 20px;
37
+ border: 3px solid rgba(255,255,255,.3);
38
+ border-radius: 50%;
39
+ border-top-color: #fff;
40
+ animation: spin 1s ease-in-out infinite;
41
+ }
42
+
43
+ @keyframes spin {
44
+ to { transform: rotate(360deg); }
45
  }
46
 
47
+ /* Markdown preview styles */
48
+ .markdown-preview {
49
+ line-height: 1.6;
50
  }
51
 
52
+ .markdown-preview h1 {
53
+ font-size: 2em;
54
+ margin: 0.67em 0;
55
+ font-weight: bold;
 
56
  }
57
 
58
+ .markdown-preview h2 {
59
+ font-size: 1.5em;
60
+ margin: 0.83em 0;
61
+ font-weight: bold;
 
 
62
  }
63
 
64
+ .markdown-preview pre {
65
+ background-color: #f6f8fa;
66
+ border-radius: 6px;
67
+ padding: 16px;
68
+ overflow: auto;
69
  }
70
+
71
+ .markdown-preview code {
72
+ font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
73
+ background-color: rgba(175,184,193,0.2);
74
+ border-radius: 6px;
75
+ padding: 0.2em 0.4em;
76
+ font-size: 85%;
77
+ }