##// 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 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 <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form">
44 <input type="hidden" name="method"
43 {% if is_favorite %}
45 {% if is_favorite %}
44 <a href="{% url 'tag' tag.name %}?method=unsubscribe&next={{ request.path }}"
46 <input type="hidden" name="method" value="unsubscribe" />
45 class="fav" rel="nofollow">β˜…</a>
47 <a class="fav" href="#">β˜…</a>
46 {% else %}
48 {% else %}
47 <a href="{% url 'tag' tag.name %}?method=subscribe&next={{ request.path }}"
49 <input type="hidden" name="method" value="subscribe" />
48 class="not_fav" rel="nofollow">β˜…</a>
50 <a class="not_fav" href="#">β˜…</a>
49 {% endif %}
51 {% endif %}
52 </form>
53 <form action="{% url 'tag' tag.name %}" method="post" class="post-button-form">
50 {% if is_hidden %}
54 {% if is_hidden %}
51 <a href="{% url 'tag' tag.name %}?method=unhide&next={{ request.path }}"
55 <input type="hidden" name="method" value="unhide" />
52 title="{% trans 'Show tag' %}"
56 <a class="fav" href="#">H</a>
53 class="fav" rel="nofollow">H</a>
54 {% else %}
57 {% else %}
55 <a href="{% url 'tag' tag.name %}?method=hide&next={{ request.path }}"
58 <input type="hidden" name="method" value="hide" />
56 title="{% trans 'Hide tag' %}"
59 <a class="not_fav" href="#">H</a>
57 class="not_fav" rel="nofollow">H</a>
58 {% endif %}
60 {% endif %}
61 </form>
59 {% autoescape off %}
62 {% autoescape off %}
60 {{ tag.get_view }}
63 {{ tag.get_view }}
61 {% endautoescape %}
64 {% endautoescape %}
@@ -43,13 +43,16 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)
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)
51
47
48
52 def post(self, request, tag_name, page=DEFAULT_PAGE):
49 def post(self, request, tag_name, page=DEFAULT_PAGE):
50 self.tag_name = tag_name
51
52 if 'method' in request.POST:
53 self.dispatch_method(request)
54 form = None
55 else:
53 form = ThreadForm(request.POST, request.FILES,
56 form = ThreadForm(request.POST, request.FILES,
54 error_class=PlainErrorList)
57 error_class=PlainErrorList)
55 form.session = request.session
58 form.session = request.session
@@ -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