Web (Storycraft): format the story a bit by adding <p> tags, for readability
This commit is contained in:
parent
07b76f3e5e
commit
865a39204f
@ -137,11 +137,8 @@ body {
|
|||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gamestory p:first-letter {
|
.gamestory p {
|
||||||
font-size: 3.5em;
|
margin-bottom: 20px;
|
||||||
line-height: 0.8em;
|
|
||||||
float: left;
|
|
||||||
margin: 0 3px 3px 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#footer {
|
#footer {
|
||||||
|
@ -3,6 +3,8 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render_to_response, get_object_or_404
|
from django.shortcuts import render_to_response, get_object_or_404
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
from django.utils.html import escape
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from storycraft.models import StorycraftGame, StorycraftLine, StorycraftPlayer
|
from storycraft.models import StorycraftGame, StorycraftLine, StorycraftPlayer
|
||||||
|
|
||||||
@ -21,7 +23,26 @@ def game_index(request, game_id):
|
|||||||
game = get_object_or_404(StorycraftGame, pk=game_id)
|
game = get_object_or_404(StorycraftGame, pk=game_id)
|
||||||
players = StorycraftPlayer.objects.filter(game=game.id)
|
players = StorycraftPlayer.objects.filter(game=game.id)
|
||||||
lines = StorycraftLine.objects.filter(game=game.id)
|
lines = StorycraftLine.objects.filter(game=game.id)
|
||||||
|
pretty_story = []
|
||||||
|
|
||||||
return render_to_response('storycraft/game_index.html', {'game': game, 'players': players, 'lines': lines}, context_instance=RequestContext(request))
|
if game.is_completed():
|
||||||
|
# make a HTML-formatted string that is the entire story, in
|
||||||
|
# which we've added paragraphs and such.
|
||||||
|
period_count = 0
|
||||||
|
pretty_story.append('<p>')
|
||||||
|
for line in lines:
|
||||||
|
period_count = period_count + line.line.count('.')
|
||||||
|
if period_count > 6:
|
||||||
|
period_count = 0
|
||||||
|
split = line.line.rsplit('.', 1)
|
||||||
|
pretty_story.append('<span title="' + line.player.nick + ' @ ' + line.time + '">' + escape(split[0]) + '.</span></p>')
|
||||||
|
pretty_story.append('<p><span title="' + line.player.nick + ' @ ' + line.time + '">' + escape(split[1]) + '</span>')
|
||||||
|
else:
|
||||||
|
pretty_story.append('<span title="' + line.player.nick + ' @ ' + line.time + '">' + escape(line.line) + '</span>')
|
||||||
|
pretty_story.append('</p>')
|
||||||
|
pretty_story_text = ' '.join(pretty_story)
|
||||||
|
mark_safe(pretty_story_text)
|
||||||
|
|
||||||
|
return render_to_response('storycraft/game_index.html', {'game': game, 'players': players, 'lines': lines, 'prettystory': pretty_story_text}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
# vi:tabstop=4:expandtab:autoindent
|
# vi:tabstop=4:expandtab:autoindent
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
{% autoescape on %}
|
{% autoescape on %}
|
||||||
<div class="storyblock">
|
<div class="storyblock">
|
||||||
{% if game.is_completed %}
|
{% if game.is_completed %}
|
||||||
<div class="gamestory">
|
<div class="gamestory">{{ prettystory|safe }}</div>
|
||||||
<p>
|
|
||||||
{% for line in lines %}
|
|
||||||
<span title="{{ line.player.nick }} @ {{ line.time }}">{{ line }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="gamenostory">
|
<div class="gamenostory">
|
||||||
<p>This game has not been completed yet. Come back later (or get to work).</p>
|
<p>This game has not been completed yet. Come back later (or get to work).</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user