feat: added frontend

This commit is contained in:
Ewen 2024-05-12 11:31:51 +02:00
parent c8370a5418
commit 31d9347876
49 changed files with 5270 additions and 0 deletions

View file

@ -1,2 +1,4 @@
FLASK_SECRET_KEY="dev" FLASK_SECRET_KEY="dev"
FLASK_DEBUG=True FLASK_DEBUG=True
VITE_API_ENDPOINT="http://localhost:8080/api/"

5
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"recommendations": [
"vue.volar"
]
}

6
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"tailwindCSS.includeLanguages": {
"plaintext": "vue"
},
"editor.formatOnSave": true
}

View file

@ -9,3 +9,14 @@ services:
- 8080:8080 - 8080:8080
volumes: volumes:
- ./api:/app - ./api:/app
frontend:
env_file:
- .env.dev
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- 5173:5173
volumes:
- ./frontend:/app

26
frontend/.eslintrc.cjs Normal file
View file

@ -0,0 +1,26 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
overrides: [
{
files: [
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}',
'cypress/support/**/*.{js,ts,jsx,tsx}'
],
'extends': [
'plugin:cypress/recommended'
]
}
],
parserOptions: {
ecmaVersion: 'latest'
}
}

30
frontend/.gitignore vendored Normal file
View file

@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo

View file

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

7
frontend/.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,7 @@
{
"recommendations": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

10
frontend/Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM node:21-alpine as frontend
RUN npm install -g pnpm
WORKDIR /app
COPY package*.json ./
RUN pnpm install
CMD ["pnpm", "run", "dev", "--host", "0.0.0.0"]

61
frontend/README.md Normal file
View file

@ -0,0 +1,61 @@
# frontend
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
pnpm install
```
### Compile and Hot-Reload for Development
```sh
pnpm dev
```
### Type-Check, Compile and Minify for Production
```sh
pnpm build
```
### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
pnpm test:unit
```
### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
```sh
pnpm test:e2e:dev
```
This runs the end-to-end tests against the Vite development server.
It is much faster than the production build.
But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):
```sh
pnpm build
pnpm test:e2e
```
### Lint with [ESLint](https://eslint.org/)
```sh
pnpm lint
```

View file

@ -0,0 +1,8 @@
import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
baseUrl: 'http://localhost:4173'
}
})

View file

@ -0,0 +1,8 @@
// https://on.cypress.io/api
describe('My First Test', () => {
it('visits the app root url', () => {
cy.visit('/')
cy.contains('h1', 'You did it!')
})
})

View file

@ -0,0 +1,10 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["./**/*", "../support/**/*"],
"compilerOptions": {
"isolatedModules": false,
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
}
}

View file

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View file

@ -0,0 +1,39 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
export {}

View file

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

1
frontend/env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="vite/client" />

12
frontend/index.html Normal file
View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rudibridge</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

51
frontend/package.json Normal file
View file

@ -0,0 +1,51 @@
{
"name": "frontend",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"test:unit": "vitest",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"@vuelidate/core": "^2.0.3",
"@vuelidate/validators": "^2.0.4",
"axios": "^1.6.8",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.8.0",
"@tsconfig/node20": "^20.1.4",
"@types/jsdom": "^21.1.6",
"@types/node": "^20.12.5",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/test-utils": "^2.4.5",
"@vue/tsconfig": "^0.5.1",
"autoprefixer": "^10.4.19",
"cypress": "^13.7.2",
"eslint": "^8.57.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-vue": "^9.23.0",
"jsdom": "^24.0.0",
"npm-run-all2": "^6.1.2",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"start-server-and-test": "^2.0.3",
"tailwindcss": "^3.4.3",
"typescript": "~5.4.0",
"vite": "^5.2.8",
"vitest": "^1.4.0",
"vue-tsc": "^2.0.11"
}
}

4266
frontend/pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

BIN
frontend/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

24
frontend/src/App.vue Normal file
View file

@ -0,0 +1,24 @@
<script setup lang="ts">
</script>
<template>
<div class="flex justify-center sm:bg-slate-100 sm:p-5">
<div class="bg-white sm:rounded-lg sm:shadow-md sm:border-gray-200 sm:border sm:max-w-lg">
<header class="p-3 border-b">
<h1 class="text-xl font-bold title"><router-link to="/">Rudibridge</router-link></h1>
</header>
<main class="p-3">
<RouterView />
</main>
<footer class="flex flex-row justify-end p-3 border-t">
<ul class="flex flex-row gap-2">
<li><router-link to="/about" class="underline text-slate-600">About</router-link></li>
<li><a href="https://git.fedi.bzh/ewen/rudibridge" class="underline text-slate-600">Code</a></li>
</ul>
</footer>
</div>
</div>
</template>

View file

@ -0,0 +1,86 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 276 B

View file

@ -0,0 +1,21 @@
<script setup lang="ts">
import { type Feed } from "@/types";
import FeedItemComponent from "@/components/FeedItemComponent.vue"
defineProps<{
feed: Feed
}>();
</script>
<template>
<div>
<h2 class="text-lg"><span class="font-light">Page title:</span> {{ feed.title }}</h2>
<p class="text-lg"><span class="font-light">Generated from:</span> <a class="underline" :href="feed.url">{{
feed.url }}</a></p>
<div class="flex flex-col gap-3 my-5">
<FeedItemComponent v-for="(item, index) in feed.items" :key="index" :item="item" />
</div>
</div>
</template>

View file

@ -0,0 +1,44 @@
<script lang="ts" setup>
import { type FeedItem } from '@/types';
defineProps<{
item: FeedItem,
}>();
</script>
<template>
<div class="p-2 bg-purple-100 rounded">
<h3 class="font-bold">
<a v-if="item.link" :href="item.link" class="text-purple-900 underline">
{{ item.title }}
</a>
<span v-else>
{{ item.title }}
</span>
</h3>
<p v-if="item.content" class="text-gray-900">{{ item.content }}</p>
<div v-if="item.author || item.datetime || true" class="flex justify-between mt-2">
<div v-if="item.author" class="flex flex-row gap-1 items-center fleflex text-slate-700x-row text-slate-700">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round"
d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" />
</svg>
<span class="text-sm">
{{ item.author }}
</span>
</div>
<div v-if="item.datetime" class="flex flex-row gap-1 items-center text-slate-700">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round"
d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
<span class="text-sm">
{{ item.datetime }}
</span>
</div>
</div>
</div>
</template>

View file

@ -0,0 +1,245 @@
<script setup lang="ts">
import FeedComponent from "@/components/FeedComponent.vue";
import ModalComponent from "@/components/ModalComponent.vue";
import { useVuelidate } from "@vuelidate/core";
import { required, url } from "@vuelidate/validators";
import { reactive, ref, type Ref } from "vue";
import axios from "axios";
import { type Feed } from "@/types";
const formRef = ref();
const showModal = ref(false);
const requestUrl: Ref<string | undefined> = ref(undefined);
const feed: Ref<Feed | undefined> = ref(undefined)
const isLoaded = ref(false);
const state = reactive({
url: '',
article: '',
title: '',
articleClass: '',
titleClass: '',
section: '',
sectionClass: '',
content: '',
contentClass: '',
link: '',
linkClass: '',
datetime: '',
datetimeClass: '',
author: '',
authorClass: '',
});
const rules = {
url: { required, url },
article: { required },
title: { required },
}
const v$ = useVuelidate(rules, state);
async function submit() {
isLoaded.value = false;
feed.value = undefined;
const isFormCorrect = await v$.value.$validate();
if (!isFormCorrect) return;
requestUrl.value = import.meta.env.VITE_API_ENDPOINT || "http://localhost:8080/api/";
requestUrl.value += `feed/?url=${state.url}&article=${state.article}&title=${state.title}`;
if (state.articleClass) {
requestUrl.value += `&articleClass=${state.articleClass}`;
}
if (state.titleClass) {
requestUrl.value += `&titleClass=${state.titleClass}`;
}
if (state.section) {
requestUrl.value += `&section=${state.section}`;
}
if (state.sectionClass) {
requestUrl.value += `&sectionClass=${state.sectionClass}`;
}
if (state.content) {
requestUrl.value += `&content=${state.content}`;
}
if (state.contentClass) {
requestUrl.value += `&contentClass=${state.contentClass}`;
}
if (state.link) {
requestUrl.value += `&link=${state.link}`;
}
if (state.linkClass) {
requestUrl.value += `&linkClass=${state.linkClass}`;
}
if (state.datetime) {
requestUrl.value += `&datetime=${state.datetime}`;
}
if (state.datetimeClass) {
requestUrl.value += `&datetimeClass=${state.datetimeClass}`;
}
if (state.author) {
requestUrl.value += `&author=${state.author}`;
}
if (state.authorClass) {
requestUrl.value += `&authorClass=${state.authorClass}`;
}
if (!requestUrl.value) return
showModal.value = true;
const response = await axios.get(requestUrl.value + "&format=json")
feed.value = response.data;
isLoaded.value = true;
}
function toggleModal() {
showModal.value = !showModal.value;
}
function copyLink() {
if (requestUrl.value) {
navigator.clipboard.writeText(requestUrl.value);
}
}
</script>
<template>
<form :ref="formRef" class="flex flex-col gap-4 py-2" @submit.prevent="submit()">
<fieldset class="flex flex-col gap-3 px-2 py-3 rounded border">
<legend class="text-lg font-light">Required parameters</legend>
<div>
<label for="url" :class="v$.url.$error ? 'text-red-500 font-bold' : ''">URL of the page</label>
<span v-if="v$.url.$error" class="text-red-500"> · {{ v$.url.$errors[0].$message }}</span>
<input type="text" name="url" id="url" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.url" placeholder="" />
</div>
<div>
<label for="article" :class="v$.article.$error ? 'text-red-500 font-bold' : ''">HTML tag encapsulating a
feed article</label>
<span v-if="v$.article.$error" class="text-red-500"> · {{ v$.article.$errors[0].$message }}</span>
<input type="text" name="article" id="article" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.article" placeholder="" />
</div>
<div>
<label for="title" :class="v$.title.$error ? 'text-red-500 font-bold' : ''">HTML tag encapsulating the
article title</label>
<span v-if="v$.title.$error" class="text-red-500"> · {{ v$.title.$errors[0].$message }}</span>
<input type="text" name="title" id="title" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.title" placeholder="" />
</div>
</fieldset>
<fieldset class="flex flex-col gap-3 p-1 rounded border">
<legend class="text-lg font-light">Optional parameters</legend>
<div>
<label for="articleClass">Article class name</label>
<input type="text" name="articleClass" id="articleClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.articleClass"
placeholder="" />
</div>
<div>
<label for="titleClass">Title class name</label>
<input type="text" name="titleClass" id="titleClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.titleClass" placeholder="" />
</div>
<div>
<label for="section">HTML tag encapsulating the group of items (section)</label>
<input type="text" name="section" id="section" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.section" placeholder="" />
</div>
<div>
<label for="sectionClass">Section class name</label>
<input type="text" name="sectionClass" id="sectionClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.sectionClass"
placeholder="" />
</div>
<div>
<label for="content">HTML tag encapsulating the content, or description, of the item</label>
<input type="text" name="content" id="content" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.content" placeholder="" />
</div>
<div>
<label for="contentClass">Content class name</label>
<input type="text" name="contentClass" id="contentClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.contentClass"
placeholder="" />
</div>
<div>
<label for="link">HTML tag encapsulating the link to the item</label>
<input type="text" name="link" id="link" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.link" placeholder="" />
</div>
<div>
<label for="linkClass">Link class name</label>
<input type="text" name="linkClass" id="linkClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.linkClass" placeholder="" />
</div>
<div>
<label for="datetime">HTML tag encapsulating the date and time of the item</label>
<input type="text" name="datetime" id="datetime" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.datetime" placeholder="" />
</div>
<div>
<label for="datetimeClass">Datetime class name</label>
<input type="text" name="datetimeClass" id="datetimeClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.datetimeClass"
placeholder="" />
</div>
<div>
<label for="author">HTML tag encapsulating the author of the item</label>
<input type="text" name="author" id="author" class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border"
v-model="state.author" placeholder="" />
</div>
<div>
<label for="author">Author class name</label>
<input type="text" name="authorClass" id="authorClass"
class="px-4 mt-1 w-full h-8 bg-gray-50 rounded border" v-model="state.authorClass" placeholder="" />
</div>
</fieldset>
<div class="flex justify-center">
<button class="p-3 w-44 text-white bg-purple-800 rounded hover:bg-purple-700"
@click.prevent="submit()">Generate
feed</button>
</div>
</form>
<Teleport to="body">
<ModalComponent v-if="showModal" @close="toggleModal()">
<div class="text-center" v-if="!isLoaded">Loading</div>
<FeedComponent v-if="feed" :feed=feed></FeedComponent>
<div class="flex flex-row gap-2">
<button @click.prevent="toggleModal" class="p-1 w-8 h-8 rounded bg-slate-300 hover:bg-slate-400">
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 12H19M5 12L11 6M5 12L11 18" stroke="#000000" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
</svg>
</button>
<div class="relative w-full">
<div class="flex absolute inset-y-0 w-full pointer-event-none">
<input disabled :value="requestUrl"
class="block p-2 ml-8 w-full h-8 text-sm bg-gray-100 rounded-r border-gray-300 text-gray" />
</div>
<button class="absolute p-2 w-8 h-8 text-sm bg-purple-300 rounded-l hover:bg-purple-500"
@click.prevent="copyLink()">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 115.77 122.88"
xml:space="preserve">
<g>
<path class="st0"
d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z" />
</g>
</svg>
</button>
</div>
</div>
</ModalComponent>
</Teleport>
</template>

View file

@ -0,0 +1,21 @@
<script setup lang="ts">
defineEmits(['close']);
</script>
<template>
<div class="overflow-y-auto fixed inset-0 pb-8 w-full bg-black bg-opacity-50">
<div class="flex justify-center items-start w-full sm:mt-24">
<div class="w-full text-black bg-white shadow-xl sm:rounded-lg sm:max-w-xl" role="dialog" aria-modal="true"
@keydown.esc="$emit('close')">
<div class="flex justify-between px-2 border-b">
<h3 class="text-lg font-bold">Preview</h3>
<button class="text-lg" @click="$emit('close')">×</button>
</div>
<div class="p-2 sm:p-4">
<slot></slot>
</div>
</div>
</div>
</div>
</template>

View file

@ -0,0 +1,11 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import HelloWorld from '../HelloWorld.vue'
describe('HelloWorld', () => {
it('renders properly', () => {
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
expect(wrapper.text()).toContain('Hello Vitest')
})
})

View file

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
/>
</svg>
</template>

View file

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" fill="currentColor">
<path
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
/>
</svg>
</template>

View file

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="currentColor">
<path
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
/>
</svg>
</template>

View file

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
/>
</svg>
</template>

View file

@ -0,0 +1,19 @@
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
class="iconify iconify--mdi"
width="24"
height="24"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
>
<path
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
fill="currentColor"
></path>
</svg>
</template>

3
frontend/src/index.css Normal file
View file

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

11
frontend/src/main.ts Normal file
View file

@ -0,0 +1,11 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './index.css'
const app = createApp(App)
app.use(router)
app.mount('#app')

View file

@ -0,0 +1,23 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import('../views/AboutView.vue')
}
]
})
export default router

View file

@ -0,0 +1,12 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', () => {
const count = ref(0)
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
return { count, doubleCount, increment }
})

13
frontend/src/types.ts Normal file
View file

@ -0,0 +1,13 @@
export type FeedItem = {
title: string,
link?: string,
content?: string,
author?: string,
datetime?: string,
}
export type Feed = {
title: string,
url: string,
items: FeedItem[],
}

View file

@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

View file

@ -0,0 +1,11 @@
<script setup lang="ts">
import FormComponent from "@/components/FormComponent.vue"
</script>
<template>
<main>
<h1 class="text-xl font-bold">Build an RSS feed from a webpage</h1>
<FormComponent />
</main>
</template>

View file

@ -0,0 +1,9 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./src/**/*.{html,js,ts,vue}"],
theme: {
extend: {},
},
plugins: [],
}

View file

@ -0,0 +1,14 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}

17
frontend/tsconfig.json Normal file
View file

@ -0,0 +1,17 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
],
"compilerOptions": {
"module": "NodeNext"
}
}

View file

@ -0,0 +1,19 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}

View file

@ -0,0 +1,11 @@
{
"extends": "./tsconfig.app.json",
"exclude": [],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
"lib": [],
"types": ["node", "jsdom"]
}
}

16
frontend/vite.config.ts Normal file
View file

@ -0,0 +1,16 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})

14
frontend/vitest.config.ts Normal file
View file

@ -0,0 +1,14 @@
import { fileURLToPath } from 'node:url'
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
import viteConfig from './vite.config'
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/**'],
root: fileURLToPath(new URL('./', import.meta.url))
}
})
)