##// END OF EJS Templates
Made "subscribe" and "hide" in tags as buttons with forms.
neko259 -
r1037:9a07761c default
parent child Browse files
Show More
@@ -79,3 +79,13 b' textarea, input {'
79 79 height: 100px;
80 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 99 $( document ).ready(function() {
85 100 hideEmailFromForm();
86 101
@@ -96,4 +111,6 b' function translate_time(node) {'
96 111 highlightCode($(document));
97 112
98 113 translate_time(null);
114
115 addPostButtonActions();
99 116 });
@@ -40,22 +40,25 b''
40 40 {% if tag %}
41 41 <div class="tag_info">
42 42 <h2>
43 {% if is_favorite %}
44 <a href="{% url 'tag' tag.name %}?method=unsubscribe&next={{ request.path }}"
45 class="fav" rel="nofollow">β˜…</a>
46 {% else %}
47 <a href="{% url 'tag' tag.name %}?method=subscribe&next={{ request.path }}"
48 class="not_fav" rel="nofollow">β˜…</a>
49 {% endif %}
50 {% if is_hidden %}
51 <a href="{% url 'tag' tag.name %}?method=unhide&next={{ request.path }}"
52 title="{% trans 'Show tag' %}"
53 class="fav" rel="nofollow">H</a>
54 {% else %}
55 <a href="{% url 'tag' tag.name %}?method=hide&next={{ request.path }}"
56 title="{% trans 'Hide tag' %}"
57 class="not_fav" rel="nofollow">H</a>
58 {% endif %}
43 <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form">
44 <input type="hidden" name="method"
45 {% if is_favorite %}
46 <input type="hidden" name="method" value="unsubscribe" />
47 <a class="fav" href="#">β˜…</a>
48 {% else %}
49 <input type="hidden" name="method" value="subscribe" />
50 <a class="not_fav" href="#">β˜…</a>
51 {% endif %}
52 </form>
53 <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form">
54 {% if is_hidden %}
55 <input type="hidden" name="method" value="unhide" />
56 <a class="fav" href="#">H</a>
57 {% else %}
58 <input type="hidden" name="method" value="hide" />
59 <a class="not_fav" href="#">H</a>
60 {% endif %}
61 </form>
59 62 {% autoescape off %}
60 63 {{ tag.get_view }}
61 64 {% endautoescape %}
@@ -43,22 +43,25 b' class TagView(AllThreadsView, Dispatcher'
43 43 def get(self, request, tag_name, page=DEFAULT_PAGE, form=None):
44 44 self.tag_name = tag_name
45 45
46 dispatch_result = self.dispatch_method(request)
47 if dispatch_result:
48 return dispatch_result
49 else:
50 return super(TagView, self).get(request, page, form)
46 return super(TagView, self).get(request, page, form)
47
51 48
52 49 def post(self, request, tag_name, page=DEFAULT_PAGE):
53 form = ThreadForm(request.POST, request.FILES,
54 error_class=PlainErrorList)
55 form.session = request.session
50 self.tag_name = tag_name
56 51
57 if form.is_valid():
58 return self.create_thread(request, form)
59 if form.need_to_ban:
60 # Ban user because he is suspected to be a bot
61 self._ban_current_user(request)
52 if 'method' in request.POST:
53 self.dispatch_method(request)
54 form = None
55 else:
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 66 return self.get(request, tag_name, page, form)
64 67
@@ -68,16 +71,12 b' class TagView(AllThreadsView, Dispatcher'
68 71 settings_manager = get_settings_manager(request)
69 72 settings_manager.add_fav_tag(tag)
70 73
71 return self.redirect_to_next(request)
72
73 74 def unsubscribe(self, request):
74 75 tag = get_object_or_404(Tag, name=self.tag_name)
75 76
76 77 settings_manager = get_settings_manager(request)
77 78 settings_manager.del_fav_tag(tag)
78 79
79 return self.redirect_to_next(request)
80
81 80 def hide(self, request):
82 81 """
83 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