feat(export-options): Google Sheets 템플릿 모드 옵션(UI+extras) 추가
This commit is contained in:
@@ -8,6 +8,7 @@ import { AssetManager } from '@/lib/assets/assetManager'
|
|||||||
import { buildZip } from '@/lib/exporter/zip'
|
import { buildZip } from '@/lib/exporter/zip'
|
||||||
import { buildExtrasForPage } from '@/lib/exporter/extras'
|
import { buildExtrasForPage } from '@/lib/exporter/extras'
|
||||||
import { buildAssetsMetadata } from '@/lib/exporter/assets.meta'
|
import { buildAssetsMetadata } from '@/lib/exporter/assets.meta'
|
||||||
|
import { buildAssetsIndex } from '@/lib/exporter/assets.index'
|
||||||
import type { Section } from '@/lib/state/store'
|
import type { Section } from '@/lib/state/store'
|
||||||
import { createFormStore, type FormState } from '@/lib/state/formStore'
|
import { createFormStore, type FormState } from '@/lib/state/formStore'
|
||||||
import FormBuilderPanel from '@/components/FormBuilderPanel'
|
import FormBuilderPanel from '@/components/FormBuilderPanel'
|
||||||
@@ -56,6 +57,7 @@ export default function BuilderClientPage() {
|
|||||||
const [manifestDisplay, setManifestDisplay] = useState<string>('')
|
const [manifestDisplay, setManifestDisplay] = useState<string>('')
|
||||||
const [manifestThemeColor, setManifestThemeColor] = useState<string>('')
|
const [manifestThemeColor, setManifestThemeColor] = useState<string>('')
|
||||||
const [robotsDisallow, setRobotsDisallow] = useState<string>('')
|
const [robotsDisallow, setRobotsDisallow] = useState<string>('')
|
||||||
|
const [sheetsMode, setSheetsMode] = useState<'auto' | 'include' | 'exclude'>('auto')
|
||||||
const [viewport, setViewport] = useState<'desktop' | 'mobile'>(() => {
|
const [viewport, setViewport] = useState<'desktop' | 'mobile'>(() => {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
try {
|
try {
|
||||||
@@ -238,14 +240,14 @@ export default function BuilderClientPage() {
|
|||||||
const disallowLines = lines.map((l) => (l.startsWith('Disallow:') ? l : `Disallow: ${l}`))
|
const disallowLines = lines.map((l) => (l.startsWith('Disallow:') ? l : `Disallow: ${l}`))
|
||||||
return `User-agent: *\n${disallowLines.join('\n')}`
|
return `User-agent: *\n${disallowLines.join('\n')}`
|
||||||
})()
|
})()
|
||||||
const baseExtras = buildExtrasForPage(valid, { robotsText: robotsTextOverride, manifest: manifestOverride })
|
const baseExtras = buildExtrasForPage(valid, { robotsText: robotsTextOverride, manifest: manifestOverride, sheetsMode })
|
||||||
const extras: Record<string, Uint8Array> = {
|
const extras: Record<string, Uint8Array> = {
|
||||||
...baseExtras,
|
...baseExtras,
|
||||||
...(am ? { 'assets.json': buildAssetsMetadata(am) } : {}),
|
...(am ? { 'assets.json': buildAssetsMetadata(am), 'assets.index.json': buildAssetsIndex(am) } : {}),
|
||||||
}
|
}
|
||||||
const zipBytes = await buildZip({ html: exported.html, css: exported.css, js: exported.js, assets, extras })
|
const zipBytes = await buildZip({ html: exported.html, css: exported.css, js: exported.js, assets, extras })
|
||||||
download('landing.zip', zipBytes)
|
download('landing.zip', zipBytes)
|
||||||
}, [pageData, am, manifestName, manifestShortName, manifestStartUrl, manifestDisplay, manifestThemeColor, robotsDisallow])
|
}, [pageData, am, manifestName, manifestShortName, manifestStartUrl, manifestDisplay, manifestThemeColor, robotsDisallow, sheetsMode])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 space-y-6">
|
<div className="p-6 space-y-6">
|
||||||
@@ -381,6 +383,20 @@ export default function BuilderClientPage() {
|
|||||||
placeholder="/private\n/tmp"
|
placeholder="/private\n/tmp"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<label className="block" htmlFor="ins-sheets-mode">
|
||||||
|
<span className="sr-only">Google Sheets Template Mode</span>
|
||||||
|
<select
|
||||||
|
id="ins-sheets-mode"
|
||||||
|
aria-label="Google Sheets Template Mode"
|
||||||
|
className="border rounded px-3 py-2 w-full"
|
||||||
|
value={sheetsMode}
|
||||||
|
onChange={(e) => setSheetsMode(e.target.value as 'auto'|'include'|'exclude')}
|
||||||
|
>
|
||||||
|
<option value="auto">Sheets Template: Auto</option>
|
||||||
|
<option value="include">Sheets Template: Include</option>
|
||||||
|
<option value="exclude">Sheets Template: Exclude</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export type ExtrasOverrides = {
|
|||||||
display: string
|
display: string
|
||||||
theme_color: string
|
theme_color: string
|
||||||
}>
|
}>
|
||||||
|
sheetsMode?: 'auto' | 'include' | 'exclude'
|
||||||
}
|
}
|
||||||
|
|
||||||
function toBytes(s: string): Uint8Array {
|
function toBytes(s: string): Uint8Array {
|
||||||
@@ -42,10 +43,12 @@ export function buildExtrasForPage(page: Page, overrides?: ExtrasOverrides): Rec
|
|||||||
const manifestJson = JSON.stringify(manifestMerged, null, 2)
|
const manifestJson = JSON.stringify(manifestMerged, null, 2)
|
||||||
out['site.webmanifest'] = toBytes(manifestJson)
|
out['site.webmanifest'] = toBytes(manifestJson)
|
||||||
|
|
||||||
// Google Sheets 템플릿: actionUrl 미지정 시 포함
|
// Google Sheets 템플릿: 기본 auto. overrides.sheetsMode로 강제 포함/제외 가능
|
||||||
|
const mode = overrides?.sheetsMode ?? 'auto'
|
||||||
const action = page.form?.actionUrl?.trim()
|
const action = page.form?.actionUrl?.trim()
|
||||||
const hasAction = !!(action && action.length > 0)
|
const hasAction = !!(action && action.length > 0)
|
||||||
if (!hasAction) {
|
const shouldInclude = mode === 'include' || (mode === 'auto' && !hasAction)
|
||||||
|
if (shouldInclude) {
|
||||||
const code = `/**
|
const code = `/**
|
||||||
* Google Apps Script Web App for form submissions
|
* Google Apps Script Web App for form submissions
|
||||||
* - Deploy as Web App and set URL as form action if needed.
|
* - Deploy as Web App and set URL as form action if needed.
|
||||||
|
|||||||
Reference in New Issue
Block a user