##// END OF EJS Templates
Added a template tag to get post link instead of using jumper
neko259 -
r320:e8a3c65d default
parent child Browse files
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,22 b''
1 from django.core.urlresolvers import reverse
2 from django.shortcuts import get_object_or_404
3 from boards.models import Post
4 from boards.views import thread
5 from django import template
6
7 register = template.Library()
8
9
10 @register.simple_tag(name='post_url')
11 def post_url(*args, **kwargs):
12 post_id = args[0]
13
14 post = get_object_or_404(Post, id=post_id)
15
16 if post.thread:
17 link = reverse(thread, kwargs={'post_id': post.thread.id}) \
18 + '#' + str(post_id)
19 else:
20 link = reverse(thread, kwargs={'post_id': post_id})
21
22 return link
@@ -1,227 +1,228 b''
1 1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load markup %}
5 5 {% load cache %}
6 {% load board %}
6 7
7 8 {% block head %}
8 9 {% if tag %}
9 10 <title>Neboard - {{ tag.name }}</title>
10 11 {% else %}
11 12 <title>Neboard</title>
12 13 {% endif %}
13 14 {% endblock %}
14 15
15 16 {% block content %}
16 17
17 18 {% get_current_language as LANGUAGE_CODE %}
18 19
19 20 {% if tag %}
20 21 <div class="tag_info">
21 22 <h2>
22 23 {% if tag in user.fav_tags.all %}
23 24 <a href="{% url 'tag_unsubscribe' tag.name %}?next={{ request.path }}"
24 25 class="fav"></a>
25 26 {% else %}
26 27 <a href="{% url 'tag_subscribe' tag.name %}?next={{ request.path }}"
27 28 class="not_fav"></a>
28 29 {% endif %}
29 30 #{{ tag.name }}
30 31 </h2>
31 32 </div>
32 33 {% endif %}
33 34
34 35 {% if threads %}
35 36 {% for thread in threads %}
36 37 {% cache 600 thread_short thread.thread.last_edit_time moderator LANGUAGE_CODE %}
37 38 <div class="thread">
38 39 {% if thread.bumpable %}
39 40 <div class="post" id="{{ thread.thread.id }}">
40 41 {% else %}
41 42 <div class="post dead_post" id="{{ thread.thread.id }}">
42 43 {% endif %}
43 44 {% if thread.thread.image %}
44 45 <div class="image">
45 46 <a class="thumb"
46 47 href="{{ thread.thread.image.url }}"><img
47 48 src="{{ thread.thread.image.url_200x150 }}"
48 49 alt="{{ thread.thread.id }}"
49 50 data-width="{{ thread.thread.image_width }}"
50 51 data-height="{{ thread.thread.image_height }}" />
51 52 </a>
52 53 </div>
53 54 {% endif %}
54 55 <div class="message">
55 56 <div class="post-info">
56 57 <span class="title">{{ thread.thread.title }}</span>
57 58 <a class="post_id" href="{% url 'thread' thread.thread.id %}"
58 59 >({{ thread.thread.id }})</a>
59 60 [{{ thread.thread.pub_time }}]
60 61 [<a class="link" href="{% url 'thread' thread.thread.id %}#form"
61 62 >{% trans "Reply" %}</a>]
62 63
63 64 {% if moderator %}
64 65 <span class="moderator_info">
65 66 [<a href="{% url 'delete' post_id=thread.thread.id %}?next={{ request.path }}"
66 67 >{% trans 'Delete' %}</a>]
67 68 ({{ thread.thread.poster_ip }})
68 69 [<a href="{% url 'ban' post_id=thread.thread.id %}?next={{ request.path }}"
69 70 >{% trans 'Ban IP' %}</a>]
70 71 </span>
71 72 {% endif %}
72 73 </div>
73 74 {% autoescape off %}
74 75 {{ thread.thread.text.rendered|truncatewords_html:50 }}
75 76 {% endautoescape %}
76 77 {% if thread.thread.referenced_posts.all %}
77 78 <div class="refmap">
78 79 {% trans "Replies" %}:
79 80 {% for ref_post in thread.thread.referenced_posts.all %}
80 <a href="{% url 'jumper' ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
81 <a href="{% post_url ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
81 82 {% endfor %}
82 83 </div>
83 84 {% endif %}
84 85 </div>
85 86 <div class="metadata">
86 87 {{ thread.thread.get_reply_count }} {% trans 'replies' %},
87 88 {{ thread.thread.get_images_count }} {% trans 'images' %}.
88 89 {% if thread.thread.tags %}
89 90 <span class="tags">
90 91 {% for tag in thread.thread.get_tags %}
91 92 <a class="tag" href="
92 93 {% url 'tag' tag_name=tag.name %}">
93 94 #{{ tag.name }}</a>
94 95 {% endfor %}
95 96 </span>
96 97 {% endif %}
97 98 </div>
98 99 </div>
99 100 {% if thread.last_replies.exists %}
100 101 <div class="last-replies">
101 102 {% for post in thread.last_replies %}
102 103 {% if thread.bumpable %}
103 104 <div class="post" id="{{ post.id }}">
104 105 {% else %}
105 106 <div class="post dead_post" id="{{ post.id }}">
106 107 {% endif %}
107 108 {% if post.image %}
108 109 <div class="image">
109 110 <a class="thumb"
110 111 href="{{ post.image.url }}"><img
111 112 src=" {{ post.image.url_200x150 }}"
112 113 alt="{{ post.id }}"
113 114 data-width="{{ post.image_width }}"
114 115 data-height="{{ post.image_height }}"/>
115 116 </a>
116 117 </div>
117 118 {% endif %}
118 119 <div class="message">
119 120 <div class="post-info">
120 121 <span class="title">{{ post.title }}</span>
121 122 <a class="post_id" href="
122 123 {% url 'thread' thread.thread.id %}#{{ post.id }}">
123 124 ({{ post.id }})</a>
124 125 [{{ post.pub_time }}]
125 126 </div>
126 127 {% autoescape off %}
127 128 {{ post.text.rendered|truncatewords_html:50 }}
128 129 {% endautoescape %}
129 130 </div>
130 131 {% if post.referenced_posts.all %}
131 132 <div class="refmap">
132 133 {% trans "Replies" %}:
133 134 {% for ref_post in post.referenced_posts.all %}
134 <a href="{% url 'jumper' ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
135 <a href="{% post_url ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
135 136 {% endfor %}
136 137 </div>
137 138 {% endif %}
138 139 </div>
139 140 {% endfor %}
140 141 </div>
141 142 {% endif %}
142 143 </div>
143 144 {% endcache %}
144 145 {% endfor %}
145 146 {% else %}
146 147 <div class="post">
147 148 {% trans 'No threads exist. Create the first one!' %}</div>
148 149 {% endif %}
149 150
150 151 <form enctype="multipart/form-data" method="post">{% csrf_token %}
151 152 <div class="post-form-w">
152 153
153 154 <div class="form-title">{% trans "Create new thread" %}</div>
154 155 <div class="post-form">
155 156 <div class="form-row">
156 157 <div class="form-label">{% trans 'Title' %}</div>
157 158 <div class="form-input">{{ form.title }}</div>
158 159 <div class="form-errors">{{ form.title.errors }}</div>
159 160 </div>
160 161 <div class="form-row">
161 162 <div class="form-label">{% trans 'Formatting' %}</div>
162 163 <div class="form-input" id="mark_panel">
163 164 <span class="mark_btn" id="quote"><span class="quote">&gt;{% trans 'quote' %}</span></span>
164 165 <span class="mark_btn" id="italic"><i>{% trans 'italic' %}</i></span>
165 166 <span class="mark_btn" id="bold"><b>{% trans 'bold' %}</b></span>
166 167 <span class="mark_btn" id="spoiler"><span class="spoiler">{% trans 'spoiler' %}</span></span>
167 168 <span class="mark_btn" id="comment"><span class="comment">// {% trans 'comment' %}</span></span>
168 169 </div>
169 170 </div>
170 171 <div class="form-row">
171 172 <div class="form-label">{% trans 'Text' %}</div>
172 173 <div class="form-input">{{ form.text }}</div>
173 174 <div class="form-errors">{{ form.text.errors }}</div>
174 175 </div>
175 176 <div class="form-row">
176 177 <div class="form-label">{% trans 'Image' %}</div>
177 178 <div class="form-input">{{ form.image }}</div>
178 179 <div class="form-errors">{{ form.image.errors }}</div>
179 180 </div>
180 181 <div class="form-row">
181 182 <div class="form-label">{% trans 'Tags' %}</div>
182 183 <div class="form-input">{{ form.tags }}</div>
183 184 <div class="form-errors">{{ form.tags.errors }}</div>
184 185 </div>
185 186 <div class="form-row form-email">
186 187 <div class="form-label">{% trans 'e-mail' %}</div>
187 188 <div class="form-input">{{ form.email }}</div>
188 189 <div class="form-errors">{{ form.email.errors }}</div>
189 190 </div>
190 191 <div class="form-row">
191 192 {{ form.captcha }}
192 193 <div class="form-errors">{{ form.captcha.errors }}</div>
193 194 </div>
194 195 <div class="form-row">
195 196 <div class="form-errors">{{ form.other.errors }}</div>
196 197 </div>
197 198 </div>
198 199 <div class="form-submit">
199 200 <input type="submit" value="{% trans "Post" %}"/></div>
200 201 <div>
201 202 {% trans 'Tags must be delimited by spaces. Text or image is required.' %}
202 203 </div>
203 204 <div><a href="{% url "staticpage" name="help" %}">
204 205 {% trans 'Text syntax' %}</a></div>
205 206 </div>
206 207 </form>
207 208
208 209 {% endblock %}
209 210
210 211 {% block metapanel %}
211 212
212 213 <span class="metapanel">
213 214 <b><a href="{% url "authors" %}">Neboard</a> 1.3</b>
214 215 {% trans "Pages:" %}
215 216 {% for page in pages %}
216 217 [<a href="
217 218 {% if tag %}
218 219 {% url "tag" tag_name=tag page=page %}
219 220 {% else %}
220 221 {% url "index" page=page %}
221 222 {% endif %}
222 223 ">{{ page }}</a>]
223 224 {% endfor %}
224 225 [<a href="rss/">RSS</a>]
225 226 </span>
226 227
227 228 {% endblock %}
@@ -1,160 +1,161 b''
1 1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load markup %}
5 5 {% load cache %}
6 6 {% load static from staticfiles %}
7 {% load board %}
7 8
8 9 {% block head %}
9 10 <title>Neboard - {{ posts.0.get_title }}</title>
10 11 {% endblock %}
11 12
12 13 {% block content %}
13 14 {% get_current_language as LANGUAGE_CODE %}
14 15
15 16 <script src="{% static 'js/thread.js' %}"></script>
16 17
17 18 {% if posts %}
18 19 {% cache 600 thread_view posts.0.last_edit_time moderator LANGUAGE_CODE %}
19 20 {% if bumpable %}
20 21 <div class="bar-bg">
21 22 <div class="bar-value" style="width:{{ bumplimit_progress }}%">
22 23 </div>
23 24 <div class="bar-text">
24 25 {{ posts_left }} {% trans 'posts to bumplimit' %}
25 26 </div>
26 27 </div>
27 28 {% endif %}
28 29 <div class="thread">
29 30 {% for post in posts %}
30 31 {% if bumpable %}
31 32 <div class="post" id="{{ post.id }}">
32 33 {% else %}
33 34 <div class="post dead_post" id="{{ post.id }}">
34 35 {% endif %}
35 36 {% if post.image %}
36 37 <div class="image">
37 38 <a
38 39 class="thumb"
39 40 href="{{ post.image.url }}"><img
40 41 src="{{ post.image.url_200x150 }}"
41 42 alt="{{ post.id }}"
42 43 data-width="{{ post.image_width }}"
43 44 data-height="{{ post.image_height }}"/>
44 45 </a>
45 46 </div>
46 47 {% endif %}
47 48 <div class="message">
48 49 <div class="post-info">
49 50 <span class="title">{{ post.title }}</span>
50 51 <a class="post_id" href="#{{ post.id }}">
51 52 ({{ post.id }})</a>
52 53 [{{ post.pub_time }}]
53 54 [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}')
54 55 ; return false;">&gt;&gt;</a>]
55 56
56 57 {% if moderator %}
57 58 <span class="moderator_info">
58 59 [<a href="{% url 'delete' post_id=post.id %}"
59 60 >{% trans 'Delete' %}</a>]
60 61 ({{ post.poster_ip }})
61 62 [<a href="{% url 'ban' post_id=post.id %}?next={{ request.path }}"
62 63 >{% trans 'Ban IP' %}</a>]
63 64 </span>
64 65 {% endif %}
65 66 </div>
66 67 {% autoescape off %}
67 68 {{ post.text.rendered }}
68 69 {% endautoescape %}
69 70 {% if post.referenced_posts.all %}
70 71 <div class="refmap">
71 72 {% trans "Replies" %}:
72 73 {% for ref_post in post.referenced_posts.all %}
73 <a href="{% url 'jumper' ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
74 <a href="{% post_url ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a>
74 75 {% endfor %}
75 76 </div>
76 77 {% endif %}
77 78 </div>
78 79 {% if post.id == posts.0.id %}
79 80 <div class="metadata">
80 81 <span class="tags">
81 82 {% for tag in post.get_tags %}
82 83 <a class="tag" href="{% url 'tag' tag.name %}">
83 84 #{{ tag.name }}</a>
84 85 {% endfor %}
85 86 </span>
86 87 </div>
87 88 {% endif %}
88 89 </div>
89 90 {% endfor %}
90 91 </div>
91 92 {% endcache %}
92 93 {% endif %}
93 94
94 95 <form id="form" enctype="multipart/form-data" method="post"
95 96 >{% csrf_token %}
96 97 <div class="post-form-w">
97 98 <div class="form-title">{% trans "Reply to thread" %} #{{ posts.0.id }}</div>
98 99 <div class="post-form">
99 100 <div class="form-row">
100 101 <div class="form-label">{% trans 'Title' %}</div>
101 102 <div class="form-input">{{ form.title }}</div>
102 103 <div class="form-errors">{{ form.title.errors }}</div>
103 104 </div>
104 105 <div class="form-row">
105 106 <div class="form-label">{% trans 'Formatting' %}</div>
106 107 <div class="form-input" id="mark_panel">
107 108 <span class="mark_btn" id="quote"><span class="quote">&gt;{% trans 'quote' %}</span></span>
108 109 <span class="mark_btn" id="italic"><i>{% trans 'italic' %}</i></span>
109 110 <span class="mark_btn" id="bold"><b>{% trans 'bold' %}</b></span>
110 111 <span class="mark_btn" id="spoiler"><span class="spoiler">{% trans 'spoiler' %}</span></span>
111 112 <span class="mark_btn" id="comment"><span class="comment">// {% trans 'comment' %}</span></span>
112 113 </div>
113 114 </div>
114 115 <div class="form-row">
115 116 <div class="form-label">{% trans 'Text' %}</div>
116 117 <div class="form-input">{{ form.text }}</div>
117 118 <div class="form-errors">{{ form.text.errors }}</div>
118 119 </div>
119 120 <div class="form-row">
120 121 <div class="form-label">{% trans 'Image' %}</div>
121 122 <div class="form-input">{{ form.image }}</div>
122 123 <div class="form-errors">{{ form.image.errors }}</div>
123 124 </div>
124 125 <div class="form-row form-email">
125 126 <div class="form-label">{% trans 'e-mail' %}</div>
126 127 <div class="form-input">{{ form.email }}</div>
127 128 <div class="form-errors">{{ form.email.errors }}</div>
128 129 </div>
129 130 <div class="form-row">
130 131 {{ form.captcha }}
131 132 <div class="form-errors">{{ form.captcha.errors }}</div>
132 133 </div>
133 134 <div class="form-row">
134 135 <div class="form-errors">{{ form.other.errors }}</div>
135 136 </div>
136 137 </div>
137 138
138 139 <div class="form-submit"><input type="submit"
139 140 value="{% trans "Post" %}"/></div>
140 141 <div><a href="{% url "staticpage" name="help" %}">
141 142 {% trans 'Text syntax' %}</a></div>
142 143 </div>
143 144 </form>
144 145
145 146 {% endblock %}
146 147
147 148 {% block metapanel %}
148 149
149 150 {% get_current_language as LANGUAGE_CODE %}
150 151
151 152 <span class="metapanel">
152 153 {% cache 600 thread_meta posts.0.last_edit_time moderator LANGUAGE_CODE %}
153 154 {{ posts.0.get_reply_count }} {% trans 'replies' %},
154 155 {{ posts.0.get_images_count }} {% trans 'images' %}.
155 156 {% trans 'Last update: ' %}{{ posts.0.last_edit_time }}
156 157 [<a href="rss/">RSS</a>]
157 158 {% endcache %}
158 159 </span>
159 160
160 161 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now