diff --git a/boards/static/css/base.css b/boards/static/css/base.css --- a/boards/static/css/base.css +++ b/boards/static/css/base.css @@ -79,3 +79,13 @@ textarea, input { height: 100px; width: 100%; } + +.post-button-form { + display: inline; +} + +.post-button-form > input[type="submit"] { + border: none; + margin: 0; + padding: 0; +} diff --git a/boards/static/js/main.js b/boards/static/js/main.js --- a/boards/static/js/main.js +++ b/boards/static/js/main.js @@ -81,6 +81,21 @@ function translate_time(node) { }); } +/** + * We use buttons viewed as a form with link and hidden inputs to ensure + * the search crawlers don't index or click them. + * + * But we need to submit the form by clicking the links. That's why these + * handlers are here. + */ +function addPostButtonActions() { + $('.post-button-form > a').each(function() { + $(this).click(function() { + $(this).parent().submit(); + }); + }); +} + $( document ).ready(function() { hideEmailFromForm(); @@ -96,4 +111,6 @@ function translate_time(node) { highlightCode($(document)); translate_time(null); + + addPostButtonActions(); }); diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -40,22 +40,25 @@ {% if tag %}

- {% if is_favorite %} - - {% else %} - - {% endif %} - {% if is_hidden %} - H - {% else %} - H - {% endif %} +
+ + + {% else %} + + + {% endif %} +
+
+ {% if is_hidden %} + + H + {% else %} + + H + {% endif %} +
{% autoescape off %} {{ tag.get_view }} {% endautoescape %} diff --git a/boards/views/tag_threads.py b/boards/views/tag_threads.py --- a/boards/views/tag_threads.py +++ b/boards/views/tag_threads.py @@ -43,22 +43,25 @@ class TagView(AllThreadsView, Dispatcher def get(self, request, tag_name, page=DEFAULT_PAGE, form=None): self.tag_name = tag_name - dispatch_result = self.dispatch_method(request) - if dispatch_result: - return dispatch_result - else: - return super(TagView, self).get(request, page, form) + return super(TagView, self).get(request, page, form) + def post(self, request, tag_name, page=DEFAULT_PAGE): - form = ThreadForm(request.POST, request.FILES, - error_class=PlainErrorList) - form.session = request.session + self.tag_name = tag_name - if form.is_valid(): - return self.create_thread(request, form) - if form.need_to_ban: - # Ban user because he is suspected to be a bot - self._ban_current_user(request) + if 'method' in request.POST: + self.dispatch_method(request) + form = None + else: + form = ThreadForm(request.POST, request.FILES, + error_class=PlainErrorList) + form.session = request.session + + if form.is_valid(): + return self.create_thread(request, form) + if form.need_to_ban: + # Ban user because he is suspected to be a bot + self._ban_current_user(request) return self.get(request, tag_name, page, form) @@ -68,16 +71,12 @@ class TagView(AllThreadsView, Dispatcher settings_manager = get_settings_manager(request) settings_manager.add_fav_tag(tag) - return self.redirect_to_next(request) - def unsubscribe(self, request): tag = get_object_or_404(Tag, name=self.tag_name) settings_manager = get_settings_manager(request) settings_manager.del_fav_tag(tag) - return self.redirect_to_next(request) - def hide(self, request): """ Adds tag to user's hidden tags. Threads with this tag will not be