198 const errorText = document.getElementById('errorText');
199
200 function showSuccess(message) {
201 successText.textContent = message;
202 successMessage.classList.remove('hidden');
204 }
205
206 function showError(message) {
207 errorText.textContent = message;
208 errorMessage.classList.remove('hidden');
210 }
211
212 function hideMessages() {
213 successMessage.classList.add('hidden');
214 errorMessage.classList.add('hidden');
5// =============================================================================
6
7// Email handler function for Val.Town
8export async function emailHandler(email) {
9 const rawContent = email.html || email.text || "No content";
10 const cleanedContent = await cleanEmailContent(rawContent);
50
51// =============================================================================
52// HELPER FUNCTIONS
53// =============================================================================
54
55// Convert app data to Notion format using field mapping
56export function mapToNotionData(appData) {
57 const notionData = {};
58
68
69// Create schema object for coverflow
70export function createNotionSchema() {
71 const schema = {};
72
82// =============================================================================
83
84export async function sendToNotion(notionData) {
85 console.log("Sending to Notion:", notionData);
86 const pipeline = [{
120// =============================================================================
121
122export async function cleanEmailContent(rawContent) {
123 const systemPrompt = `
124You are an assistant for a weekly community newsletter.
143// =============================================================================
144
145export async function emailHandler(email) {
146 const rawContent = email.html || email.text || "No content";
147 const cleanedContent = await cleanEmailContent(rawContent);
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",
9import { fetchPastGoals, createFatebookGoal } from "./utils/fatebook.ts";
10
11function App() {
12 const [settings, setSettings] = useState(() => loadSettings());
13 const [showSettings, setShowSettings] = useState(false);
145}
146
147function client() {
148 createRoot(document.getElementById("root")).render(<App />);
149}
153}
154
155export default async function server(request: Request): Promise<Response> {
156 const url = new URL(request.url);
157
10}
11
12export function TodaysGoalView({ settings, todaysGoal, pastGoals, onShowSettings }: TodaysGoalViewProps) {
13 const extractGoalAmount = (title: string) => {
14 const match = title.match(/My goal is ([\d.]+)/);
15};
16
17export function loadSettings(): Settings {
18 if (typeof localStorage === 'undefined') return DEFAULT_SETTINGS;
19
27}
28
29export function saveSettings(settings: Settings): void {
30 if (typeof localStorage === 'undefined') return;
31
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.