Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
- Output directory: `dist`
- Production branch: `main`
- Automatic Production deployments: disabled
- Custom domains / DNS: none
- GitHub Pages environment URL: `http://ocodejs.co/docs.rtf/` (from the successful Pages deployment log).
- The frontend detects the `/docs.rtf` base path on `ocodejs.co`; Cloudflare Preview remains rooted at `/`.
- Custom domains / DNS: none changed by this project.

## Build output

Expand All @@ -18,3 +20,5 @@ The build validates `index.html` and `studio.html`, then publishes only those tw
## Product boundaries

This repository currently contains a static frontend prototype. Authentication, contact submission, student data, course purchases, and checkout are demonstrations only. No real payment or account operation is performed. Production launch requires backend integration, security review, privacy/legal review, and explicit production approval.

The `fix/github-pages-subpath-routing` branch is also included in Preview builds so the `/docs.rtf` path fix can be tested before any further GitHub Pages release.
2 changes: 1 addition & 1 deletion README-IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ npx serve dist
- Build Cloudflare chỉ xuất bản `index.html`, `studio.html` và metadata; Pages tự động fallback về `index.html` cho route SPA khi không có `404.html`. GitHub Pages workflow tạo riêng `404.html` sau bước build.
- `_redirects` hỗ trợ refresh các SPA route; `404.html` dùng app shell để router xử lý route trực tiếp.
- `_headers` ngăn index bản preview.
- GitHub Pages dùng workflow `.github/workflows/pages.yml` làm pipeline tự động duy nhất khi có thay đổi trên `main`. Các workflow `static.yml`, `jekyll-gh-pages.yml` và `jekyll.yml` là legacy/manual-only để tránh nhiều workflow ghi đè cùng Pages deployment.
- GitHub Pages dùng workflow `.github/workflows/pages.yml` làm pipeline tự động duy nhất khi có thay đổi trên `main`. Frontend tự nhận diện base path `/docs.rtf` trên `ocodejs.co`, còn Cloudflare Preview chạy ở root. Các workflow `static.yml`, `jekyll-gh-pages.yml` và `jekyll.yml` là legacy/manual-only để tránh nhiều workflow ghi đè cùng Pages deployment.
- Không tự bật domain riêng hoặc Production trong cấu hình staging.

## Phạm vi hiện tại
Expand Down
12 changes: 7 additions & 5 deletions index.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"version": "0.1.0",
"type": "module",
"scripts": {
"build": "node scripts/build-site.mjs"
"build": "npm test && node scripts/build-site.mjs",
"test": "node --test scripts/base-path.test.mjs"
},
"engines": {
"node": ">=20"
Expand Down
22 changes: 22 additions & 0 deletions scripts/base-path.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export function createBasePathTools(hostname, pathname) {
const isDocsPagesHost = hostname === "ocodejs.co";
const isDocsSubpath = pathname === "/docs.rtf" || pathname.startsWith("/docs.rtf/");
const basePath = isDocsPagesHost && isDocsSubpath ? "/docs.rtf" : "";

function appPath(path) {
if (!basePath) return path;
if (path === "/") return basePath + "/";
return basePath + (path.startsWith("/") ? path : "/" + path);
}

function applyBaseLinks(root = document) {
if (!basePath) return;
root.querySelectorAll('a[href^="/"]').forEach(anchor => {
const href = anchor.getAttribute("href");
if (href === basePath || href.startsWith(basePath + "/")) return;
anchor.setAttribute("href", appPath(href));
});
}

return { basePath, appPath, applyBaseLinks };
}
62 changes: 62 additions & 0 deletions scripts/base-path.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import test from "node:test";
import assert from "node:assert/strict";
import { createBasePathTools } from "./base-path.mjs";

function fakeRoot(hrefs) {
const anchors = hrefs.map(href => ({
href,
getAttribute(name) { return name === "href" ? this.href : null; },
setAttribute(name, value) { if (name === "href") this.href = value; }
}));
return {
anchors,
querySelectorAll(selector) {
assert.equal(selector, 'a[href^="/"]');
return anchors.filter(anchor => anchor.href.startsWith("/"));
}
};
}

test("GitHub Pages docs subpath is detected only inside /docs.rtf", () => {
assert.equal(createBasePathTools("ocodejs.co", "/docs.rtf/").basePath, "/docs.rtf");
assert.equal(createBasePathTools("ocodejs.co", "/docs.rtf/kham-pha").basePath, "/docs.rtf");
assert.equal(createBasePathTools("ocodejs.co", "/studio.html").basePath, "");
assert.equal(createBasePathTools("preview.pages.dev", "/").basePath, "");
});

test("client navigation preserves the docs base path", () => {
const { appPath } = createBasePathTools("ocodejs.co", "/docs.rtf/");
assert.equal(appPath("/"), "/docs.rtf/");
assert.equal(appPath("/kham-pha"), "/docs.rtf/kham-pha");
assert.equal(appPath("studio.html"), "/docs.rtf/studio.html");
});

test("base path rewrites dynamically generated course-card anchors", () => {
const { applyBaseLinks } = createBasePathTools("ocodejs.co", "/docs.rtf/kham-pha");
const root = fakeRoot(["/khoa-hoc/js-core", "/studio.html", "/docs.rtf/khoa-hoc/already-prefixed", "https://example.com"]);
applyBaseLinks(root);
assert.deepEqual(root.anchors.map(anchor => anchor.href), [
"/docs.rtf/khoa-hoc/js-core",
"/docs.rtf/studio.html",
"/docs.rtf/khoa-hoc/already-prefixed",
"https://example.com"
]);
});

test("root deployment on ocodejs.co does not force docs subpath", () => {
const { basePath, appPath } = createBasePathTools("ocodejs.co", "/studio.html");
assert.equal(basePath, "");
assert.equal(appPath("/"), "/");
const root = fakeRoot(["/studio.html"]);
createBasePathTools("ocodejs.co", "/studio.html").applyBaseLinks(root);
assert.equal(root.anchors[0].href, "/studio.html");
});

test("Cloudflare Preview remains rooted and does not rewrite links", () => {
const { basePath, appPath, applyBaseLinks } = createBasePathTools("fix-preview.pages.dev", "/kham-pha");
assert.equal(basePath, "");
assert.equal(appPath("/kham-pha"), "/kham-pha");
const root = fakeRoot(["/studio.html"]);
applyBaseLinks(root);
assert.equal(root.anchors[0].href, "/studio.html");
});
3 changes: 3 additions & 0 deletions scripts/build-site.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { resolve } from "node:path";
const root = process.cwd();
const output = resolve(root, "dist");
const required = ["index.html", "studio.html"];
const browserHelpers = ["scripts/base-path.mjs"];

for (const file of required) {
const source = await readFile(resolve(root, file), "utf8");
Expand All @@ -27,6 +28,8 @@ for (const file of required) {
await rm(output, { recursive: true, force: true });
await mkdir(output, { recursive: true });
for (const file of required) await cp(resolve(root, file), resolve(output, file));
await mkdir(resolve(output, "scripts"), { recursive: true });
for (const file of browserHelpers) await cp(resolve(root, file), resolve(output, file));
// Cloudflare Pages automatically serves index.html for unmatched routes when
// no top-level 404.html is present. GitHub Pages gets its own 404 fallback
// in the Pages workflow after this build command.
Expand Down
5 changes: 4 additions & 1 deletion studio.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
}

</style></head><body><div class="wrap"><header class="top"><a class="brand" href="/">O<b>CODEJS</b> <span style="color:#8794a8;font-size:11px">/ AI STUDIO</span></a><div class="topright"><span><i class="dot"></i>STUDIO PREVIEW</span><span class="hide">React · Next.js · Tailwind · shadcn/ui</span><a href="/" class="muted">← Website</a></div></header></div><div class="layout"><aside><div class="side-title">WORKSPACE</div><a class="side-link active" href="#">✳ New generation</a><a class="side-link" href="#history">◷ Generation history</a><a class="side-link" href="#projects">▧ My projects</a><div class="side-title">TOOLS</div><a class="side-link" href="#design">▤ UI generator</a><a class="side-link" href="#code">⌘ Code assistant</a><a class="side-link" href="#figma">◇ Figma import</a><div class="side-title">RESOURCES</div><a class="side-link" href="#github">⌁ GitHub sync <span>↗</span></a><a class="side-link" href="#docs">▣ Documentation</a><div class="side-title">ACCOUNT</div><a class="side-link" href="#settings">⚙ Settings</a></aside><main class="main"><div class="eyebrow">OCODEJS INTELLIGENCE / PRODUCT STUDIO</div><h1>Biến ý tưởng thành<br><span style="color:#91a8ff">sản phẩm thực tế.</span></h1><p class="sub">Trợ lý AI lập trình và thiết kế giao diện do OCodeJS phát triển. Mô tả bằng văn bản, đưa ảnh tham chiếu hoặc nhập liên kết Figma để bắt đầu.</p><div class="tabs"><button class="tab active" data-mode="ui">✳ Generate UI</button><button class="tab" data-mode="code">⌘ Code assistant</button><button class="tab" data-mode="image">▧ Image to UI</button></div><section class="promptbox"><textarea id="prompt" placeholder="Ví dụ: Tạo dashboard quản lý bán hàng hiện đại, sidebar tối, biểu đồ doanh thu, bảng đơn hàng và bộ lọc theo thời gian..."></textarea><div class="promptfoot"><div class="tools"><label class="toolbtn" for="imagefile">+ Ảnh / Screenshot</label><input id="imagefile" type="file" accept="image/*" hidden><button class="toolbtn" id="figmaBtn">◇ Figma URL</button><span id="fileName" class="small muted"></span></div><span class="small muted">Tiếng Việt · English</span></div></section><div id="figmaField" class="field hidden" style="margin-top:10px"><label>Figma file / prototype URL</label><input id="figmaUrl" placeholder="https://www.figma.com/design/..."></div><div class="upload" id="uploadInfo"><span>Thêm ảnh giao diện hoặc screenshot để AI phân tích layout, màu sắc và component.</span><span>PNG · JPG · WEBP</span></div><div class="options"><div class="field"><label>Framework</label><select id="framework"><option>React + Vite</option><option selected>Next.js App Router</option><option>React + TypeScript</option></select></div><div class="field"><label>Styling / UI</label><select id="styling"><option selected>Tailwind CSS + shadcn/ui</option><option>Tailwind CSS</option><option>CSS Modules</option></select></div></div><div class="field"><label>AI MODEL — OCODEJS AGENTS</label></div><div class="model-grid"><button class="model selected" data-model="mini"><strong>Agents Mini</strong><small>Nhanh · tác vụ gọn</small></button><button class="model" data-model="pro"><strong>Agents Pro</strong><small>Cân bằng · đa bước</small></button><button class="model" data-model="max"><strong>Agents Max</strong><small>Chuyên sâu · phức tạp</small></button></div><div class="field"><label>OUTPUT CAPABILITIES</label><div class="chips"><span class="chip on">Responsive UI</span><span class="chip on">TypeScript</span><span class="chip on">Accessible</span><span class="chip">Dark mode</span><span class="chip on">Reusable components</span></div></div><button class="primary generate" id="generate">✳ Generate with OCodeJS AI</button><p class="hint">Bản hiện tại là giao diện prototype. Kết quả mẫu được tạo cục bộ; cần kết nối inference API để gọi Agents Mini / Pro / Max thực sự.</p><div class="modalnote">🔒 Không gửi ảnh, prompt hay Figma URL tới máy chủ trong bản preview này. Chưa có xác thực, lưu dự án hoặc đồng bộ GitHub thật.</div></main><section class="right"><div class="preview-head"><strong>LIVE PREVIEW</strong><div class="tools"><button class="toolbtn" id="refresh">↻ Refresh</button><button class="toolbtn" id="expand">↗ Preview</button></div></div><div class="preview" id="preview"><div class="mock"><div class="mocknav"><span class="mockbrand">NORTHSTAR</span><span>Overview  Products  Pricing</span><span>Sign in</span></div><div class="mockhero"><div style="font-size:9px;color:#405fe8;font-weight:800;letter-spacing:1px">DESIGNED TO MOVE YOU FORWARD</div><h2>Your next big idea<br>starts right here.</h2><p>A clean, responsive interface generated with OCodeJS Studio.</p><span class="mockbtn">Get started →</span></div><div class="mockcards"><div class="mockcard">◈<b>Build faster</b>Reusable UI blocks</div><div class="mockcard">⌘<b>Ship confidently</b>Typed components</div><div class="mockcard">↗<b>Scale further</b>Modern workflow</div></div></div></div><div class="preview-caption" id="previewCaption">Preview mẫu · Chưa kết nối AI inference</div><div class="codepanel"><div class="codehead"><span id="codeFile">app/page.tsx</span><div class="tools"><button class="toolbtn" id="copy">Copy</button><button class="toolbtn" id="download">Download</button></div></div><pre class="code" id="code">// Your generated source code will appear here.
// Enter a prompt and select Generate to create a local UI starter.</pre></div><div class="tools" style="margin-top:12px"><button class="toolbtn" id="github">↗ Connect GitHub</button><button class="toolbtn" id="terminal">⌘ Terminal command</button></div><div class="modalnote" id="integration">GitHub sync và terminal export là điểm tích hợp dự kiến; chưa cấp quyền repository hoặc chạy lệnh từ trình duyệt.</div></section></div><script>
// Enter a prompt and select Generate to create a local UI starter.</pre></div><div class="tools" style="margin-top:12px"><button class="toolbtn" id="github">↗ Connect GitHub</button><button class="toolbtn" id="terminal">⌘ Terminal command</button></div><div class="modalnote" id="integration">GitHub sync và terminal export là điểm tích hợp dự kiến; chưa cấp quyền repository hoặc chạy lệnh từ trình duyệt.</div></section></div><script type="module">
import { createBasePathTools } from "./scripts/base-path.mjs";
const { applyBaseLinks } = createBasePathTools(location.hostname, location.pathname);
applyBaseLinks(document);
let model='mini',mode='ui',source='// Your generated source code will appear here.\n// Enter a prompt and select Generate to create a local UI starter.';
const $=id=>document.getElementById(id);
document.querySelectorAll('[data-model]').forEach(b=>b.onclick=()=>{document.querySelectorAll('[data-model]').forEach(x=>x.classList.remove('selected'));b.classList.add('selected');model=b.dataset.model});
Expand Down
Loading