-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Batiste Bieler
committed
Jan 16, 2019
1 parent
fb611ad
commit 912aeaa
Showing
39 changed files
with
565 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import url | ||
from blog import views | ||
from django.urls import include, path, re_path | ||
|
||
urlpatterns = [ | ||
url(r'^category/(?P<tag_id>[0-9]+)$', views.category_view, name='blog_category_view'), | ||
url(r'^$', views.blog_index, name='blog_index') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.shortcuts import render | ||
from pages.models import Page | ||
from taggit.models import Tag | ||
from django.core.paginator import Paginator | ||
|
||
def category_view(request, *args, **kwargs): | ||
context = dict(kwargs) | ||
category = Tag.objects.get(id=kwargs['tag_id']) | ||
page = context['current_page'] | ||
blogs = page.get_children_for_frontend().filter(tags__name__in=[category.name]) | ||
|
||
paginator = Paginator(blogs, 8) | ||
page_index = request.GET.get('page') | ||
blogs = paginator.get_page(page_index) | ||
context['blogs'] = blogs | ||
|
||
context['category'] = category.name | ||
return render(request, 'blog-home.html', context) | ||
|
||
def blog_index(request, *args, **kwargs): | ||
context = dict(kwargs) | ||
page = context['current_page'] | ||
blogs = page.get_children_for_frontend() | ||
|
||
paginator = Paginator(blogs, 7) | ||
page = request.GET.get('page') | ||
blogs = paginator.get_page(page) | ||
context['blogs'] = blogs | ||
context['template_name'] = 'blog-home.html' | ||
|
||
return render(request, 'blog-home.html', context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
example_dir = os.path.dirname(__file__) | ||
sys.path.insert(0, os.path.join(example_dir, '..')) | ||
|
||
if __name__ == "__main__": | ||
def main(): | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
execute_from_command_line(sys.argv) | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
.blog-lead-image { | ||
text-align: center; | ||
} | ||
|
||
.blog-lead-image img { | ||
width: 100%; | ||
max-width: 500px; | ||
} | ||
|
||
.blog-home .card img { | ||
width: 100%; | ||
border-top-left-radius: 2px; | ||
border-top-right-radius: 2px; | ||
} | ||
|
||
.blog-home .card { | ||
min-width: 25%; | ||
max-width: calc(33% - 30px); | ||
} | ||
|
||
.blog-meta { | ||
margin-bottom: 0; | ||
font-size: 14px; | ||
} | ||
|
||
.blog-home .card:first-child { | ||
min-width: 75%; | ||
max-width: 100%; | ||
flex-direction: row; | ||
} | ||
.blog-home .card:first-child .blog-lead-image { | ||
width: 33%; | ||
flex-shrink: 0; | ||
} | ||
|
||
.blog-post .blog-lead-image { | ||
margin-bottom: 30px; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.blog-home .card, .blog-home .card:first-child { | ||
min-width: 33%; | ||
max-width: 45%; | ||
flex-direction: column; | ||
} | ||
.blog-home .card:first-child .blog-lead-image { | ||
width: 100%; | ||
flex-shrink: 1; | ||
} | ||
} | ||
|
||
@media (max-width: 576px) { | ||
.blog-home .card, .blog-home .card:first-child { | ||
max-width: 100%; | ||
} | ||
} |
Oops, something went wrong.