Merged [2676] from kivinen@iki.fi:

Added new setting to the /cookies page which enables always showing
	full document text instead of showing beginning of the document. This fixes issue #551.
 - Legacy-Id: 2680
Note: SVN reference [2676] has been migrated to Git commit f7a33efea768e70c1865c3bbd084cf82cd512c78
This commit is contained in:
Henrik Levkowetz 2010-11-11 02:31:38 +00:00
parent b0576a064a
commit f733c1acc8
4 changed files with 41 additions and 4 deletions

View file

@ -9,4 +9,6 @@ urlpatterns = patterns('',
(r'^new_enough/', views.new_enough),
(r'^expires_soon/(?P<days>.*)$', views.expires_soon),
(r'^expires_soon/', views.expires_soon),
(r'^full_draft/(?P<enabled>.*)$', views.full_draft),
(r'^full_draft/', views.full_draft),
)

View file

@ -4,7 +4,7 @@ from django.http import HttpResponse
from django.shortcuts import render_to_response as render, get_object_or_404
from django.template import RequestContext
def settings(request, new_enough = -1, expires_soon = -1):
def settings(request, new_enough = -1, expires_soon = -1, full_draft = ""):
if new_enough < 0:
if "new_enough" in request.COOKIES:
new_enough = int(request.COOKIES["new_enough"])
@ -15,10 +15,16 @@ def settings(request, new_enough = -1, expires_soon = -1):
expires_soon = int(request.COOKIES["expires_soon"])
else:
expires_soon = 14
if full_draft == "":
if "full_draft" in request.COOKIES:
full_draft = request.COOKIES["full_draft"]
else:
full_draft = "off"
return render("cookies/settings.html",
{
"new_enough" : new_enough,
"expires_soon" : expires_soon
"expires_soon" : expires_soon,
"full_draft" : full_draft
}, context_instance=RequestContext(request))
def new_enough(request, days="14"):
@ -42,3 +48,10 @@ def expires_soon(request, days="14"):
response = settings(request, -1, days)
response.set_cookie("expires_soon", days)
return response
def full_draft(request, enabled="off"):
if enabled != "on" and enabled != "off":
enabled = "off"
response = settings(request, -1, -1, enabled)
response.set_cookie("full_draft", enabled)
return response

View file

@ -74,6 +74,13 @@ def _get_html(key, filename):
(c1,c2) = markup_txt.markup(raw_content)
return (c1,c2)
def include_text(request):
include_text = request.GET.get( 'include_text' )
if "full_draft" in request.COOKIES:
if request.COOKIES["full_draft"] == "on":
include_text = 1
return include_text
def document_main_rfc(request, rfc_number, tab):
rfci = get_object_or_404(RfcIndex, rfc_number=rfc_number)
doc = RfcWrapper(rfci)
@ -99,7 +106,7 @@ def document_main_rfc(request, rfc_number, tab):
return render_to_response(template + ".html",
{'content1':content1, 'content2':content2,
'doc':doc, 'info':info, 'tab':tab,
'include_text':request.GET.get( 'include_text' ),
'include_text':include_text(request),
'history':history},
context_instance=RequestContext(request));
@ -150,7 +157,7 @@ def document_main(request, name, tab):
return render_to_response(template + ".html",
{'content1':content1, 'content2':content2,
'doc':doc, 'info':info, 'tab':tab,
'include_text':request.GET.get( 'include_text' ),
'include_text':include_text(request),
'versions':versions, 'history':history},
context_instance=RequestContext(request));

View file

@ -48,6 +48,21 @@ cookies disabled then you are not able to change the settings
<td>{% if expires_soon|equal:"60" %}<span class="ietf-highlight-y"><a href="/cookies/expires_soon/60">60 days</a></span>{%else%}<a href="/cookies/expires_soon/60">60 days</a>{% endif %}</td>
<td>{% if expires_soon|equal:"90" %}<span class="ietf-highlight-y"><a href="/cookies/expires_soon/90">90 days</a></span>{%else%}<a href="/cookies/expires_soon/90">90 days</a>{% endif %}</td>
</tr>
<tr class="setting-header">
<td colspan="6">
<h2 class="ietf-divider">Show full document text in document page</h2>
</td>
<tr>
<tr class="setting-description">
<td colspan="6">
<p>Show the full draft immediately on the document page instead of only showing beginning of it. This defaults to off.</p>
</td>
</tr>
<tr class="settings-values">
<td>{% if full_draft|equal:"off" %}<span class="ietf-highlight-y"><a href="/cookies/full_draft/off">off</a></span>{%else%}<a href="/cookies/full_draft/off">off</a>{% endif %}</td></td>
<td>{% if full_draft|equal:"on" %}<span class="ietf-highlight-y"><a href="/cookies/full_draft/on">on</a></span>{%else%}<a href="/cookies/full_draft/on">on</a>{% endif %}</td></td>
</tr>
</table>
{% endblock %}