Merge soutade.fr:dynastie
This commit is contained in:
commit
505cb5e0c6
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
tinyMCE.init({
|
tinyMCE.init({
|
||||||
// General options
|
// General options
|
||||||
mode : "textareas",
|
mode : "textareas",
|
||||||
|
@ -17,8 +18,10 @@ tinyMCE.init({
|
||||||
theme_advanced_toolbar_align : "left",
|
theme_advanced_toolbar_align : "left",
|
||||||
theme_advanced_statusbar_location : "bottom",
|
theme_advanced_statusbar_location : "bottom",
|
||||||
theme_advanced_resizing : true,
|
theme_advanced_resizing : true,
|
||||||
width: "100%",
|
width: "60%",
|
||||||
height: "400"
|
height: "400",
|
||||||
|
|
||||||
|
external_image_list_url : external_list,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<script type="text/javascript" src="/static/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
<script type="text/javascript" src="/static/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var external_list = "/tinyMCEExternalList/post/add/{{ blog_id }}";
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="/static/js/dynastie.js"></script>
|
<script type="text/javascript" src="/static/js/dynastie.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<script type="text/javascript" src="/static/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
<script type="text/javascript" src="/static/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var external_list = "/tinyMCEExternalList/post/edit/{{ post_id }}";
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="/static/js/dynastie.js"></script>
|
<script type="text/javascript" src="/static/js/dynastie.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
2
urls.py
2
urls.py
|
@ -26,6 +26,8 @@ urlpatterns = patterns('',
|
||||||
url(r'^post/delete/(\d+)$','dynastie.views.delete_post', name='delete_post'),
|
url(r'^post/delete/(\d+)$','dynastie.views.delete_post', name='delete_post'),
|
||||||
url(r'^generate/(\d+)$', 'dynastie.views.generate', name='generate'),
|
url(r'^generate/(\d+)$', 'dynastie.views.generate', name='generate'),
|
||||||
url(r'^preview/(\d+)$', 'dynastie.views.preview', name='preview'),
|
url(r'^preview/(\d+)$', 'dynastie.views.preview', name='preview'),
|
||||||
|
url(r'^tinyMCEExternalList/post/add/(\d+)$', 'dynastie.views.tinymcelist_add', name='tinymce'),
|
||||||
|
url(r'^tinyMCEExternalList/post/edit/(\d+)$', 'dynastie.views.tinymcelist_edit', name='tinymce'),
|
||||||
# url(r'^dynastie/', include('dynastie.foo.urls')),
|
# url(r'^dynastie/', include('dynastie.foo.urls')),
|
||||||
|
|
||||||
# Uncomment the admin/doc line below to enable admin documentation:
|
# Uncomment the admin/doc line below to enable admin documentation:
|
||||||
|
|
62
views.py
62
views.py
|
@ -2,7 +2,7 @@ import os
|
||||||
from datetime import datetime, date, time
|
from datetime import datetime, date, time
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
from django.http import HttpResponseRedirect, Http404
|
from django.http import HttpResponseRedirect, HttpResponse, Http404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
from dynastie.models import *
|
from dynastie.models import *
|
||||||
|
@ -406,3 +406,63 @@ def preview(request, blog_id):
|
||||||
|
|
||||||
return HttpResponseRedirect('http://' + b.name + '/preview.html')
|
return HttpResponseRedirect('http://' + b.name + '/preview.html')
|
||||||
# return HttpResponseRedirect('http://' + 'localhost:8080' + '/preview.html')
|
# return HttpResponseRedirect('http://' + 'localhost:8080' + '/preview.html')
|
||||||
|
|
||||||
|
def _tinymcelist(request, b, year, month):
|
||||||
|
ret = 'var tinyMCEImageList = new Array('
|
||||||
|
|
||||||
|
b.create_paths()
|
||||||
|
|
||||||
|
if month < 10:
|
||||||
|
suffix = '/images/' + str(year) + '/0' + str(month)
|
||||||
|
else:
|
||||||
|
suffix = '/images/' + str(year) + '/' + str(month)
|
||||||
|
|
||||||
|
path = b.src_path + '/' + suffix
|
||||||
|
# url = 'http://' + 'localhost:8080' + '/' + suffix + '/'
|
||||||
|
url = 'http://' + b.name + '/' + suffix + '/'
|
||||||
|
|
||||||
|
if os.path.exists(path):
|
||||||
|
files = ''
|
||||||
|
for p in os.listdir(path):
|
||||||
|
files += '["' + p + '", "' + url + p + '"],'
|
||||||
|
# Remove last comma
|
||||||
|
if len(files) != 0:
|
||||||
|
ret += files[:-1]
|
||||||
|
|
||||||
|
ret += ');'
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def tinymcelist_add(request, blog_id):
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
year = now.year
|
||||||
|
month = now.month
|
||||||
|
b = Blog.objects.filter(pk=blog_id).filter(writers=request.user.id)[0]
|
||||||
|
if b is None:
|
||||||
|
return HttpResponse('', content_type='application/x-javascript')
|
||||||
|
|
||||||
|
ret = _tinymcelist(request, b, year, month)
|
||||||
|
|
||||||
|
print 'Ret1 ' + ret
|
||||||
|
|
||||||
|
return HttpResponse(ret, content_type='application/x-javascript')
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def tinymcelist_edit(request, post_id):
|
||||||
|
post = Post.objects.filter(pk=post_id)
|
||||||
|
if post is None:
|
||||||
|
return HttpResponse('', content_type='application/x-javascript')
|
||||||
|
b = Blog.objects.filter(pk=post.blog).filter(writers=request.user.id)[0]
|
||||||
|
if b is None:
|
||||||
|
return HttpResponse('', content_type='application/x-javascript')
|
||||||
|
year = post.creation_date.year()
|
||||||
|
month = post.creation_date.month()
|
||||||
|
|
||||||
|
ret = _tinymcelist(request, b, year, month)
|
||||||
|
|
||||||
|
print 'Ret2 ' + ret
|
||||||
|
|
||||||
|
return HttpResponse(ret, content_type='application/x-javascript')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user