##// END OF EJS Templates
Added landing page which will be the default on /
neko259 -
r1732:24d0b585 default
parent child Browse files
Show More
@@ -0,0 +1,31 b''
1 {% extends "boards/base.html" %}
2
3 {% load i18n %}
4 {% load static %}
5
6 {% block head %}
7 <title>{{ site_name }}</title>
8 {% endblock %}
9
10 {% block content %}
11 <div class="post">
12 <div class="landing-images">
13 {% for image in images %}
14 <div class="gallery_image">
15 {{ image.get_view|safe }}
16 {% with image.get_random_associated_post as post %}
17 {{ post.get_link_view|safe }}
18 {% endwith %}
19 </div>
20 {% endfor %}
21 </div>
22 <div class="landing-tags">
23 {{ section_str|safe }}
24 </div>
25 <div class="landing-threads">
26 {% for op in latest_threads %}
27 {{ op.get_link_view|safe }} {{ op.get_title_or_text }}<br />
28 {% endfor %}
29 </div>
30 </div>
31 {% endblock %}
@@ -0,0 +1,32 b''
1 from django.shortcuts import render
2 from django.utils.decorators import method_decorator
3 from django.views.decorators.csrf import csrf_protect
4
5 from boards.views.base import BaseBoardView
6 from boards.models import Tag, Post, Attachment
7
8
9 PARAM_SECTION_STR = 'section_str'
10 PARAM_LATEST_THREADS = 'latest_threads'
11 PARAM_IMAGES = 'images'
12
13 TEMPLATE = 'boards/landing.html'
14
15 MAX_NEW_THREADS = 10
16 RANDOM_IMAGE_COUNT = 3
17
18
19 class LandingView(BaseBoardView):
20 @method_decorator(csrf_protect)
21 def get(self, request):
22 params = dict()
23
24 params[PARAM_SECTION_STR] = Tag.objects.get_tag_url_list(
25 Tag.objects.filter(required=True))
26 params[PARAM_LATEST_THREADS] = Post.objects.filter(opening=True)\
27 .order_by('-pub_time')[:MAX_NEW_THREADS]
28 params[PARAM_IMAGES] = Attachment.objects.get_random_images(
29 RANDOM_IMAGE_COUNT)
30
31 return render(request, TEMPLATE, params)
32
@@ -173,3 +173,14 b' textarea, input {'
173 .url-image:hover {
173 .url-image:hover {
174 filter: invert(100%);
174 filter: invert(100%);
175 }
175 }
176
177 .landing-tags, .landing-threads, .landing-images {
178 max-width: 800px;
179 margin-left: auto;
180 margin-right: auto;
181 }
182
183 .landing-images {
184 text-align: center;
185 }
186
@@ -29,7 +29,8 b''
29 <script src="{% static 'js/jquery-2.2.0.min.js' %}"></script>
29 <script src="{% static 'js/jquery-2.2.0.min.js' %}"></script>
30
30
31 <header class="navigation_panel">
31 <header class="navigation_panel">
32 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
32 <a class="link" href="{% url 'landing' %}">{{ site_name }}</a>
33 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>,
33 {% if tags_str %}
34 {% if tags_str %}
34 <form action="{% url 'index' %}" method="post" class="post-button-form">{% csrf_token %}
35 <form action="{% url 'index' %}" method="post" class="post-button-form">{% csrf_token %}
35 {% if only_favorites %}
36 {% if only_favorites %}
@@ -39,8 +40,6 b''
39 {% endif %}
40 {% endif %}
40 </form>
41 </form>
41 {{ tags_str|safe }},
42 {{ tags_str|safe }},
42 {% else %}
43 {% trans 'Add tags' %} →
44 {% endif %}
43 {% endif %}
45 <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>,
44 <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}">{% trans "tags" %}</a>,
46 <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>,
45 <a href="{% url 'search' %}" title="{% trans 'Search' %}">{% trans 'search' %}</a>,
@@ -13,9 +13,7 b''
13 <div>
13 <div>
14 {% for image in images %}
14 {% for image in images %}
15 <div class="gallery_image">
15 <div class="gallery_image">
16 {% autoescape off %}
16 {{ image.get_view|safe }}
17 {{ image.get_view }}
18 {% endautoescape %}
19 {% with image.get_random_associated_post as post %}
17 {% with image.get_random_associated_post as post %}
20 {{ post.get_link_view|safe }}
18 {{ post.get_link_view|safe }}
21 <div>
19 <div>
@@ -15,6 +15,7 b' from boards.views.random import RandomIm'
15 from boards.views.tag_gallery import TagGalleryView
15 from boards.views.tag_gallery import TagGalleryView
16 from boards.views.translation import cached_javascript_catalog
16 from boards.views.translation import cached_javascript_catalog
17 from boards.views.search import BoardSearchView
17 from boards.views.search import BoardSearchView
18 from boards.views.landing import LandingView
18
19
19
20
20 js_info_dict = {
21 js_info_dict = {
@@ -23,7 +24,7 b' js_info_dict = {'
23
24
24 urlpatterns = [
25 urlpatterns = [
25 # /boards/
26 # /boards/
26 url(r'^$', all_threads.AllThreadsView.as_view(), name='index'),
27 url(r'^all/$', all_threads.AllThreadsView.as_view(), name='index'),
27
28
28 # /boards/tag/tag_name/
29 # /boards/tag/tag_name/
29 url(r'^tag/(?P<tag_name>\w+)/$', tag_threads.TagView.as_view(),
30 url(r'^tag/(?P<tag_name>\w+)/$', tag_threads.TagView.as_view(),
@@ -51,6 +52,7 b' urlpatterns = ['
51 url(r'^random/$', RandomImageView.as_view(), name='random'),
52 url(r'^random/$', RandomImageView.as_view(), name='random'),
52 url(r'^tag/(?P<tag_name>\w+)/gallery/$', TagGalleryView.as_view(), name='tag_gallery'),
53 url(r'^tag/(?P<tag_name>\w+)/gallery/$', TagGalleryView.as_view(), name='tag_gallery'),
53 url(r'^search/$', BoardSearchView.as_view(), name='search'),
54 url(r'^search/$', BoardSearchView.as_view(), name='search'),
55 url(r'^$', LandingView.as_view(), name='landing'),
54
56
55 # RSS feeds
57 # RSS feeds
56 url(r'^rss/$', AllThreadsFeed()),
58 url(r'^rss/$', AllThreadsFeed()),
General Comments 0
You need to be logged in to leave comments. Login now