cduss commited on
Commit
f19738b
Β·
1 Parent(s): f80fdc0

app parsing name

Browse files
Files changed (1) hide show
  1. index.html +73 -27
index.html CHANGED
@@ -31,15 +31,17 @@
31
  <div class="template-info">
32
  <div class="info-box">
33
  <h3>🎨 Template Purpose</h3>
34
- <p>This is an example landing page for Reachy Mini apps. Feel free to duplicate this template
35
- and customize it for your own applications!</p>
36
  </div>
37
  <div class="info-box">
38
  <h3>πŸš€ Getting Started</h3>
39
- <p>Use this template to showcase your Reachy Mini app with a landing page. Simply
40
- modify the content, add your app's repository URL, and deploy!</p>
41
  </div>
42
  </div>
 
 
43
  <div class="how-to-use">
44
  <h3>How to Use This Template</h3>
45
  <div class="steps">
@@ -87,14 +89,6 @@
87
 
88
  <div id="installStatus" class="install-status"></div>
89
 
90
- <div class="manual-option">
91
- <h3>Manual Installation</h3>
92
- <p>Or copy this repository URL for manual installation:</p>
93
- <div class="manual-install">
94
- <code id="repoUrl">https://github.com/your-username/your-reachy-app.git</code>
95
- <button onclick="copyToClipboard()" class="copy-btn">πŸ“‹ Copy</button>
96
- </div>
97
- </div>
98
  </div>
99
  </div>
100
 
@@ -112,19 +106,66 @@
112
  // πŸ”§ CUSTOMIZE THIS VALUE FOR YOUR APP:
113
  const APP_REPO_URL = "https://github.com/your-username/your-reachy-app.git";
114
 
115
- // Auto-extract app name from repository URL
116
- function getAppNameFromUrl(url) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  try {
118
- // Remove .git extension if present
119
- let cleanUrl = url.replace(/\.git$/, '');
 
 
 
 
 
 
120
 
121
- // Extract the last part of the URL (repository name)
122
- const parts = cleanUrl.split('/');
123
- const repoName = parts[parts.length - 1];
 
124
 
125
- // Convert to lowercase and replace invalid characters
126
- return repoName.toLowerCase().replace(/[^a-z0-9-_]/g, '-');
127
  } catch (error) {
 
 
128
  return 'app-from-repo';
129
  }
130
  }
@@ -154,10 +195,12 @@
154
  throw new Error('Cannot connect to dashboard. Make sure the URL is correct and the dashboard is running.');
155
  }
156
 
157
- showStatus('loading', 'Starting installation...');
158
 
159
- // Auto-generate app name from repository URL
160
- const appName = getAppNameFromUrl(APP_REPO_URL);
 
 
161
 
162
  // Start installation
163
  const installResponse = await fetch(`${dashboardUrl}/api/install`, {
@@ -188,7 +231,7 @@
188
  showStatus('error', `❌ ${error.message}`);
189
  } finally {
190
  installBtn.disabled = false;
191
- installBtn.innerHTML = '<span class="btn-icon">πŸ“₯</span>Install Example App to Reachy';
192
  }
193
  }
194
 
@@ -216,8 +259,11 @@
216
  document.getElementById('dashboardUrl').value = 'http://localhost:8000';
217
  }
218
 
219
- // Update the repository URL display
220
- document.getElementById('repoUrl').textContent = APP_REPO_URL;
 
 
 
221
  });
222
 
223
  // Event listeners
 
31
  <div class="template-info">
32
  <div class="info-box">
33
  <h3>🎨 Template Purpose</h3>
34
+ <p>This is an example landing page for Reachy Mini apps. Feel free to duplicate this template and
35
+ customize it for your own applications!</p>
36
  </div>
37
  <div class="info-box">
38
  <h3>πŸš€ Getting Started</h3>
39
+ <p>Use this template to showcase your Reachy Mini app with a landing page. Simply modify the
40
+ content, add your app's repository URL, and deploy!</p>
41
  </div>
42
  </div>
43
+
44
+
45
  <div class="how-to-use">
46
  <h3>How to Use This Template</h3>
47
  <div class="steps">
 
89
 
90
  <div id="installStatus" class="install-status"></div>
91
 
 
 
 
 
 
 
 
 
92
  </div>
93
  </div>
94
 
 
106
  // πŸ”§ CUSTOMIZE THIS VALUE FOR YOUR APP:
107
  const APP_REPO_URL = "https://github.com/your-username/your-reachy-app.git";
108
 
109
+ // Parse TOML content to extract project name
110
+ function parseTomlProjectName(tomlContent) {
111
+ try {
112
+ const lines = tomlContent.split('\n');
113
+ let inProjectSection = false;
114
+
115
+ for (const line of lines) {
116
+ const trimmedLine = line.trim();
117
+
118
+ // Check if we're entering the [project] section
119
+ if (trimmedLine === '[project]') {
120
+ inProjectSection = true;
121
+ continue;
122
+ }
123
+
124
+ // Check if we're entering a different section
125
+ if (trimmedLine.startsWith('[') && trimmedLine !== '[project]') {
126
+ inProjectSection = false;
127
+ continue;
128
+ }
129
+
130
+ // If we're in the project section, look for the name field
131
+ if (inProjectSection && trimmedLine.startsWith('name')) {
132
+ const match = trimmedLine.match(/name\s*=\s*["']([^"']+)["']/);
133
+ if (match) {
134
+ // Convert to lowercase and replace invalid characters for app naming
135
+ return match[1].toLowerCase().replace(/[^a-z0-9-_]/g, '-');
136
+ }
137
+ }
138
+ }
139
+
140
+ throw new Error('Project name not found in pyproject.toml');
141
+ } catch (error) {
142
+ console.error('Error parsing pyproject.toml:', error);
143
+ return 'unknown-app';
144
+ }
145
+ }
146
+
147
+ // Fetch and parse pyproject.toml from the repository
148
+ async function getAppNameFromRepo(repoUrl) {
149
  try {
150
+ // Convert GitHub repo URL to raw content URL for pyproject.toml
151
+ let rawUrl = repoUrl.replace(/\.git$/, '');
152
+ if (rawUrl.includes('github.com')) {
153
+ rawUrl = rawUrl.replace('github.com', 'raw.githubusercontent.com');
154
+ rawUrl += '/main/pyproject.toml';
155
+ } else {
156
+ throw new Error('Only GitHub repositories are supported for automatic name detection');
157
+ }
158
 
159
+ const response = await fetch(rawUrl);
160
+ if (!response.ok) {
161
+ throw new Error(`Failed to fetch pyproject.toml: ${response.status}`);
162
+ }
163
 
164
+ const tomlContent = await response.text();
165
+ return parseTomlProjectName(tomlContent);
166
  } catch (error) {
167
+ console.error('Error fetching app name from repository:', error);
168
+ // Fallback to a default name if parsing fails
169
  return 'app-from-repo';
170
  }
171
  }
 
195
  throw new Error('Cannot connect to dashboard. Make sure the URL is correct and the dashboard is running.');
196
  }
197
 
198
+ showStatus('loading', 'Reading app configuration from repository...');
199
 
200
+ // Get app name from pyproject.toml
201
+ const appName = await getAppNameFromRepo(APP_REPO_URL);
202
+
203
+ showStatus('loading', `Starting installation of "${appName}"...`);
204
 
205
  // Start installation
206
  const installResponse = await fetch(`${dashboardUrl}/api/install`, {
 
231
  showStatus('error', `❌ ${error.message}`);
232
  } finally {
233
  installBtn.disabled = false;
234
+ installBtn.innerHTML = '<span class="btn-icon">πŸ“₯</span>Install App to Reachy';
235
  }
236
  }
237
 
 
259
  document.getElementById('dashboardUrl').value = 'http://localhost:8000';
260
  }
261
 
262
+ // Update the repository URL display if element exists
263
+ const repoUrlElement = document.getElementById('repoUrl');
264
+ if (repoUrlElement) {
265
+ repoUrlElement.textContent = APP_REPO_URL;
266
+ }
267
  });
268
 
269
  // Event listeners