Show More
@@ -1,89 +1,89 b'' | |||||
1 | {% load staticfiles %} |
|
1 | {% load staticfiles %} | |
2 | {% load i18n %} |
|
2 | {% load i18n %} | |
3 | {% load l10n %} |
|
3 | {% load l10n %} | |
4 | {% load static from staticfiles %} |
|
4 | {% load static from staticfiles %} | |
5 |
|
5 | |||
6 | <!DOCTYPE html> |
|
6 | <!DOCTYPE html> | |
7 | <html> |
|
7 | <html> | |
8 | <head> |
|
8 | <head> | |
9 | <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}" media="all"/> |
|
9 | <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}" media="all"/> | |
10 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/highlight.css' %}" media="all"/> |
|
10 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/highlight.css' %}" media="all"/> | |
11 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/jquery-ui.min.css' %}" media="all"/> |
|
11 | <link rel="stylesheet" type="text/css" href="{% static 'css/3party/jquery-ui.min.css' %}" media="all"/> | |
12 | <link rel="stylesheet" type="text/css" href="{% static theme_css %}" media="all"/> |
|
12 | <link rel="stylesheet" type="text/css" href="{% static theme_css %}" media="all"/> | |
13 |
|
13 | |||
14 | {% if rss_url %} |
|
14 | {% if rss_url %} | |
15 | <link rel="alternate" type="application/rss+xml" href="{{ rss_url }}" title="{% trans 'Feed' %}"/> |
|
15 | <link rel="alternate" type="application/rss+xml" href="{{ rss_url }}" title="{% trans 'Feed' %}"/> | |
16 | {% endif %} |
|
16 | {% endif %} | |
17 |
|
17 | |||
18 | <link rel="icon" type="image/png" |
|
18 | <link rel="icon" type="image/png" | |
19 | href="{% static 'favicon.png' %}"> |
|
19 | href="{% static 'favicon.png' %}"> | |
20 |
|
20 | |||
21 | <meta name="viewport" content="width=device-width, initial-scale=1"/> |
|
21 | <meta name="viewport" content="width=device-width, initial-scale=1"/> | |
22 | <meta charset="utf-8"/> |
|
22 | <meta charset="utf-8"/> | |
23 |
|
23 | |||
24 | {% block head %}{% endblock %} |
|
24 | {% block head %}{% endblock %} | |
25 | </head> |
|
25 | </head> | |
26 | <body data-image-viewer="{{ image_viewer }}" |
|
26 | <body data-image-viewer="{{ image_viewer }}" | |
27 | data-pow-difficulty="{{ pow_difficulty }}" |
|
27 | data-pow-difficulty="{{ pow_difficulty }}" | |
28 | data-update-script="{% static 'js/updates.js' %}"> |
|
28 | data-update-script="{% static 'js/updates.js' %}"> | |
29 | <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script> |
|
29 | <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script> | |
30 |
|
30 | |||
31 | <div class="navigation_panel header"> |
|
31 | <div class="navigation_panel header"> | |
32 | <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a> |
|
32 | <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a> | |
33 | {% if tags_str %} |
|
33 | {% if tags_str %} | |
34 | {% autoescape off %} |
|
34 | {% autoescape off %} | |
35 | {{ tags_str }}, |
|
35 | {{ tags_str }}, | |
36 | {% endautoescape %} |
|
36 | {% endautoescape %} | |
37 | {% else %} |
|
37 | {% else %} | |
38 | {% trans 'Add tags' %} β |
|
38 | {% trans 'Add tags' %} β | |
39 | {% endif %} |
|
39 | {% endif %} | |
40 | <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>, |
|
40 | <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>, | |
41 | <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>, |
|
41 | <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>, | |
42 | <a href="{% url 'feed' %}" title="{% trans 'Feed' %}">{% trans 'feed' %}</a>, |
|
42 | <a href="{% url 'feed' %}" title="{% trans 'Feed' %}">{% trans 'feed' %}</a>, | |
43 | <a href="{% url 'random' %}" title="{% trans 'Random images' %}">{% trans 'random' %}</a>{% if has_fav_threads %}, |
|
43 | <a href="{% url 'random' %}" title="{% trans 'Random images' %}">{% trans 'random' %}</a>{% if has_fav_threads %}, | |
44 |
|
44 | |||
45 |
<a href=" |
|
45 | <a href="{% url 'feed' %}?favorites" id="fav-panel-btn">{% trans 'favorites' %} <span id="new-fav-post-count" {% if not new_post_count %}style="display: none" {% endif %}>{{ new_post_count }}</span></a> | |
46 | {% endif %} |
|
46 | {% endif %} | |
47 |
|
47 | |||
48 | {% if usernames %} |
|
48 | {% if usernames %} | |
49 | <a class="right-link link" href="{% url 'notifications' %}" title="{% trans 'Notifications' %}"> |
|
49 | <a class="right-link link" href="{% url 'notifications' %}" title="{% trans 'Notifications' %}"> | |
50 | {% trans 'Notifications' %} |
|
50 | {% trans 'Notifications' %} | |
51 | {% ifnotequal new_notifications_count 0 %} |
|
51 | {% ifnotequal new_notifications_count 0 %} | |
52 | (<b>{{ new_notifications_count }}</b>) |
|
52 | (<b>{{ new_notifications_count }}</b>) | |
53 | {% endifnotequal %} |
|
53 | {% endifnotequal %} | |
54 | </a> |
|
54 | </a> | |
55 | {% endif %} |
|
55 | {% endif %} | |
56 |
|
56 | |||
57 | <a class="right-link link" href="{% url 'settings' %}">{% trans 'Settings' %}</a> |
|
57 | <a class="right-link link" href="{% url 'settings' %}">{% trans 'Settings' %}</a> | |
58 | </div> |
|
58 | </div> | |
59 |
|
59 | |||
60 | <div id="fav-panel"><div class="post">{% trans "Loading..." %}</div></div> |
|
60 | <div id="fav-panel"><div class="post">{% trans "Loading..." %}</div></div> | |
61 |
|
61 | |||
62 | {% block content %}{% endblock %} |
|
62 | {% block content %}{% endblock %} | |
63 |
|
63 | |||
64 | <script src="{% static 'js/3party/jquery-ui.min.js' %}"></script> |
|
64 | <script src="{% static 'js/3party/jquery-ui.min.js' %}"></script> | |
65 | <script src="{% static 'js/jquery.mousewheel.js' %}"></script> |
|
65 | <script src="{% static 'js/jquery.mousewheel.js' %}"></script> | |
66 | <script src="{% static 'js/3party/highlight.min.js' %}"></script> |
|
66 | <script src="{% static 'js/3party/highlight.min.js' %}"></script> | |
67 |
|
67 | |||
68 | <script src="{% url 'js_info_dict' %}"></script> |
|
68 | <script src="{% url 'js_info_dict' %}"></script> | |
69 |
|
69 | |||
70 | <script src="{% static 'js/popup.js' %}"></script> |
|
70 | <script src="{% static 'js/popup.js' %}"></script> | |
71 | <script src="{% static 'js/image.js' %}"></script> |
|
71 | <script src="{% static 'js/image.js' %}"></script> | |
72 | <script src="{% static 'js/refpopup.js' %}"></script> |
|
72 | <script src="{% static 'js/refpopup.js' %}"></script> | |
73 | <script src="{% static 'js/main.js' %}"></script> |
|
73 | <script src="{% static 'js/main.js' %}"></script> | |
74 |
|
74 | |||
75 | <div class="navigation_panel footer"> |
|
75 | <div class="navigation_panel footer"> | |
76 | {% block metapanel %}{% endblock %} |
|
76 | {% block metapanel %}{% endblock %} | |
77 | {% if rss_url %} |
|
77 | {% if rss_url %} | |
78 | [<a href="{{ rss_url }}">RSS</a>] |
|
78 | [<a href="{{ rss_url }}">RSS</a>] | |
79 | {% endif %} |
|
79 | {% endif %} | |
80 | [<a href="{% url 'admin:index' %}">{% trans 'Admin' %}</a>] |
|
80 | [<a href="{% url 'admin:index' %}">{% trans 'Admin' %}</a>] | |
81 | [<a href="{% url 'index' %}?order=pub">{% trans 'New threads' %}</a>] |
|
81 | [<a href="{% url 'index' %}?order=pub">{% trans 'New threads' %}</a>] | |
82 | {% with ppd=posts_per_day|floatformat:2 %} |
|
82 | {% with ppd=posts_per_day|floatformat:2 %} | |
83 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} |
|
83 | {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %} | |
84 | {% endwith %} |
|
84 | {% endwith %} | |
85 | <a class="link" href="#top" id="up">{% trans 'Up' %}</a> |
|
85 | <a class="link" href="#top" id="up">{% trans 'Up' %}</a> | |
86 | </div> |
|
86 | </div> | |
87 |
|
87 | |||
88 | </body> |
|
88 | </body> | |
89 | </html> |
|
89 | </html> |
@@ -1,71 +1,70 b'' | |||||
1 | from django.core.urlresolvers import reverse |
|
1 | from django.core.urlresolvers import reverse | |
2 | from django.shortcuts import render |
|
2 | from django.shortcuts import render | |
3 |
|
3 | |||
4 | from boards.abstracts.paginator import get_paginator |
|
4 | from boards.abstracts.paginator import get_paginator | |
5 | from boards.abstracts.settingsmanager import get_settings_manager |
|
5 | from boards.abstracts.settingsmanager import get_settings_manager | |
6 | from boards.models import Post |
|
6 | from boards.models import Post | |
7 | from boards.views.base import BaseBoardView |
|
7 | from boards.views.base import BaseBoardView | |
8 | from boards.views.posting_mixin import PostMixin |
|
8 | from boards.views.posting_mixin import PostMixin | |
9 |
|
9 | |||
10 | POSTS_PER_PAGE = 10 |
|
10 | POSTS_PER_PAGE = 10 | |
11 |
|
11 | |||
12 | PARAMETER_CURRENT_PAGE = 'current_page' |
|
12 | PARAMETER_CURRENT_PAGE = 'current_page' | |
13 | PARAMETER_PAGINATOR = 'paginator' |
|
13 | PARAMETER_PAGINATOR = 'paginator' | |
14 | PARAMETER_POSTS = 'posts' |
|
14 | PARAMETER_POSTS = 'posts' | |
15 | PARAMETER_ADDITONAL_ATTRS = 'additional_attrs' |
|
|||
16 |
|
15 | |||
17 | PARAMETER_PREV_LINK = 'prev_page_link' |
|
16 | PARAMETER_PREV_LINK = 'prev_page_link' | |
18 | PARAMETER_NEXT_LINK = 'next_page_link' |
|
17 | PARAMETER_NEXT_LINK = 'next_page_link' | |
19 |
|
18 | |||
20 | TEMPLATE = 'boards/feed.html' |
|
19 | TEMPLATE = 'boards/feed.html' | |
21 | DEFAULT_PAGE = 1 |
|
20 | DEFAULT_PAGE = 1 | |
22 |
|
21 | |||
23 |
|
22 | |||
24 | class FeedView(PostMixin, BaseBoardView): |
|
23 | class FeedView(PostMixin, BaseBoardView): | |
25 |
|
24 | |||
26 | def get(self, request): |
|
25 | def get(self, request): | |
27 | page = request.GET.get('page', DEFAULT_PAGE) |
|
26 | page = request.GET.get('page', DEFAULT_PAGE) | |
28 | tripcode = request.GET.get('tripcode', None) |
|
27 | tripcode = request.GET.get('tripcode', None) | |
|
28 | favorites = 'favorites' in request.GET | |||
29 |
|
29 | |||
30 | params = self.get_context_data(request=request) |
|
30 | params = self.get_context_data(request=request) | |
31 |
|
31 | |||
32 | settings_manager = get_settings_manager(request) |
|
32 | settings_manager = get_settings_manager(request) | |
33 |
|
33 | |||
34 | posts = Post.objects.exclude( |
|
34 | posts = Post.objects.exclude( | |
35 | threads__tags__in=settings_manager.get_hidden_tags()).order_by( |
|
35 | threads__tags__in=settings_manager.get_hidden_tags()).order_by( | |
36 | '-pub_time').prefetch_related('images', 'thread', 'threads') |
|
36 | '-pub_time').prefetch_related('images', 'thread', 'threads') | |
37 | if tripcode: |
|
37 | if tripcode: | |
38 | posts = posts.filter(tripcode=tripcode) |
|
38 | posts = posts.filter(tripcode=tripcode) | |
|
39 | if favorites: | |||
|
40 | fav_thread_ops = Post.objects.filter(id__in=settings_manager.get_fav_threads().keys()) | |||
|
41 | fav_threads = [op.get_thread() for op in fav_thread_ops] | |||
|
42 | posts = posts.filter(threads__in=fav_threads) | |||
39 |
|
43 | |||
40 | paginator = get_paginator(posts, POSTS_PER_PAGE) |
|
44 | paginator = get_paginator(posts, POSTS_PER_PAGE) | |
41 | paginator.current_page = int(page) |
|
45 | paginator.current_page = int(page) | |
42 |
|
46 | |||
43 | params[PARAMETER_POSTS] = paginator.page(page).object_list |
|
47 | params[PARAMETER_POSTS] = paginator.page(page).object_list | |
44 |
|
48 | |||
45 | additional_params = dict() |
|
|||
46 | if tripcode: |
|
|||
47 | additional_params['tripcode'] = tripcode |
|
|||
48 | params[PARAMETER_ADDITONAL_ATTRS] = '&tripcode=' + tripcode |
|
|||
49 |
|
||||
50 | paginator.set_url(reverse('feed'), request.GET.dict()) |
|
49 | paginator.set_url(reverse('feed'), request.GET.dict()) | |
51 |
|
50 | |||
52 | self.get_page_context(paginator, params, page) |
|
51 | self.get_page_context(paginator, params, page) | |
53 |
|
52 | |||
54 | return render(request, TEMPLATE, params) |
|
53 | return render(request, TEMPLATE, params) | |
55 |
|
54 | |||
56 | # TODO Dedup this into PagedMixin |
|
55 | # TODO Dedup this into PagedMixin | |
57 | def get_page_context(self, paginator, params, page): |
|
56 | def get_page_context(self, paginator, params, page): | |
58 | """ |
|
57 | """ | |
59 | Get pagination context variables |
|
58 | Get pagination context variables | |
60 | """ |
|
59 | """ | |
61 |
|
60 | |||
62 | params[PARAMETER_PAGINATOR] = paginator |
|
61 | params[PARAMETER_PAGINATOR] = paginator | |
63 | current_page = paginator.page(int(page)) |
|
62 | current_page = paginator.page(int(page)) | |
64 | params[PARAMETER_CURRENT_PAGE] = current_page |
|
63 | params[PARAMETER_CURRENT_PAGE] = current_page | |
65 | if current_page.has_previous(): |
|
64 | if current_page.has_previous(): | |
66 | params[PARAMETER_PREV_LINK] = paginator.get_page_url( |
|
65 | params[PARAMETER_PREV_LINK] = paginator.get_page_url( | |
67 | current_page.previous_page_number()) |
|
66 | current_page.previous_page_number()) | |
68 | if current_page.has_next(): |
|
67 | if current_page.has_next(): | |
69 | params[PARAMETER_NEXT_LINK] = paginator.get_page_url( |
|
68 | params[PARAMETER_NEXT_LINK] = paginator.get_page_url( | |
70 | current_page.next_page_number()) |
|
69 | current_page.next_page_number()) | |
71 |
|
70 |
General Comments 0
You need to be logged in to leave comments.
Login now