def get_image_folders():
- return [fn for fn in os.listdir(settings.IMAGE_DIR) if not fn.startswith('.')]
+ return [fn for fn in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR)) if not fn.startswith('.')]
def get_images_from_folder(folder):
- return ['/media/images/' + folder + '/' + fn for fn
- in os.listdir(os.path.join(settings.IMAGE_DIR, folder))
+ return [settings.MEDIA_URL + settings.IMAGE_DIR + '/' + folder + '/' + fn for fn
+ in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, folder))
if not fn.startswith('.')]
from librarian import html
-import hg, urllib2, json
+import hg, urllib2
+from django.utils import simplejson as json
from django.views.generic.simple import direct_to_template
from django.conf import settings
--- /dev/null
+from django.contrib import admin
+from django.utils.translation import ugettext_lazy as _
+
+from toolbar import models
+
+
+class ButtonGroupAdmin(admin.ModelAdmin):
+ list_display = ('name', 'slug', 'position',)
+ search_fields = ('name', 'slug',)
+ prepopulated_fields = {'slug': ('name',)}
+ list_editable = ('position',)
+
+admin.site.register(models.ButtonGroup, ButtonGroupAdmin)
+
+
+class ButtonAdmin(admin.ModelAdmin):
+ list_display = ('label', 'slug', 'tag', 'key', 'position',)
+ list_filter = ('group',)
+ search_fields = ('label', 'slug', 'tag', 'key',)
+ prepopulated_fields = {'slug': ('label',)}
+ filter_horizontal = ('group',)
+ list_editable = ('position',)
+
+admin.site.register(models.Button, ButtonAdmin)
+
--- /dev/null
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+
+class ButtonGroup(models.Model):
+ name = models.CharField(max_length=32)
+ slug = models.SlugField()
+ position = models.IntegerField(default=0)
+
+ class Meta:
+ ordering = ('position', 'name',)
+ verbose_name, verbose_name_plural = _('button group'), _('button groups')
+
+ def __unicode__(self):
+ return self.name
+
+
+class Button(models.Model):
+ label = models.CharField(max_length=32)
+ slug = models.SlugField()
+ tag = models.CharField(max_length=128)
+ key = models.IntegerField(blank=True, null=True)
+ position = models.IntegerField(default=0)
+
+ group = models.ManyToManyField(ButtonGroup)
+
+ class Meta:
+ ordering = ('position', 'label',)
+ verbose_name, verbose_name_plural = _('button'), _('buttons')
+
+ def __unicode__(self):
+ return self.label
+
--- /dev/null
+<div id="toolbar">
+ <ol id="toolbar-tabs">
+ {% for group in groups %}
+ <li p:button-list="{{ group.slug }}">{{ group.name }}</li>
+ {% endfor %}
+ </ol>
+ <div style="clear: both; height: 0; width: 0"> </div>
+ <div id="toolbar-buttons">
+ {% for group in groups %}
+ <ol id="{{ group.slug }}" style="display:none">
+ {% for button in group.button_set.all %}
+ <li p:tag="{{ button.slug }}" {% if button.key %}p:key="{{ button.key }}"{% endif %}>{{ button.label }}</li>
+ {% endfor %}
+ </ol>
+ {% endfor %}
+ <div style="clear: both; height: 0; width: 0"> </div>
+ </div>
+</div>
\ No newline at end of file
--- /dev/null
+from django import template
+
+from toolbar import models
+
+
+register = template.Library()
+
+
+@register.inclusion_tag('toolbar/toolbar.html')
+def toolbar():
+ groups = models.ButtonGroup.objects.all()
+ return {'groups': groups}
+
'django.contrib.admin',
'django.contrib.admindocs',
- 'explorer'
+ 'explorer',
+ 'toolbar',
)
REPOSITORY_PATH = '/Users/zuber/Projekty/platforma/files/books'
-IMAGE_DIR = '/Users/zuber/Projekty/platforma/files/images'
+IMAGE_DIR = 'images'
try:
from localsettings import *
body {
margin: 0;
- font: 100%/1.5 Georgia, Verdana, sans-serif;
+ font: 14px Helvetica, Verdana, sans-serif;
overflow: hidden;
}
.image-box {
border-top: 1px solid #DDD;
}
+
+#toolbar, #toolbar ol {
+ display: block;
+ margin: 0;
+ padding: 0;
+ background-color: #CCC;
+ border-bottom: 1px solid #AAA;
+}
+
+#toolbar {
+ overflow: hidden;
+ width: 400%;
+}
+
+#toolbar-tabs li {
+ font-size: 14px;
+ display: block;
+ float: left;
+ margin: 4px 4px 0 0;
+ padding: 2px 10px 0 10px;
+ border-left: 1px solid #EEE;
+ border-right: 1px solid #AAA;
+ margin-bottom: -1px;
+ border: 1px solid #AAA;
+ border-radius-topleft: 8px;
+ border-radius-topright: 8px;
+ -moz-border-radius-topleft: 8px;
+ -moz-border-radius-topright: 8px;
+ -webkit-border-top-left-radius: 8px;
+ -webkit-border-top-right-radius: 8px;
+}
+
+#toolbar-tabs li:hover, #toolbar-tabs li.active {
+ cursor: default;
+ background-color: #EEE;
+ border-bottom: 1px solid #EEE;
+}
+
+#toolbar-buttons {
+ background-color: #EEE;
+}
+
+#toolbar-buttons li {
+ display: block;
+ font-size: 12px;
+ padding: 1px 8px;
+ margin: 4px;
+ border-radius: 10px;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 8px;
+ float: left;
+}
+
+#toolbar-buttons li:hover {
+ background-color: #777;
+ color: #FFF;
+ cursor: default;
+}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://platforma.wolnelektury.pl/">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>{% block title %}Platforma Redakcyjna{% endblock %}</title>
{% extends "base.html" %}
+{% load toolbar_tags %}
{% block extrahead %}
<script src="/static/js/jquery.fieldselection.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
$('#id_folders').change(function() {
- $('#images').load('/images/' + $('#id_folders').val() + '/', function() {
+ $('#images').load('{% url folder_image_ajax %}' + $('#id_folders').val() + '/', function() {
$('#images').data('lastScroll', -1000);
});
});
$(this).html('Nie synchronizuj przewijania');
$('#images').enableAutoscroll();
})
-
- keys = {}
- function addEditorButton(editor, label, keyCode, fn) {
+ // Toolbar
+ $('#toolbar-tabs li').click(function() {
+ var id = $(this).attr('p:button-list');
+ $('#toolbar-tabs li').removeClass('active');
+ $(this).addClass('active');
+ if (!$('#' + id).is(':visible')) {
+ $('#toolbar-buttons ol').not('#' + id).hide();
+ $('#' + id).show();
+ }
+ })
+
+ var keys = {};
+ $('#toolbar-buttons li').each(function() {
+ var tag = $(this).attr('p:tag');
var handler = function() {
var text = editor.selection();
- editor.replaceSelection(fn(text));
+ editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
+ if (text.length == 0) {
+ var pos = editor.cursorPosition();
+ editor.selectLines(pos.line, pos.character + tag.length + 2);
+ }
}
-
- keys[keyCode] = handler;
-
- $('<button type="button">' + label + '</button>').click(function(event) {
- event.preventDefault();
- handler();
- }).appendTo('#buttons');
- }
-
- addEditorButton(editor, 'utwór', 65, function(text) { return '<utwor>' + text + '</utwor>'; });
- addEditorButton(editor, 'akap', 83, function(text) { return '<akap>' + text + '</akap>'; });
+ if ($(this).attr('p:key')) {
+ keys[$(this).attr('p:key')] = handler;
+ }
+ $(this).click(handler)
+ });
editor.grabKeys(function(event) {
- // console.log('handle', event, event.keyCode)
+ console.log('handle', event, event.keyCode)
if (keys[event.keyCode]) {
keys[event.keyCode]();
}
resizePanels();
}
});
-
+
$('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
});
{% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> ❯ plik {{ hash }}{% endblock breadcrumbs %}
{% block maincontent %}
- <div id="tabs">
- <a href="{% url file_xml hash %}" class="active">Źródło</a>
- <a href="{% url file_html hash %}">HTML</a>
- <div style="float: left" id="buttons"></div>
- <div style="clear: both; height: 0; width: 0"> </div>
- </div>
+ {% toolbar %}
<form action="." method="post" accept-charset="utf-8">
<div id="panels">
url(r'^file/(?P<path>[^/]+)/$', 'explorer.views.file_xml', name='file_xml'),
url(r'^html/(?P<path>[^/]+)/$', 'explorer.views.file_html', name='file_html'),
url(r'^images/(?P<folder>[^/]+)/$', 'explorer.views.folder_images', name='folder_image'),
+ url(r'^images/$', 'explorer.views.folder_images', {'folder': '.'}, name='folder_image_ajax'),
# Admin panel
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),