2026-05-12 13:07:34 +00:00
{% extends "base.html" %}
2026-05-30 18:16:39 +00:00
{% from "_macros.html" import modal %}
2026-05-12 13:07:34 +00:00
{% block extra_head %}
2026-06-14 00:16:22 +00:00
< link rel = "stylesheet" href = "{{ static_url('/static/css/gists.css') }}" >
< link rel = "stylesheet" href = "{{ static_url('/static/css/post.css') }}" >
< link rel = "stylesheet" href = "{{ static_url('/static/vendor/codemirror/codemirror.min.css') }}" >
< link rel = "stylesheet" href = "{{ static_url('/static/vendor/codemirror/theme/monokai.min.css') }}" >
2026-05-12 13:07:34 +00:00
{% endblock %}
{% block content %}
< div class = "gist-detail-page" >
< a href = "/gists" class = "back-link" > ← Back to Gists</ a >
< article class = "gist-detail" >
< div class = "gist-detail-header" >
2026-07-19 18:57:43 +02:00
< h1 class = "gist-detail-title" > {{ render_title(gist['title'], author_is_admin=is_admin(author)) }}</ h1 >
2026-05-13 19:17:57 +00:00
< span class = "gist-language-badge" > 📝 {{ language_name(gist['language']) }}</ span >
2026-05-12 13:07:34 +00:00
</ div >
< div class = "gist-detail-author" >
{% set _size = 32 %}{% set _size_class = "sm" %}{% set _user = author %}{% include "_avatar_link.html" %}
< div >
2026-06-02 21:17:51 +00:00
{% set _user = author %}{% set _class = none %}{% include "_user_link.html" %}
2026-06-22 23:13:48 +00:00
< span class = "meta-muted" > · Level {{ author.get('level', 1) if author else 1 }}</ span >
< span class = "meta-muted meta-muted-spaced" > · {{ dt_ago(gist.created_at) if gist.get('created_at') else time_ago }}</ span >
2026-05-12 13:07:34 +00:00
</ div >
</ div >
{% if gist.get('description') %}
2026-07-19 18:57:43 +02:00
< div class = "gist-detail-desc rendered-content" > {{ render_content(gist['description'], author_is_admin=is_admin(author)) }}</ div >
2026-05-12 13:07:34 +00:00
{% endif %}
{% if attachments %}
{% include "_attachment_display.html" %}
{% endif %}
2026-07-19 18:57:43 +02:00
{% if gist['language'] == 'markdown_rendered' %}
< div class = "gist-rendered-content rendered-content" > {{ render_content(gist['source_code'], author_is_admin=is_admin(author)) }}</ div >
{% else %}
2026-05-12 13:07:34 +00:00
< div class = "gist-code-block" >
< div class = "gist-code-header" >
2026-05-13 19:17:57 +00:00
< span class = "gist-language-name" > {{ language_name(gist['language']) }}</ span >
2026-05-12 13:07:34 +00:00
< button type = "button" class = "gist-copy-btn" data-copy = "gist-code-content" > Copy</ button >
</ div >
< pre >< code id = "gist-code-content" class = "language-{{ gist['language'] }}" > {{ gist['source_code'] }}</ code ></ pre >
</ div >
2026-07-19 18:57:43 +02:00
{% endif %}
2026-05-12 13:07:34 +00:00
< div class = "gist-detail-actions" >
2026-06-15 22:44:12 +00:00
< button type = "button" class = "gist-star-btn" data-share = "/gists/{{ gist['slug'] or gist['uid'] }}" >< span class = "icon" > 🔗 </ span >< span class = "label" > Share</ span ></ button >
2026-05-12 13:07:34 +00:00
{% if user %}
2026-05-30 18:16:39 +00:00
{% set _type = "gist" %}{% set _uid = gist['uid'] %}{% set _my_vote = my_vote %}{% set _count = star_count %}{% set _btn_class = "gist-star-btn" %}{% include "_star_vote.html" %}
2026-05-12 13:07:34 +00:00
{% endif %}
2026-06-06 14:31:42 +00:00
{% set _type = "gist" %}{% set _uid = gist['uid'] %}{% set _bookmarked = bookmarked %}{% include "_bookmark_button.html" %}
2026-05-12 13:07:34 +00:00
{% if is_owner %}
2026-06-15 22:44:12 +00:00
< button type = "button" class = "gist-star-btn" data-modal = "edit-gist-modal" >< span class = "icon" > ✏️ </ span >< span class = "label" > Edit</ span ></ button >
2026-06-14 23:00:30 +00:00
{% endif %}
{% if is_owner or is_admin(user) %}
2026-06-22 23:13:48 +00:00
< form method = "POST" action = "/gists/delete/{{ gist['slug'] or gist['uid'] }}" class = "inline-form" >
2026-06-15 22:44:12 +00:00
< button type = "submit" class = "gist-star-btn" data-confirm = "Delete this gist?" >< span class = "icon" > 🗑️ </ span >< span class = "label" > Delete</ span ></ button >
2026-05-12 13:07:34 +00:00
</ form >
{% endif %}
2026-06-06 14:31:42 +00:00
{% set _type = "gist" %}{% set _uid = gist['uid'] %}{% set _reactions = reactions %}{% include "_reaction_bar.html" %}
2026-05-12 13:07:34 +00:00
</ div >
</ article >
2026-05-13 19:17:57 +00:00
{% if is_owner %}
2026-05-30 18:16:39 +00:00
{% call modal('edit-gist-modal', 'Edit Gist', wide=true) %}
2026-05-13 19:17:57 +00:00
< form method = "POST" action = "/gists/edit/{{ gist['slug'] or gist['uid'] }}" >
< div class = "auth-field auth-field-gap" >
< label for = "edit-gist-title" > Title</ label >
< input type = "text" id = "edit-gist-title" name = "title" required maxlength = "200" value = "{{ gist['title'] }}" >
</ div >
< div class = "auth-field auth-field-gap" >
< label for = "edit-gist-description" > Description (optional)</ label >
< textarea id = "edit-gist-description" name = "description" maxlength = "5000" class = "min-h-80" data-mention > {{ gist.get('description', '') }}</ textarea >
</ div >
< div class = "auth-field auth-field-gap" >
< label for = "edit-gist-language" > Language</ label >
< select id = "edit-gist-language" name = "language" >
{% for code, name in languages %}
< option value = "{{ code }}" {% if code = = gist [' language '] %} selected {% endif %} > {{ name }}</ option >
{% endfor %}
</ select >
</ div >
< div class = "auth-field auth-field-gap-last" >
< label for = "edit-gist-source-editor" > Source Code</ label >
2026-05-16 01:10:55 +00:00
< textarea id = "edit-gist-source-editor" name = "source_code" class = "hidden-textarea" data-language = "{{ gist['language'] }}" > {{ gist['source_code'] }}</ textarea >
2026-05-13 19:17:57 +00:00
</ div >
{% include "_attachment_form.html" %}
< div class = "modal-footer" >
< button type = "button" class = "modal-close btn btn-secondary" > Cancel</ button >
< button type = "submit" class = "btn btn-primary" >< span class = "icon" > 💾 </ span > Save Changes</ button >
</ div >
</ form >
2026-05-30 18:16:39 +00:00
{% endcall %}
2026-05-13 19:17:57 +00:00
{% endif %}
2026-05-12 13:07:34 +00:00
{% with target_uid=gist['uid'], target_type="gist" %}
{% include "_comment_section.html" %}
{% endwith %}
</ div >
{% endblock %}
2026-05-13 19:17:57 +00:00
{% block extra_js %}
2026-06-14 00:16:22 +00:00
< script defer src = "{{ static_url('/static/vendor/codemirror/codemirror.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/python/python.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/javascript/javascript.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/clike/clike.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/htmlmixed/htmlmixed.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/xml/xml.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/css/css.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/go/go.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/rust/rust.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/sql/sql.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/shell/shell.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/yaml/yaml.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/markdown/markdown.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/swift/swift.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/php/php.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/ruby/ruby.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/haskell/haskell.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/lua/lua.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/perl/perl.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/r/r.min.js') }}" ></ script >
< script defer src = "{{ static_url('/static/vendor/codemirror/mode/dart/dart.min.js') }}" ></ script >
< script type = "module" src = "{{ static_url('/static/js/GistEditor.js') }}" ></ script >
2026-05-13 19:17:57 +00:00
< script type = "module" >
const editModal = document . getElementById ( "edit-gist-modal" );
if ( editModal ) {
const editGistEditor = new window . GistEditor ( "edit-gist-source-editor" , "edit-gist-language" );
const observer = new MutationObserver (() => {
if ( editModal . classList . contains ( "visible" )) {
editGistEditor . refresh ();
}
});
observer . observe ( editModal , { attributes : true , attributeFilter : [ "class" ] });
}
</ script >
{% endblock %}