File size: 8,537 Bytes
0bd1f77 b44cc91 f80fdc0 b44cc91 f80fdc0 f19738b b44cc91 f80fdc0 f19738b f80fdc0 f19738b f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 e15d4cc f80fdc0 f19738b e15d4cc f80fdc0 e15d4cc f19738b f80fdc0 f19738b f80fdc0 e15d4cc f80fdc0 b44cc91 e15d4cc b44cc91 e15d4cc f19738b f80fdc0 b44cc91 e15d4cc f80fdc0 b44cc91 f80fdc0 b44cc91 f19738b b44cc91 f80fdc0 b44cc91 f80fdc0 b44cc91 f80fdc0 f19738b e15d4cc f19738b b44cc91 f80fdc0 b44cc91 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Example App - Reachy Mini Template</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="hero">
<div class="hero-content">
<div class="app-icon">π€β‘</div>
<h1>Example Reachy Mini App</h1>
<p class="tagline">Template for creating your own Reachy Mini applications</p>
</div>
</div>
<div class="container">
<div class="main-card">
<div class="app-preview">
<div class="preview-image">
<div class="camera-feed">π οΈ</div>
</div>
</div>
</div>
<div class="app-details">
<h2>Example Template App</h2>
<div class="template-info">
<div class="info-box">
<h3>π¨ Template Purpose</h3>
<p>This is an example landing page for Reachy Mini apps. Feel free to duplicate this template and
customize it for your own applications!</p>
</div>
<div class="info-box">
<h3>π Getting Started</h3>
<p>Use this template to showcase your Reachy Mini app with a landing page. Simply modify the
content, add your app's repository URL, and deploy!</p>
</div>
</div>
<div class="how-to-use">
<h3>How to Use This Template</h3>
<div class="steps">
<div class="step">
<span class="step-number">1</span>
<div>
<h4>Duplicate & Customize</h4>
<p>Copy this template and modify the content for your app</p>
</div>
</div>
<div class="step">
<span class="step-number">2</span>
<div>
<h4>Update Repository URL</h4>
<p>Change the JavaScript to point to your app's Git repository</p>
</div>
</div>
<div class="step">
<span class="step-number">3</span>
<div>
<h4>Deploy to HF Spaces</h4>
<p>Upload your customized version to Hugging Face Spaces</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="download-section">
<div class="download-card">
<h2>Install This Example App</h2>
<p>Try out the installation process with this template app</p>
<div class="dashboard-config">
<label for="dashboardUrl">Your Reachy Dashboard URL:</label>
<input type="url" id="dashboardUrl" value="http://localhost:8000"
placeholder="http://your-reachy-ip:8000" />
</div>
<button id="installBtn" class="install-btn primary">
<span class="btn-icon">π₯</span>
Install Example App to Reachy
</button>
<div id="installStatus" class="install-status"></div>
</div>
</div>
<div class="footer">
<p>
π€ Template for Reachy Mini Apps β’
<a href="https://github.com/pollen-robotics" target="_blank">Pollen Robotics</a> β’
<a href="https://huggingface.co/spaces/pollen-robotics/Reachy_Mini_Apps" target="_blank">Browse More
Apps</a>
</p>
</div>
</div>
<script>
// Get the current Hugging Face Space URL as the repository URL
function getCurrentSpaceUrl() {
// Get current page URL and convert to repository format
const currentUrl = window.location.href;
// Remove any trailing slashes and query parameters
const cleanUrl = currentUrl.split('?')[0].replace(/\/$/, '');
return cleanUrl;
}
// Parse TOML content to extract project name
function parseTomlProjectName(tomlContent) {
try {
const lines = tomlContent.split('\n');
let inProjectSection = false;
for (const line of lines) {
const trimmedLine = line.trim();
// Check if we're entering the [project] section
if (trimmedLine === '[project]') {
inProjectSection = true;
continue;
}
// Check if we're entering a different section
if (trimmedLine.startsWith('[') && trimmedLine !== '[project]') {
inProjectSection = false;
continue;
}
// If we're in the project section, look for the name field
if (inProjectSection && trimmedLine.startsWith('name')) {
const match = trimmedLine.match(/name\s*=\s*["']([^"']+)["']/);
if (match) {
// Convert to lowercase and replace invalid characters for app naming
return match[1].toLowerCase().replace(/[^a-z0-9-_]/g, '-');
}
}
}
throw new Error('Project name not found in pyproject.toml');
} catch (error) {
console.error('Error parsing pyproject.toml:', error);
return 'unknown-app';
}
}
// Fetch and parse pyproject.toml from the current space
async function getAppNameFromCurrentSpace() {
try {
// Fetch pyproject.toml from the current space
const response = await fetch('./pyproject.toml');
if (!response.ok) {
throw new Error(`Failed to fetch pyproject.toml: ${response.status}`);
}
const tomlContent = await response.text();
return parseTomlProjectName(tomlContent);
} catch (error) {
console.error('Error fetching app name from current space:', error);
// Fallback to extracting from URL if pyproject.toml is not accessible
const url = getCurrentSpaceUrl();
const parts = url.split('/');
const spaceName = parts[parts.length - 1];
return spaceName.toLowerCase().replace(/[^a-z0-9-_]/g, '-');
}
}
async function installToReachy() {
const dashboardUrl = document.getElementById('dashboardUrl').value.trim();
const statusDiv = document.getElementById('installStatus');
const installBtn = document.getElementById('installBtn');
if (!dashboardUrl) {
showStatus('error', 'Please enter your Reachy dashboard URL');
return;
}
try {
installBtn.disabled = true;
installBtn.innerHTML = '<span class="btn-icon">β³</span>Installing...';
showStatus('loading', 'Connecting to your Reachy dashboard...');
// Test connection
const testResponse = await fetch(`${dashboardUrl}/api/status`, {
method: 'GET',
mode: 'cors',
});
if (!testResponse.ok) {
throw new Error('Cannot connect to dashboard. Make sure the URL is correct and the dashboard is running.');
}
showStatus('loading', 'Reading app configuration...');
// Get app name from pyproject.toml in current space
const appName = await getAppNameFromCurrentSpace();
// Get current space URL as repository URL
const repoUrl = getCurrentSpaceUrl();
showStatus('loading', `Starting installation of "${appName}"...`);
// Start installation
const installResponse = await fetch(`${dashboardUrl}/api/install`, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: repoUrl,
name: appName
})
});
const result = await installResponse.json();
if (installResponse.ok) {
showStatus('success', `β
Installation started for "${appName}"! Check your dashboard for progress.`);
setTimeout(() => {
showStatus('info', `Open your dashboard at ${dashboardUrl} to see the installed app.`);
}, 3000);
} else {
throw new Error(result.detail || 'Installation failed');
}
} catch (error) {
console.error('Installation error:', error);
showStatus('error', `β ${error.message}`);
} finally {
installBtn.disabled = false;
installBtn.innerHTML = '<span class="btn-icon">π₯</span>Install App to Reachy';
}
}
function showStatus(type, message) {
const statusDiv = document.getElementById('installStatus');
statusDiv.className = `install-status ${type}`;
statusDiv.textContent = message;
statusDiv.style.display = 'block';
}
function copyToClipboard() {
const repoUrl = document.getElementById('repoUrl').textContent;
navigator.clipboard.writeText(repoUrl).then(() => {
showStatus('success', 'π Repository URL copied to clipboard!');
}).catch(() => {
showStatus('error', 'Failed to copy URL. Please copy manually.');
});
}
// Update the displayed repository URL on page load
document.addEventListener('DOMContentLoaded', () => {
// Auto-detect local dashboard
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
if (isLocalhost) {
document.getElementById('dashboardUrl').value = 'http://localhost:8000';
}
// Update the repository URL display if element exists
const repoUrlElement = document.getElementById('repoUrl');
if (repoUrlElement) {
repoUrlElement.textContent = getCurrentSpaceUrl();
}
});
// Event listeners
document.getElementById('installBtn').addEventListener('click', installToReachy);
</script>
</body>
</html> |