button for adding browser/os/flash details to forum post

This commit is contained in:
Glen Chiacchieri 2013-09-18 19:35:31 +00:00
parent 79e00ad094
commit eeb4db9843
7 changed files with 26 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -9,6 +9,13 @@
// ----------------------------------------------------------------------------
// Feel free to add more tags
// ----------------------------------------------------------------------------
var _simple_http_agent = $('#simple-user-agent').text()
if (swfobject.hasFlashPlayerVersion('1')) {
var version = swfobject.getFlashPlayerVersion();
_simple_http_agent += ', Flash '+ version.major +'.'+ version.minor +' (release '+ version.release +')';
} else {
_simple_http_agent += ', No Flash version detected'
}
mySettings = {
previewParserPath: POST_PREVIEW_URL, // path to your BBCode parser
markupSet: [
@ -45,7 +52,10 @@ mySettings = {
{name:'Roll', openWith:':rolleyes:'},
{name:'Cool', openWith:':cool:'}
]},
{separator:'---------------' },
{separator:'---------------' },
{name:'Paste browser / operating system versions', openWith: _simple_http_agent, replaceWith: '', closeWith:'', className:'browser-os-button'},
// PUT SCRATCH BLOCKS HERE
{separator:'---------------' },
{name:'Clean', className:"clean", replaceWith:function(markitup) { return markitup.selection.replace(/\[(.*?)\]/g, "") } },
{name:'Preview', className:"preview", call:'preview' }
]

View file

@ -78,6 +78,9 @@
.markItUp .markItUpButton12-12 a {
background-image:url(../../../../img/smilies/cool.png);
}
.markItUp .browser-os-button a {
background-image:url(../../../../img/browser-os.png);
}
.markItUp .clean a {
background-image:url(images/clean.png);
}

View file

@ -56,4 +56,4 @@ miu = {
}
return '\n'+heading;
}
}
}

View file

@ -1,5 +1,6 @@
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}/djangobb_forum/js/markitup/skins/simple/style.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}/djangobb_forum/js/markitup/sets/{{ markup }}/style.css" />
<script type="text/javascript" src="{{ STATIC_URL }}/js/swfobject.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}/djangobb_forum/js/markitup/jquery.markitup.pack.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}/djangobb_forum/js/markitup/sets/{{ markup }}/set.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}/djangobb_forum/js/markup/{{ markup }}/board.js"></script>

View file

@ -6,6 +6,7 @@
<div class="box-content">
<form id="post" action="{{ form_url|default_if_none:"." }}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div style="display: none" id="simple-user-agent">My browser / operating system: {{ simple_user_agent|default:'NOT PROVIDED' }}</div>
{% if create_poll_form %}
<script>{# TODO: move to html head! #}

View file

@ -3,6 +3,7 @@
import math
import re
import urllib2
import httpagentparser
from datetime import timedelta
from django.contrib import messages
@ -36,6 +37,12 @@ from djangobb_forum.util import build_form, paginate, set_language, smiles, conv
from lib.utils import get_client_ip
def simple_user_agent(request):
"""
Utility function to show the user agent in a human-readable form. Uses
simple parser from httpagentparser and removes the punctuation from that.
"""
return ', '.join(httpagentparser.simple_detect(request.META['HTTP_USER_AGENT']))
def index(request, full=True):
users_cached = cache.get('djangobb_users_online', {})
@ -506,6 +513,7 @@ def show_topic(request, topic_id, full=True):
'can_edit': can_edit,
'can_close': can_close,
'group_titles': group_titles,
'simple_user_agent': simple_user_agent(request),
})
else:
return render(request, 'djangobb_forum/mobile/topic.html', {'categories': Category.objects.all(),
@ -604,6 +612,7 @@ def add_topic(request, forum_id, full=True):
'form': form,
'form_url': request.path,
'back_url': forum.get_absolute_url(),
'simple_user_agent': simple_user_agent(request),
}
return render(request, 'djangobb_forum/add_topic.html' if full else 'djangobb_forum/mobile/add_topic.html', context)