diff --git a/ai/frontend_prompt_template.md b/ai/frontend_prompt_template.md new file mode 100644 index 0000000..24eb7c3 --- /dev/null +++ b/ai/frontend_prompt_template.md @@ -0,0 +1,43 @@ +# Frontend Prompt Template + +Follow the existing patterns in this codebase to: +- xxxxxxxx + +Requirements: +- xxxxx + +Process (TDD - Test Driven Development): +1. Write a test first +2. Run the test to confirm it fails +3. Implement the code to make the test pass +4. Run the test to confirm it passes +5. Repeat for each new behavior + +Code patterns to follow: +- First, explore the codebase to understand existing entity patterns +- Look at similar pages for reference +- Tests: follow existing patterns in cypress/e2e/ +- Lines should not exceed 80 columns, but should use up to 80 columns when possible — do not split lines unnecessarily +- Imports: always put imports at the top of the file +- Variable names: use explicit, descriptive names — never single-letter or abbreviated variables (e.g., use sponsorship not s, event not e) + +Git commit style: +- Present tense, imperative mood (add, create, test, fix) +- Lowercase +- Short (3-6 words) +- Match patterns found in git history + +Git commits: +- Tests should be committed first, before implementation +- One commit per file - each new file gets its own commit +- Make commits SMALL and FREQUENT - every meaningful change should be a commit +- Commits are for reviewing and documenting the development of code +- A commit can be as simple as adding one import, one getter, one property, etc. +- Don't wait to commit - commit as you go + +Branch naming: +- Use kebab-case (e.g., node-page text-page) +- Use descriptive feature names +- NEVER work directly on master - always create and work on a branch + +Do not push anything. Make commits as you go. diff --git a/app/View/ViewController.php b/app/View/ViewController.php index 742b4be..c131683 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -29,4 +29,12 @@ class ViewController return $response; } + + public function home(Response $response): Response + { + $html = file_get_contents(__DIR__ . '/../../views/templates/home.php', true); + $response->getBody()->write($html); + + return $response; + } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 6dfce21..db0dd63 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -13,6 +13,7 @@ $app = Bridge::create($container); // change first param to false for production $app->addErrorMiddleware(true, true, true); +$app->get('/home', [ViewController::class, 'home']); $app->get('/admin', [ViewController::class, 'admin']); $app->get('/admin/texts', [ViewController::class, 'texts']); $app->get('/admin/texts/{textId}', [ViewController::class, 'text']); diff --git a/cypress/e2e/home.cy.js b/cypress/e2e/home.cy.js new file mode 100644 index 0000000..d0ba1fe --- /dev/null +++ b/cypress/e2e/home.cy.js @@ -0,0 +1,20 @@ +describe('The home page', () => { + beforeEach(() => { + cy.exec('npm run db:seed') + }) + afterEach(() => { + cy.exec('npm run db:wipe') + }) + + it('displays heading', () => { + cy.visit('/home') + cy.get('h1').should('contain', 'Home') + }) + + it('displays texts from api', () => { + cy.intercept('GET', '/api/texts').as('getTexts') + cy.visit('/home') + cy.wait('@getTexts') + cy.get('#texts-list').should('contain', 'Tanach') + }) +}) diff --git a/public/js/home.js b/public/js/home.js new file mode 100644 index 0000000..3e7cde8 --- /dev/null +++ b/public/js/home.js @@ -0,0 +1,13 @@ +document.addEventListener('DOMContentLoaded', () => { + const textsList = document.getElementById('texts-list'); + + async function loadTexts() { + const response = await fetch('/api/texts'); + const texts = await response.json(); + textsList.innerHTML = texts + .map(text => '