42 lines
3.8 KiB
JavaScript
42 lines
3.8 KiB
JavaScript
'use strict';
|
|||
|
|
// ============================================================================
|
||
|
|
// 발행 취소 안내 페이지 ("사이트 수정 중") — v1.5.27 (요구 5)
|
||
|
|
//
|
||
|
|
// 발행을 취소한 사이트의 운영 주소에 보이는 페이지. 세 곳이 같은 내용을 써야 해서 한 모듈로 모았다.
|
||
|
|
// 1) server.js deployMaintenance — 원격(ssh) 배포 서버에는 이 HTML 을 index.html 로 올린다
|
||
|
|
// 2) lib/deploy.js vhostBlock — 서비스 서버 자신(같은 경로) 배포 서버의 사이트 vhost: 작업 폴더에 .unpublished 표식이 있으면 nginx 가 이 HTML 을 503 으로 돌려준다
|
||
|
|
// 3) deploy/nginx-webhosting.conf · remote-install.sh — 서비스 공개 주소(https://서비스/<사이트ID>/)의 nginx 규칙(설치 때 생성, 같은 문구를 손으로 맞춘다)
|
||
|
|
//
|
||
|
|
// 1.5.19 까지는 한국어 한 줄("사이트 수정 중입니다")뿐이었다. 이제 영어를 크게, 그 아래 한국어·일본어·중국어·스페인어 안내, 마지막 줄에
|
||
|
|
// "Webmaker is working .... supported by <도메인>" 을 둔다. <도메인> 은 플랫폼 도메인(서비스 주소에서 유도, 예: ariweb.net).
|
||
|
|
// ============================================================================
|
||
|
|
|
||
|
|
/** 안내 문구 (언어별). 영어는 제목, 나머지는 본문 줄 */
|
||
|
|
const HEADLINE = "We're updating our site. Please check back soon.";
|
||
|
|
const LINES = [
|
||
|
|
['ko', '사이트 개정 작업 중입니다. 잠시 후에 다시 접속해주세요.'],
|
||
|
|
['ja', 'サイトの改訂作業中です。しばらくしてから再度アクセスしてください。'],
|
||
|
|
['zh', '网站正在改版中,请稍后再访问。'],
|
||
|
|
['es', 'El sitio está en proceso de revisión. Vuelva a intentarlo en unos minutos.'],
|
||
|
|
];
|
||
|
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||
|
|
|
||
|
|
/** 서비스 도메인(플랫폼 도메인): 설정값 → 서비스 공개 주소 호스트에서 유도 → 빈 값이면 'Webmaker' */
|
||
|
|
function serviceDomain() {
|
||
|
|
try { const d = require('./domains').config().platformDomain; if (d) return d; } catch (_) {}
|
||
|
|
try { const u = process.env.PUBLIC_BASE_URL || require('./config').get('service.publicBaseUrl'); const h = new URL(u).hostname; if (h && !require('net').isIP(h)) return h.split('.').length > 2 ? h.split('.').slice(1).join('.') : h; } catch (_) {}
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 안내 페이지 HTML.
|
||
|
|
* @param {{title?:string, domain?:string}} [o] title: 사이트 이름(<title> 에만), domain: 마지막 줄의 "supported by" 뒤 도메인(없으면 serviceDomain())
|
||
|
|
*/
|
||
|
|
function html(o = {}) {
|
||
|
|
const dom = o.domain || serviceDomain(); const t = esc(o.title || '');
|
||
|
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${t ? t + ' — ' : ''}Updating</title><style>body{margin:0;min-height:100vh;display:grid;place-items:center;font-family:-apple-system,"Segoe UI","Noto Sans KR","Noto Sans JP","Noto Sans SC",sans-serif;background:#f4f5f7;color:#1f2933}main{text-align:center;padding:32px 24px;max-width:640px}h1{font-size:28px;line-height:1.3;margin:0 0 18px}p{color:#4b5563;margin:6px 0;line-height:1.6;font-size:15px}.f{margin-top:26px;font-size:12px;color:#9aa3af}</style></head><body><main><h1>${HEADLINE}</h1>${LINES.map(([l, s]) => `<p lang="${l}">${s}</p>`).join('')}<p class="f">Webmaker is working .... supported by ${esc(dom || 'Webmaker')}</p></main></body></html>`;
|
||
|
|
}
|
||
|
|
/** nginx `return 503 '…'` 안에 넣을 수 있게 작은따옴표를 피한 문자열 (HTML 에는 작은따옴표를 쓰지 않았지만 안전하게) */
|
||
|
|
function nginxString(o) { return html(o).replace(/'/g, ''').replace(/\r?\n/g, ''); }
|
||
|
|
|
||
|
|
module.exports = { html, nginxString, serviceDomain, HEADLINE, LINES };
|