added quest homepage
This commit is contained in:
parent
edf5ef62b7
commit
7a2f74c86e
89
quest/jinja2/quest/quest_homepage.html
Normal file
89
quest/jinja2/quest/quest_homepage.html
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}{{ quest.title }}: Home{% endblock %}
|
||||||
|
{% block head %}
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ static('quest.css') }}">
|
||||||
|
{% endblock %}
|
||||||
|
{% block header %}
|
||||||
|
{% if request.user == quest.owner %}
|
||||||
|
<span><a href="{{ url('quest:edit_quest', args=[quest_id, page_num]) }}">Edit Quest</a></span>
|
||||||
|
<script>
|
||||||
|
const quest_id = {{ quest.id }};
|
||||||
|
const page_num = '{{ page_num }}';
|
||||||
|
const SCRIPT_NAME = '{{ request.META["SCRIPT_NAME"] }}';
|
||||||
|
const anon_name = '{{ quest.anon_name }}';
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="{{ static('quest.js') }}"></script>
|
||||||
|
<script>window.onload = load;</script>
|
||||||
|
{% endif %}
|
||||||
|
<span>
|
||||||
|
<select onChange="window.location.href=this.value">
|
||||||
|
<optgroup label="Pages">
|
||||||
|
{% for page in pages %}
|
||||||
|
<option value="{{ url('quest:quest', args=[quest_id, page.page_num]) }}"{% if page.page_num == page_num %} selected="yes" {% if vars.update({'next_page': loop.nextitem}) %}{% endif %}{% endif %}>{{ page.title }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</optgroup>
|
||||||
|
{% if appendices %}
|
||||||
|
<optgroup label="Appendices">
|
||||||
|
{% for appendix in appendices %}
|
||||||
|
<option value="{{ url('quest:quest', args=[quest_id, appendix.page_num]) }}"{% if appendix.page_num == page_num %} selected="yes"{% endif %}>{{ appendix.title }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</optgroup>
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
{% if quest.live %}
|
||||||
|
<span id="live">
|
||||||
|
LIVE
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
{% if quest.live_time %}
|
||||||
|
<span id="liveIn">
|
||||||
|
Live in: <span id="liveCountdown"></span> (<span id="liveTime">{{ localtime(quest.live_time).strftime('%Y-%m-%d %H:%M') }}</span>)
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<span id="toggleChat"><a onclick="toggle_chat()" href="javascript:void(0);">{% if request.session.get("hide_chat") == True %}←{% else %}→{% endif %}</a></span>
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div id="questPane" style="width:{% if request.session.get("hide_chat") == True %}100%{% else %}70%{% endif %};">
|
||||||
|
<h3>Pages</h3>
|
||||||
|
<ul>
|
||||||
|
{% for page in pages %}
|
||||||
|
<li><a href="{{ url('quest:quest', args=[quest_id, page.page_num]) }}">{{ page.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% if appendices %}
|
||||||
|
<h3>Appendices</h3>
|
||||||
|
<ul>
|
||||||
|
{% for appendix in appendices %}
|
||||||
|
<li><a href="{{ url('quest:quest', args=[quest_id, appendix.page_num]) }}">{{ appendix.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% if vars['next_page'] %}
|
||||||
|
<div id="nextPageContainer">
|
||||||
|
<input type="button" id="nextPage" value="Next Page: {{ vars['next_page'].title }}" onclick="window.location.href='{{ url('quest:quest', args=[quest_id, vars['next_page'].page_num]) }}'">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div id="chatPane" style="display:{% if request.session.get("hide_chat") == True %}none{% else %}flex{% endif %};">
|
||||||
|
<h1>Chat</h1>
|
||||||
|
<div id="chatWindow">
|
||||||
|
{% autoescape false %}
|
||||||
|
{% for message in chat_messages %}
|
||||||
|
<div id="msg-{{ message.id }}" class="message">
|
||||||
|
<div class="messageHeader">
|
||||||
|
<span class="messageName">{{ message.user.username or quest.anon_name }}</span>
|
||||||
|
<span class="messageDate">{{ localtime(message.timestamp).strftime('%Y-%m-%d %H:%M:%S') }}</span>
|
||||||
|
<span class="messageID">No.<a href="javascript:quote('{{ message.id }}')">{{ message.id }}</a></span>
|
||||||
|
</div>
|
||||||
|
<div class="messageContent">{{ message.message }}</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endautoescape %}
|
||||||
|
</div>
|
||||||
|
<div id="messageTextDiv"><textarea id="messageTextArea" maxlength="512"></textarea></div>
|
||||||
|
</div>
|
||||||
|
<div id="preview" style="display:none;"></div>
|
||||||
|
{% endblock %}
|
|
@ -33,7 +33,7 @@ def quest(request, quest_id, page_num='1'):
|
||||||
page = Page.objects.get(quest=quest, page_num=page_num)
|
page = Page.objects.get(quest=quest, page_num=page_num)
|
||||||
except Page.DoesNotExist:
|
except Page.DoesNotExist:
|
||||||
messages.error(request, "Page not found, redirecting you.")
|
messages.error(request, "Page not found, redirecting you.")
|
||||||
return redirect('quest:quest', quest_id=quest.id, page_num='1')
|
return redirect('quest:quest', quest_id=quest.id, page_num='0')
|
||||||
posts = quest.post_set.filter(page=page)
|
posts = quest.post_set.filter(page=page)
|
||||||
# TODO: filter by page_num as well
|
# TODO: filter by page_num as well
|
||||||
dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest)
|
dice_rolls = DiceRoll.objects.filter(dicecall__post__quest=quest)
|
||||||
|
@ -41,7 +41,10 @@ def quest(request, quest_id, page_num='1'):
|
||||||
poll_votes = PollVote.objects.filter(option__poll__post__quest=quest)
|
poll_votes = PollVote.objects.filter(option__poll__post__quest=quest)
|
||||||
ip_address = request.META['REMOTE_ADDR']
|
ip_address = request.META['REMOTE_ADDR']
|
||||||
context = locals()
|
context = locals()
|
||||||
return render(request, 'quest/quest.html', context)
|
if page_num == '0':
|
||||||
|
return render(request, 'quest/quest_homepage.html', context)
|
||||||
|
else:
|
||||||
|
return render(request, 'quest/quest.html', context)
|
||||||
|
|
||||||
|
|
||||||
def edit_quest(request, quest_id, page_num=1):
|
def edit_quest(request, quest_id, page_num=1):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user