diff --git a/web/static/storycraft/page.css b/web/static/storycraft/page.css index 1fd475a..ab8044d 100644 --- a/web/static/storycraft/page.css +++ b/web/static/storycraft/page.css @@ -137,11 +137,8 @@ body { line-height: 1.5em; } -.gamestory p:first-letter { - font-size: 3.5em; - line-height: 0.8em; - float: left; - margin: 0 3px 3px 0; +.gamestory p { + margin-bottom: 20px; } #footer { diff --git a/web/storycraft/views.py b/web/storycraft/views.py index 96ecc40..ebf25bb 100644 --- a/web/storycraft/views.py +++ b/web/storycraft/views.py @@ -3,6 +3,8 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect from django.shortcuts import render_to_response, get_object_or_404 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 @@ -21,7 +23,26 @@ def game_index(request, game_id): game = get_object_or_404(StorycraftGame, pk=game_id) players = StorycraftPlayer.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('

') + 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('' + escape(split[0]) + '.

') + pretty_story.append('

' + escape(split[1]) + '') + else: + pretty_story.append('' + escape(line.line) + '') + pretty_story.append('

') + 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 diff --git a/web/templates/storycraft/tmpl_game_story.html b/web/templates/storycraft/tmpl_game_story.html index 0a9b06a..115e84c 100644 --- a/web/templates/storycraft/tmpl_game_story.html +++ b/web/templates/storycraft/tmpl_game_story.html @@ -1,13 +1,7 @@ {% autoescape on %}
{% if game.is_completed %} -
-

- {% for line in lines %} - {{ line }} - {% endfor %} -

-
+
{{ prettystory|safe }}
{% else %}

This game has not been completed yet. Come back later (or get to work).