Skip to content

Commit

Permalink
Feed ready
Browse files Browse the repository at this point in the history
  • Loading branch information
mariklolik committed Apr 25, 2020
1 parent dc0b06b commit fb12cc1
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 71 deletions.
24 changes: 24 additions & 0 deletions 1111.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from colour import Color
from PIL import ImageDraw, ImageFont, Image


def generate_cover(sid, aid, grad):
img = Image.new("RGBA", (1920, 1080))
im = img.load()
x, y = img.size
if grad == 0:
col = Color('#9D00B9')
colors = list(map(lambda x: x.rgb, col.range_to(Color("blue"), 1920)))
elif grad == 1:
col = Color('#9D00B9')
colors = list(map(lambda x: x.rgb, col.range_to(Color("white"), 1920)))
elif grad == 2:
col = Color('#9D00B9')
colors = list(map(lambda x: x.rgb, col.range_to(Color((74, 186, 87)), 1920)))
for i in range(x):
for j in range(y):
im[i, j] = (int(colors[i][0]), int(colors[i][1]), int(colors[i][2]))

img.save(f"data/{aid}/{sid}_cover.png")

generate_cover(1, 1, 0)
Binary file modified __pycache__/stories_api.cpython-37.pyc
Binary file not shown.
Binary file added data/1/1_cover.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 modified db/data.sqlite
Binary file not shown.
24 changes: 21 additions & 3 deletions static/css/main2.css
Original file line number Diff line number Diff line change
Expand Up @@ -472,23 +472,36 @@ form input {
}
}

#carousel-example-1z{
margin:10%;
}
#but{
display: block;
margin: 25% 0 5% 0;
}

.carousel-caption h2{
margin-bottom: 30%;
}
/* Smartphones (вертикальная и горизонтальная ориентация) ----------- */
@media only screen and (min-width : 320px) and (max-width : 480px) {
#carousel-example-1z {
margin: 0;
height: 150%;
}

#but {
display: block;
margin: 25% 0 5% 0;
}
}

.carousel-caption h2{
color:red;
margin-bottom: 5%;
}
}

/* Smartphones (вертикальная) ----------- */
@media only screen and (max-width: 320px) {
@media only screen and (max-width: 370px) {
#carousel-example-1z {
margin: 0;
}
Expand All @@ -497,4 +510,9 @@ form input {
display: block;
margin: 25% 0 5% 0;
}

.carousel-caption h2{
color:red;
margin-bottom: 5%;
}
}
Binary file added static/img/green.jpg
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/red.jpg
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/white.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions static/js/main2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ $(document).ready(function () {
$(this).text('Your link is waiting for you at ЭЛЕКТРОМЫЛО');
});



$('#summernote').summernote({
height: 300, // set editor height
minHeight: null, // set minimum height of editor
Expand Down
1 change: 1 addition & 0 deletions static/js/slick.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions stories_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ def feed():
stories_for_watching = []
session = create_session()
user = session.query(User).filter(User.id == current_user.id)
for i in user.followed:
stories_for_watching += i
return flask.render_template("feed.html",
stories=stories_for_watching)
print(current_user.id)
print(type(user))
return flask.render_template("feed.html")


@blueprint.route("/story/<int:sid>")
Expand Down Expand Up @@ -66,6 +65,7 @@ def story(sid):
session.commit()
content = story.content
comments = story.commented

return flask.render_template("story.html", content=content, comments=comments)


Expand Down Expand Up @@ -100,13 +100,13 @@ def post():
checkbox2 = flask.request.form.get('radio2')
checkbox3 = flask.request.form.get('radio3')
if checkbox1:
color = 'linear-gradient(45deg, #EECFBA, #C5DDE8)'
color = "/static/img/white.jpg"
elif checkbox2:
color = 'radial-gradient(circle, rgba(63,94,251,1) 0%, rgba(252,70,107,1) 100%)'
color = "/static/img/green.jpg"
elif checkbox3:
color = 'radial-gradient(circle, rgba(63,94,251,1) 0%, rgba(26,246,73,1) 100%)'
else:
color = 'linear-gradient(45deg, #EECFBA, #C5DDE8)'
color = "/static/img/red.jpg"
print(text)
print(post_name)
print(checkbox1)
Expand Down
19 changes: 10 additions & 9 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<!-- <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript> -->




</head>

<body class="homepage is-preload">
Expand All @@ -29,7 +27,7 @@
<div style="display: flex;justify-content: space-between;margin-top:2%;justify-content: center;align-items: center;background-color:azure;">
<div class="col-xs-3 col-sm-5 col-lg-4"><a href="/logout" class="btn btn-block btn-primary" style="float:left;">Logout</a></div>
<div class='col'>
{% if not current_user.utype %}
{% if not current_user.utype %}
<h3 class="post-category" style='float:right; margin-right: 5%;'>Hello <a class='username' href='/dashboard'>{{ current_user.nickname }}!</a></h3>

{% else %}
Expand Down Expand Up @@ -75,16 +73,19 @@ <h3 class="post-category" style='float:right; margin-right: 5%;'>Hello <a class=

<!-- Scripts -->
<script src="{{ url_for('static', filename='/js/jquery.min.js') }}"></script>

<script src="{{ url_for('static', filename='/js/main2.js') }}"></script>

<!-- include libraries(jQuery, bootstrap) -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script c="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script c="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<!-- include summernote css/js -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.min.js"></script>


<!-- include summernote css/js -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.min.js"></script>


</body>
Expand Down
110 changes: 58 additions & 52 deletions templates/feed.html
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
<!DOCTYPE HTML>
<html>

<head>
<title>stories.ua.kz.ru</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="static/css/main2.css" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/f755b64f54.js" crossorigin="anonymous"></script>
<!-- <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript> -->
</head>

<body class="homepage is-preload">
<!-- NAVBAR -->
<nav class="navbar navbar-light" id='navbar-nav'>
<div class="navbar-in" id='navbar-in'>STO <a href="/"><img src="https://img.icons8.com/nolan/64/r.png"></a>IES.RU</div>
</nav>
{% block content %}{% endblock %}

<div class="row">
<div class="col"></div>
</div>





<!-- FOOTER -->
<footer>
<div class="container">
<div class="d-flex justify-content-around">
<div class="footer-left">
<a href="https://vk.com/m.kashirsky"><i class="fab fa-vk fa-5x"></i></a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id enim voluptatibus culpa facere, eveniet qui libero atque, aliquam dignissimos velit, provident modi laudantium quae ipsa. Neque, inventore nobis explicabo optio.</p>
</div>

<div class="footer-center">
<i class="fab fa-discord fa-5x"></i>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id enim voluptatibus culpa facere, eveniet qui libero atque, aliquam dignissimos velit, provident modi laudantium quae ipsa. Neque, inventore nobis explicabo optio.</p>
</div>

<div class="footer-right">
<a href="https://vk.com/kiryabikeev"><i class="fab fa-vk fa-5x"></i></a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id enim voluptatibus culpa facere, eveniet qui libero atque, aliquam dignissimos velit, provident modi laudantium quae ipsa. Neque, inventore nobis explicabo optio.</p>
</div>
{% extends "base.html" %}

{% block content %}

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

<!--Carousel Wrapper-->
<div id="carousel-example-1z" class="carousel slide carousel-fade" data-ride="carousel">
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#carousel-example-1z" data-slide-to="0" class="active"></li>
{% for ind in range(1, len(stories) + 1) %}
<li data-target="#carousel-example-1z" data-slide-to="{{ str(ind) }}"></li>
{% endfor %}
</ol>
<!--/.Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listbox">
<!--First slide-->
<div class="carousel-item active">
<img class="d-block w-100" src="/static/img/white.jpg" alt="First slide">
<div class="carousel-caption d-md-block">
<h2>Hello! Let's have a look!</h2>
<a href="#" class='btn btn-block btn-primary'>Let's go!</a>
</div>
</div>
<!--/First slide-->

{% for story in stories %}
<div class="carousel-item">
<img class="d-block w-100" src="{{ story.color }}" alt="Second slide">
<div class="carousel-caption d-md-block">
<h2>{{ story.head }}</h2>
<a href="/story/{ stoty.id }" class='btn btn-block btn-primary'>Read more</a>
</div>
</div>
</footer>

<!-- Scripts -->
<script src="static/js/jquery.min.js"></script>
<script src="static/js/main2.js"></script>
</body>
{% endfor %}

</html>
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#carousel-example-1z" role="button" data-slide="prev" id="but">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-example-1z" role="button" data-slide="next" id="but">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
</div>



{% endblock %}

0 comments on commit fb12cc1

Please sign in to comment.