##// END OF EJS Templates
Added debug suffix to the site name when DEBUG is set to true. Optimized post...
neko259 -
r583:cf14ad32 default
parent child Browse files
Show More
@@ -1,103 +1,97 b''
1 {% load i18n %}
1 {% load i18n %}
2 {% load board %}
2 {% load board %}
3 {% load cache %}
3 {% load cache %}
4
4
5 {% get_current_language as LANGUAGE_CODE %}
5 {% get_current_language as LANGUAGE_CODE %}
6
6
7 {% with thread=post.thread_new %}
8 {% with bumpable=thread.can_bump %}
9 {% cache 600 post post.id post.last_edit_time thread.archived bumpable truncated moderator LANGUAGE_CODE need_open_link %}
7 {% cache 600 post post.id post.last_edit_time thread.archived bumpable truncated moderator LANGUAGE_CODE need_open_link %}
10
8
11 {% with is_opening=post.is_opening %}
12 {% spaceless %}
9 {% spaceless %}
13 {% if thread.archived %}
10 {% if thread.archived %}
14 <div class="post archive_post" id="{{ post.id }}">
11 <div class="post archive_post" id="{{ post.id }}">
15 {% elif bumpable %}
12 {% elif bumpable %}
16 <div class="post" id="{{ post.id }}">
13 <div class="post" id="{{ post.id }}">
17 {% else %}
14 {% else %}
18 <div class="post dead_post" id="{{ post.id }}">
15 <div class="post dead_post" id="{{ post.id }}">
19 {% endif %}
16 {% endif %}
20
17
21 {% if post.image %}
18 {% if post.image %}
22 <div class="image">
19 <div class="image">
23 <a
20 <a
24 class="thumb"
21 class="thumb"
25 href="{{ post.image.url }}"><img
22 href="{{ post.image.url }}"><img
26 src="{{ post.image.url_200x150 }}"
23 src="{{ post.image.url_200x150 }}"
27 alt="{{ post.id }}"
24 alt="{{ post.id }}"
28 width="{{ post.image_pre_width }}"
25 width="{{ post.image_pre_width }}"
29 height="{{ post.image_pre_height }}"
26 height="{{ post.image_pre_height }}"
30 data-width="{{ post.image_width }}"
27 data-width="{{ post.image_width }}"
31 data-height="{{ post.image_height }}"/>
28 data-height="{{ post.image_height }}"/>
32 </a>
29 </a>
33 </div>
30 </div>
34 {% endif %}
31 {% endif %}
35 <div class="message">
32 <div class="message">
36 <div class="post-info">
33 <div class="post-info">
37 <span class="title">{{ post.title }}</span>
34 <span class="title">{{ post.title }}</span>
38 <a class="post_id" href="{% post_url post.id %}">
35 <a class="post_id" href="{% post_url post.id %}">
39 ({{ post.id }}) </a>
36 ({{ post.id }}) </a>
40 [<span class="pub_time">{{ post.pub_time }}</span>]
37 [<span class="pub_time">{{ post.pub_time }}</span>]
41 {% if thread.archived %}
38 {% if thread.archived %}
42 β€” [{{ thread.bump_time }}]
39 β€” [{{ thread.bump_time }}]
43 {% endif %}
40 {% endif %}
44 {% if not truncated and not thread.archived %}
41 {% if not truncated and not thread.archived %}
45 [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}')
42 [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}')
46 ; return false;">&gt;&gt;</a>]
43 ; return false;">&gt;&gt;</a>]
47 {% endif %}
44 {% endif %}
48 {% if is_opening and need_open_link %}
45 {% if is_opening and need_open_link %}
49 {% if post.thread_new.archived %}
46 {% if post.thread_new.archived %}
50 [<a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>]
47 [<a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>]
51 {% else %}
48 {% else %}
52 [<a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>]
49 [<a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>]
53 {% endif %}
50 {% endif %}
54 {% endif %}
51 {% endif %}
55
52
56 {% if moderator %}
53 {% if moderator %}
57 <span class="moderator_info">
54 <span class="moderator_info">
58 [<a href="{% url 'post_admin' post_id=post.id %}"
55 [<a href="{% url 'post_admin' post_id=post.id %}"
59 >{% trans 'Edit' %}</a>]
56 >{% trans 'Edit' %}</a>]
60 [<a href="{% url 'delete' post_id=post.id %}"
57 [<a href="{% url 'delete' post_id=post.id %}"
61 >{% trans 'Delete' %}</a>]
58 >{% trans 'Delete' %}</a>]
62 ({{ post.poster_ip }})
59 ({{ post.poster_ip }})
63 [<a href="{% url 'ban' post_id=post.id %}?next={{ request.path }}"
60 [<a href="{% url 'ban' post_id=post.id %}?next={{ request.path }}"
64 >{% trans 'Ban IP' %}</a>]
61 >{% trans 'Ban IP' %}</a>]
65 </span>
62 </span>
66 {% endif %}
63 {% endif %}
67 </div>
64 </div>
68 {% autoescape off %}
65 {% autoescape off %}
69 {% if truncated %}
66 {% if truncated %}
70 {{ post.text.rendered|truncatewords_html:50 }}
67 {{ post.text.rendered|truncatewords_html:50 }}
71 {% else %}
68 {% else %}
72 {{ post.text.rendered }}
69 {{ post.text.rendered }}
73 {% endif %}
70 {% endif %}
74 {% endautoescape %}
71 {% endautoescape %}
75 {% if post.is_referenced %}
72 {% if post.is_referenced %}
76 <div class="refmap">
73 <div class="refmap">
77 {% trans "Replies" %}:
74 {% trans "Replies" %}:
78 {% for ref_post in post.get_sorted_referenced_posts %}
75 {% for ref_post in post.get_sorted_referenced_posts %}
79 <a href="{% post_url ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a
76 <a href="{% post_url ref_post.id %}">&gt;&gt;{{ ref_post.id }}</a
80 >{% if not forloop.last %},{% endif %}
77 >{% if not forloop.last %},{% endif %}
81 {% endfor %}
78 {% endfor %}
82 </div>
79 </div>
83 {% endif %}
80 {% endif %}
84 </div>
81 </div>
85 {% if is_opening and thread.tags.exists %}
82 {% if is_opening and thread.tags.exists %}
86 <div class="metadata">
83 <div class="metadata">
87 {% if is_opening and need_open_link %}
84 {% if is_opening and need_open_link %}
88 {{ thread.get_images_count }} {% trans 'images' %}.
85 {{ thread.get_images_count }} {% trans 'images' %}.
89 {% endif %}
86 {% endif %}
90 <span class="tags">
87 <span class="tags">
91 {% for tag in thread.get_tags %}
88 {% for tag in thread.get_tags %}
92 <a class="tag" href="{% url 'tag' tag.name %}">
89 <a class="tag" href="{% url 'tag' tag.name %}">
93 #{{ tag.name }}</a>{% if not forloop.last %},{% endif %}
90 #{{ tag.name }}</a>{% if not forloop.last %},{% endif %}
94 {% endfor %}
91 {% endfor %}
95 </span>
92 </span>
96 </div>
93 </div>
97 {% endif %}
94 {% endif %}
98 </div>
95 </div>
99 {% endspaceless %}
96 {% endspaceless %}
100 {% endwith %}
101 {% endcache %}
97 {% endcache %}
102 {% endwith %}
103 {% endwith %}
@@ -1,161 +1,163 b''
1 {% extends "boards/base.html" %}
1 {% extends "boards/base.html" %}
2
2
3 {% load i18n %}
3 {% load i18n %}
4 {% load cache %}
4 {% load cache %}
5 {% load board %}
5 {% load board %}
6 {% load static %}
6 {% load static %}
7
7
8 {% block head %}
8 {% block head %}
9 {% if tag %}
9 {% if tag %}
10 <title>{{ tag.name }} - {{ site_name }}</title>
10 <title>{{ tag.name }} - {{ site_name }}</title>
11 {% else %}
11 {% else %}
12 <title>{{ site_name }}</title>
12 <title>{{ site_name }}</title>
13 {% endif %}
13 {% endif %}
14
14
15 {% if current_page.has_previous %}
15 {% if current_page.has_previous %}
16 <link rel="prev" href="
16 <link rel="prev" href="
17 {% if tag %}
17 {% if tag %}
18 {% url "tag" tag_name=tag page=current_page.previous_page_number %}
18 {% url "tag" tag_name=tag page=current_page.previous_page_number %}
19 {% elif archived %}
19 {% elif archived %}
20 {% url "archive" page=current_page.previous_page_number %}
20 {% url "archive" page=current_page.previous_page_number %}
21 {% else %}
21 {% else %}
22 {% url "index" page=current_page.previous_page_number %}
22 {% url "index" page=current_page.previous_page_number %}
23 {% endif %}
23 {% endif %}
24 " />
24 " />
25 {% endif %}
25 {% endif %}
26 {% if current_page.has_next %}
26 {% if current_page.has_next %}
27 <link rel="next" href="
27 <link rel="next" href="
28 {% if tag %}
28 {% if tag %}
29 {% url "tag" tag_name=tag page=current_page.next_page_number %}
29 {% url "tag" tag_name=tag page=current_page.next_page_number %}
30 {% elif archived %}
30 {% elif archived %}
31 {% url "archive" page=current_page.next_page_number %}
31 {% url "archive" page=current_page.next_page_number %}
32 {% else %}
32 {% else %}
33 {% url "index" page=current_page.next_page_number %}
33 {% url "index" page=current_page.next_page_number %}
34 {% endif %}
34 {% endif %}
35 " />
35 " />
36 {% endif %}
36 {% endif %}
37
37
38 {% endblock %}
38 {% endblock %}
39
39
40 {% block content %}
40 {% block content %}
41
41
42 {% get_current_language as LANGUAGE_CODE %}
42 {% get_current_language as LANGUAGE_CODE %}
43
43
44 {% if tag %}
44 {% if tag %}
45 <div class="tag_info">
45 <div class="tag_info">
46 <h2>
46 <h2>
47 {% if tag in user.fav_tags.all %}
47 {% if tag in user.fav_tags.all %}
48 <a href="{% url 'tag' tag.name %}?method=unsubscribe&next={{ request.path }}"
48 <a href="{% url 'tag' tag.name %}?method=unsubscribe&next={{ request.path }}"
49 class="fav">β˜…</a>
49 class="fav">β˜…</a>
50 {% else %}
50 {% else %}
51 <a href="{% url 'tag' tag.name %}?method=subscribe&next={{ request.path }}"
51 <a href="{% url 'tag' tag.name %}?method=subscribe&next={{ request.path }}"
52 class="not_fav">β˜…</a>
52 class="not_fav">β˜…</a>
53 {% endif %}
53 {% endif %}
54 #{{ tag.name }}
54 #{{ tag.name }}
55 </h2>
55 </h2>
56 </div>
56 </div>
57 {% endif %}
57 {% endif %}
58
58
59 {% if threads %}
59 {% if threads %}
60 {% if current_page.has_previous %}
60 {% if current_page.has_previous %}
61 <div class="page_link">
61 <div class="page_link">
62 <a href="
62 <a href="
63 {% if tag %}
63 {% if tag %}
64 {% url "tag" tag_name=tag page=current_page.previous_page_number %}
64 {% url "tag" tag_name=tag page=current_page.previous_page_number %}
65 {% elif archived %}
65 {% elif archived %}
66 {% url "archive" page=current_page.previous_page_number %}
66 {% url "archive" page=current_page.previous_page_number %}
67 {% else %}
67 {% else %}
68 {% url "index" page=current_page.previous_page_number %}
68 {% url "index" page=current_page.previous_page_number %}
69 {% endif %}
69 {% endif %}
70 ">{% trans "Previous page" %}</a>
70 ">{% trans "Previous page" %}</a>
71 </div>
71 </div>
72 {% endif %}
72 {% endif %}
73
73
74 {% for thread in threads %}
74 {% for thread in threads %}
75 {% cache 600 thread_short thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
75 {% cache 600 thread_short thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
76 <div class="thread">
76 <div class="thread">
77 {% post_view_truncated thread.get_opening_post True moderator %}
77 {% with can_bump=thread.can_bump %}
78 {% if not thread.archived %}
78 {% post_view_truncated thread.get_opening_post True moderator is_opening=True thread=thread can_bump=can_bump %}
79 {% if thread.get_last_replies.exists %}
79 {% if not thread.archived %}
80 {% if thread.get_skipped_replies_count %}
80 {% if thread.get_last_replies.exists %}
81 <div class="skipped_replies">
81 {% if thread.get_skipped_replies_count %}
82 <a href="{% url 'thread' thread.get_opening_post.id %}">
82 <div class="skipped_replies">
83 {% blocktrans with count=thread.get_skipped_replies_count %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %}
83 <a href="{% url 'thread' thread.get_opening_post.id %}">
84 </a>
84 {% blocktrans with count=thread.get_skipped_replies_count %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %}
85 </a>
86 </div>
87 {% endif %}
88 <div class="last-replies">
89 {% for post in thread.get_last_replies %}
90 {% post_view_truncated post moderator=moderator is_opening=False thread=thread can_bump=can_bump %}
91 {% endfor %}
85 </div>
92 </div>
86 {% endif %}
93 {% endif %}
87 <div class="last-replies">
94 {% endif %}
88 {% for post in thread.get_last_replies %}
95 {% endwith %}
89 {% post_view_truncated post moderator=moderator%}
90 {% endfor %}
91 </div>
92 {% endif %}
93 {% endif %}
94 </div>
96 </div>
95 {% endcache %}
97 {% endcache %}
96 {% endfor %}
98 {% endfor %}
97
99
98 {% if current_page.has_next %}
100 {% if current_page.has_next %}
99 <div class="page_link">
101 <div class="page_link">
100 <a href="
102 <a href="
101 {% if tag %}
103 {% if tag %}
102 {% url "tag" tag_name=tag page=current_page.next_page_number %}
104 {% url "tag" tag_name=tag page=current_page.next_page_number %}
103 {% elif archived %}
105 {% elif archived %}
104 {% url "archive" page=current_page.next_page_number %}
106 {% url "archive" page=current_page.next_page_number %}
105 {% else %}
107 {% else %}
106 {% url "index" page=current_page.next_page_number %}
108 {% url "index" page=current_page.next_page_number %}
107 {% endif %}
109 {% endif %}
108 ">{% trans "Next page" %}</a>
110 ">{% trans "Next page" %}</a>
109 </div>
111 </div>
110 {% endif %}
112 {% endif %}
111 {% else %}
113 {% else %}
112 <div class="post">
114 <div class="post">
113 {% trans 'No threads exist. Create the first one!' %}</div>
115 {% trans 'No threads exist. Create the first one!' %}</div>
114 {% endif %}
116 {% endif %}
115
117
116 <div class="post-form-w">
118 <div class="post-form-w">
117 <script src="{% static 'js/panel.js' %}"></script>
119 <script src="{% static 'js/panel.js' %}"></script>
118 <div class="post-form">
120 <div class="post-form">
119 <div class="form-title">{% trans "Create new thread" %}</div>
121 <div class="form-title">{% trans "Create new thread" %}</div>
120 <form enctype="multipart/form-data" method="post">{% csrf_token %}
122 <form enctype="multipart/form-data" method="post">{% csrf_token %}
121 {{ form.as_div }}
123 {{ form.as_div }}
122 <div class="form-submit">
124 <div class="form-submit">
123 <input type="submit" value="{% trans "Post" %}"/>
125 <input type="submit" value="{% trans "Post" %}"/>
124 </div>
126 </div>
125 </form>
127 </form>
126 <div>
128 <div>
127 {% trans 'Tags must be delimited by spaces. Text or image is required.' %}
129 {% trans 'Tags must be delimited by spaces. Text or image is required.' %}
128 </div>
130 </div>
129 <div><a href="{% url "staticpage" name="help" %}">
131 <div><a href="{% url "staticpage" name="help" %}">
130 {% trans 'Text syntax' %}</a></div>
132 {% trans 'Text syntax' %}</a></div>
131 </div>
133 </div>
132 </div>
134 </div>
133
135
134 {% endblock %}
136 {% endblock %}
135
137
136 {% block metapanel %}
138 {% block metapanel %}
137
139
138 <span class="metapanel">
140 <span class="metapanel">
139 <b><a href="{% url "authors" %}">{{ site_name }}</a> {{ version }}</b>
141 <b><a href="{% url "authors" %}">{{ site_name }}</a> {{ version }}</b>
140 {% trans "Pages:" %}[
142 {% trans "Pages:" %}[
141 {% for page in paginator.page_range %}
143 {% for page in paginator.page_range %}
142 <a
144 <a
143 {% ifequal page current_page.number %}
145 {% ifequal page current_page.number %}
144 class="current_page"
146 class="current_page"
145 {% endifequal %}
147 {% endifequal %}
146 href="
148 href="
147 {% if tag %}
149 {% if tag %}
148 {% url "tag" tag_name=tag page=page %}
150 {% url "tag" tag_name=tag page=page %}
149 {% elif archived %}
151 {% elif archived %}
150 {% url "archive" page=page %}
152 {% url "archive" page=page %}
151 {% else %}
153 {% else %}
152 {% url "index" page=page %}
154 {% url "index" page=page %}
153 {% endif %}
155 {% endif %}
154 ">{{ page }}</a>
156 ">{{ page }}</a>
155 {% if not forloop.last %},{% endif %}
157 {% if not forloop.last %},{% endif %}
156 {% endfor %}
158 {% endfor %}
157 ]
159 ]
158 [<a href="rss/">RSS</a>]
160 [<a href="rss/">RSS</a>]
159 </span>
161 </span>
160
162
161 {% endblock %}
163 {% endblock %}
@@ -1,82 +1,88 b''
1 {% extends "boards/base.html" %}
1 {% extends "boards/base.html" %}
2
2
3 {% load i18n %}
3 {% load i18n %}
4 {% load cache %}
4 {% load cache %}
5 {% load static from staticfiles %}
5 {% load static from staticfiles %}
6 {% load board %}
6 {% load board %}
7
7
8 {% block head %}
8 {% block head %}
9 <title>{{ opening_post.get_title|striptags|truncatewords:10 }}
9 <title>{{ opening_post.get_title|striptags|truncatewords:10 }}
10 - {{ site_name }}</title>
10 - {{ site_name }}</title>
11 {% endblock %}
11 {% endblock %}
12
12
13 {% block content %}
13 {% block content %}
14 {% spaceless %}
14 {% spaceless %}
15 {% get_current_language as LANGUAGE_CODE %}
15 {% get_current_language as LANGUAGE_CODE %}
16
16
17 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
17 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
18
18
19 <div class="image-mode-tab">
19 <div class="image-mode-tab">
20 <a class="current_mode" href="{% url 'thread' opening_post.id %}">{% trans 'Normal mode' %}</a>,
20 <a class="current_mode" href="{% url 'thread' opening_post.id %}">{% trans 'Normal mode' %}</a>,
21 <a href="{% url 'thread_mode' opening_post.id 'gallery' %}">{% trans 'Gallery mode' %}</a>
21 <a href="{% url 'thread_mode' opening_post.id 'gallery' %}">{% trans 'Gallery mode' %}</a>
22 </div>
22 </div>
23
23
24 {% if bumpable %}
24 {% if bumpable %}
25 <div class="bar-bg">
25 <div class="bar-bg">
26 <div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
26 <div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
27 </div>
27 </div>
28 <div class="bar-text">
28 <div class="bar-text">
29 <span id="left_to_limit">{{ posts_left }}</span> {% trans 'posts to bumplimit' %}
29 <span id="left_to_limit">{{ posts_left }}</span> {% trans 'posts to bumplimit' %}
30 </div>
30 </div>
31 </div>
31 </div>
32 {% endif %}
32 {% endif %}
33
33
34 <div class="thread">
34 <div class="thread">
35 {% with can_bump=thread.can_bump %}
35 {% for post in thread.get_replies %}
36 {% for post in thread.get_replies %}
36 {% post_view post moderator=moderator %}
37 {% if forloop.first %}
38 {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump %}
39 {% else %}
40 {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump %}
41 {% endif %}
37 {% endfor %}
42 {% endfor %}
43 {% endwith %}
38 </div>
44 </div>
39
45
40 {% if not thread.archived %}
46 {% if not thread.archived %}
41
47
42 <div class="post-form-w">
48 <div class="post-form-w">
43 <script src="{% static 'js/panel.js' %}"></script>
49 <script src="{% static 'js/panel.js' %}"></script>
44 <div class="form-title">{% trans "Reply to thread" %} #{{ opening_post.id }}</div>
50 <div class="form-title">{% trans "Reply to thread" %} #{{ opening_post.id }}</div>
45 <div class="post-form">
51 <div class="post-form">
46 <form id="form" enctype="multipart/form-data" method="post"
52 <form id="form" enctype="multipart/form-data" method="post"
47 >{% csrf_token %}
53 >{% csrf_token %}
48 {{ form.as_div }}
54 {{ form.as_div }}
49 <div class="form-submit">
55 <div class="form-submit">
50 <input type="submit" value="{% trans "Post" %}"/>
56 <input type="submit" value="{% trans "Post" %}"/>
51 </div>
57 </div>
52 </form>
58 </form>
53 <div><a href="{% url "staticpage" name="help" %}">
59 <div><a href="{% url "staticpage" name="help" %}">
54 {% trans 'Text syntax' %}</a></div>
60 {% trans 'Text syntax' %}</a></div>
55 </div>
61 </div>
56 </div>
62 </div>
57
63
58 <script src="{% static 'js/jquery.form.min.js' %}"></script>
64 <script src="{% static 'js/jquery.form.min.js' %}"></script>
59 <script src="{% static 'js/thread_update.js' %}"></script>
65 <script src="{% static 'js/thread_update.js' %}"></script>
60 {% endif %}
66 {% endif %}
61
67
62 <script src="{% static 'js/thread.js' %}"></script>
68 <script src="{% static 'js/thread.js' %}"></script>
63
69
64 {% endcache %}
70 {% endcache %}
65
71
66 {% endspaceless %}
72 {% endspaceless %}
67 {% endblock %}
73 {% endblock %}
68
74
69 {% block metapanel %}
75 {% block metapanel %}
70
76
71 {% get_current_language as LANGUAGE_CODE %}
77 {% get_current_language as LANGUAGE_CODE %}
72
78
73 <span class="metapanel" data-last-update="{{ last_update }}">
79 <span class="metapanel" data-last-update="{{ last_update }}">
74 {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %}
80 {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %}
75 <span id="reply-count">{{ thread.get_reply_count }}</span> {% trans 'replies' %},
81 <span id="reply-count">{{ thread.get_reply_count }}</span> {% trans 'replies' %},
76 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
82 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
77 {% trans 'Last update: ' %}<span id="last-update">{{ thread.last_edit_time }}</span>
83 {% trans 'Last update: ' %}<span id="last-update">{{ thread.last_edit_time }}</span>
78 [<a href="rss/">RSS</a>]
84 [<a href="rss/">RSS</a>]
79 {% endcache %}
85 {% endcache %}
80 </span>
86 </span>
81
87
82 {% endblock %}
88 {% endblock %}
@@ -1,76 +1,112 b''
1 from django.core.urlresolvers import reverse
1 from django.core.urlresolvers import reverse
2 from django.shortcuts import get_object_or_404
2 from django.shortcuts import get_object_or_404
3 from boards.models import Post
3 from boards.models import Post
4 from boards.views import thread, api
4 from boards.views import thread, api
5 from django import template
5 from django import template
6
6
7 register = template.Library()
7 register = template.Library()
8
8
9 actions = [
9 actions = [
10 {
10 {
11 'name': 'google',
11 'name': 'google',
12 'link': 'http://google.com/searchbyimage?image_url=%s',
12 'link': 'http://google.com/searchbyimage?image_url=%s',
13 },
13 },
14 {
14 {
15 'name': 'iqdb',
15 'name': 'iqdb',
16 'link': 'http://iqdb.org/?url=%s',
16 'link': 'http://iqdb.org/?url=%s',
17 },
17 },
18 ]
18 ]
19
19
20
20
21 @register.simple_tag(name='post_url')
21 @register.simple_tag(name='post_url')
22 def post_url(*args, **kwargs):
22 def post_url(*args, **kwargs):
23 post_id = args[0]
23 post_id = args[0]
24
24
25 post = get_object_or_404(Post, id=post_id)
25 post = get_object_or_404(Post, id=post_id)
26
26
27 if not post.is_opening():
27 if not post.is_opening():
28 link = reverse('thread', kwargs={
28 link = reverse('thread', kwargs={
29 'post_id': post.thread_new.get_opening_post().id}) + '#' + str(
29 'post_id': post.thread_new.get_opening_post().id}) + '#' + str(
30 post_id)
30 post_id)
31 else:
31 else:
32 link = reverse('thread', kwargs={'post_id': post_id})
32 link = reverse('thread', kwargs={'post_id': post_id})
33
33
34 return link
34 return link
35
35
36
36
37 @register.simple_tag(name='image_actions')
37 @register.simple_tag(name='image_actions')
38 def image_actions(*args, **kwargs):
38 def image_actions(*args, **kwargs):
39 image_link = args[0]
39 image_link = args[0]
40 if len(args) > 1:
40 if len(args) > 1:
41 image_link = 'http://' + args[1] + image_link # TODO https?
41 image_link = 'http://' + args[1] + image_link # TODO https?
42
42
43 result = ''
43 result = ''
44
44
45 for action in actions:
45 for action in actions:
46 result += '[<a href="' + action['link'] % image_link + '">' + \
46 result += '[<a href="' + action['link'] % image_link + '">' + \
47 action['name'] + '</a>]'
47 action['name'] + '</a>]'
48
48
49 return result
49 return result
50
50
51
51
52 @register.inclusion_tag('boards/post.html', name='post_view')
52 @register.inclusion_tag('boards/post.html', name='post_view')
53 def post_view(post, moderator=False):
53 def post_view(post, moderator=False, **kwargs):
54 """
54 """
55 Get post
55 Get post
56 """
56 """
57
57
58 if 'is_opening' in kwargs:
59 is_opening = kwargs['is_opening']
60 else:
61 is_opening = post.is_opening()
62
63 if 'thread' in kwargs:
64 thread = kwargs['thread']
65 else:
66 thread = post.thread_new
67
68 if 'can_bump' in kwargs:
69 can_bump = kwargs['can_bump']
70 else:
71 can_bump = thread.can_bump()
72
58 return {
73 return {
59 'post': post,
74 'post': post,
60 'moderator': moderator,
75 'moderator': moderator,
76 'is_opening': is_opening,
77 'thread': thread,
78 'bumpable': can_bump,
61 }
79 }
62
80
63
81
64 @register.inclusion_tag('boards/post.html', name='post_view_truncated')
82 @register.inclusion_tag('boards/post.html', name='post_view_truncated')
65 def post_view_truncated(post, need_open_link=False, moderator=False):
83 def post_view_truncated(post, need_open_link=False, moderator=False, **kwargs):
66 """
84 """
67 Get post with truncated text. If the 'open' or 'reply' link is needed, pass
85 Get post with truncated text. If the 'open' or 'reply' link is needed, pass
68 the second parameter as True.
86 the second parameter as True.
69 """
87 """
70
88
89 if 'is_opening' in kwargs:
90 is_opening = kwargs['is_opening']
91 else:
92 is_opening = post.is_opening()
93
94 if 'thread' in kwargs:
95 thread = kwargs['thread']
96 else:
97 thread = post.thread_new
98
99 if 'can_bump' in kwargs:
100 can_bump = kwargs['can_bump']
101 else:
102 can_bump = thread.can_bump()
103
71 return {
104 return {
72 'post': post,
105 'post': post,
73 'truncated': True,
106 'truncated': True,
74 'need_open_link': need_open_link,
107 'need_open_link': need_open_link,
75 'moderator': moderator,
108 'moderator': moderator,
109 'is_opening': is_opening,
110 'thread': thread,
111 'bumpable': can_bump,
76 }
112 }
@@ -1,249 +1,252 b''
1 # Django settings for neboard project.
1 # Django settings for neboard project.
2 import os
2 import os
3 from boards.mdx_neboard import markdown_extended
3 from boards.mdx_neboard import markdown_extended
4
4
5 DEBUG = True
5 DEBUG = True
6 TEMPLATE_DEBUG = DEBUG
6 TEMPLATE_DEBUG = DEBUG
7
7
8 ADMINS = (
8 ADMINS = (
9 # ('Your Name', 'your_email@example.com'),
9 # ('Your Name', 'your_email@example.com'),
10 ('admin', 'admin@example.com')
10 ('admin', 'admin@example.com')
11 )
11 )
12
12
13 MANAGERS = ADMINS
13 MANAGERS = ADMINS
14
14
15 DATABASES = {
15 DATABASES = {
16 'default': {
16 'default': {
17 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
17 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
18 'NAME': 'database.db', # Or path to database file if using sqlite3.
18 'NAME': 'database.db', # Or path to database file if using sqlite3.
19 'USER': '', # Not used with sqlite3.
19 'USER': '', # Not used with sqlite3.
20 'PASSWORD': '', # Not used with sqlite3.
20 'PASSWORD': '', # Not used with sqlite3.
21 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
21 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
22 'PORT': '', # Set to empty string for default. Not used with sqlite3.
22 'PORT': '', # Set to empty string for default. Not used with sqlite3.
23 'CONN_MAX_AGE': None,
23 'CONN_MAX_AGE': None,
24 }
24 }
25 }
25 }
26
26
27 # Local time zone for this installation. Choices can be found here:
27 # Local time zone for this installation. Choices can be found here:
28 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
28 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
29 # although not all choices may be available on all operating systems.
29 # although not all choices may be available on all operating systems.
30 # In a Windows environment this must be set to your system time zone.
30 # In a Windows environment this must be set to your system time zone.
31 TIME_ZONE = 'Europe/Kiev'
31 TIME_ZONE = 'Europe/Kiev'
32
32
33 # Language code for this installation. All choices can be found here:
33 # Language code for this installation. All choices can be found here:
34 # http://www.i18nguy.com/unicode/language-identifiers.html
34 # http://www.i18nguy.com/unicode/language-identifiers.html
35 LANGUAGE_CODE = 'en'
35 LANGUAGE_CODE = 'en'
36
36
37 SITE_ID = 1
37 SITE_ID = 1
38
38
39 # If you set this to False, Django will make some optimizations so as not
39 # If you set this to False, Django will make some optimizations so as not
40 # to load the internationalization machinery.
40 # to load the internationalization machinery.
41 USE_I18N = True
41 USE_I18N = True
42
42
43 # If you set this to False, Django will not format dates, numbers and
43 # If you set this to False, Django will not format dates, numbers and
44 # calendars according to the current locale.
44 # calendars according to the current locale.
45 USE_L10N = True
45 USE_L10N = True
46
46
47 # If you set this to False, Django will not use timezone-aware datetimes.
47 # If you set this to False, Django will not use timezone-aware datetimes.
48 USE_TZ = True
48 USE_TZ = True
49
49
50 # Absolute filesystem path to the directory that will hold user-uploaded files.
50 # Absolute filesystem path to the directory that will hold user-uploaded files.
51 # Example: "/home/media/media.lawrence.com/media/"
51 # Example: "/home/media/media.lawrence.com/media/"
52 MEDIA_ROOT = './media/'
52 MEDIA_ROOT = './media/'
53
53
54 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
54 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
55 # trailing slash.
55 # trailing slash.
56 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
56 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
57 MEDIA_URL = '/media/'
57 MEDIA_URL = '/media/'
58
58
59 # Absolute path to the directory static files should be collected to.
59 # Absolute path to the directory static files should be collected to.
60 # Don't put anything in this directory yourself; store your static files
60 # Don't put anything in this directory yourself; store your static files
61 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
61 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
62 # Example: "/home/media/media.lawrence.com/static/"
62 # Example: "/home/media/media.lawrence.com/static/"
63 STATIC_ROOT = ''
63 STATIC_ROOT = ''
64
64
65 # URL prefix for static files.
65 # URL prefix for static files.
66 # Example: "http://media.lawrence.com/static/"
66 # Example: "http://media.lawrence.com/static/"
67 STATIC_URL = '/static/'
67 STATIC_URL = '/static/'
68
68
69 # Additional locations of static files
69 # Additional locations of static files
70 # It is really a hack, put real paths, not related
70 # It is really a hack, put real paths, not related
71 STATICFILES_DIRS = (
71 STATICFILES_DIRS = (
72 os.path.dirname(__file__) + '/boards/static',
72 os.path.dirname(__file__) + '/boards/static',
73
73
74 # '/d/work/python/django/neboard/neboard/boards/static',
74 # '/d/work/python/django/neboard/neboard/boards/static',
75 # Put strings here, like "/home/html/static" or "C:/www/django/static".
75 # Put strings here, like "/home/html/static" or "C:/www/django/static".
76 # Always use forward slashes, even on Windows.
76 # Always use forward slashes, even on Windows.
77 # Don't forget to use absolute paths, not relative paths.
77 # Don't forget to use absolute paths, not relative paths.
78 )
78 )
79
79
80 # List of finder classes that know how to find static files in
80 # List of finder classes that know how to find static files in
81 # various locations.
81 # various locations.
82 STATICFILES_FINDERS = (
82 STATICFILES_FINDERS = (
83 'django.contrib.staticfiles.finders.FileSystemFinder',
83 'django.contrib.staticfiles.finders.FileSystemFinder',
84 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
84 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
85 )
85 )
86
86
87 if DEBUG:
87 if DEBUG:
88 STATICFILES_STORAGE = \
88 STATICFILES_STORAGE = \
89 'django.contrib.staticfiles.storage.StaticFilesStorage'
89 'django.contrib.staticfiles.storage.StaticFilesStorage'
90 else:
90 else:
91 STATICFILES_STORAGE = \
91 STATICFILES_STORAGE = \
92 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
92 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
93
93
94 # Make this unique, and don't share it with anybody.
94 # Make this unique, and don't share it with anybody.
95 SECRET_KEY = '@1rc$o(7=tt#kd+4s$u6wchm**z^)4x90)7f6z(i&amp;55@o11*8o'
95 SECRET_KEY = '@1rc$o(7=tt#kd+4s$u6wchm**z^)4x90)7f6z(i&amp;55@o11*8o'
96
96
97 # List of callables that know how to import templates from various sources.
97 # List of callables that know how to import templates from various sources.
98 TEMPLATE_LOADERS = (
98 TEMPLATE_LOADERS = (
99 'django.template.loaders.filesystem.Loader',
99 'django.template.loaders.filesystem.Loader',
100 'django.template.loaders.app_directories.Loader',
100 'django.template.loaders.app_directories.Loader',
101 )
101 )
102
102
103 TEMPLATE_CONTEXT_PROCESSORS = (
103 TEMPLATE_CONTEXT_PROCESSORS = (
104 'django.core.context_processors.media',
104 'django.core.context_processors.media',
105 'django.core.context_processors.static',
105 'django.core.context_processors.static',
106 'django.core.context_processors.request',
106 'django.core.context_processors.request',
107 'django.contrib.auth.context_processors.auth',
107 'django.contrib.auth.context_processors.auth',
108 )
108 )
109
109
110 MIDDLEWARE_CLASSES = (
110 MIDDLEWARE_CLASSES = (
111 'django.contrib.sessions.middleware.SessionMiddleware',
111 'django.contrib.sessions.middleware.SessionMiddleware',
112 'django.middleware.locale.LocaleMiddleware',
112 'django.middleware.locale.LocaleMiddleware',
113 'django.middleware.common.CommonMiddleware',
113 'django.middleware.common.CommonMiddleware',
114 'django.contrib.auth.middleware.AuthenticationMiddleware',
114 'django.contrib.auth.middleware.AuthenticationMiddleware',
115 'django.contrib.messages.middleware.MessageMiddleware',
115 'django.contrib.messages.middleware.MessageMiddleware',
116 'boards.middlewares.BanMiddleware',
116 'boards.middlewares.BanMiddleware',
117 'boards.middlewares.MinifyHTMLMiddleware',
117 'boards.middlewares.MinifyHTMLMiddleware',
118 )
118 )
119
119
120 ROOT_URLCONF = 'neboard.urls'
120 ROOT_URLCONF = 'neboard.urls'
121
121
122 # Python dotted path to the WSGI application used by Django's runserver.
122 # Python dotted path to the WSGI application used by Django's runserver.
123 WSGI_APPLICATION = 'neboard.wsgi.application'
123 WSGI_APPLICATION = 'neboard.wsgi.application'
124
124
125 TEMPLATE_DIRS = (
125 TEMPLATE_DIRS = (
126 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
126 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
127 # Always use forward slashes, even on Windows.
127 # Always use forward slashes, even on Windows.
128 # Don't forget to use absolute paths, not relative paths.
128 # Don't forget to use absolute paths, not relative paths.
129 'templates',
129 'templates',
130 )
130 )
131
131
132 INSTALLED_APPS = (
132 INSTALLED_APPS = (
133 'django.contrib.auth',
133 'django.contrib.auth',
134 'django.contrib.contenttypes',
134 'django.contrib.contenttypes',
135 'django.contrib.sessions',
135 'django.contrib.sessions',
136 # 'django.contrib.sites',
136 # 'django.contrib.sites',
137 'django.contrib.messages',
137 'django.contrib.messages',
138 'django.contrib.staticfiles',
138 'django.contrib.staticfiles',
139 # Uncomment the next line to enable the admin:
139 # Uncomment the next line to enable the admin:
140 'django.contrib.admin',
140 'django.contrib.admin',
141 # Uncomment the next line to enable admin documentation:
141 # Uncomment the next line to enable admin documentation:
142 # 'django.contrib.admindocs',
142 # 'django.contrib.admindocs',
143 'django.contrib.humanize',
143 'django.contrib.humanize',
144 'django_cleanup',
144 'django_cleanup',
145 'boards',
145 'boards',
146 'captcha',
146 'captcha',
147 'south',
147 'south',
148 'debug_toolbar',
148 'debug_toolbar',
149 )
149 )
150
150
151 DEBUG_TOOLBAR_PANELS = (
151 DEBUG_TOOLBAR_PANELS = (
152 'debug_toolbar.panels.version.VersionDebugPanel',
152 'debug_toolbar.panels.version.VersionDebugPanel',
153 'debug_toolbar.panels.timer.TimerDebugPanel',
153 'debug_toolbar.panels.timer.TimerDebugPanel',
154 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
154 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
155 'debug_toolbar.panels.headers.HeaderDebugPanel',
155 'debug_toolbar.panels.headers.HeaderDebugPanel',
156 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
156 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
157 'debug_toolbar.panels.template.TemplateDebugPanel',
157 'debug_toolbar.panels.template.TemplateDebugPanel',
158 'debug_toolbar.panels.sql.SQLDebugPanel',
158 'debug_toolbar.panels.sql.SQLDebugPanel',
159 'debug_toolbar.panels.signals.SignalDebugPanel',
159 'debug_toolbar.panels.signals.SignalDebugPanel',
160 'debug_toolbar.panels.logger.LoggingPanel',
160 'debug_toolbar.panels.logger.LoggingPanel',
161 )
161 )
162
162
163 # TODO: NEED DESIGN FIXES
163 # TODO: NEED DESIGN FIXES
164 CAPTCHA_OUTPUT_FORMAT = (u' %(hidden_field)s '
164 CAPTCHA_OUTPUT_FORMAT = (u' %(hidden_field)s '
165 u'<div class="form-label">%(image)s</div>'
165 u'<div class="form-label">%(image)s</div>'
166 u'<div class="form-text">%(text_field)s</div>')
166 u'<div class="form-text">%(text_field)s</div>')
167
167
168 # A sample logging configuration. The only tangible logging
168 # A sample logging configuration. The only tangible logging
169 # performed by this configuration is to send an email to
169 # performed by this configuration is to send an email to
170 # the site admins on every HTTP 500 error when DEBUG=False.
170 # the site admins on every HTTP 500 error when DEBUG=False.
171 # See http://docs.djangoproject.com/en/dev/topics/logging for
171 # See http://docs.djangoproject.com/en/dev/topics/logging for
172 # more details on how to customize your logging configuration.
172 # more details on how to customize your logging configuration.
173 LOGGING = {
173 LOGGING = {
174 'version': 1,
174 'version': 1,
175 'disable_existing_loggers': False,
175 'disable_existing_loggers': False,
176 'filters': {
176 'filters': {
177 'require_debug_false': {
177 'require_debug_false': {
178 '()': 'django.utils.log.RequireDebugFalse'
178 '()': 'django.utils.log.RequireDebugFalse'
179 }
179 }
180 },
180 },
181 'handlers': {
181 'handlers': {
182 'mail_admins': {
182 'mail_admins': {
183 'level': 'ERROR',
183 'level': 'ERROR',
184 'filters': ['require_debug_false'],
184 'filters': ['require_debug_false'],
185 'class': 'django.utils.log.AdminEmailHandler'
185 'class': 'django.utils.log.AdminEmailHandler'
186 }
186 }
187 },
187 },
188 'loggers': {
188 'loggers': {
189 'django.request': {
189 'django.request': {
190 'handlers': ['mail_admins'],
190 'handlers': ['mail_admins'],
191 'level': 'ERROR',
191 'level': 'ERROR',
192 'propagate': True,
192 'propagate': True,
193 },
193 },
194 }
194 }
195 }
195 }
196
196
197 MARKUP_FIELD_TYPES = (
197 MARKUP_FIELD_TYPES = (
198 ('markdown', markdown_extended),
198 ('markdown', markdown_extended),
199 )
199 )
200 # Custom imageboard settings
200 # Custom imageboard settings
201 # TODO These should me moved to
201 # TODO These should me moved to
202 MAX_POSTS_PER_THREAD = 10 # Thread bumplimit
202 MAX_POSTS_PER_THREAD = 10 # Thread bumplimit
203 MAX_THREAD_COUNT = 500 # Old threads will be deleted to preserve this count
203 MAX_THREAD_COUNT = 500 # Old threads will be deleted to preserve this count
204 THREADS_PER_PAGE = 3
204 THREADS_PER_PAGE = 3
205 SITE_NAME = 'Neboard'
205 SITE_NAME = 'Neboard'
206
206
207 THEMES = [
207 THEMES = [
208 ('md', 'Mystic Dark'),
208 ('md', 'Mystic Dark'),
209 ('md_centered', 'Mystic Dark (centered)'),
209 ('md_centered', 'Mystic Dark (centered)'),
210 ('sw', 'Snow White'),
210 ('sw', 'Snow White'),
211 ('pg', 'Photon Gray'),
211 ('pg', 'Photon Gray'),
212 ]
212 ]
213
213
214 DEFAULT_THEME = 'md'
214 DEFAULT_THEME = 'md'
215
215
216 POPULAR_TAGS = 10
216 POPULAR_TAGS = 10
217 LAST_REPLIES_COUNT = 3
217 LAST_REPLIES_COUNT = 3
218
218
219 ENABLE_CAPTCHA = False
219 ENABLE_CAPTCHA = False
220 # if user tries to post before CAPTCHA_DEFAULT_SAFE_TIME. Captcha will be shown
220 # if user tries to post before CAPTCHA_DEFAULT_SAFE_TIME. Captcha will be shown
221 CAPTCHA_DEFAULT_SAFE_TIME = 30 # seconds
221 CAPTCHA_DEFAULT_SAFE_TIME = 30 # seconds
222 POSTING_DELAY = 20 # seconds
222 POSTING_DELAY = 20 # seconds
223
223
224 COMPRESS_HTML = True
224 COMPRESS_HTML = True
225
225
226 VERSION = '1.7 Anubis'
226 VERSION = '1.7 Anubis'
227
227
228 # Debug mode middlewares
228 # Debug mode middlewares
229 if DEBUG:
229 if DEBUG:
230
231 SITE_NAME += '_debug'
232
230 MIDDLEWARE_CLASSES += (
233 MIDDLEWARE_CLASSES += (
231 'boards.profiler.ProfilerMiddleware',
234 'boards.profiler.ProfilerMiddleware',
232 'debug_toolbar.middleware.DebugToolbarMiddleware',
235 'debug_toolbar.middleware.DebugToolbarMiddleware',
233 )
236 )
234
237
235 def custom_show_toolbar(request):
238 def custom_show_toolbar(request):
236 return DEBUG
239 return DEBUG
237
240
238 DEBUG_TOOLBAR_CONFIG = {
241 DEBUG_TOOLBAR_CONFIG = {
239 'INTERCEPT_REDIRECTS': False,
242 'INTERCEPT_REDIRECTS': False,
240 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
243 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
241 'HIDE_DJANGO_SQL': False,
244 'HIDE_DJANGO_SQL': False,
242 'ENABLE_STACKTRACES': True,
245 'ENABLE_STACKTRACES': True,
243 }
246 }
244
247
245 # FIXME Uncommenting this fails somehow. Need to investigate this
248 # FIXME Uncommenting this fails somehow. Need to investigate this
246 #DEBUG_TOOLBAR_PANELS += (
249 #DEBUG_TOOLBAR_PANELS += (
247 # 'debug_toolbar.panels.profiling.ProfilingDebugPanel',
250 # 'debug_toolbar.panels.profiling.ProfilingDebugPanel',
248 #)
251 #)
249
252
General Comments 0
You need to be logged in to leave comments. Login now