Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Оживил блог на Django #24

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5396662
Add index page layout
GuidingPlace855 May 18, 2024
efa5ec6
Use static template tag
GuidingPlace855 May 23, 2024
321a8ef
Add post cards
GuidingPlace855 May 23, 2024
b15c151
Render posts on index page
GuidingPlace855 May 25, 2024
f7cb5a1
Truncate post text.
GuidingPlace855 May 25, 2024
a9a7345
Fix card max-width
GuidingPlace855 May 25, 2024
d68f37b
Add post page layout.
GuidingPlace855 May 25, 2024
e2b3a9d
Add template logic to post page
GuidingPlace855 May 25, 2024
6c13333
Add comments to post page
GuidingPlace855 May 30, 2024
57e40be
Update "add comments to post page"
GuidingPlace855 May 30, 2024
799b563
Make like heart red
GuidingPlace855 May 30, 2024
d0ea03f
"Sensitive" leads to the main page
GuidingPlace855 May 30, 2024
14f7c86
Added transitions to the post page
GuidingPlace855 Jun 1, 2024
927813f
Added a blog-base
GuidingPlace855 Jun 1, 2024
0902236
Added contact.html and map in it
GuidingPlace855 Jun 1, 2024
6d196be
Added switching to home or contact
GuidingPlace855 Jun 13, 2024
f253ac6
"Home" and "Contact" turned gray
GuidingPlace855 Jun 13, 2024
84af006
Added a different name for each browser tab of the page
GuidingPlace855 Jun 13, 2024
f2a7f22
Update README
GuidingPlace855 Jun 13, 2024
705ff1b
Удалил папку media
GuidingPlace855 Jun 13, 2024
925a13e
Delete .gitkeep
GuidingPlace855 Jun 13, 2024
8d9c506
Указал img alt
GuidingPlace855 Jun 13, 2024
a268c2f
Поправил отступы
GuidingPlace855 Jun 13, 2024
e511039
Поправил отступы
GuidingPlace855 Jun 15, 2024
c03cb5d
Исправил ссылки
GuidingPlace855 Jun 15, 2024
eaec357
Высушил код
GuidingPlace855 Jun 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,6 @@ dmypy.json
.pytype/

# Cython debug symbols
cython_debug/
cython_debug/

media
63 changes: 0 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,69 +27,6 @@
- `MEDIA_URL` — по умолчанию это `'/media/'`. [Что такое MEDIA_URL](https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-MEDIA_URL).
- `MEDIA_ROOT` — по умолчанию это `'media'`. [Что такое MEDIA_ROOT](https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-MEDIA_ROOT).


## Страницы сайта

### Главная

Страница называется `index` и находится по адресу [http://127.0.0.1:8000](http://127.0.0.1:8000).

Шаблон страницы получает 2 переменные: `most_popular_posts` и `fresh_posts`.
Обе переменные — это списки из **постов**. Каждый пост — это словарь такого вида:

```
{
'title': 'Are You Preparing Your Kids for the Real World?',
'text': 'We baby our kids like infants; we coddle them like delicate crystal; ...',
'author': 'Frank Sonnenberg',
'comments_amount': 138,
'image_url': 'image_are-you-preparing-your-kids-for-the-real-world.jpg',
'published_at': datetime.datetime(2017, 6, 4, 2, 9, tzinfo=<UTC>),
'slug': 'are-you-preparing-your-kids-for-the-real-world'
}
```

Словарь содержит следующие ключи:

* `title` — заголовок поста
* `text` — текст поста
* `author` — строка с именем автора поста
* `comments_amount` — число комментариев под постом
* `image_url` — ссылка на картинку поста
* `published_at` — когда пост опубликован, это объект datetime
* `slug` — [слаг](https://toster.ru/q/375615)



### Страница поста

Страница называется `post_detail` и требует передать `slug` поста. Пример страницы можно найти по адресу [http://127.0.0.1:8000/post/5-qualities-of-great-leaders](http://127.0.0.1:8000/post/5-qualities-of-great-leaders). Это страница поста со слагом `5-qualities-of-great-leaders`.

Шаблон страницы получает переменную: `post`.

`post` — это словарь, похожий на посты на главной, но с отличиями:

* `title` — заголовок поста
* `text` — текст поста
* `author` — строка с именем автора поста
* `comments` — **список комментариев** (о них ниже)
* `likes_amount` — число лайков под постом
* `image_url` — ссылка на картинку поста
* `published_at` — когда пост опубликован, это объект datetime
* `slug` — [слаг](https://toster.ru/q/375615)

Каждый **комментарий** — это словарь вида:

* `text` — текст комментария
* `published_at` — когда пост опубликован, это объект datetime
* `author` — строка с именем автора поста

### Контакты

Страница называется `contact`.

Её можно найти по адресу [127.0.0.1:8000/contacts](127.0.0.1:8000/contacts). К шаблонизации в неё отдаётся только переменная `html_map`. Это строка, в которой лежит HTML-код с картой.

## Цели проекта

Код написан в учебных целях — это урок в курсе по Python и веб-разработке на сайте [Devman](https://dvmn.org).
Empty file removed static/.gitkeep
Empty file.
Binary file added static/fonts/Linearicons-Free.eot
Binary file not shown.
199 changes: 199 additions & 0 deletions static/fonts/Linearicons-Free.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/fonts/Linearicons-Free.ttf
Binary file not shown.
Binary file added static/fonts/Linearicons-Free.woff
Binary file not shown.
Binary file added static/fonts/Linearicons-Free.woff2
Binary file not shown.
Binary file added static/fonts/fa-brands-400.eot
Binary file not shown.
Binary file added static/fonts/fa-brands-400.ttf
Binary file not shown.
Binary file added static/fonts/fa-brands-400.woff
Binary file not shown.
Binary file added static/fonts/fa-brands-400.woff2
Binary file not shown.
Binary file added static/fonts/fa-regular-400.eot
Binary file not shown.
Binary file added static/fonts/fa-regular-400.ttf
Binary file not shown.
Binary file added static/fonts/fa-regular-400.woff
Binary file not shown.
Binary file added static/fonts/fa-regular-400.woff2
Binary file not shown.
Binary file added static/fonts/fa-solid-900.eot
Binary file not shown.
Binary file added static/fonts/fa-solid-900.ttf
Binary file not shown.
Binary file added static/fonts/fa-solid-900.woff
Binary file not shown.
Binary file added static/fonts/fa-solid-900.woff2
Binary file not shown.
Binary file added static/fonts/themify.eot
Binary file not shown.
362 changes: 362 additions & 0 deletions static/fonts/themify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/fonts/themify.ttf
Binary file not shown.
Binary file added static/fonts/themify.woff
Binary file not shown.
Binary file added static/hero-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/banner/blog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/banner/hero-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog-slider/blog-slide1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog-slider/blog-slide2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog-slider/blog-slide3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/blog/blog4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions static/scripts.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions static/styles.min.css

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions templates/blog-base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{% block title %}{% endblock %}
<link rel="icon" href="{% static 'img/favicon.png' %}" type="image/png">

<link rel="stylesheet" href="{% static 'styles.min.css' %}">
</head>
<body>
<!--================Header Menu Area =================-->
<header class="header_area">
<div class="main_menu">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container box_1620">
<!-- Brand and toggle get grouped for better mobile display -->
<a class="navbar-brand logo_h" href="{% url 'index' %}"><img src="{% static 'img/logo.png' %}" alt="Img logo"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse offset" id="navbarSupportedContent">
<ul class="nav navbar-nav menu_nav justify-content-center">
<li class="nav-item active"><a class="nav-link" href="{% url 'index' %}" style="color:#3a414e">Home</a></li>
<li class="nav-item"><a class="nav-link" href="{% url 'contact' %}" style="color:#3a414e">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right navbar-social">
<li><a href="#"><i class="ti-facebook"></i></a></li>
<li><a href="#"><i class="ti-twitter-alt"></i></a></li>
<li><a href="#"><i class="ti-instagram"></i></a></li>
<li><a href="#"><i class="ti-skype"></i></a></li>
</ul>
</div>
</div>
</nav>
</div>
</header>
<!--================Header Menu Area =================-->

<main class="site-main">
{% block content %}
{% endblock %}
</main>

<!--================ Start Footer Area =================-->
<footer class="footer-area section-padding">
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">
<div class="single-footer-widget">
<h6>About Us</h6>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore dolore
magna aliqua.
</p>
</div>
</div>
<div class="col-lg-4 col-md-6 col-sm-6">
<div class="single-footer-widget">
<h6>Newsletter</h6>
<p>Stay update with our latest</p>
<div class="" id="mc_embed_signup">

<form target="_blank" novalidate action="https://spondonit.us12.list-manage.com/subscribe/post?u=1462626880ade1ac87bd9c93a&amp;id=92a4423d01"
method="get" class="form-inline">

<div class="d-flex flex-row">

<input class="form-control" name="EMAIL" placeholder="Enter Email" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter Email '"
required="" type="email">


<button class="click-btn btn btn-default"><span class="lnr lnr-arrow-right"></span></button>
<div style="position: absolute; left: -5000px;">
<input name="b_36c4fd991d266f23781ded980_aefe40901a" tabindex="-1" value="" type="text">
</div>

</div>
<div class="info"></div>
</form>
</div>
</div>
</div>
<div class="col-lg-3 col-md-6 col-sm-6">
</div>
<div class="col-lg-2 col-md-6 col-sm-6">
<div class="single-footer-widget">
<h6>Follow Us</h6>
<p>Let us be social</p>
<div class="footer-social d-flex align-items-center">
<a href="#">
<i class="fab fa-facebook-f"></i>
</a>
<a href="#">
<i class="fab fa-twitter"></i>
</a>
<a href="#">
<i class="fab fa-dribbble"></i>
</a>
<a href="#">
<i class="fab fa-behance"></i>
</a>
</div>
</div>
</div>
</div>
<div class="footer-bottom d-flex justify-content-center align-items-center flex-wrap">
<p class="footer-text m-0">
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
</p>
</div>
</div>
</footer>
<!--================ End Footer Area =================-->

<script src="{% static 'scripts.js' %}"></script>
</body>
</html>
116 changes: 109 additions & 7 deletions templates/blog-details.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,109 @@
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>Страница поста</h1>
</body>
</html>
{% extends 'blog-base.html' %}
{% load static %}
{% block title %}
<title>{{post.title}} - Blog Details</title>
{% endblock %}
{% block content %}
<!--================ Hero sm Banner start =================-->
<section class="mb-30px">
<div class="container">
<div class="hero-banner hero-banner--sm">
<div class="hero-banner__content">
<h1>Blog details</h1>
<nav aria-label="breadcrumb" class="banner-breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'index' %}">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Blog Details</li>
</ol>
</nav>
</div>
</div>
</div>
</section>
<!--================ Hero sm Banner end =================-->


<!--================ Start Blog Post Area =================-->
<section class="blog-post-area section-margin">
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="main_blog_details">
{% if fresh_post.image_url %}
img class="img-fluid" src="{{post.image_url}}" alt="Картинка поста">
{% else %}
<img class="img-fluid" src="{% static 'img/banner/blog.png' %}" alt="Картина поста">
{% endif %}
<h4>{{post.title}}</h4>
<div class="user_details">
<div class="mt-sm-0 mt-3">
<div class="media">
<div class="media-body">
<h5>{{post.author}}</h5>
<p>{{post.published_at}}</p>
</div>
</div>
</div>
</div>
<p>{{post.text}}</p>
<div class="news_d_footer flex-column flex-sm-row">
<a href="#"><span class="align-middle mr-2"><i class="ti-heart" style="color: red;"></i></span>{{post.likes_amount}} people like this</a>
<a class="justify-content-sm-center ml-sm-auto mt-sm-0 mt-2" href="#"><span class="align-middle mr-2"><i class="ti-themify-favicon"></i></span>{{post.comments|length}} comments</a>
<div class="news_socail ml-sm-auto mt-sm-0 mt-2">
<a href="#"><i class="fab fa-facebook-f"></i></a>
<a href="#"><i class="fab fa-twitter"></i></a>
<a href="#"><i class="fab fa-dribbble"></i></a>
<a href="#"><i class="fab fa-behance"></i></a>
</div>
</div>
</div>


<div class="comments-area">
<h4>{{post.comments|length}} Comments</h4>
{% for comment in post.comments %}
<div class="comment-list">
<div class="single-comment justify-content-between d-flex">
<div class="user justify-content-between d-flex">
<div class="desc">
<h5><a href="#">{{comment.author}}</a></h5>
<p class="date">{{comment.published_at}}</p>
<p class="comment">{{comment.text}}</p>
</div>
</div>
<div class="reply-btn">
<a href="" class="btn-reply text-uppercase">reply</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>


<!-- Start Blog Post Siddebar -->
<div class="col-lg-4 sidebar-widgets">
<div class="widget-wrap">
<div class="single-sidebar-widget newsletter-widget">
<h4 class="single-sidebar-widget__title">Newsletter</h4>
<div class="form-group mt-30">
<div class="col-autos">
<input type="text" class="form-control" id="inlineFormInputGroup" placeholder="Enter email" onfocus="this.placeholder = ''"
onblur="this.placeholder = 'Enter email'">
</div>
</div>
<button class="bbtns d-block mt-20 w-100">Subcribe</button>
</div>


<div class="single-sidebar-widget post-category-widget">
<h4 class="single-sidebar-widget" style="height:200px;">Здесь будет реклама</h4>
</div>
</div>
</div>
<!-- End Blog Post Siddebar -->
</div>
</div>
</section>
<!--================ End Blog Post Area =================-->
{% endblock %}
Loading