Skip to content

Commit 0d6284b

Browse files
committed
Serve frontend from root path
1 parent ead6312 commit 0d6284b

11 files changed

Lines changed: 25 additions & 16 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ renovate.json
2020
spec/
2121
tmp/
2222
work/
23+
public/assets/
24+
public/frontend/
25+
public/index.html

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
# Ignore frontend build output and tooling caches
4040
/frontend/dist/
41+
/public/assets/
42+
/public/index.html
4143
/frontend/node_modules/
4244
/public/frontend
4345
/frontend/playwright-report/

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ COPY --chown=$USER:$USER Gemfile Gemfile.lock app.rb config.ru ./
9393
COPY --chown=$USER:$USER app ./app
9494
COPY --chown=$USER:$USER config ./config
9595
COPY --chown=$USER:$USER public ./public
96-
COPY --from=frontend-builder --chown=$USER:$USER /app/public/frontend ./public/frontend
96+
COPY --from=frontend-builder --chown=$USER:$USER /app/public/index.html ./public/index.html
97+
COPY --from=frontend-builder --chown=$USER:$USER /app/public/assets ./public/assets
9798

9899
CMD ["bundle", "exec", "puma", "-C", "./config/puma.rb"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ html2rss-web converts arbitrary websites into RSS 2.0 feeds with a slim Ruby bac
2020
## Architecture
2121

2222
- **Backend:** Ruby + Roda, backed by the `html2rss` gem for extraction.
23-
- **Frontend:** Preact app built with Vite into `public/frontend`.
23+
- **Frontend:** Preact app built with Vite into `public/`.
2424
- **Distribution:** Docker Compose by default; other deployments require manual wiring.
2525
- [Project notes](docs/README.md)
2626

@@ -101,7 +101,7 @@ The OpenAPI file is generated from Ruby request specs only.
101101
| Command | Purpose |
102102
| ----------------------- | -------------------------------------------- |
103103
| `npm run dev` | Vite dev server with hot reload (port 4001). |
104-
| `npm run build` | Build static assets into `public/frontend`. |
104+
| `npm run build` | Build static assets into `public/`. |
105105
| `npm run test:run` | Unit tests (Vitest). |
106106
| `npm run test:contract` | Contract tests with MSW. |
107107

app.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def development? = self.class.development?
100100
private
101101

102102
def render_index_page(router)
103-
index_path = 'public/frontend/index.html'
103+
index_path = 'public/index.html'
104104
router.response['Content-Type'] = 'text/html'
105105
File.exist?(index_path) ? File.read(index_path) : FALLBACK_HTML
106106
end

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The only other file that belongs in `docs/` is the generated OpenAPI contract at
99
## System Snapshot
1010

1111
- Backend: Ruby + Roda under the `Html2rss::Web` namespace.
12-
- Frontend: Preact + Vite, built into `public/frontend`.
12+
- Frontend: Preact + Vite, built into `public/`.
1313
- Feed extraction: delegated to the `html2rss` gem.
1414
- Distribution: Docker Compose / Dev Container first.
1515

frontend/index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
name="description"
99
content="html2rss converts fixed demo pages or operator-submitted URLs into feed endpoints."
1010
/>
11-
<link
12-
rel="icon"
13-
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='10' fill='%230b0c0d'/%3E%3Cpath d='M14 20h36v6H14zm0 12h25v6H14zm0 12h16v6H14z' fill='%23f3f4f6'/%3E%3C/svg%3E"
14-
/>
11+
<link rel="icon" href="/favicon.ico" />
1512
<title>html2rss</title>
1613
</head>
1714
<body>

frontend/src/__tests__/App.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ describe('App', () => {
272272
});
273273
});
274274

275-
it('builds a bookmarklet that returns to the current frontend entry', () => {
276-
window.history.replaceState({}, '', 'http://localhost:3000/frontend/index.html');
275+
it('builds a bookmarklet that returns to the root app entry', () => {
276+
window.history.replaceState({}, '', 'http://localhost:3000/');
277277
render(<App />);
278278

279279
fireEvent.click(screen.getByRole('button', { name: 'More' }));
280280
const bookmarklet = screen.getByRole('link', { name: 'Bookmarklet' });
281-
expect(bookmarklet.getAttribute('href')).toContain('/frontend/index.html?url=');
281+
expect(bookmarklet.getAttribute('href')).toContain('/?url=');
282282
expect(bookmarklet.getAttribute('href')).not.toContain('%27+encodeURIComponent');
283283
});
284284
});

frontend/src/components/Bookmarklet.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ export function Bookmarklet() {
66
appUrl.search = '';
77
appUrl.hash = '';
88

9-
const targetPath = appUrl.pathname.endsWith('/frontend/index.html') ? appUrl.pathname : '/';
10-
const targetPrefix = `${appUrl.origin}${targetPath}?url=`;
9+
const targetPrefix = `${appUrl.origin}/?url=`;
1110

1211
return `javascript:window.location.href=${JSON.stringify(targetPrefix)}+encodeURIComponent(window.location.href);`;
1312
})();

frontend/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
22
import preact from '@preact/preset-vite';
33

44
export default defineConfig({
5+
base: '/',
56
plugins: [preact()],
67
server: {
78
host: true,
@@ -19,7 +20,7 @@ export default defineConfig({
1920
exclude: ['msw/node'],
2021
},
2122
build: {
22-
outDir: '../public/frontend',
23-
emptyOutDir: true,
23+
outDir: '../public',
24+
emptyOutDir: false,
2425
},
2526
});

0 commit comments

Comments
 (0)