|
1 | | --py! |
2 | | - from firefly.libs.markdown import Markdown |
3 | | - from firefly.views.utils import short_timesince |
4 | | --inherit /base.html |
5 | | -- namespace name='forms' /_forms.html |
6 | | --namespace name="widgets_editor" /widgets/markdown_editor.html |
| 1 | +{% extends "base.html" %} |
| 2 | +{% import 'widgets/markdown_editor.html' as markdown_editor %} |
7 | 3 |
|
8 | | --def outlet() |
9 | | - div#topic-title |
10 | | - div.container |
| 4 | +{% block outlet %} |
| 5 | +<div id="topic-title"> |
| 6 | + <div class="container"> |
11 | 7 | div.title-wrapper |
12 | | - h1 |
13 | | - a.fancy-title href="${post.url()}" |
14 | | - ${post.title} |
15 | | - - if post.category |
16 | | - div.category-title |
17 | | - a.badge-wrapper.bullet href="/c/${post.category.id}" |
18 | | - span.badge-category-bg style="background-color: ${post.category.color if post.category else '#999'}" |
19 | | - span.badge-category.clear-badge style="vertical-align: middle;" title="${post.category.description}" |
20 | | - ${post.category.name} |
21 | | - div.container.posts |
22 | | - div.row |
23 | | - section#topic.topic-area data-topic-id="${post.id}" |
24 | | - div.posts-wrapper |
25 | | - - for index, p in enumerate([post] + post.comments) |
26 | | - -py |
27 | | - cloak_id = 'post-cloak-{}'.format(index) |
28 | | - class c(object): |
29 | | - id = 100001 |
30 | | - name = 'test1' |
31 | | - avatar = lambda x:'https://meta-discourse.global.ssl.fastly.net/user_avatar/meta.discourse.org/codinghorror/90/5297.png' |
32 | | - cn = 'Test' |
33 | | - def url(self): |
34 | | - return '/user/1000001' |
35 | | - author = p.author if p.author else c() |
36 | | - author_name = author.username if hasattr(author, 'username') and author.username else author.cn |
37 | | - div#${cloak_id}.post-cloak data-comment-id=${p.id} data-order-id=${index} |
38 | | - div.topic-post.clearfix.regular |
39 | | - article.boxed data-user-id="${author.id}" data-post-id="${p.id}" |
40 | | - div.row |
41 | | - div.topic-avatar |
42 | | - div.contents |
43 | | - a href="${author.url()}" data-user-card="${author_name}" |
44 | | - img.avatar alt="" width="45" height="45" src="${author.avatar()}" title="${author_name}" |
45 | | - div.topic-body |
46 | | - div.topic-meta-data |
47 | | - div.names.trigger-user-card |
48 | | - span.username.staff |
49 | | - a href="${author.url()}" data-user-card="${author_name}" |
50 | | - ${author_name} |
51 | | - i.fa.fa-shield title="This user is a moderator" alt="This user is a moderator" |
52 | | - span.full-name |
53 | | - a href="${author.url()}" data-user-card="${author_name}" |
54 | | - ${author.cn} |
55 | | - span.user-title |
56 | | - a.user-group href="/groups/discourse" |
57 | | - co-founder |
58 | | - div.post-info |
59 | | - a.post-date href="/t/quickly-tell-someone-why-they-should-look-at-a-topic/27503/2" data-bindattr-1516="1516" |
60 | | - span.relative-date title="${p.created_at.strftime('%c %p')}" data-time="1428885788713" data-format="tiny" |
61 | | - ${short_timesince(p.created_at)} |
62 | | - div.contents.regular |
63 | | - div.cooked |
64 | | - - if p.content |
65 | | - -py |
66 | | - content = Markdown.render(p.content) |
67 | | - - if p.post_type == 'Quote' |
68 | | - blockquote |
69 | | - ${content|n} |
70 | | - - else |
71 | | - ${content|n} |
72 | | - - if hasattr(p, 'embed_code') and p.embed_code |
73 | | - ${p.embed_code} |
74 | | - - if hasattr(p, 'image_url') and p.image_url |
75 | | - p |
76 | | - img" src=${p.image_url}" |
77 | | - p |
78 | | - ${p.created_at.strftime('%H:%M %Y-%m-%d')} |
79 | | - section.post-menu-area.clearfix |
80 | | - nav.post-controls |
81 | | - -py |
82 | | - coments = p.get_replies() if p.post_type == 'Comment' else [] |
83 | | - -if coments: |
84 | | - button.show-replies |
85 | | - span.badge-posts |
86 | | - ${len(coments)} |
87 | | - Replies |
88 | | - i.fa.fa-chevron-down |
89 | | - div.actions |
90 | | - - if current_user.is_authenticated() |
91 | | - button.like title='喜欢这个主题?' |
92 | | - i.fa.fa-heart |
93 | | - button title='分享' data-share-url="/t/dd" |
94 | | - i.fa.fa-link |
95 | | - - if current_user.is_authenticated() |
96 | | - button.bookmark title='标记' |
97 | | - div.read-icon |
98 | | - button.create title='评论' |
99 | | - i.fa.fa-reply |
100 | | - 评论 |
101 | | - section.embedded-posts.bottom.hide |
| 8 | + <h1> |
| 9 | + <a class="fancy-title" href="{{post.url()}}">{{post.title}}</a> |
| 10 | + </h1> |
| 11 | + {% if post.category %} |
| 12 | + <div class="category-title"> |
| 13 | + <a class="badge-wrapper bullet" href="/c/{{post.category.id}}"> |
| 14 | + <span class="badge-category-bg" style="background-color: {{post.category.color if post.category else '#999'}}"></span> |
| 15 | + <span class="badge-category clear-badge" style="vertical-align: middle;" title="{{post.category.description}}">{{post.category.name}}</span> |
| 16 | + </a> |
| 17 | + {% endif %} |
| 18 | + </div> |
| 19 | + </div> |
| 20 | +</div> |
| 21 | +<div class="container posts"> |
| 22 | + <div class="row"> |
| 23 | + <section id="topic" class="topic-area" data-topic-id="{{post.id}}"> |
| 24 | + <div class="posts-wrapper"> |
| 25 | + {% for p in [post] + post.comments %} |
| 26 | + {% set author = gen_author(p) %} |
| 27 | + {% set author_name = gen_author_name(p).decode('utf-8') %} |
| 28 | + {% set index = loop.index %} |
| 29 | + <div id="{{'post-cloak-{}'.format(index)}}" class="post-cloak" data-comment-id={{p.id}} data-order-id={{index}}> |
| 30 | + <div class="topic-post clearfix regular"> |
| 31 | + <article class="boxed" data-user-id="{{author.id}}" data-post-id="{{p.id}}"> |
| 32 | + <div class="row"> |
| 33 | + <div class="topic-avatar"> |
| 34 | + <div class="contents"> |
| 35 | + <a href="{{author.url()}}" data-user-card="{{author_name}}" > |
| 36 | + <img class="avatar" alt="" src="{{author.avatar()}}" width="45" height="45" title="{{author_name}}"/> |
| 37 | + </a> |
| 38 | + </div> |
| 39 | + </div> |
| 40 | + <div class="topic-body"> |
| 41 | + <div class="topic-meta-data"> |
| 42 | + <div class="names trigger-user-card"> |
| 43 | + <span class="username staff"> |
| 44 | + <a href="{{author.url()}}" data-user-card="{{author_name}}"> |
| 45 | + {{author_name}} |
| 46 | + </a> |
| 47 | + <i class="fa fa-shield" title="This user is a moderator" alt="This user is a moderator"></i> |
| 48 | + </span> |
| 49 | + <span class="full-name"> |
| 50 | + <a href="{{author.url()}}" data-user-card="{{author_name}}"> |
| 51 | + {{author.cn.decode('utf-8')}} |
| 52 | + </a> |
| 53 | + </span> |
| 54 | + <span class="user-title"> |
| 55 | + <a class="user-group" href="/groups/discourse"> |
| 56 | + co-founder |
| 57 | + </a> |
| 58 | + </span> |
| 59 | + </div> |
| 60 | + <div class="post-info"> |
| 61 | + <a class="post-date" href="/t/quickly-tell-someone-why-they-should-look-at-a-topic/27503/2" data-bindattr-1516="1516"> |
| 62 | + <span class="relative-date" title="{{p.created_at.strftime('%c %p')}}" data-time="1428885788713" data-format="tiny" > |
| 63 | + {{short_timesince(p.created_at)}} |
| 64 | + </span> |
| 65 | + </a> |
| 66 | + </div> |
| 67 | + <div class="contents regular"> |
| 68 | + <div class="cooked"> |
| 69 | + {% if p.content %} |
| 70 | + {% autoescape false %} |
| 71 | + {{Markdown.render(p.content)}} |
| 72 | + {% endautoescape %} |
| 73 | + {% endif %} |
| 74 | + {% if hasattr(p, 'embed_code') and p.embed_code %} |
| 75 | + {{p.embed_code}} |
| 76 | + {% endif %} |
| 77 | + {% if hasattr(p, 'image_url') and p.image_url %} |
| 78 | + <p><img src={{p.image_url}}></p> |
| 79 | + <p>{{p.created_at.strftime('%H:%M %Y-%m-%d')}}</p> |
| 80 | + {% endif %} |
| 81 | + </div> |
| 82 | + <section class="post-menu-area clearfix"> |
| 83 | + <nav class="post-controls"> |
| 84 | + {% set coments = p.get_replies() if p.post_type == 'Comment' else [] %} |
| 85 | + {% if coments %} |
| 86 | + <button class="show-replies"> |
| 87 | + <span class="badge-posts">{{len(coments)}}</span> |
| 88 | + Replies |
| 89 | + <i class="fa fa-chevron-down"></i> |
| 90 | + </button> |
| 91 | + {% endif %} |
| 92 | + <div class="actions"> |
| 93 | + {% if current_user.is_authenticated() %} |
| 94 | + <button class="like" title='喜欢这个主题?'> |
| 95 | + <i class="fa fa-heart"></i> |
| 96 | + </button> |
| 97 | + {% endif %} |
| 98 | + <button title='分享' data-share-url="/t/dd"> |
| 99 | + <i class="fa fa-link"></i> |
| 100 | + </button> |
| 101 | + {% if current_user.is_authenticated() %} |
| 102 | + <button class="bookmark" title='标记'> |
| 103 | + <div class="read-icon"></div> |
| 104 | + </button> |
| 105 | + <button class="create" title='评论'> |
| 106 | + <i class="fa fa-reply">评论</i> |
| 107 | + </button> |
| 108 | + {% endif %} |
| 109 | + </div> |
| 110 | + </nav> |
| 111 | + </section> |
| 112 | + <section class="embedded-posts bottom hide"></section> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + </div> |
| 117 | + </article> |
| 118 | + </div> |
| 119 | + </div> |
| 120 | + {% endfor %} |
| 121 | + </div> |
| 122 | + </section> |
| 123 | + </div> |
| 124 | +</div> |
| 125 | +{% endblock %} |
102 | 126 |
|
103 | | --def head_script() |
104 | | - link href="${url_for('static', filename='stylesheets/base16-light.css')}" rel="stylesheet" |
105 | | - link href="${url_for('static', filename='stylesheets/codemirror.css')}" rel="stylesheet" |
106 | | - link href="${url_for('static', filename='stylesheets/post.css')}" rel="stylesheet" media="all" |
| 127 | +{% block head_script %} |
| 128 | +<link href="{{url_for('static', filename='stylesheets/base16-light.css')}}" rel="stylesheet"/> |
| 129 | +<link href="{{url_for('static', filename='stylesheets/codemirror.css')}}" rel="stylesheet"/> |
| 130 | +<link href="{{url_for('static', filename='stylesheets/post.css')}}" rel="stylesheet" media="all"/> |
| 131 | +{% endblock %} |
107 | 132 |
|
108 | | --def footer_script() |
109 | | - script |
| 133 | +{% block footer_script %} |
| 134 | +<script> |
110 | 135 | require(['../../static/javascripts/common'], function (common) { |
111 | 136 | require(['post']); |
112 | 137 | }); |
| 138 | +</script> |
| 139 | +{% endblock %} |
113 | 140 |
|
114 | | -- if current_user.is_authenticated() |
115 | | - - def others() |
116 | | - ${widgets_editor.topic()} |
| 141 | +{% block others %} |
| 142 | + {% if current_user.is_authenticated() %} |
| 143 | + {{ markdown_editor.topic() }} |
| 144 | + {% endif %} |
| 145 | +{% endblock %} |
0 commit comments