Show More
@@ -79,3 +79,13 b' textarea, input {' | |||||
79 | height: 100px; |
|
79 | height: 100px; | |
80 | width: 100%; |
|
80 | width: 100%; | |
81 | } |
|
81 | } | |
|
82 | ||||
|
83 | .post-button-form { | |||
|
84 | display: inline; | |||
|
85 | } | |||
|
86 | ||||
|
87 | .post-button-form > input[type="submit"] { | |||
|
88 | border: none; | |||
|
89 | margin: 0; | |||
|
90 | padding: 0; | |||
|
91 | } |
@@ -81,6 +81,21 b' function translate_time(node) {' | |||||
81 | }); |
|
81 | }); | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
|
84 | /** | |||
|
85 | * We use buttons viewed as a form with link and hidden inputs to ensure | |||
|
86 | * the search crawlers don't index or click them. | |||
|
87 | * | |||
|
88 | * But we need to submit the form by clicking the links. That's why these | |||
|
89 | * handlers are here. | |||
|
90 | */ | |||
|
91 | function addPostButtonActions() { | |||
|
92 | $('.post-button-form > a').each(function() { | |||
|
93 | $(this).click(function() { | |||
|
94 | $(this).parent().submit(); | |||
|
95 | }); | |||
|
96 | }); | |||
|
97 | } | |||
|
98 | ||||
84 | $( document ).ready(function() { |
|
99 | $( document ).ready(function() { | |
85 | hideEmailFromForm(); |
|
100 | hideEmailFromForm(); | |
86 |
|
101 | |||
@@ -96,4 +111,6 b' function translate_time(node) {' | |||||
96 | highlightCode($(document)); |
|
111 | highlightCode($(document)); | |
97 |
|
112 | |||
98 | translate_time(null); |
|
113 | translate_time(null); | |
|
114 | ||||
|
115 | addPostButtonActions(); | |||
99 | }); |
|
116 | }); |
@@ -40,22 +40,25 b'' | |||||
40 | {% if tag %} |
|
40 | {% if tag %} | |
41 | <div class="tag_info"> |
|
41 | <div class="tag_info"> | |
42 | <h2> |
|
42 | <h2> | |
43 | {% if is_favorite %} |
|
43 | <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form"> | |
44 | <a href="{% url 'tag' tag.name %}?method=unsubscribe&next={{ request.path }}" |
|
44 | <input type="hidden" name="method" | |
45 | class="fav" rel="nofollow">β </a> |
|
45 | {% if is_favorite %} | |
46 | {% else %} |
|
46 | <input type="hidden" name="method" value="unsubscribe" /> | |
47 | <a href="{% url 'tag' tag.name %}?method=subscribe&next={{ request.path }}" |
|
47 | <a class="fav" href="#">β </a> | |
48 | class="not_fav" rel="nofollow">β </a> |
|
48 | {% else %} | |
49 | {% endif %} |
|
49 | <input type="hidden" name="method" value="subscribe" /> | |
50 | {% if is_hidden %} |
|
50 | <a class="not_fav" href="#">β </a> | |
51 | <a href="{% url 'tag' tag.name %}?method=unhide&next={{ request.path }}" |
|
51 | {% endif %} | |
52 | title="{% trans 'Show tag' %}" |
|
52 | </form> | |
53 | class="fav" rel="nofollow">H</a> |
|
53 | <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form"> | |
54 |
|
|
54 | {% if is_hidden %} | |
55 | <a href="{% url 'tag' tag.name %}?method=hide&next={{ request.path }}" |
|
55 | <input type="hidden" name="method" value="unhide" /> | |
56 | title="{% trans 'Hide tag' %}" |
|
56 | <a class="fav" href="#">H</a> | |
57 | class="not_fav" rel="nofollow">H</a> |
|
57 | {% else %} | |
58 | {% endif %} |
|
58 | <input type="hidden" name="method" value="hide" /> | |
|
59 | <a class="not_fav" href="#">H</a> | |||
|
60 | {% endif %} | |||
|
61 | </form> | |||
59 | {% autoescape off %} |
|
62 | {% autoescape off %} | |
60 | {{ tag.get_view }} |
|
63 | {{ tag.get_view }} | |
61 | {% endautoescape %} |
|
64 | {% endautoescape %} |
@@ -43,22 +43,25 b' class TagView(AllThreadsView, Dispatcher' | |||||
43 | def get(self, request, tag_name, page=DEFAULT_PAGE, form=None): |
|
43 | def get(self, request, tag_name, page=DEFAULT_PAGE, form=None): | |
44 | self.tag_name = tag_name |
|
44 | self.tag_name = tag_name | |
45 |
|
45 | |||
46 | dispatch_result = self.dispatch_method(request) |
|
46 | return super(TagView, self).get(request, page, form) | |
47 | if dispatch_result: |
|
47 | ||
48 | return dispatch_result |
|
|||
49 | else: |
|
|||
50 | return super(TagView, self).get(request, page, form) |
|
|||
51 |
|
48 | |||
52 | def post(self, request, tag_name, page=DEFAULT_PAGE): |
|
49 | def post(self, request, tag_name, page=DEFAULT_PAGE): | |
53 | form = ThreadForm(request.POST, request.FILES, |
|
50 | self.tag_name = tag_name | |
54 | error_class=PlainErrorList) |
|
|||
55 | form.session = request.session |
|
|||
56 |
|
51 | |||
57 | if form.is_valid(): |
|
52 | if 'method' in request.POST: | |
58 |
|
|
53 | self.dispatch_method(request) | |
59 | if form.need_to_ban: |
|
54 | form = None | |
60 | # Ban user because he is suspected to be a bot |
|
55 | else: | |
61 | self._ban_current_user(request) |
|
56 | form = ThreadForm(request.POST, request.FILES, | |
|
57 | error_class=PlainErrorList) | |||
|
58 | form.session = request.session | |||
|
59 | ||||
|
60 | if form.is_valid(): | |||
|
61 | return self.create_thread(request, form) | |||
|
62 | if form.need_to_ban: | |||
|
63 | # Ban user because he is suspected to be a bot | |||
|
64 | self._ban_current_user(request) | |||
62 |
|
65 | |||
63 | return self.get(request, tag_name, page, form) |
|
66 | return self.get(request, tag_name, page, form) | |
64 |
|
67 | |||
@@ -68,16 +71,12 b' class TagView(AllThreadsView, Dispatcher' | |||||
68 | settings_manager = get_settings_manager(request) |
|
71 | settings_manager = get_settings_manager(request) | |
69 | settings_manager.add_fav_tag(tag) |
|
72 | settings_manager.add_fav_tag(tag) | |
70 |
|
73 | |||
71 | return self.redirect_to_next(request) |
|
|||
72 |
|
||||
73 | def unsubscribe(self, request): |
|
74 | def unsubscribe(self, request): | |
74 | tag = get_object_or_404(Tag, name=self.tag_name) |
|
75 | tag = get_object_or_404(Tag, name=self.tag_name) | |
75 |
|
76 | |||
76 | settings_manager = get_settings_manager(request) |
|
77 | settings_manager = get_settings_manager(request) | |
77 | settings_manager.del_fav_tag(tag) |
|
78 | settings_manager.del_fav_tag(tag) | |
78 |
|
79 | |||
79 | return self.redirect_to_next(request) |
|
|||
80 |
|
||||
81 | def hide(self, request): |
|
80 | def hide(self, request): | |
82 | """ |
|
81 | """ | |
83 | Adds tag to user's hidden tags. Threads with this tag will not be |
|
82 | Adds tag to user's hidden tags. Threads with this tag will not be |
General Comments 0
You need to be logged in to leave comments.
Login now