Show More
@@ -1,7 +1,3 b'' | |||||
1 | {% load board %} |
|
1 | {% load board %} | |
2 |
|
2 | |||
3 | {% if truncated %} |
|
3 | {% post_view post truncated=truncated %} No newline at end of file | |
4 | {% post_view_truncated post %} |
|
|||
5 | {% else %} |
|
|||
6 | {% post_view post %} |
|
|||
7 | {% endif %} |
|
@@ -1,163 +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 | {% with can_bump=thread.can_bump %} |
|
77 | {% with can_bump=thread.can_bump %} | |
78 |
{% post_view |
|
78 | {% post_view thread.get_opening_post moderator is_opening=True thread=thread can_bump=can_bump truncated=True need_open_link=True %} | |
79 | {% if not thread.archived %} |
|
79 | {% if not thread.archived %} | |
80 | {% if thread.get_last_replies.exists %} |
|
80 | {% if thread.get_last_replies.exists %} | |
81 | {% if thread.get_skipped_replies_count %} |
|
81 | {% if thread.get_skipped_replies_count %} | |
82 | <div class="skipped_replies"> |
|
82 | <div class="skipped_replies"> | |
83 | <a href="{% url 'thread' thread.get_opening_post.id %}"> |
|
83 | <a href="{% url 'thread' thread.get_opening_post.id %}"> | |
84 | {% blocktrans with count=thread.get_skipped_replies_count %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %} |
|
84 | {% blocktrans with count=thread.get_skipped_replies_count %}Skipped {{ count }} replies. Open thread to see all replies.{% endblocktrans %} | |
85 | </a> |
|
85 | </a> | |
86 | </div> |
|
86 | </div> | |
87 | {% endif %} |
|
87 | {% endif %} | |
88 | <div class="last-replies"> |
|
88 | <div class="last-replies"> | |
89 | {% for post in thread.get_last_replies %} |
|
89 | {% for post in thread.get_last_replies %} | |
90 |
{% post_view |
|
90 | {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump truncated=True %} | |
91 | {% endfor %} |
|
91 | {% endfor %} | |
92 | </div> |
|
92 | </div> | |
93 | {% endif %} |
|
93 | {% endif %} | |
94 | {% endif %} |
|
94 | {% endif %} | |
95 | {% endwith %} |
|
95 | {% endwith %} | |
96 | </div> |
|
96 | </div> | |
97 | {% endcache %} |
|
97 | {% endcache %} | |
98 | {% endfor %} |
|
98 | {% endfor %} | |
99 |
|
99 | |||
100 | {% if current_page.has_next %} |
|
100 | {% if current_page.has_next %} | |
101 | <div class="page_link"> |
|
101 | <div class="page_link"> | |
102 | <a href=" |
|
102 | <a href=" | |
103 | {% if tag %} |
|
103 | {% if tag %} | |
104 | {% url "tag" tag_name=tag page=current_page.next_page_number %} |
|
104 | {% url "tag" tag_name=tag page=current_page.next_page_number %} | |
105 | {% elif archived %} |
|
105 | {% elif archived %} | |
106 | {% url "archive" page=current_page.next_page_number %} |
|
106 | {% url "archive" page=current_page.next_page_number %} | |
107 | {% else %} |
|
107 | {% else %} | |
108 | {% url "index" page=current_page.next_page_number %} |
|
108 | {% url "index" page=current_page.next_page_number %} | |
109 | {% endif %} |
|
109 | {% endif %} | |
110 | ">{% trans "Next page" %}</a> |
|
110 | ">{% trans "Next page" %}</a> | |
111 | </div> |
|
111 | </div> | |
112 | {% endif %} |
|
112 | {% endif %} | |
113 | {% else %} |
|
113 | {% else %} | |
114 | <div class="post"> |
|
114 | <div class="post"> | |
115 | {% trans 'No threads exist. Create the first one!' %}</div> |
|
115 | {% trans 'No threads exist. Create the first one!' %}</div> | |
116 | {% endif %} |
|
116 | {% endif %} | |
117 |
|
117 | |||
118 | <div class="post-form-w"> |
|
118 | <div class="post-form-w"> | |
119 | <script src="{% static 'js/panel.js' %}"></script> |
|
119 | <script src="{% static 'js/panel.js' %}"></script> | |
120 | <div class="post-form"> |
|
120 | <div class="post-form"> | |
121 | <div class="form-title">{% trans "Create new thread" %}</div> |
|
121 | <div class="form-title">{% trans "Create new thread" %}</div> | |
122 | <form enctype="multipart/form-data" method="post">{% csrf_token %} |
|
122 | <form enctype="multipart/form-data" method="post">{% csrf_token %} | |
123 | {{ form.as_div }} |
|
123 | {{ form.as_div }} | |
124 | <div class="form-submit"> |
|
124 | <div class="form-submit"> | |
125 | <input type="submit" value="{% trans "Post" %}"/> |
|
125 | <input type="submit" value="{% trans "Post" %}"/> | |
126 | </div> |
|
126 | </div> | |
127 | </form> |
|
127 | </form> | |
128 | <div> |
|
128 | <div> | |
129 | {% 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.' %} | |
130 | </div> |
|
130 | </div> | |
131 | <div><a href="{% url "staticpage" name="help" %}"> |
|
131 | <div><a href="{% url "staticpage" name="help" %}"> | |
132 | {% trans 'Text syntax' %}</a></div> |
|
132 | {% trans 'Text syntax' %}</a></div> | |
133 | </div> |
|
133 | </div> | |
134 | </div> |
|
134 | </div> | |
135 |
|
135 | |||
136 | {% endblock %} |
|
136 | {% endblock %} | |
137 |
|
137 | |||
138 | {% block metapanel %} |
|
138 | {% block metapanel %} | |
139 |
|
139 | |||
140 | <span class="metapanel"> |
|
140 | <span class="metapanel"> | |
141 | <b><a href="{% url "authors" %}">{{ site_name }}</a> {{ version }}</b> |
|
141 | <b><a href="{% url "authors" %}">{{ site_name }}</a> {{ version }}</b> | |
142 | {% trans "Pages:" %}[ |
|
142 | {% trans "Pages:" %}[ | |
143 | {% for page in paginator.page_range %} |
|
143 | {% for page in paginator.page_range %} | |
144 | <a |
|
144 | <a | |
145 | {% ifequal page current_page.number %} |
|
145 | {% ifequal page current_page.number %} | |
146 | class="current_page" |
|
146 | class="current_page" | |
147 | {% endifequal %} |
|
147 | {% endifequal %} | |
148 | href=" |
|
148 | href=" | |
149 | {% if tag %} |
|
149 | {% if tag %} | |
150 | {% url "tag" tag_name=tag page=page %} |
|
150 | {% url "tag" tag_name=tag page=page %} | |
151 | {% elif archived %} |
|
151 | {% elif archived %} | |
152 | {% url "archive" page=page %} |
|
152 | {% url "archive" page=page %} | |
153 | {% else %} |
|
153 | {% else %} | |
154 | {% url "index" page=page %} |
|
154 | {% url "index" page=page %} | |
155 | {% endif %} |
|
155 | {% endif %} | |
156 | ">{{ page }}</a> |
|
156 | ">{{ page }}</a> | |
157 | {% if not forloop.last %},{% endif %} |
|
157 | {% if not forloop.last %},{% endif %} | |
158 | {% endfor %} |
|
158 | {% endfor %} | |
159 | ] |
|
159 | ] | |
160 | [<a href="rss/">RSS</a>] |
|
160 | [<a href="rss/">RSS</a>] | |
161 | </span> |
|
161 | </span> | |
162 |
|
162 | |||
163 | {% endblock %} |
|
163 | {% endblock %} |
@@ -1,104 +1,74 b'' | |||||
1 | from django.shortcuts import get_object_or_404 |
|
1 | from django.shortcuts import get_object_or_404 | |
2 | from boards.models import Post |
|
2 | from boards.models import Post | |
3 | from boards.views import thread, api |
|
3 | from boards.views import thread, api | |
4 | from django import template |
|
4 | from django import template | |
5 |
|
5 | |||
6 | register = template.Library() |
|
6 | register = template.Library() | |
7 |
|
7 | |||
8 | actions = [ |
|
8 | actions = [ | |
9 | { |
|
9 | { | |
10 | 'name': 'google', |
|
10 | 'name': 'google', | |
11 | 'link': 'http://google.com/searchbyimage?image_url=%s', |
|
11 | 'link': 'http://google.com/searchbyimage?image_url=%s', | |
12 | }, |
|
12 | }, | |
13 | { |
|
13 | { | |
14 | 'name': 'iqdb', |
|
14 | 'name': 'iqdb', | |
15 | 'link': 'http://iqdb.org/?url=%s', |
|
15 | 'link': 'http://iqdb.org/?url=%s', | |
16 | }, |
|
16 | }, | |
17 | ] |
|
17 | ] | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | @register.simple_tag(name='post_url') |
|
20 | @register.simple_tag(name='post_url') | |
21 | def post_url(*args, **kwargs): |
|
21 | def post_url(*args, **kwargs): | |
22 | post_id = args[0] |
|
22 | post_id = args[0] | |
23 |
|
23 | |||
24 | post = get_object_or_404(Post, id=post_id) |
|
24 | post = get_object_or_404(Post, id=post_id) | |
25 |
|
25 | |||
26 | return post.get_url() |
|
26 | return post.get_url() | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | @register.simple_tag(name='image_actions') |
|
29 | @register.simple_tag(name='image_actions') | |
30 | def image_actions(*args, **kwargs): |
|
30 | def image_actions(*args, **kwargs): | |
31 | image_link = args[0] |
|
31 | image_link = args[0] | |
32 | if len(args) > 1: |
|
32 | if len(args) > 1: | |
33 | image_link = 'http://' + args[1] + image_link # TODO https? |
|
33 | image_link = 'http://' + args[1] + image_link # TODO https? | |
34 |
|
34 | |||
35 | result = '' |
|
35 | result = '' | |
36 |
|
36 | |||
37 | for action in actions: |
|
37 | for action in actions: | |
38 | result += '[<a href="' + action['link'] % image_link + '">' + \ |
|
38 | result += '[<a href="' + action['link'] % image_link + '">' + \ | |
39 | action['name'] + '</a>]' |
|
39 | action['name'] + '</a>]' | |
40 |
|
40 | |||
41 | return result |
|
41 | return result | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | @register.inclusion_tag('boards/post.html', name='post_view') |
|
44 | @register.inclusion_tag('boards/post.html', name='post_view') | |
45 |
def post_view(post, moderator=False, |
|
45 | def post_view(post, moderator=False, need_open_link=False, truncated=False, | |
|
46 | **kwargs): | |||
46 | """ |
|
47 | """ | |
47 | Get post |
|
48 | Get post | |
48 | """ |
|
49 | """ | |
49 |
|
50 | |||
50 | if 'is_opening' in kwargs: |
|
51 | if 'is_opening' in kwargs: | |
51 | is_opening = kwargs['is_opening'] |
|
52 | is_opening = kwargs['is_opening'] | |
52 | else: |
|
53 | else: | |
53 | is_opening = post.is_opening() |
|
54 | is_opening = post.is_opening() | |
54 |
|
55 | |||
55 | if 'thread' in kwargs: |
|
56 | if 'thread' in kwargs: | |
56 | thread = kwargs['thread'] |
|
57 | thread = kwargs['thread'] | |
57 | else: |
|
58 | else: | |
58 | thread = post.thread_new |
|
59 | thread = post.thread_new | |
59 |
|
60 | |||
60 | # if 'can_bump' in kwargs: |
|
|||
61 | # can_bump = kwargs['can_bump'] |
|
|||
62 | # else: |
|
|||
63 | can_bump = thread.can_bump() |
|
|||
64 |
|
||||
65 | return { |
|
|||
66 | 'post': post, |
|
|||
67 | 'moderator': moderator, |
|
|||
68 | 'is_opening': is_opening, |
|
|||
69 | 'thread': thread, |
|
|||
70 | 'bumpable': can_bump, |
|
|||
71 | } |
|
|||
72 |
|
||||
73 |
|
||||
74 | @register.inclusion_tag('boards/post.html', name='post_view_truncated') |
|
|||
75 | def post_view_truncated(post, need_open_link=False, moderator=False, **kwargs): |
|
|||
76 | """ |
|
|||
77 | Get post with truncated text. If the 'open' or 'reply' link is needed, pass |
|
|||
78 | the second parameter as True. |
|
|||
79 | """ |
|
|||
80 |
|
||||
81 | if 'is_opening' in kwargs: |
|
|||
82 | is_opening = kwargs['is_opening'] |
|
|||
83 | else: |
|
|||
84 | is_opening = post.is_opening() |
|
|||
85 |
|
||||
86 | if 'thread' in kwargs: |
|
|||
87 | thread = kwargs['thread'] |
|
|||
88 | else: |
|
|||
89 | thread = post.thread_new |
|
|||
90 |
|
||||
91 | if 'can_bump' in kwargs: |
|
61 | if 'can_bump' in kwargs: | |
92 | can_bump = kwargs['can_bump'] |
|
62 | can_bump = kwargs['can_bump'] | |
93 | else: |
|
63 | else: | |
94 | can_bump = thread.can_bump() |
|
64 | can_bump = thread.can_bump() | |
95 |
|
65 | |||
96 | return { |
|
66 | return { | |
97 | 'post': post, |
|
67 | 'post': post, | |
98 | 'truncated': True, |
|
|||
99 | 'need_open_link': need_open_link, |
|
|||
100 | 'moderator': moderator, |
|
68 | 'moderator': moderator, | |
101 | 'is_opening': is_opening, |
|
69 | 'is_opening': is_opening, | |
102 | 'thread': thread, |
|
70 | 'thread': thread, | |
103 | 'bumpable': can_bump, |
|
71 | 'bumpable': can_bump, | |
104 | } |
|
72 | 'need_open_link': need_open_link, | |
|
73 | 'truncated': truncated, | |||
|
74 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now