Spaces:
Running
Running
Location and name should be extracted from the URL, Notes should be optional
Browse files
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: π»
|
| 4 |
colorFrom: pink
|
| 5 |
-
colorTo:
|
|
|
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: URL Notes Extractor π
|
|
|
|
| 3 |
colorFrom: pink
|
| 4 |
+
colorTo: blue
|
| 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,102 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>URL Notes Extractor</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 |
+
<div class="container mx-auto px-4 py-8 max-w-4xl">
|
| 14 |
+
<header class="mb-8">
|
| 15 |
+
<h1 class="text-3xl font-bold text-gray-800 flex items-center">
|
| 16 |
+
<i data-feather="file-text" class="mr-2"></i>
|
| 17 |
+
URL Notes Extractor
|
| 18 |
+
</h1>
|
| 19 |
+
<p class="text-gray-600">Extract location, name and notes from URLs</p>
|
| 20 |
+
</header>
|
| 21 |
+
|
| 22 |
+
<main>
|
| 23 |
+
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
|
| 24 |
+
<div class="mb-6">
|
| 25 |
+
<label for="url-input" class="block text-sm font-medium text-gray-700 mb-1">Enter URL</label>
|
| 26 |
+
<div class="flex">
|
| 27 |
+
<input type="text" id="url-input" placeholder="https://example.com/location/name?notes=optional"
|
| 28 |
+
class="flex-1 px-4 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
| 29 |
+
<button id="extract-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-r-md transition duration-200">
|
| 30 |
+
Extract
|
| 31 |
+
</button>
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
| 34 |
+
|
| 35 |
+
<div class="space-y-4">
|
| 36 |
+
<div>
|
| 37 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Extracted Data</label>
|
| 38 |
+
<div class="bg-gray-50 p-4 rounded-md">
|
| 39 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 40 |
+
<div>
|
| 41 |
+
<p class="text-sm text-gray-500">Location:</p>
|
| 42 |
+
<p id="location" class="font-medium">-</p>
|
| 43 |
+
</div>
|
| 44 |
+
<div>
|
| 45 |
+
<p class="text-sm text-gray-500">Name:</p>
|
| 46 |
+
<p id="name" class="font-medium">-</p>
|
| 47 |
+
</div>
|
| 48 |
+
<div class="md:col-span-2">
|
| 49 |
+
<p class="text-sm text-gray-500">Notes:</p>
|
| 50 |
+
<p id="notes" class="font-medium italic">-</p>
|
| 51 |
+
</div>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
<div>
|
| 57 |
+
<label for="notes-input" class="block text-sm font-medium text-gray-700 mb-1">Add/Edit Notes (optional)</label>
|
| 58 |
+
<textarea id="notes-input" rows="3" placeholder="Add your notes here..."
|
| 59 |
+
class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"></textarea>
|
| 60 |
+
<div class="flex justify-end mt-2">
|
| 61 |
+
<button id="save-notes-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md transition duration-200">
|
| 62 |
+
Save Notes
|
| 63 |
+
</button>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
|
| 69 |
+
<div class="bg-white rounded-lg shadow-md p-6">
|
| 70 |
+
<h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
|
| 71 |
+
<i data-feather="info" class="mr-2"></i>
|
| 72 |
+
How It Works
|
| 73 |
+
</h2>
|
| 74 |
+
<ul class="space-y-3 text-gray-700">
|
| 75 |
+
<li class="flex items-start">
|
| 76 |
+
<i data-feather="chevron-right" class="text-blue-500 mr-2 mt-0.5"></i>
|
| 77 |
+
<span>Enter a URL with location, name and optional notes parameters</span>
|
| 78 |
+
</li>
|
| 79 |
+
<li class="flex items-start">
|
| 80 |
+
<i data-feather="chevron-right" class="text-blue-500 mr-2 mt-0.5"></i>
|
| 81 |
+
<span>The tool extracts the values automatically</span>
|
| 82 |
+
</li>
|
| 83 |
+
<li class="flex items-start">
|
| 84 |
+
<i data-feather="chevron-right" class="text-blue-500 mr-2 mt-0.5"></i>
|
| 85 |
+
<span>You can add or edit notes which will be appended to the URL</span>
|
| 86 |
+
</li>
|
| 87 |
+
<li class="flex items-start">
|
| 88 |
+
<i data-feather="chevron-right" class="text-blue-500 mr-2 mt-0.5"></i>
|
| 89 |
+
<span>Example URL: <code class="text-sm bg-gray-100 px-1">https://example.com/new-york/central-park?notes=beautiful-park</code></span>
|
| 90 |
+
</li>
|
| 91 |
+
</ul>
|
| 92 |
+
</div>
|
| 93 |
+
</main>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<script src="script.js"></script>
|
| 97 |
+
<script>
|
| 98 |
+
feather.replace();
|
| 99 |
+
</script>
|
| 100 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 101 |
+
</body>
|
| 102 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 2 |
+
const urlInput = document.getElementById('url-input');
|
| 3 |
+
const extractBtn = document.getElementById('extract-btn');
|
| 4 |
+
const locationElement = document.getElementById('location');
|
| 5 |
+
const nameElement = document.getElementById('name');
|
| 6 |
+
const notesElement = document.getElementById('notes');
|
| 7 |
+
const notesInput = document.getElementById('notes-input');
|
| 8 |
+
const saveNotesBtn = document.getElementById('save-notes-btn');
|
| 9 |
+
|
| 10 |
+
// Extract data from URL
|
| 11 |
+
extractBtn.addEventListener('click', function() {
|
| 12 |
+
const url = urlInput.value.trim();
|
| 13 |
+
|
| 14 |
+
if (!url) {
|
| 15 |
+
alert('Please enter a URL');
|
| 16 |
+
return;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
try {
|
| 20 |
+
const urlObj = new URL(url);
|
| 21 |
+
const pathSegments = urlObj.pathname.split('/').filter(segment => segment);
|
| 22 |
+
|
| 23 |
+
// Extract location and name from path
|
| 24 |
+
if (pathSegments.length >= 2) {
|
| 25 |
+
locationElement.textContent = decodeURIComponent(pathSegments[pathSegments.length - 2]);
|
| 26 |
+
nameElement.textContent = decodeURIComponent(pathSegments[pathSegments.length - 1]);
|
| 27 |
+
} else if (pathSegments.length === 1) {
|
| 28 |
+
locationElement.textContent = '-';
|
| 29 |
+
nameElement.textContent = decodeURIComponent(pathSegments[0]);
|
| 30 |
+
} else {
|
| 31 |
+
locationElement.textContent = '-';
|
| 32 |
+
nameElement.textContent = '-';
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// Extract notes from query params
|
| 36 |
+
const notes = urlObj.searchParams.get('notes');
|
| 37 |
+
if (notes) {
|
| 38 |
+
notesElement.textContent = decodeURIComponent(notes);
|
| 39 |
+
notesInput.value = decodeURIComponent(notes);
|
| 40 |
+
} else {
|
| 41 |
+
notesElement.textContent = '-';
|
| 42 |
+
notesInput.value = '';
|
| 43 |
+
}
|
| 44 |
+
} catch (error) {
|
| 45 |
+
alert('Invalid URL format');
|
| 46 |
+
console.error(error);
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
// Save notes to URL
|
| 51 |
+
saveNotesBtn.addEventListener('click', function() {
|
| 52 |
+
const url = urlInput.value.trim();
|
| 53 |
+
|
| 54 |
+
if (!url) {
|
| 55 |
+
alert('Please enter a URL first');
|
| 56 |
+
return;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
try {
|
| 60 |
+
const urlObj = new URL(url);
|
| 61 |
+
const notes = notesInput.value.trim();
|
| 62 |
+
|
| 63 |
+
if (notes) {
|
| 64 |
+
urlObj.searchParams.set('notes', encodeURIComponent(notes));
|
| 65 |
+
notesElement.textContent = notes;
|
| 66 |
+
} else {
|
| 67 |
+
urlObj.searchParams.delete('notes');
|
| 68 |
+
notesElement.textContent = '-';
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
urlInput.value = urlObj.toString();
|
| 72 |
+
} catch (error) {
|
| 73 |
+
alert('Error updating URL');
|
| 74 |
+
console.error(error);
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
// Example URL on page load for demonstration
|
| 79 |
+
urlInput.value = 'https://example.com/new-york/central-park?notes=beautiful-park';
|
| 80 |
+
});
|
style.css
CHANGED
|
@@ -1,28 +1,51 @@
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&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: #3b82f6;
|
| 20 |
+
border-radius: 10px;
|
| 21 |
}
|
| 22 |
|
| 23 |
+
::-webkit-scrollbar-thumb:hover {
|
| 24 |
+
background: #2563eb;
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
+
/* Animation for extracted data */
|
| 28 |
+
@keyframes fadeIn {
|
| 29 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 30 |
+
to { opacity: 1; transform: translateY(0); }
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
+
#location, #name, #notes {
|
| 34 |
+
animation: fadeIn 0.3s ease-out forwards;
|
| 35 |
}
|
| 36 |
+
|
| 37 |
+
/* Button hover effects */
|
| 38 |
+
button {
|
| 39 |
+
transition: all 0.2s ease;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
button:hover {
|
| 43 |
+
transform: translateY(-1px);
|
| 44 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/* Focus styles for better accessibility */
|
| 48 |
+
input:focus, textarea:focus, button:focus {
|
| 49 |
+
outline: none;
|
| 50 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
|
| 51 |
+
}
|