You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.2 KiB
119 lines
3.2 KiB
{% extends "base.html" %}
|
|
|
|
{% load static %}
|
|
|
|
{% block title %}{{ post.html_title }}{% endblock %}
|
|
|
|
{% block content %}
|
|
|
|
<div class="post_padding">
|
|
|
|
{% if post.style == 1 %}
|
|
<div class="quote">
|
|
{% endif %}
|
|
{% if post.style != 2 %}
|
|
<h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
|
|
{% endif %}
|
|
{% if post.style == 1 %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="details">
|
|
{{ post.date }} - {{ post.author.username }}
|
|
</div>
|
|
</div>
|
|
|
|
{% if post.style == 3 %}
|
|
<iframe class="youtube" src="https://www.youtube.com/embed/{{ post.url }}"></iframe>
|
|
{% elif post.style != 1 %}
|
|
<img src="{% static 'media/' %}{{ post.image_url }}"/>
|
|
{% endif %}
|
|
|
|
<div class="post_padding">
|
|
|
|
{% if post.style == 0 %}
|
|
<p class="contentbody">
|
|
{{ post.body }}
|
|
</p>
|
|
{% endif %}
|
|
<br/>
|
|
|
|
{% if user.is_authenticated %}
|
|
<form action="{% url 'news:comment' post.id %}" method="post">
|
|
{% csrf_token %}
|
|
<p>Add comment</p>
|
|
<p>
|
|
<textarea name="body" rows="3" cols="50"></textarea>
|
|
</p>
|
|
<button class="primary_button" type="submit">Submit</button>
|
|
</form>
|
|
{% else %}
|
|
<p>
|
|
Please <a href="{% url 'news:signin' %}">login</a> to comment the post
|
|
</p>
|
|
{% endif %}
|
|
|
|
<script type="text/javascript">
|
|
function myFunction(divID) {
|
|
var x = document.getElementById("div_" + divID);
|
|
if (x.style.display === "none") {
|
|
x.style.display = "block";
|
|
window.location.hash = "sub_" + divID;
|
|
document.getElementById("text_" + divID).focus();
|
|
} else {
|
|
x.style.display = "none";
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<br/>
|
|
|
|
<!-- Comments -->
|
|
{% for comment in comments %}
|
|
{% for n in comment.level %}<ul>{% endfor %}
|
|
|
|
<span class="details info">{{ comment.author.username }} - {{ comment.date }} - score: {{ comment.score }}</span>
|
|
<br/>
|
|
{{ comment.body }}
|
|
|
|
<div>
|
|
{% if comment.upvoted == False and user.is_authenticated %}
|
|
<form action="{% url 'news:upvote' comment.id %}" method="post" class="inline">
|
|
{% csrf_token %}
|
|
<button class="primary_button" type="submit">+1</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
{% if comment.is_deletable %}
|
|
<form action="{% url 'news:delete_comment' comment.id %}" method="post" class="inline">
|
|
{% csrf_token %}
|
|
<button class="secondary_button" type="submit">delete</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
<button class="secondary_button inline" onclick="myFunction('{{ comment.id }}')">reply</button>
|
|
|
|
<div id="div_{{ comment.id }}" class="inline reply_form" style="display:none">
|
|
{% if user.is_authenticated %}
|
|
<form action="{% url 'news:comment_with_parent' post.id comment.id %}" method="post">
|
|
{% csrf_token %}
|
|
<textarea id="text_{{ comment.id}}" name="body" rows="3" cols="50"></textarea>
|
|
<button id="sub_{{ comment.id}}" class="primary_button" type="submit">Submit</button>
|
|
</form>
|
|
{% else %}
|
|
<p>
|
|
Please <a href="{% url 'news:signin' %}">login</a> to reply
|
|
</p>
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% for n in comment.level %}</ul>{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% endblock content %}
|
|
|