grievingYellowAspREADME.md1 match
456
78
51return new Response(svgContent, {
52headers: {
53"content-type": "image/svg+xml",
54},
55});
89appName: 'ValPush',
90appIconUrl: '${iconURL}',
91assetUrl: 'https://cdn.jsdelivr.net/gh/philfung/add-to-homescreen@1.9/dist/assets/img/', // Link to directory of library image assets.
92maxModalDisplayCount: -1
93});
test_migratedmain.tsx1 match
97const svg = render(badge);
9899return new Response(svg, { headers: { "Content-Type": "image/svg+xml;charset=utf-8" } });
100}
whenfilmedmain.tsx3 matches
78const TMDB_API_BASE = "https://api.themoviedb.org/3"
9const TMDB_IMAGE_BASE = "https://image.tmdb.org/t/p/w200"
1011const headers = {
65movies.map((movie, index) => `
66<div class="movie-container">
67<img src="${TMDB_IMAGE_BASE}${movie.poster_path}" alt="${movie.title}" style="width: 100px;">
68<div class="movie-info">
69<h3>${movie.title}</h3>
130return `
131<div class="movie-result ${resultClass}">
132<img src="${TMDB_IMAGE_BASE}${movie.poster_path}" alt="${movie.title}" style="width: 100px;">
133<div class="movie-info">
134<h3>${movie.title}</h3>
azureCheetahmain.tsx1 match
42functions where possible. Unless specified, don't add error handling,
43make sure that errors bubble up to the caller.
44Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
45not practical for the user's request (e.g. if they ask for a particular animated gif).
46If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
42functions where possible. Unless specified, don't add error handling,
43make sure that errors bubble up to the caller.
44Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
45not practical for the user's request (e.g. if they ask for a particular animated gif).
46If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
1112<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>
327---
328
329Val Town comes with blob storage built-in. It allows for storing any data: text, JSON, images. You can access it via [\`std/blob\`](https://www.val.town/v/std/blob).
330
331Blob storage is scoped globally to your account. If you set a blob in one val, you can retrieve it by the same key in another val. It's backed by Cloudflare R2.
infiniteSVGGraphmain.tsx16 matches
8// Val-name scoped table addressing.
9const { name } = extractValInfo(import.meta.url);
10const tableName = `${name}_svg_images`;
11const heartHashTableName = `${name}_heart_hash`;
1294const decoder = new TextDecoder();
95const svgCode = document.getElementById("svgCode");
96const svgImage = document.getElementById("svgImage");
97let foundSVGEnd = false;
98let htmlContent = "";
99let jsonResponse = "";
100svgCode.textContent = "";
101svgImage.innerHTML = "";
102while (true) {
103const { done, value } = await reader.read();
105if (!foundSVGEnd) {
106svgCode.textContent += decoder.decode(value, { stream: true });
107svgImage.innerHTML = svgCode.textContent + "</svg>";
108Prism.highlightElement(svgCode);
109if (svgCode.textContent.indexOf("</svg>") > -1) {
338<div class="bg-white p-6 rounded-lg shadow-md mb-8">
339<div class="flex space-x-4 mb-4">
340<div class="w-1/2 border p-4 rounded" id="svgImage">
341${svg.svg.svg_source}
342</div>
398const stream = await openai.chat.completions.create({
399messages: [
400{ role: "user", content: "make me an svg image" },
401{ role: "system", content: "```xml\n" + svg.svg_source + "\n```" },
402{ role: "user", content: "Edit this svg. " + prompt },
421});
422try {
423const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
424if (!svgDoc) return false;
425const parserError = svgDoc.getElementsByTagName("parsererror");
434let foundSVGEnd = false;
435let buffer = "";
436let svgImage = "";
437return new Response(
438new ReadableStream({
444if (!foundSVGStart && location > -1) {
445foundSVGStart = true;
446svgImage = buffer.slice(location);
447controller.enqueue(encoder.encode(buffer.slice(location)));
448buffer = "";
449} else if (foundSVGStart && !foundSVGEnd) {
450svgImage += line;
451let endLocation = svgImage.indexOf("</svg>");
452if (endLocation > -1) {
453svgImage = svgImage.slice(0, endLocation + "</svg>".length);
454foundSVGEnd = true;
455console.log(JSON.stringify(svgImage));
456}
457controller.enqueue(encoder.encode(line));
459}
460controller.enqueue(encoder.encode(" "));
461if (isValidSVG(svgImage)) {
462try {
463let resp = await sqlite.execute({
464sql: `INSERT INTO ${tableName} (prompt, svg_source, parent_id) VALUES (?, ?, ?) RETURNING *`,
465args: [prompt, svgImage, svg.id],
466});
467controller.enqueue(encoder.encode(JSON.stringify(resultSetToSVG(resp)[0])));
496let svg = await getSVG(c.req.param("id"));
497return new Response(addSVGNamespace(svg.svg_source), {
498headers: { "Content-Type": "image/svg+xml", "Cache-Control": "max-age=86400" },
499});
500});