diff --git a/static/js/dynastie.js b/static/js/dynastie.js
index 4b0dec0..29e61fc 100644
--- a/static/js/dynastie.js
+++ b/static/js/dynastie.js
@@ -1,3 +1,4 @@
+
tinyMCE.init({
// General options
mode : "textareas",
@@ -17,8 +18,10 @@ tinyMCE.init({
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
- width: "100%",
- height: "400"
+ width: "60%",
+ height: "400",
+
+ external_image_list_url : external_list,
});
diff --git a/templates/add_post.html b/templates/add_post.html
index 2209789..3287865 100644
--- a/templates/add_post.html
+++ b/templates/add_post.html
@@ -2,6 +2,9 @@
{% block head %}
+
{% endblock %}
diff --git a/templates/edit_post.html b/templates/edit_post.html
index 67ebcf3..6a032d9 100644
--- a/templates/edit_post.html
+++ b/templates/edit_post.html
@@ -2,6 +2,9 @@
{% block head %}
+
{% endblock %}
diff --git a/urls.py b/urls.py
index a8ed039..87e3ac4 100644
--- a/urls.py
+++ b/urls.py
@@ -26,6 +26,8 @@ urlpatterns = patterns('',
url(r'^post/delete/(\d+)$','dynastie.views.delete_post', name='delete_post'),
url(r'^generate/(\d+)$', 'dynastie.views.generate', name='generate'),
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')),
# Uncomment the admin/doc line below to enable admin documentation:
diff --git a/views.py b/views.py
index eda3ab3..10c7694 100644
--- a/views.py
+++ b/views.py
@@ -2,7 +2,7 @@ import os
from datetime import datetime, date, time
from django.shortcuts import render
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.forms.models import inlineformset_factory
from dynastie.models import *
@@ -406,3 +406,63 @@ def preview(request, blog_id):
return HttpResponseRedirect('http://' + b.name + '/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')