improved layout

master
Laurent 6 years ago
parent 759b23e6b1
commit 2454fa1303
  1. BIN
      db.sqlite3
  2. BIN
      news/__pycache__/models.cpython-37.pyc
  3. BIN
      news/__pycache__/views.cpython-37.pyc
  4. 0
      news/static/media/74d7e72e-e415-462e-8978-5ef942ff96a4 copie
  5. BIN
      news/static/media/74d7e72e-e415-462e-8978-5ef942ff96a4.png
  6. BIN
      news/static/media/a1f5bf0d-2dbb-4cd7-8cc0-dc39b93935d4 copie.png
  7. BIN
      news/static/media/a1f5bf0d-2dbb-4cd7-8cc0-dc39b93935d4.png
  8. BIN
      news/static/news/LibreBaskerville-Bold.otf
  9. 100
      news/static/news/css/app.css
  10. 20
      news/templates/base.html
  11. 88
      news/templates/news/index.html
  12. 23
      news/templates/news/post.html
  13. 16
      news/views.py

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

@ -1,6 +1,10 @@
@font-face { @font-face {
font-family: LibreBaskerville; font-family: LibreBaskerville;
src: url("LibreBaskerville-Regular.otf") format("opentype"); src: url("../LibreBaskerville-Regular.otf") format("opentype");
}
@font-face {
font-family: LibreBaskervilleBold;
src: url("../LibreBaskerville-Bold.otf") format("opentype");
} }
body { body {
@ -10,32 +14,108 @@ body {
padding: 0px; padding: 0px;
} }
.postcontainer {
}
.even {
background-color: #fff;
padding: 20px 0px;
}
.odd {
background-color: #eee;
padding: 20px 0px;
}
.header {
text-align: center;
/* background-color: #aaa; */
}
.imgcontainer {
position: relative;
/* text-align: center; */
color: white;
}
/* Bottom left text */
.bottom-left {
width: 800px;
position: absolute;
bottom: 8px;
left: 16px;
}
.crop {
width: 1000px;
/* width: 1000px; */
height: 200px;
overflow: hidden;
border-radius: 20px;/*0px 20px 20px 0px;*/
}
.crop img {
width: 1000px;
height: 200px;
margin: -100px 0 0 -200px;
}
.header h1 {
font-size: 36px;
line-height: 90%;
margin-top: 20px;
}
.content { .content {
/* background-color: #eee; */
padding: 16px; padding: 16px;
} }
.content h1 { .content h1 {
font-family: 'LibreBaskerville'; font-family: 'LibreBaskervilleBold';
font-size: 28px; font-size: 28px;
margin: 0px; margin: 10px 0px 0px 0px;
padding: 0px; padding: 0px;
} }
.imgcontainer a {
color: #fff;
}
.imgcontainer a:hover {
color: #aaa;
}
.contentbody {
font-family: 'LibreBaskerville';
padding: 12px 12px 0px 12px;
}
.post { .post {
margin-bottom: 20px; padding: 10px 0px;
margin-bottom: 10px;
}
.padded {
padding: 8px;
} }
.comments { .comments {
font-size: 14px;
color: #666; color: #666;
padding: 0px 10px; /* padding: 0px 10px; */
background-color: #efe; /* background-color: #efe; */
border-radius: 16px; /* border-radius: 16px; */
} }
.info { .info {
text-align: right; font-size: 14px;
padding: 0px 20px; border-bottom: 1px solid #ccc;
margin-top: 10px; /* margin-bottom: 6px; */
}
.current {
font-size: 14px; font-size: 14px;
} }

@ -12,23 +12,31 @@
<body> <body>
<!-- Header --> <!-- Header -->
<header> <!-- <header>
<h1><a href="{% url 'news:index' %}">Poker CC</a></h1>
</header> -->
<div class="grid-x">
<!-- Header -->
<div class="cell large-2 header">
<h1><a href="{% url 'news:index' %}">poker<br/>downtown</a></h1>
<span>hardcore newsing</span>
<p> <p>
<br/>
{% if user.is_authenticated %} {% if user.is_authenticated %}
<a href="{% url 'news:submission' %}">Submit</a> <a href="{% url 'news:submission' %}">Submit</a>
{% else %} {% else %}
<a href="{% url 'news:createaccount' %}">Create account</a> <a href="{% url 'news:createaccount' %}">Create account</a>
{% endif %} {% endif %}
</p> </p>
</div>
</header>
<!-- Body --> <!-- Body -->
<div class="content"> <div class="cell large-8 content">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
</div>
<!-- Footer --> <!-- Footer -->
<footer> <footer>

@ -9,10 +9,36 @@
{% for post in latest_post_list %} {% for post in latest_post_list %}
<!-- <div class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}"> -->
<!-- A post --> <!-- A post -->
{% if post.style == 0 %} {% if post.style == 0 %}
<div class="grid-x post"> <div class="post">
<div class="imgcontainer">
<a href="{{ post.url }}">
<img class="crop" src="{% static 'media/' %}{{ post.image_url }}"/>
<div class="bottom-left">
<h1>{{ post.title }}</h1>
</div>
</a>
</div>
<p class="contentbody">
{{ post.body }}
</p>
<div class="info">
{{ post.date }} - {{ post.author.username }} - <a href="{% url 'news:post' post.id %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comments{% else %}write comment{% endif %}</a>
</div>
<!-- Some comments -->
<div class="comments">
{% for comment in post.top_comments %}
<span>{{ comment.body }} - {{ comment.author.username }}</span><br/>
{% endfor %}
</div>
</div>
<!-- <div class="grid-x post">
<div class="cell large-2 large-offset-2 info"> <div class="cell large-2 large-offset-2 info">
<br/> <br/>
{{ post.date }} {{ post.date }}
@ -29,7 +55,6 @@
{{ post.body }} {{ post.body }}
</div> </div>
<div class="cell large-4 comments"> <div class="cell large-4 comments">
<!-- Some comments -->
{% for comment in post.top_comments %} {% for comment in post.top_comments %}
<div class="grid-x"> <div class="grid-x">
<div class="cell small-2 large-2">{{ comment.body }}</div> <div class="cell small-2 large-2">{{ comment.body }}</div>
@ -39,43 +64,60 @@
</div> </div>
</div> </div>
</div> </div> -->
{% else %} {% else %}
<div class="grid-x post"> <div class="post">
<div class="cell large-2 large-offset-2 info"> <div class="grid-x">
<img src="{% static 'media/' %}{{ post.image_url }}" width="100" height="100"/> <div class="cell large-2">
<br/> <img src="{% static 'media/' %}{{ post.image_url }}" width="150" height="150"/>
{{ post.date }}
<br/>
{{ post.author.username }}
<br/>
<a href="{% url 'news:post' post.id %}">comments</a>
</div> </div>
<div class="cell large-4"> <div class="cell large-8">
<div class="grid-y">
<div class="cell large-4">
<h1><a href="{{ post.url }}">{{ post.title }}</a></h1> <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
{{ post.body }} <p class="contentbody">{{ post.body }}</p>
</div>
</div>
<div class="info">
{{ post.date }} - {{ post.author.username }} - <a href="{% url 'news:post' post.id %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comments{% else %}write comment{% endif %}</a>
</div> </div>
<div class="cell large-4 comments">
<!-- Some comments --> <!-- Some comments -->
<div class="comments">
{% for comment in post.top_comments %} {% for comment in post.top_comments %}
<div class="grid-x"> <span>{{ comment.body }} - {{ comment.author.username }}</span><br/>
<div class="cell small-2 large-2">{{ comment.body }}</div>
</div>
{% endfor %} {% endfor %}
</div> </div>
</div>
</div> </div>
</div>
{% endif %} {% endif %}
<!-- </div> -->
{% endfor %} {% endfor %}
<!-- Pagination -->
<div class="pagination">
<span class="step-links">
{% if latest_post_list.has_previous %}
<a href="?page=1">&laquo; first</a>
<a href="?page={{ latest_post_list.previous_page_number }}">previous</a>
{% endif %}
<span class="current">
Page {{ latest_post_list.number }} of {{ latest_post_list.paginator.num_pages }}
</span>
{% if latest_post_list.has_next %}
<a href="?page={{ latest_post_list.next_page_number }}">next</a>
<a href="?page={{ latest_post_list.paginator.num_pages }}">last &raquo;</a>
{% endif %}
</span>
</div>
{% else %} {% else %}
<p>No posts are available.</p> <p>No posts are available.</p>
{% endif %} {% endif %}

@ -8,11 +8,14 @@
<img src="{% static 'media/' %}{{ post.image_url }}"/> <img src="{% static 'media/' %}{{ post.image_url }}"/>
<a href="{{ post.url }}"><h1>{{ post.title }}</h1></a> <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
<p>submitted by {{ post.author.username }}</p> <p class="contentbody">
<p>----Body----</p> {{ post.body }}
<p>{{ post.content }}</p> </p>
<p>----Comments----</p> <div class="info">
{{ post.date }} - {{ post.author.username }}
</div>
<br/>
<form action="{% url 'news:comment' post.id %}" method="post"> <form action="{% url 'news:comment' post.id %}" method="post">
{% csrf_token %} {% csrf_token %}
@ -25,10 +28,14 @@
<input type="submit" value="Submit"> <input type="submit" value="Submit">
</form> </form>
<ul> <br/>
<p>----Comments----</p>
{% for comment in post.comment_set.all %} {% for comment in post.comment_set.all %}
<li>{{ comment.body }}</li> <p>
<span class="info">{{ comment.author.username }} - {{ comment.date }}</span>
<br/>
{{ comment.body }}
</p>
{% endfor %} {% endfor %}
</ul>
{% endblock content %} {% endblock content %}

@ -2,26 +2,28 @@ from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse, Http404, HttpResponseRedirect from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.template import loader from django.template import loader
from django.urls import reverse from django.urls import reverse
from django.core.paginator import Paginator
from django.conf import settings
from .models import Post, Comment from .models import Post, Comment
from .forms import PostForm from .forms import PostForm
from datetime import datetime from datetime import datetime
import logging import logging
from django.conf import settings
import uuid import uuid
# Create your views here.
def index(request): def index(request):
latest_post_list = Post.objects.filter(state=1).order_by('-date')[:25] latest_post_list = Post.objects.filter(state=1).order_by('-date')
context = { 'latest_post_list' : latest_post_list } paginator = Paginator(latest_post_list, 25)
page = request.GET.get('page')
posts = paginator.get_page(page)
context = { 'latest_post_list' : posts }
return render(request, 'news/index.html', context) return render(request, 'news/index.html', context)
def post(request, post_id): def post(request, post_id):
post = get_object_or_404(Post, pk=post_id) post = get_object_or_404(Post, pk=post_id)
return render(request, 'news/post.html', {'post': post}) return render(request, 'news/post.html', {'post': post})
# def submission(request):
# return render(request, 'news/submission.html', {})
def createaccount(request): def createaccount(request):
return render(request, 'news/createaccount.html', {}) return render(request, 'news/createaccount.html', {})

Loading…
Cancel
Save