Skip to content

Commit e57a705

Browse files
feat: require https://cppalliance.org/ and .html path Link post section
1 parent de07ffa commit e57a705

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

templates/news/v3/create.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ <h1 class="create-post-page__title">Create Post</h1>
150150
</span>
151151
</span>
152152
</div>
153+
{% comment %} Inline help that explains the cppalliance.org restriction so the disabled button doesn't look mysterious. {% endcomment %}
154+
<p class="field__help" x-show="isLink" x-cloak>Auto-Generate only works for <code>.html</code> links from <code>cppalliance.org</code>.</p>
153155
</div>
154156

155157
{% include "v3/includes/_field_file.html" with name="image" label="Image" accept="image/png,image/jpeg" preview=True alpine_error="errors.image" error=form.errors.image.0 help_text="This should be a PNG or JPEG format and no longer than 1MB" extra_class="field--file-narrow create-post-page__field-image" %}
@@ -195,10 +197,20 @@ <h1 class="create-post-page__title">Create Post</h1>
195197
get isWriteUp() { return this.postType === 'blog' || this.postType === 'news'; },
196198
get isLinkType() { return this.postType === 'video' || this.postType === 'link'; },
197199
get isLink() { return this.postType === 'link'; },
200+
// Auto-Generate fetches and summarizes the linked page, so we only
201+
// enable it for URLs we trust (cppalliance.org over HTTPS). Other Link
202+
// posts are still allowed — they just can't use Auto-Generate.
198203
get linkUrlValid() {
199204
const url = (this.externalUrl || '').trim();
200205
if (!url) return false;
201-
try { new URL(url); return true; } catch (_) { return false; }
206+
try {
207+
const parsed = new URL(url);
208+
return (
209+
parsed.protocol === 'https:' &&
210+
parsed.hostname === 'cppalliance.org' &&
211+
parsed.pathname.endsWith('.html')
212+
);
213+
} catch (_) { return false; }
202214
},
203215

204216
init() {

0 commit comments

Comments
 (0)