convertResumemain.tsx12 matches
86}
8788/* API Key Input Styles */
89#apiKeyInput {
90display: none;
91margin-top: 10px;
108<div class="buttons">
109<div class="hosting">
110<input type="text" id="apiKeyInput" placeholder="Enter your Val Town API Key">
111<button id="hostButton">Host Resume on Val Town</button>
112</div>
122event.preventDefault();
123const resumeContent = document.getElementById('resumeContent').value;
124const apiKey = '${Deno.env.get("OPENAI_API_KEY")}';
125const spinner = document.getElementById('spinner');
126const jsonOutput = document.getElementById('jsonOutput');
127const copyButton = document.getElementById('copyButton');
128const hostButton = document.getElementById('hostButton');
129const apiKeyInput = document.getElementById('apiKeyInput');
130131spinner.style.display = 'block';
133copyButton.style.display = 'none';
134hostButton.style.display = 'none';
135apiKeyInput.style.display = 'none';
136
137try {
138const jsonResume = await convertToResumeJSON(resumeContent, apiKey);
139jsonOutput.textContent = JSON.stringify(JSON.parse(jsonResume), null, 2);
140copyButton.style.display = 'block';
141hostButton.style.display = 'block';
142apiKeyInput.style.display = 'block';
143} catch (error) {
144jsonOutput.textContent = 'An error occurred while converting the resume.';
153document.getElementById('hostButton').addEventListener('click', async function() {
154const jsonOutput = document.querySelector('#jsonOutput').innerText;
155const valTownApiKey = document.getElementById('apiKeyInput').value; // Get the Val Town API key from input
156
157if (!valTownApiKey) {
158alert('Please enter your Val Town API Key.');
159return;
160}
161
162try {
163const hostedUrl = await hostResume(JSON.parse(jsonOutput), valTownApiKey);
164alert('Resume hosted at: ' + hostedUrl);
165window.open(hostedUrl, '_blank');
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
hostResumemain.tsx5 matches
1export async function hostResume(jsonResume, apiKey) {
2const userDetailsEndpoint = 'https://api.val.town/v1/me/';
3const createValEndpoint = 'https://api.val.town/v1/vals/';
45// get user details
7method: 'GET',
8headers: {
9'Authorization': `Bearer ${apiKey}`
10}
11});
22method: 'POST',
23headers: {
24'Authorization': `Bearer ${apiKey}`,
25'Content-Type': 'application/json'
26},
sqliteExplorerAppREADME.md1 match
13## Authentication
1415Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
1617## Todos / Plans
sqliteExplorerAppmain.tsx2 matches
26<head>
27<title>SQLite Explorer</title>
28<link rel="preconnect" href="https://fonts.googleapis.com" />
2930<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
31<link
32href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
33rel="stylesheet"
34/>
purpleKangaroomain.tsx1 match
3import { renderToString } from "npm:react-dom/server";
45// This uses by personal API key, you'll need to provide your own if
6// you fork this. We'll be adding support to the std/openai lib soon!
7const openai = new OpenAI();
1import { ValTownAPI } from 'https://esm.town/v/iamseeley/ValTownAPI';
2import { GitHubAPI } from 'https://esm.town/v/iamseeley/GitHubAPI';
34const VAL_TOWN_API_KEY = Deno.env.get('valtown');
5const GITHUB_TOKEN = Deno.env.get("GITHUB_TOKEN");
6const GITHUB_REPO = "iamseeley/vals-backup";
7const GITHUB_BRANCH = "main";
89const valTownAPI = new ValTownAPI(VAL_TOWN_API_KEY);
10const gitHubAPI = new GitHubAPI(GITHUB_TOKEN);
1112async function fetchVals() {
13const response = await valTownAPI.getAllVals();
14return response.data;
15}
18console.log(`Fetching existing files from repo: ${GITHUB_REPO}, branch: ${GITHUB_BRANCH}`);
19try {
20const response = await gitHubAPI.getRepoContent(GITHUB_REPO, "", GITHUB_BRANCH);
21console.log("Existing files:", response);
22return response.map(file => file.path);
3233for (const file of files) {
34const commitHistory = await gitHubAPI.getCommitHistory(GITHUB_REPO, file, GITHUB_BRANCH);
35lastModifiedDates[file] = new Date(commitHistory[0].commit.committer.date).getTime();
36}
46if (fileExists) {
47console.log(`File exists: ${filePath}`);
48const shaResponse = await gitHubAPI.getRepoContent(GITHUB_REPO, filePath, GITHUB_BRANCH);
49const sha = shaResponse.sha;
50console.log(`Fetched SHA for ${filePath}: ${sha}`);
52throw new Error(`Failed to fetch SHA for ${filePath}`);
53}
54await gitHubAPI.updateFile(GITHUB_REPO, filePath, fileContent, sha, commitMessage, GITHUB_BRANCH);
55console.log(`File updated: ${filePath}`);
56} else {
57console.log(`File does not exist: ${filePath}`);
58await gitHubAPI.createFile(GITHUB_REPO, filePath, fileContent, commitMessage, GITHUB_BRANCH);
59console.log(`File created: ${filePath}`);
60}
1export class GitHubAPI {
2constructor(private token: string) {}
34async getRepoContent(repo: string, path: string, branch: string) {
5const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}`, {
6method: 'GET',
7headers: {
1819async getFileSHA(repo: string, path: string, branch: string) {
20const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}`, {
21method: 'GET',
22headers: {
3435async updateFile(repo: string, path: string, content: string, sha: string, message: string, branch: string) {
36const response = await fetch(`https://api.github.com/repos/${repo}/contents/${path}`, {
37method: 'PUT',
38headers: {
5960async createFile(repo: string, path: string, content: string, message: string, branch: string) {
61const url = `https://api.github.com/repos/${repo}/contents/${path}`;
6263let body: any = {
104105async getCommitHistory(repo: string, path: string, branch: string) {
106const response = await fetch(`https://api.github.com/repos/${repo}/commits?path=${path}&sha=${branch}`, {
107method: 'GET',
108headers: {
ValTownAPImain.tsx6 matches
1export class ValTownAPI {
2constructor(private apiKey: string) {}
34async getUserID() {
5const response = await fetch('https://api.val.town/v1/me', {
6method: 'GET',
7headers: {
8'Authorization': `Bearer ${this.apiKey}`,
9'Content-Type': 'application/json'
10}
21async getAllVals() {
22const userId = await this.getUserID();
23const response = await fetch(`https://api.val.town/v1/users/${userId}/vals`, {
24method: 'GET',
25headers: {
26'Authorization': `Bearer ${this.apiKey}`,
27'Content-Type': 'application/json'
28}