def faq(request): if getattr(askbot_settings, 'FORUM_FAQ', ''): text = _(getattr(askbot_settings, 'FORUM_FAQ', '')) data = { 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', } forum_faq = render_text_into_skin(text, data, request) data_out = { 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', 'forum_faq': forum_faq, } return render_into_skin('faq.html', data_out, request) data = { 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', } return render_into_skin('faq_static.html', data, request)
def faq(request): if getattr(askbot_settings, 'FORUM_FAQ',''): text = _(getattr(askbot_settings, 'FORUM_FAQ','')) data = { 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', } forum_faq = render_text_into_skin(text, data, request) data_out = { 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', 'forum_faq' : forum_faq, } return render_into_skin('faq.html', data_out, request) data = { 'gravatar_faq_url': reverse('faq') + '#gravatar', #'send_email_key_url': reverse('send_email_key'), 'ask_question_url': reverse('ask'), 'page_class': 'meta', } return render_into_skin('faq_static.html', data, request)
def get_editor(request): """returns bits of html for the tinymce editor in a dictionary with keys: * html - the editor element * scripts - an array of script tags * success - True """ if 'config' not in request.GET: return HttpResponseForbidden() config = json.loads(request.GET['config']) element_id = request.GET.get('id', 'editor') form = forms.EditorForm( attrs={'id': element_id}, editor_attrs=config, user=request.user, ) editor_html = render_text_into_skin( '{{ form.media }} {{ form.editor }}', {'form': form}, request ) # parse out javascript and dom, and return them separately # we need that, because js needs to be added in a special way html_soup = BeautifulSoup(editor_html, 'html5lib') parsed_scripts = [] for script in html_soup.find_all('script'): parsed_scripts.append({ 'contents': script.string, 'src': script.get('src', None) }) data = { 'html': str(html_soup.textarea), 'scripts': parsed_scripts, 'success': True } return JsonResponse(data)
def get_editor(request): """returns bits of html for the tinymce editor in a dictionary with keys: * html - the editor element * scripts - an array of script tags * success - True """ if "config" not in request.GET: return HttpResponseForbidden() config = simplejson.loads(request.GET["config"]) element_id = request.GET.get("id", "editor") form = forms.EditorForm(attrs={"id": element_id}, editor_attrs=config, user=request.user) editor_html = render_text_into_skin("{{ form.media }} {{ form.editor }}", {"form": form}, request) # parse out javascript and dom, and return them separately # we need that, because js needs to be added in a special way html_soup = BeautifulSoup(editor_html, "html5lib") parsed_scripts = list() for script in html_soup.find_all("script"): parsed_scripts.append({"contents": script.string, "src": script.get("src", None)}) data = {"html": str(html_soup.textarea), "scripts": parsed_scripts, "success": True} return HttpResponse(simplejson.dumps(data), content_type="application/json")
def get_editor(request): """returns bits of html for the tinymce editor in a dictionary with keys: * html - the editor element * scripts - an array of script tags * success - True """ if 'config' not in request.GET: return HttpResponseForbidden() config = json.loads(request.GET['config']) element_id = request.GET.get('id', 'editor') form = forms.EditorForm( attrs={'id': element_id}, editor_attrs=config, user=request.user, ) editor_html = render_text_into_skin('{{ form.media }} {{ form.editor }}', {'form': form}, request) # parse out javascript and dom, and return them separately # we need that, because js needs to be added in a special way html_soup = BeautifulSoup(editor_html, 'html5lib') parsed_scripts = [] for script in html_soup.find_all('script'): parsed_scripts.append({ 'contents': script.string, 'src': script.get('src', None) }) data = { 'html': str(html_soup.textarea), 'scripts': parsed_scripts, 'success': True } return JsonResponse(data)