valtownInstagramindex.ts2 matches
31});
3233// Utility function to serve files from the project
34async function serveFile(path: string, baseUrl: string): Promise<Response> {
35try {
36const content = await readFile(path, baseUrl);
vtProjectSearchdb.ts23 matches
1213// Load all usernames and val paths into memory for fast typeahead
14export async function loadTypeaheadDataIntoMemory(): Promise<void> {
15console.log("Loading typeahead data into memory...");
1646* Search typeahead data by prefix
47*/
48export function searchTypeahead(query: string, limit: number = 10): string[] {
49const lowerQuery = query.toLowerCase();
50const results: string[] = [];
63* Get activity data for the last 6 months
64*/
65export async function getActivityHeatmap(): Promise<{
66date: string;
67count: number;
96* Get top contributors based on recency
97*/
98export async function getTopContributors(limit: number = 10): Promise<{
99username: string;
100valCount: number;
134* Get most active vals based on recency and file count
135*/
136export async function getMostActiveVals(limit: number = 10): Promise<{
137name: string;
138username: string;
174* Get database statistics for the homepage
175*/
176export async function getSearchStats(): Promise<{
177totalVals: number;
178totalFiles: number;
363};
364365// Helper functions for val and file management
366367/**
368* Get a user by ID
369*/
370export async function getUser(userId: string): Promise<User | null> {
371const result = await sqlite.execute(
372`SELECT * FROM ${tablePrefix}_users WHERE id = ?`,
387* Insert or update a user if it's newer than existing data
388*/
389export async function upsertUser(user: User): Promise<boolean> {
390// Check if user exists and compare timestamps
391const existingUser = await getUser(user.id);
430* Get a val by ID
431*/
432async function getVal(valId: string): Promise<Val | null> {
433const result = await sqlite.execute(
434`SELECT * FROM ${tablePrefix}_vals WHERE id = ?`,
449* Insert or update a val if it's newer than existing data
450*/
451export async function upsertVal(val: Val): Promise<boolean> {
452// Convert Date object to string if needed
453const updatedAt = val.updated_at;
501* Get a file by ID
502*/
503async function getFile(fileId: string): Promise<File | null> {
504const result = await sqlite.execute(
505`SELECT * FROM ${tablePrefix}_files WHERE id = ?`,
520* Insert or update a file if it's newer than existing data
521*/
522export async function upsertFile(file: File): Promise<boolean> {
523// Convert Date object to string if needed
524569* Extract matched lines with context around matches
570*/
571function extractMatchedLines(
572content: string,
573searchText: string,
629* Search for files containing specific text
630*/
631export async function searchFileContent(
632searchText: string,
633): Promise<FileSearchResult[]> {
677* Count total file search results
678*/
679export async function countFileSearchResults(searchText: string): Promise<number> {
680const searchPattern = `%${searchText}%`;
681695* Count total val search results
696*/
697export async function countValSearchResults(searchText: string): Promise<number> {
698const searchPattern = `%${searchText}%`;
699712* Count total user search results
713*/
714export async function countUserSearchResults(searchText: string): Promise<number> {
715const searchPattern = `%${searchText}%`;
716729* Count total vals for a specific username
730*/
731export async function countUserVals(username: string): Promise<number> {
732const result = await sqlite.execute(
733`SELECT COUNT(*) as total
743* Get vals by username with pagination
744*/
745export async function getValsByUsername(
746username: string,
747page: number = 1,
775* Search for vals matching the query
776*/
777export async function searchVals(
778searchText: string,
779page: number = 1,
810* Search for users matching the query
811*/
812export async function searchUsers(
813searchText: string,
814page: number = 1,
851* Enhanced search that returns matched content with context and pagination
852*/
853export async function searchFileContentWithContext(
854searchText: string,
855contextLines: number = 2,
vtProjectSearchapi.tsx3 matches
1415// Handle typeahead API requests
16export function handleTypeahead(req: Request): Response {
17const url = new URL(req.url);
18const searchTerm = url.searchParams.get("q") || "";
4647// Handle user vals API requests
48export async function handleUserVals(req: Request): Response {
49const url = new URL(req.url);
50const username = url.searchParams.get("user") || "";
142143// Main request handler
144export async function handler(req: Request): Promise<Response> {
145const url = new URL(req.url);
146
vtProjectSearchcomponents.tsx14 matches
1718// Define the Activity Heatmap component
19export function ActivityHeatmap({ activityData }: { activityData: { date: string; count: number }[] }) {
20// Convert activity data to a map for easier lookup
21const activityMap = new Map(activityData.map(item => [item.date, item.count]));
157158// Helper to highlight the search terms in the code
159export function highlightText(text: string, searchTerm: string): JSX.Element {
160if (!searchTerm) return <>{text}</>;
161178179// CodeBlock component for displaying code with line numbers
180export function CodeBlock(
181{ matchedLines, searchTerm, totalMatches: _totalMatches }: {
182matchedLines: EnhancedSearchResult["matchedLines"];
204205// File search result component
206export function FileSearchResultComponent(
207{ result, searchTerm }: { result: EnhancedSearchResult; searchTerm: string },
208) {
282283// Val search result component
284export function ValSearchResultComponent(
285{ result, searchTerm }: { result: ValSearchResult; searchTerm: string },
286) {
356357// User search result component
358export function UserSearchResultComponent(
359{ result, searchTerm }: { result: UserSearchResult; searchTerm: string },
360) {
415416// Sub-section result for docs
417export function SubDocResultComponent(
418{ result, _searchTerm }: { result: SubDocResult; _searchTerm: string },
419) {
436437// Doc search result component
438export function DocSearchResultComponent(
439{ result, searchTerm }: { result: DocSearchResult; searchTerm: string },
440) {
491492// Result count tabs component
493export function ResultTypeTabs({
494totalFileResults,
495totalValResults,
539540// Pagination component
541export function Pagination({
542currentPage,
543totalPages,
644645// Sample results component for preview of other result types
646export function SampleResultsSection({
647title,
648linkText,
681682// Main search page component
683export function SearchPage({
684fileResults,
685valResults,
1244<a href="?q=database" className="example-link">database</a>
1245<a href="?q=image" className="example-link">image</a>
1246<a href="?q=function" className="example-link">function</a>
1247<a href="?q=discord" className="example-link">discord</a>
1248<a href="?q=openai" className="example-link">openai</a>
1399<a href="?q=database" className="example-link">database</a>
1400<a href="?q=image" className="example-link">image</a>
1401<a href="?q=function" className="example-link">function</a>
1402<a href="?q=discord" className="example-link">discord</a>
1403<a href="?q=openai" className="example-link">openai</a>
vtProjectSearchclient.tsx12 matches
1// Client-side script for typeahead and keyboard navigation
2export const clientScript = `
3document.addEventListener('DOMContentLoaded', function() {
4const searchInput = document.getElementById('search-input');
5const resultsContainer = document.getElementById('typeahead-results');
11let selectedIndex = -1;
1213// Function to fetch typeahead results
14async function fetchTypeahead(query) {
15if (query.length < 1) {
16hideResults();
61}
6263// Function to display results
64function displayResults(results, query) {
65// Clear previous results
66resultsContainer.innerHTML = '';
102}
103104// Function to hide results
105function hideResults() {
106resultsContainer.classList.remove('active');
107selectedIndex = -1;
109110// Input event to trigger typeahead
111searchInput.addEventListener('input', function() {
112const query = this.value.trim();
113135136// Handle keyboard navigation
137searchInput.addEventListener('keydown', function(e) {
138const items = resultsContainer.querySelectorAll('.typeahead-item');
139167168// Update selection highlight
169function updateSelection(items) {
170items.forEach((item, i) => {
171if (i === selectedIndex) {
178179// Close results when clicking outside
180document.addEventListener('click', function(e) {
181if (!searchInput.contains(e.target) && !resultsContainer.contains(e.target)) {
182hideResults();
185186// Handle mouse movement to keep the search term item highlighted
187resultsContainer.addEventListener('mouseover', function(e) {
188// Find the search term item (last child)
189const searchItem = resultsContainer.querySelector('.search-term');
1import { Evaluation } from "npm:@autoblocks/client/testing";
23export default async function httpHandler(request: Request): Promise<Response> {
4if (request.method !== "POST") {
5return Response.json({ message: "Invalid method." }, {
vtProjectSearchutils.tsx2 matches
1// Format date to relative time
2export function formatRelativeTime(dateString: string): string {
3const date = new Date(dateString);
4const now = new Date();
3738// Format date for tooltip (full date)
39export function formatFullDate(dateString: string): string {
40const date = new Date(dateString);
41return date.toLocaleDateString("en-US", {
vtProjectSearchdocsearch.ts2 matches
62* @param query Search query
63*/
64export async function searchDocsCount(
65query: string
66): Promise<number> {
85* @param fetchData Whether to fetch the full data for each result
86*/
87export async function searchDocs(
88query: string,
89page: number = 1,
vtProjectSearchdeno.lock4 matches
131"dependencies": [
132"es-errors",
133"function-bind"
134]
135},
216]
217},
218"function-bind@1.1.2": {
219"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="
220},
226"es-errors",
227"es-object-atoms",
228"function-bind",
229"get-proto",
230"gopd",
256"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
257"dependencies": [
258"function-bind"
259]
260},
8"https://img.clerk.com/eyJ0eXBlIjoiZGVmYXVsdCIsImlpZCI6Imluc18yTm10cGhQUklwU0tqZHNiOHNnNGd2ZjJURFUiLCJyaWQiOiJ1c2VyXzJnZ3hadk1yUE5VUk5KY01VZnZtSWV2b3pkaiJ9";
910export default async function(req: Request): Promise<Response> {
11const url = new URL(req.url);
12if (url.pathname === "/") return serveFile("./index.html", import.meta.url);