editor: support ok/error icon in shared page
@@ -8,11 +8,14 @@ SHARE_LINK_DIGITS = 7
|
||||
SHORT_SHARE_URL = false
|
||||
|
||||
# Icon URL for rendered pages
|
||||
PAGE_ICON_URL = ''
|
||||
PAGE_ICON_URL = 'https://virt.moe/cferr/editor/assets/icon-{status}-32x32.png'
|
||||
|
||||
# MIME type of page icon
|
||||
PAGE_ICON_TYPE = 'image/png'
|
||||
|
||||
# Image URL for rendered pages
|
||||
PAGE_IMAGE_URL = 'https://virt.moe/cferr/editor/assets/icon-{status}-large-white.png'
|
||||
|
||||
# Set to true if trust X-Forwarded-For/X-Forwarded-Proto header
|
||||
BEHIND_PROXY = true
|
||||
|
||||
|
||||
@@ -122,21 +122,23 @@ def render_extended_template(params: ErrorPageParams,
|
||||
*args: Any,
|
||||
**kwargs: Any) -> str:
|
||||
fill_cf_template_params(params)
|
||||
description = params.get('what_happened') or 'Cloudflare error page'
|
||||
description = re.sub(r'</?.*?>', '', description).strip()
|
||||
description = params.get('what_happened') or 'There is an internal server error on Cloudflare\'s network.'
|
||||
description = re.sub(r'<\/?.*?>', '', description).strip()
|
||||
|
||||
page_image_id = 'ok'
|
||||
status = 'ok'
|
||||
cf_status_obj = params.get('cloudflare_status')
|
||||
if cf_status_obj:
|
||||
cf_status = cf_status_obj.get('status')
|
||||
if cf_status == 'error':
|
||||
page_image_id = 'error'
|
||||
page_image_url = f'https://virt.moe/cferr/editor/assets/icon-{page_image_id}-large.png'
|
||||
status = 'error'
|
||||
page_icon_url = current_app.config.get('PAGE_ICON_URL', '').replace('{status}', status)
|
||||
page_icon_type = current_app.config.get('PAGE_ICON_TYPE')
|
||||
page_image_url = current_app.config.get('PAGE_IMAGE_URL', '').replace('{status}', status)
|
||||
return render_cf_error_page(params=params,
|
||||
template=template,
|
||||
base=base_template,
|
||||
page_icon_url=current_app.config.get('PAGE_ICON_URL'),
|
||||
page_icon_type=current_app.config.get('PAGE_ICON_TYPE'),
|
||||
page_icon_url=page_icon_url,
|
||||
page_icon_type=page_icon_type,
|
||||
page_url=request.url,
|
||||
page_description=description,
|
||||
page_image_url=page_image_url,
|
||||
|
||||
BIN
editor/web/assets/icon-error-32x32.png
Normal file
|
After Width: | Height: | Size: 676 B |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 708 B |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@@ -14,7 +14,7 @@
|
||||
<meta name="description" content="Online editor to create customized Cloudflare-style error pages.">
|
||||
<meta name="keywords" content="cloudflare,error,page,editor">
|
||||
<link rel="canonical" href="https://virt.moe/cferr/editor/" />
|
||||
<link rel="icon" type="image/png" href="assets/icon-32x32.png">
|
||||
<link rel="icon" type="image/png" href="assets/icon-ok-32x32.png">
|
||||
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:site_name" content="moe::virt" />
|
||||
|
||||