From: Łukasz Rekucki Date: Wed, 9 Sep 2009 14:32:14 +0000 (+0200) Subject: Refaktor przyciskow. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/fc7a60feb9496c250cd1e8ca3db8c74267790047?ds=sidebyside;hp=--cc Refaktor przyciskow. Refaktor paneli. Dodanie przycisku wyswietlajace widok do wydruku. Closes #100. Scriptlet 'insert_stanza'. Closes #95. --- fc7a60feb9496c250cd1e8ca3db8c74267790047 diff --git a/apps/explorer/admin.py b/apps/explorer/admin.py new file mode 100644 index 00000000..e4389e0c --- /dev/null +++ b/apps/explorer/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin +from django.utils.translation import ugettext_lazy as _ + +import explorer.models + +admin.site.register(explorer.models.EditorSettings) +admin.site.register(explorer.models.Book) +admin.site.register(explorer.models.EditorPanel) \ No newline at end of file diff --git a/apps/explorer/models.py b/apps/explorer/models.py index f292283f..09271526 100644 --- a/apps/explorer/models.py +++ b/apps/explorer/models.py @@ -5,8 +5,9 @@ from django.contrib.auth.models import User from django.conf import settings from django.utils.translation import gettext_lazy as _ -from explorer import fields +import toolbar.models +from explorer import fields class EditorSettings(models.Model): user = models.ForeignKey(User, unique=True) @@ -18,7 +19,17 @@ class EditorSettings(models.Model): def __unicode__(self): return u"Editor settings for %s" % self.user.username +class EditorPanel(models.Model): + id = models.CharField(max_length=24, primary_key=True) + display_name = models.CharField(max_length=128) + + toolbar_groups = models.ManyToManyField(toolbar.models.ButtonGroup, blank=True) + toolbar_extra = models.ForeignKey(toolbar.models.ButtonGroup, null=True, blank=True, + unique=True, related_name='main_editor_panels') + def __unicode__(self): + return self.display_name + class Book(models.Model): class Meta: permissions = ( diff --git a/apps/explorer/views.py b/apps/explorer/views.py index b3cc09bc..7f99b662 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -10,9 +10,10 @@ from django.conf import settings from django.contrib.auth.decorators import login_required, permission_required from django.core.urlresolvers import reverse -from django.http import HttpResponseRedirect, HttpResponse +from django.http import HttpResponseRedirect, HttpResponse, HttpResponseNotFound from django.utils import simplejson as json from django.views.generic.simple import direct_to_template +from django.contrib.auth.decorators import login_required from explorer import forms, models from toolbar import models as toolbar_models @@ -350,66 +351,93 @@ def display_editor(request, path, repo): repo.with_wlock(ensure_branch_exists) return direct_to_template(request, 'explorer/editor.html', extra_context={ - 'hash': path, + 'fileid': path, 'panel_list': ['lewy', 'prawy'], + 'availble_panels': models.EditorPanel.objects.all(), 'scriptlets': toolbar_models.Scriptlet.objects.all() }) except KeyError: return direct_to_template(request, 'explorer/nofile.html', \ - extra_context = { 'path': path }) + extra_context = { 'fileid': path }) # =============== # = Panel views = # =============== +class panel_view(object): -@ajax_login_required -@with_repo -def xmleditor_panel(request, path, repo): - text = repo.get_file(path, file_branch(path, request.user)) - - return direct_to_template(request, 'explorer/panels/xmleditor.html', extra_context={ - 'fpath': path, - 'text': text, - }) - + def __new__(cls, request, name, path, **kwargs): + #try: + panel = models.EditorPanel.objects.get(id=name) + method = getattr(cls, name + '_panel', None) + if not panel or method is None: + raise HttpResponseNotFound -@ajax_login_required -def gallery_panel(request, path): - return direct_to_template(request, 'explorer/panels/gallery.html', extra_context={ - 'fpath': path, - 'form': forms.ImageFoldersForm(), - }) + extra_context = method(request, path, panel, **kwargs) -@ajax_login_required -@with_repo -def htmleditor_panel(request, path, repo): - user_branch = file_branch(path, request.user) - try: - return direct_to_template(request, 'explorer/panels/htmleditor.html', extra_context={ - 'fpath': path, - 'html': html.transform(repo.get_file(path, user_branch), is_file=False), + if not isinstance(extra_context, dict): + return extra_context + + extra_context.update({ + 'toolbar_groups': panel.toolbar_groups.all(), + 'toolbar_extra_group': panel.toolbar_extra, + 'fileid': path }) - except (ParseError, ValidationError), e: - return direct_to_template(request, 'explorer/panels/parse_error.html', extra_context={ - 'fpath': path, 'exception_type': type(e).__name__, 'exception': e, 'panel_name': 'Edytor HTML'}) -@ajax_login_required + return direct_to_template(request, 'explorer/panels/'+name+'.html',\ + extra_context=extra_context) + + @staticmethod + @ajax_login_required + @with_repo + def xmleditor_panel(request, path, panel, repo): + return {'text': repo.get_file(path, file_branch(path, request.user))} + + @staticmethod + @ajax_login_required + def gallery_panel(request, path, panel): + return {'form': forms.ImageFoldersForm() } + + @staticmethod + @ajax_login_required + @with_repo + def htmleditor_panel(request, path, panel, repo): + user_branch = file_branch(path, request.user) + try: + return {'html': html.transform(repo.get_file(path, user_branch), is_file=False)} + except (ParseError, ValidationError), e: + return direct_to_template(request, 'explorer/panels/parse_error.html', extra_context={ + 'fileid': path, 'exception_type': type(e).__name__, 'exception': e, + 'panel_name': panel.display_name}) + + @staticmethod + @ajax_login_required + @with_repo + def dceditor_panel(request, path, panel, repo): + user_branch = file_branch(path, request.user) + try: + doc_text = repo.get_file(path, user_branch) + document = parser.WLDocument.from_string(doc_text) + form = forms.DublinCoreForm(info=document.book_info) + return {'form': form} + except (ParseError, ValidationError), e: + return direct_to_template(request, 'explorer/panels/parse_error.html', extra_context={ + 'fileid': path, 'exception_type': type(e).__name__, 'exception': e, + 'panel_name': panel.display_name}) + + +@login_required @with_repo -def dceditor_panel(request, path, repo): +def print_html(request, path, repo): user_branch = file_branch(path, request.user) + return HttpResponse( + html.transform(repo.get_file(path, user_branch), is_file=False), + mimetype="text/html") - try: - doc_text = repo.get_file(path, user_branch) - document = parser.WLDocument.from_string(doc_text) - form = forms.DublinCoreForm(info=document.book_info) - return direct_to_template(request, 'explorer/panels/dceditor.html', extra_context={ - 'fpath': path, - 'form': form, - }) - except (ParseError, ValidationError), e: - return direct_to_template(request, 'explorer/panels/parse_error.html', extra_context={ - 'fpath': path, 'exception_type': type(e).__name__, 'exception': e, - 'panel_name': 'Edytor DublinCore'}) +@login_required +@with_repo +def print_xml(request, path, repo): + user_branch = file_branch(path, request.user) + return HttpResponse( repo.get_file(path, user_branch), mimetype="text/plain; charset=utf-8") # ================= # = Utility views = diff --git a/apps/toolbar/admin.py b/apps/toolbar/admin.py index dca934cc..4f03702c 100644 --- a/apps/toolbar/admin.py +++ b/apps/toolbar/admin.py @@ -11,13 +11,13 @@ from toolbar import models # prepopulated_fields = {'slug': ('name',)} # list_editable = ('position',) - class KeyModSelector(forms.MultiWidget): def __init__(self): super(KeyModSelector, self).__init__( [forms.CheckboxInput() for x in xrange(0,3)]) def decompress(self, v): + if not v: v = 0 r = [(v&0x01) != 0, (v&0x02) != 0, (v&0x04) != 0] print "DECOMPRESS: " , v, repr(r) return r diff --git a/apps/toolbar/models.py b/apps/toolbar/models.py index 004fde9f..8d123fd1 100644 --- a/apps/toolbar/models.py +++ b/apps/toolbar/models.py @@ -19,8 +19,9 @@ class Button(models.Model): slug = models.SlugField(unique=True) #unused # behaviour - params = models.TextField() # TODO: should be a JSON field - scriptlet = models.ForeignKey('Scriptlet') + params = models.TextField(default='[]') # TODO: should be a JSON field + scriptlet = models.ForeignKey('Scriptlet', null=True, blank=True) + link = models.CharField(max_length=256, blank=True, default='') # ui related stuff key = models.CharField(blank=True, max_length=1) diff --git a/apps/toolbar/templates/toolbar/button.html b/apps/toolbar/templates/toolbar/button.html new file mode 100755 index 00000000..6ed4c857 --- /dev/null +++ b/apps/toolbar/templates/toolbar/button.html @@ -0,0 +1,13 @@ +{% if button.link %} + +{% endif %} + +{% if button.link %} + +{% endif %} \ No newline at end of file diff --git a/apps/toolbar/templates/toolbar/toolbar.html b/apps/toolbar/templates/toolbar/toolbar.html index a6241d1e..b0ee028f 100644 --- a/apps/toolbar/templates/toolbar/toolbar.html +++ b/apps/toolbar/templates/toolbar/toolbar.html @@ -1,9 +1,16 @@ {% load toolbar_tags %}
+ {# This div will be connected to the right place #} + + {% for button in toolbar_extra_group.button_set.all %} + {% toolbar_button button %} + {% endfor %} + +

- {% for group in groups %} + {% for group in toolbar_groups %} @@ -12,17 +19,11 @@

- {% for group in groups %} + {% for group in toolbar_groups %}

{# buttons for this group #} {% for button in group.button_set.all %} - + {% toolbar_button button %} {% endfor %}

{% endfor %} diff --git a/apps/toolbar/templatetags/toolbar_tags.py b/apps/toolbar/templatetags/toolbar_tags.py index a38ed017..9957a939 100644 --- a/apps/toolbar/templatetags/toolbar_tags.py +++ b/apps/toolbar/templatetags/toolbar_tags.py @@ -1,9 +1,12 @@ from django import template -from toolbar import models +# from toolbar import models register = template.Library() @register.inclusion_tag('toolbar/toolbar.html') -def toolbar(): - groups = models.ButtonGroup.objects.all() - return {'groups': groups} +def toolbar(groups, extra): + return {'toolbar_groups': groups, 'toolbar_extra_group': extra} + +@register.inclusion_tag('toolbar/button.html') +def toolbar_button(b): + return {'button': b} diff --git a/fixtures/przyciski.xml b/fixtures/przyciski.xml index ec2acaba..2065b151 100755 --- a/fixtures/przyciski.xml +++ b/fixtures/przyciski.xml @@ -1,982 +1,1180 @@ - - - - Akapity i długie cytaty - akapity-i-dlugie-cytaty - 0 - - - Autokorekta - autokorekta - 0 - - - Bloki - bloki - 0 - - - Dramat wierszowany - dramat-wierszowany - 0 - - - Dramat współczesny - dramat-wspolczesny - 0 - - - Elementy początkowe - elementy-poczatkowe - 0 - - - Nagłówki - naglowki - 0 - - - Początek dramatu - poczatek-dramatu - 0 - - - Polecenia - polecenia - 0 - - - Strukturalne - strukturalne - 0 - - - Style znakowe - style-znakowe - 0 - - - Wersy - wersy - 0 - - - Widok - display_options - 2 - - - A<sup>+</sup> - increase_font_size - {"change": 2} - codemirror_fontsize - + - Zwiększ rozmiar czcionki. - - - - - - A<sup>-</sup> - descrease_font_size - {"change": -2} - codemirror_fontsize - - - Zmniejsz rozmiar czcionki. - - - - - - A<sup>=</sup> - reset_font_size - {"fontSize": 13} - codemirror_fontsize - = - Przywróć orginalny rozmiar czcionki. - - - - - - A<sup>↓</sup> - tolowercase - [] - lowercase - u - Zamień wielkie litery na małe. - - - - - - akapit - akapit - {"tag": "akap"} - insert_tag - - - - - - - - akapit cd. - akapit-cd - {"tag": "akap_cd"} - insert_tag - - - - - - - - akapit dialogowy - akapit-dialogowy - {"tag": "akap_dialog"} - insert_tag - - - - - - - - akt - akt - {"tag": "akt"} - insert_tag - - - - - - - - autor - autor - {"tag": "autor"} - insert_tag - - - - - - - - część/księga - czesc - {"tag": "naglowek_czesc"} - insert_tag - - - - - - - - dedykacja - dedykacja - {"tag": "dedykacja"} - insert_tag - - - - - - - - - didaskalia - didaskalia - {"tag": "didaskalia"} - insert_tag - - - - - - - - - didaskalia początkowe - didaskalia-poczatkowe - {"tag": "miejsce_czas"} - insert_tag - - - - - - - - didaskalia wewn. - didaskalia-wewn - {"tag": "didask_tekst"} - insert_tag - - - - - - - - - dramat wiersz. - dramat-wiersz - {"tag": "dramat_wierszowany_l"} - insert_tag - - - - - - - - dramat wiersz./w. łam - dramat-wiersz-w-lam - {"tag": "dramat_wierszowany_lp"} - insert_tag - - - - - - - - dramat współczesny - dramat-wspolczesny - {"tag": "dramat_wspolczesny"} - insert_tag - - - - - - - - dzieło nadrzędne - dzielo-nadrzedne - {"tag": "dzielo_nadrzedne"} - insert_tag - - - - - - - - długi cyt. poet. - dlugi-cyt-poet - {"tag": "poezja_cyt"} - insert_tag - - - - - - - - - długi cytat - dlugi-cytat - {"tag": "dlugi_cyt"} - insert_tag - - - - - - - - - ekstra - ekstra - {"tag": "ekstra"} - insert_tag - - - - - - - - kwestia - kwestia - {"tag": "kwestia"} - insert_tag - - - - - - - - - liryka - liryka - {"tag": "liryka_l"} - insert_tag - - - - - - - - liryka/w. łam - liryka-w-lam - {"tag": "liryka_lp"} - insert_tag - - - - - - - - lista osób: pole - lista-osob-pole - {"tag": "lista_osoba", "attrs": {"typ": ""}} - insert_tag - - - - - - - - mamtemat. - matemat - {"tag": "mat"} - insert_tag - - - - - - - - motto - motto - {"tag": "motto"} - insert_tag - - - - - - - - - motto podpis - motto-podpis - {"tag": "motto_podpis"} - insert_tag - - - - - - - - nagłówek kwestii - naglowek-kwestii - {"tag": "naglowek_osoba"} - insert_tag - - - - - - - - nota - nota - {"tag": "nota"} - insert_tag - - - - - - - - opowiadanie - opowiadanie - {"tag": "opowiadanie"} - insert_tag - - - - - - - - osoba - osoba - {"tag": "osoba"} - insert_tag - - - - - - - - - podrozdział - podrozdzial - {"tag": "naglowek_podrozdzial"} - insert_tag - - - - - - - - Podstawowa - basic_correction - {"exprs": [["\n\\d+\n", "\n"], ["-\\s*\n+", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]} - fulltextregexp - - Wykonuję operację z novel-pages i poem-pages. - - - - - - podtytuł - podtytul - {"tag": "podtytul"} - insert_tag - - - - - - - - powieść - powiesc - {"tag": "powiesc"} - insert_tag - - - - - - - - przypis autorski - przypis-autorski - {"tag": "pa"} - insert_tag - - - - - - - - przypis edytorski - przypis-edytorski - {"tag": "pe"} - insert_tag - - - - - - - - przypis redaktorski - przypis-redaktorski - {"tag": "pr"} - insert_tag - - - - - - - - przypis tłumacza - przypis-tlumacza - {"tag": "pt"} - insert_tag - - - - - - - - rozdział - rozdzial - {"tag": "naglowek_rozdzial"} - insert_tag - - - - - - - - scena - scena - {"tag": "naglowek_scena"} - insert_tag - - - - - - - - sep. asteryks - sep-asteryks - {"tag": "sekcja_asteryks"} - insert_tag - - - - - - - - sep. linia - sep-linia - {"tag": "separator_linia"} - insert_tag - - - - - - - - sep. światło - sep-swiatlo - {"tag": "sekcja_swiatlo"} - insert_tag - - - - - - - - śródtytuł - srodtytul - {"tag": "srodtytul"} - insert_tag - - - - - - - - strofa - strofa - {"tag": "strofa"} - insert_tag - s - - - - - - - - słowo obce - slowo-obce - {"tag": "slowo_obce"} - insert_tag - - - - - - - - tagi główne - tagi-glowne - {"tag": "utwor"} - insert_tag - - - - - - - - tytuł - tytul - {"tag": "nazwa_utworu"} - insert_tag - - - - - - - - tytuł dzieła - tytul-dziela - {"tag": "tytul_dziela", "attrs": {"typ": "1"}} - insert_tag - - - - - - - - Usuń spację - strip_whitespace - {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "]]} - lineregexp - - Usuwa zbędne spację z dokumentu. - - - - - - uwaga - uwaga - {"tag": "uwaga"} - insert_tag - - - - - - - - wers akap. - wers-akap - {"tag": "wers_akap"} - insert_tag - - - - - - - - - wers cd. - wers-cd - {"tag": "wers_cd"} - insert_tag - - - - - - - - - Wers wcięty - wers-wciety - {"tag": "wers_wciety", "attrs": {"typ": ""}} - insert_tag - - - - - - - - - www - www - {"tag": "www"} - insert_tag - - - - - - - - wyróżnienie - wyroznienie - {"tag": "wyroznienie"} - insert_tag - - - - - - - - wywiad - wywiad - {"tag": "wywiad"} - insert_tag - - - - - - - - wywiad odpowiedź - wywiad-odpowiedz - {"tag": "wywiad_odp"} - insert_tag - - - - - - - - wywiad pytanie - wywiad-pytanie - {"tag": "wywiad_pyt"} - insert_tag - - - - - - - - Zamień cudzysłowy - zamien-cudzyslowy - {"exprs": [["\u00bb|\u201e", ",,"], ["\u00ab", "\""], ["\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", ",,$1"]]} - lineregexp - - - - - - - - Zamień dywiz - zamien_dywiz - {"exprs": [["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"]]} - lineregexp - - Zamienia '—' na '---', oraz '1—2' na '1--2'. - - - - - - zastępnik wersu - zastepnik-wersu - {"tag": "zastepnik_wersu"} - insert_tag - - - - - - - - var texteditor = panel.texteditor; - -var text = texteditor.selection(); - -var out = '<'+params.tag; - -for (var attr in params.attrs) { - - out += ' '+attr+'="' + params.attrs[attr] + '"'; - -}; - -out += '>'; - -out += text; - -out += '</' + params.tag + '>'; - - - -texteditor.replaceSelection(out); - - - -if (text.length == 0) { - - var pos = texteditor.cursorPosition(); - - texteditor.selectLines(pos.line, pos.character + params.tag.length + 2); - -} - - - -panel.fireEvent('contentChanged'); - - - editor.showPopup('generic-info', 'Przetwarzanie zaznaczonego tekstu...', '', -1); - -var cm = panel.texteditor; -var exprs = $.map(params.exprs, function(expr) { - - var opts = "g"; - - if(expr.length > 2) - - opts = expr[2]; - - return {rx: new RegExp(expr[0], opts), repl: expr[1]}; - -}); - - - -var partial = true; - -var text = cm.selection(); - - - -if(!text) { - - var cpos = cm.cursorPosition(); - - cpos.line = cm.lineNumber(cpos.line) - - cm.selectLines(cm.firstLine(), 0, cm.lastLine(), 0); - - text = cm.selection(); - - partial = false; - -} - - - -var changed = 0; -var lines = text.split('\n'); -var lines = $.map(lines, function(line) { - var old_line = line; - $(exprs).each(function() { - var expr = this; - line = line.replace(expr.rx, expr.repl); - }); - - if(old_line != line) changed += 1; - return line; -}); - -if(changed > 0) -{ - cm.replaceSelection( lines.join('\n') ); - panel.fireEvent('contentChanged'); - editor.showPopup('generic-yes', 'Zmieniono ' + changed + ' linii.', 1500); - editor.advancePopupQueue(); -} -else { - editor.showPopup('generic-info', 'Brak zmian w tekście', 1500); - editor.advancePopupQueue(); -} - -if(!partial) - cm.selectLines( cm.nthLine(cpos.line), cpos.character ) - - - var texteditor = panel.texteditor; - -var frameBody = $('body', $(texteditor.frame).contents()); - - - -if(params.fontSize) { - - frameBody.css('font-size', params.fontSize); - -} - -else { - - var old_size = parseInt(frameBody.css('font-size')); - - frameBody.css('font-size', old_size + (params.change || 0) ); - -} - - - editor.showPopup('generic-info', 'Przetwarzanie zaznaczonego tekstu...', '', -1); - -var cm = panel.texteditor; - -var exprs = $.map(params.exprs, function(expr) { - var opts = "mg"; - if(expr.length > 2) - opts = expr[2]; - - return {rx: new RegExp(expr[0], opts), repl: expr[1]}; -}); - -var partial = true; -var text = cm.selection(); - -if(!text) { - var cpos = cm.cursorPosition(); - cpos.line = cm.lineNumber(cpos.line) - cm.selectLines(cm.firstLine(), 0, cm.lastLine(), 0); - - text = cm.selection(); - partial = false; -} - - - -var original = text; -$(exprs).each(function() { - text = text.replace(this.rx, this.repl); -}); - -if( original != text) -{ - cm.replaceSelection(text); - panel.fireEvent('contentChanged'); - editor.showPopup('generic-yes', 'Zmieniono tekst' ); - editor.advancePopupQueue(); -} -else { - editor.showPopup('generic-info', 'Brak zmian w tekście.'); - editor.advancePopupQueue(); -} - -if(!partial) { - cm.selectLines( cm.nthLine(cpos.line), cpos.character ); -} - - - params.each(function() { - - editor.callScriptlet(this[0], this[1]); - -}); - - - var cm = panel.texteditor; - -var text = cm.selection(); - -if(!text) return; - -var repl = text.toLowerCase(); - -if(repl != text) { - - cm.replaceSelection(repl); - - panel.fireEvent('contentChanged'); - -}; - - + + + + Dodatkowe przyciski w XMLEditor + xmleditor-extra-buttons + -1 + + + HTMLEditor Extra + htmleditor-extra + -1 + + + Akapity i długie cytaty + akapity-i-dlugie-cytaty + 0 + + + Autokorekta + autokorekta + 0 + + + Bloki + bloki + 0 + + + Dramat wierszowany + dramat-wierszowany + 0 + + + Dramat współczesny + dramat-wspolczesny + 0 + + + Elementy początkowe + elementy-poczatkowe + 0 + + + Nagłówki + naglowki + 0 + + + Początek dramatu + poczatek-dramatu + 0 + + + Polecenia + polecenia + 0 + + + Strukturalne + strukturalne + 0 + + + Style znakowe + style-znakowe + 0 + + + Wersy + wersy + 0 + + + A<sup>+</sup> + increase_font_size + {"change": 2} + codemirror_fontsize + + + 0 + Zwiększ rozmiar czcionki. + + + + + + A<sup>-</sup> + descrease_font_size + {"change": -2} + codemirror_fontsize + + + 0 + Zmniejsz rozmiar czcionki. + + + + + + A<sup>=</sup> + reset_font_size + {"fontSize": 13} + codemirror_fontsize + + + 0 + Przywróć orginalny rozmiar czcionki. + + + + + + A<sup>↓</sup> + tolowercase + [] + lowercase + + u + 6 + Zamień wielkie litery na małe. + + + + + + Podstawowa + basic_correction + {"exprs": [["\n\\d+\n", "\n"], ["-\\s*\n+", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]} + fulltextregexp + + + 0 + Wykonuję operację z novel-pages i poem-pages. + + + + + + Usuń spację + strip_whitespace + {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "]]} + lineregexp + + + 0 + Usuwa zbędne spację z dokumentu. + + + + + + Wers wcięty + wers-wciety + {"tag": "wers_wciety", "attrs": {"typ": ""}} + insert_tag + + + 0 + + + + + + + + Wydrukuj + print-xml + [] + + + + print/xml + + 0 + + + + + + + Wydrukuj + htmleditor-print + [] + + + + print/html + + 0 + + + + + + + Zamień cudzysłowy + zamien-cudzyslowy + {"exprs": [["\u00bb|\u201e", ",,"], ["\u00ab", "\""], ["\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", ",,$1"]]} + lineregexp + + + 0 + + + + + + + Zamień dywiz + zamien_dywiz + {"exprs": [["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"]]} + lineregexp + + + 0 + Zamienia '—' na '---', oraz '1—2' na '1--2'. + + + + + + akapit + akapit + {"tag": "akap"} + insert_tag + + + 0 + + + + + + + akapit cd. + akapit-cd + {"tag": "akap_cd"} + insert_tag + + + 0 + + + + + + + akapit dialogowy + akapit-dialogowy + {"tag": "akap_dialog"} + insert_tag + + + 0 + + + + + + + akt + akt + {"tag": "akt"} + insert_tag + + + 0 + + + + + + + autor + autor + {"tag": "autor"} + insert_tag + + + 0 + + + + + + + część/księga + czesc + {"tag": "naglowek_czesc"} + insert_tag + + + 0 + + + + + + + dedykacja + dedykacja + {"tag": "dedykacja"} + insert_tag + + + 0 + + + + + + + + didaskalia + didaskalia + {"tag": "didaskalia"} + insert_tag + + + 0 + + + + + + + + didaskalia początkowe + didaskalia-poczatkowe + {"tag": "miejsce_czas"} + insert_tag + + + 0 + + + + + + + didaskalia wewn. + didaskalia-wewn + {"tag": "didask_tekst"} + insert_tag + + + 0 + + + + + + + + dramat wiersz. + dramat-wiersz + {"tag": "dramat_wierszowany_l"} + insert_tag + + + 0 + + + + + + + dramat wiersz./w. łam + dramat-wiersz-w-lam + {"tag": "dramat_wierszowany_lp"} + insert_tag + + + 0 + + + + + + + dramat współczesny + dramat-wspolczesny + {"tag": "dramat_wspolczesny"} + insert_tag + + + 0 + + + + + + + dzieło nadrzędne + dzielo-nadrzedne + {"tag": "dzielo_nadrzedne"} + insert_tag + + + 0 + + + + + + + długi cyt. poet. + dlugi-cyt-poet + {"tag": "poezja_cyt"} + insert_tag + + + 0 + + + + + + + + długi cytat + dlugi-cytat + {"tag": "dlugi_cyt"} + insert_tag + + + 0 + + + + + + + + ekstra + ekstra + {"tag": "ekstra"} + insert_tag + + + 0 + + + + + + + kwestia + kwestia + {"tag": "kwestia"} + insert_tag + + + 0 + + + + + + + + liryka + liryka + {"tag": "liryka_l"} + insert_tag + + + 0 + + + + + + + liryka/w. łam + liryka-w-lam + {"tag": "liryka_lp"} + insert_tag + + + 0 + + + + + + + lista osób: pole + lista-osob-pole + {"tag": "lista_osoba", "attrs": {"typ": ""}} + insert_tag + + + 0 + + + + + + + mamtemat. + matemat + {"tag": "mat"} + insert_tag + + + 0 + + + + + + + motto + motto + {"tag": "motto"} + insert_tag + + + 0 + + + + + + + + motto podpis + motto-podpis + {"tag": "motto_podpis"} + insert_tag + + + 0 + + + + + + + nagłówek kwestii + naglowek-kwestii + {"tag": "naglowek_osoba"} + insert_tag + + + 0 + + + + + + + nota + nota + {"tag": "nota"} + insert_tag + + + 0 + + + + + + + opowiadanie + opowiadanie + {"tag": "opowiadanie"} + insert_tag + + + 0 + + + + + + + osoba + osoba + {"tag": "osoba"} + insert_tag + + + 0 + + + + + + + + podrozdział + podrozdzial + {"tag": "naglowek_podrozdzial"} + insert_tag + + + 0 + + + + + + + podtytuł + podtytul + {"tag": "podtytul"} + insert_tag + + + 0 + + + + + + + powieść + powiesc + {"tag": "powiesc"} + insert_tag + + + 0 + + + + + + + przypis autorski + przypis-autorski + {"tag": "pa"} + insert_tag + + + 0 + + + + + + + przypis edytorski + przypis-edytorski + {"tag": "pe"} + insert_tag + + + 0 + + + + + + + przypis redaktorski + przypis-redaktorski + {"tag": "pr"} + insert_tag + + + 0 + + + + + + + przypis tłumacza + przypis-tlumacza + {"tag": "pt"} + insert_tag + + + 0 + + + + + + + rozdział + rozdzial + {"tag": "naglowek_rozdzial"} + insert_tag + + + 0 + + + + + + + scena + scena + {"tag": "naglowek_scena"} + insert_tag + + + 0 + + + + + + + sep. asteryks + sep-asteryks + {"tag": "sekcja_asteryks"} + insert_tag + + + 0 + + + + + + + sep. linia + sep-linia + {"tag": "separator_linia"} + insert_tag + + + 0 + + + + + + + sep. światło + sep-swiatlo + {"tag": "sekcja_swiatlo"} + insert_tag + + + 0 + + + + + + + strofa + strofa + {"tag": "strofa"} + insert_stanza + + s + 1 + + + + + + + + słowo obce + slowo-obce + {"tag": "slowo_obce"} + insert_tag + + + 0 + + + + + + + tagi główne + tagi-glowne + {"tag": "utwor"} + insert_tag + + + 0 + + + + + + + tytuł + tytul + {"tag": "nazwa_utworu"} + insert_tag + + + 0 + + + + + + + tytuł dzieła + tytul-dziela + {"tag": "tytul_dziela", "attrs": {"typ": "1"}} + insert_tag + + + 0 + + + + + + + uwaga + uwaga + {"tag": "uwaga"} + insert_tag + + + 0 + + + + + + + wers akap. + wers-akap + {"tag": "wers_akap"} + insert_tag + + + 0 + + + + + + + + wers cd. + wers-cd + {"tag": "wers_cd"} + insert_tag + + + 0 + + + + + + + + www + www + {"tag": "www"} + insert_tag + + + 0 + + + + + + + wyróżnienie + wyroznienie + {"tag": "wyroznienie"} + insert_tag + + + 0 + + + + + + + wywiad + wywiad + {"tag": "wywiad"} + insert_tag + + + 0 + + + + + + + wywiad odpowiedź + wywiad-odpowiedz + {"tag": "wywiad_odp"} + insert_tag + + + 0 + + + + + + + wywiad pytanie + wywiad-pytanie + {"tag": "wywiad_pyt"} + insert_tag + + + 0 + + + + + + + zastępnik wersu + zastepnik-wersu + {"tag": "zastepnik_wersu"} + insert_tag + + + 0 + + + + + + + śródtytuł + srodtytul + {"tag": "srodtytul"} + insert_tag + + + 0 + + + + + + + var texteditor = panel.texteditor; + +var text = texteditor.selection(); + +var out = '<'+params.tag; + +for (var attr in params.attrs) { + + out += ' '+attr+'="' + params.attrs[attr] + '"'; + +}; + +out += '>'; + +out += text; + +out += '</' + params.tag + '>'; + + + +texteditor.replaceSelection(out); + + + +if (text.length == 0) { + + var pos = texteditor.cursorPosition(); + + texteditor.selectLines(pos.line, pos.character + params.tag.length + 2); + +} + + + +panel.fireEvent('contentChanged'); + + + editor.showPopup('generic-info', 'Przetwarzanie zaznaczonego tekstu...', '', -1); + +var cm = panel.texteditor; +var exprs = $.map(params.exprs, function(expr) { + + var opts = "g"; + + if(expr.length > 2) + + opts = expr[2]; + + return {rx: new RegExp(expr[0], opts), repl: expr[1]}; + +}); + + + +var partial = true; + +var text = cm.selection(); + + + +if(!text) { + + var cpos = cm.cursorPosition(); + + cpos.line = cm.lineNumber(cpos.line) + + cm.selectLines(cm.firstLine(), 0, cm.lastLine(), 0); + + text = cm.selection(); + + partial = false; + +} + + + +var changed = 0; +var lines = text.split('\n'); +var lines = $.map(lines, function(line) { + var old_line = line; + $(exprs).each(function() { + var expr = this; + line = line.replace(expr.rx, expr.repl); + }); + + if(old_line != line) changed += 1; + return line; +}); + +if(changed > 0) +{ + cm.replaceSelection( lines.join('\n') ); + panel.fireEvent('contentChanged'); + editor.showPopup('generic-yes', 'Zmieniono ' + changed + ' linii.', 1500); + editor.advancePopupQueue(); +} +else { + editor.showPopup('generic-info', 'Brak zmian w tekście', 1500); + editor.advancePopupQueue(); +} + +if(!partial) + cm.selectLines( cm.nthLine(cpos.line), cpos.character ) + + + var texteditor = panel.texteditor; + +var frameBody = $('body', $(texteditor.frame).contents()); + + + +if(params.fontSize) { + + frameBody.css('font-size', params.fontSize); + +} + +else { + + var old_size = parseInt(frameBody.css('font-size')); + + frameBody.css('font-size', old_size + (params.change || 0) ); + +} + + + editor.showPopup('generic-info', 'Przetwarzanie zaznaczonego tekstu...', '', -1); + +var cm = panel.texteditor; + +var exprs = $.map(params.exprs, function(expr) { + var opts = "mg"; + if(expr.length > 2) + opts = expr[2]; + + return {rx: new RegExp(expr[0], opts), repl: expr[1]}; +}); + +var partial = true; +var text = cm.selection(); + +if(!text) { + var cpos = cm.cursorPosition(); + cpos.line = cm.lineNumber(cpos.line) + cm.selectLines(cm.firstLine(), 0, cm.lastLine(), 0); + + text = cm.selection(); + partial = false; +} + + + +var original = text; +$(exprs).each(function() { + text = text.replace(this.rx, this.repl); +}); + +if( original != text) +{ + cm.replaceSelection(text); + panel.fireEvent('contentChanged'); + editor.showPopup('generic-yes', 'Zmieniono tekst' ); + editor.advancePopupQueue(); +} +else { + editor.showPopup('generic-info', 'Brak zmian w tekście.'); + editor.advancePopupQueue(); +} + +if(!partial) { + cm.selectLines( cm.nthLine(cpos.line), cpos.character ); +} + + + params.each(function() { + + editor.callScriptlet(this[0], this[1]); + +}); + + + var cm = panel.texteditor; + +var text = cm.selection(); + +if(!text) return; + +var repl = text.toLowerCase(); + +if(repl != text) { + + cm.replaceSelection(repl); + + panel.fireEvent('contentChanged'); + +}; + + + var texteditor = panel.texteditor; + +var text = texteditor.selection(); + + + +if(text) { + + text = '\n' + text.split('\n').join('\\\n') + '\n'; + +} + + + +texteditor.replaceSelection('<strofa>'+text+'</strofa>'); + + + +if (!text) { + + var pos = texteditor.cursorPosition(); + + texteditor.selectLines(pos.line, pos.character + 6 + 2); + +} + + + + + + + +panel.fireEvent('contentChanged'); + + diff --git a/project/admin.py b/project/admin.py deleted file mode 100644 index 7bf80973..00000000 --- a/project/admin.py +++ /dev/null @@ -1,4 +0,0 @@ -from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ - -import toolbar.admin \ No newline at end of file diff --git a/project/static/css/master.css b/project/static/css/master.css index 2eaf801e..33a9f684 100644 --- a/project/static/css/master.css +++ b/project/static/css/master.css @@ -161,25 +161,44 @@ label { } /* Toolbars with select box to change panel contents*/ -.panel-toolbar { +.panel-wrap .panel-toolbar { position: absolute; - top: 0px; left:0px; right: 0px; height: 24px; + top: 0px; left:0px; right: 0px; height: 26px; + padding: 0px; - padding: 0 0 2px 0; /* border-top: 1px solid #AAA; */ border-bottom: 1px solid #AAA; + z-index: 80; +} + +.panel-toolbar label { + display: inline; +} + +.panel-toolbar p { + /* position: relative; */ font-size: 12px; - line-height: 20px; + line-height: 26px; background-color: #DDD; white-space: nowrap; overflow: hidden; - z-index: 80; + + margin: 0px; + padding: 0px 1em; + + width: auto; + height: 26px; } -.panel-toolbar label { - display: block; - float: left; - margin: 0 10px 0 2px; + +.panel-toolbar .toolbar-button-groups-container .panel-toolbar-extra button { + /* this is uber specific */ + font-size: 12px; + font-family: Sans-Serif; + padding: 2px 5px; + margin: 0px; + border: 0px solid black; + vertical-align: bottom; } /* Slider between panels */ @@ -207,6 +226,8 @@ label { } + + /* ================= */ /* = Gallery panel = */ /* ================= */ @@ -215,38 +236,6 @@ label { overflow-y: scroll; } - -/* ==================== */ -/* = XML Editor panel = */ -/* ==================== */ - -.change-font-size { - width: 45px; - height: 18px; - padding: 3px 0 0; - position: absolute; - top: 0; - right: 0; -} - -.change-font-size div { - float: left; - text-align: center; - width: 20px; - font-size: 13px; - margin: 1px; - cursor: default; - border-radius: 2px; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; -} - -.change-font-size div:hover { - background-color: #EEE; - border: 1px solid #AAA; - margin: 0; -} - /* =========================== */ /* = DublinCore Editor panel = */ /* =========================== */ diff --git a/project/static/css/toolbar.css b/project/static/css/toolbar.css index f38f4ddb..4c5fa740 100644 --- a/project/static/css/toolbar.css +++ b/project/static/css/toolbar.css @@ -5,33 +5,33 @@ position: absolute; top: 0px; left:0px; right: 0px; height: auto; - padding: 1pt; - margin: 0pt; + padding: 2px; + margin: 0px; } .toolbar p { - margin: 0pt; + margin: 0px; - padding: 0pt; + padding: 0px; padding-left: 0.5em; border: none; background: #AAA; - font-size: 10pt; - line-height: 12pt; + font-size: 10px; + line-height: 12px; } .toolbar button { border: none; - padding: 2pt 0.5em; + padding: 2px 0.5em; background: #AAA; font-family: Sans-Serif; } .toolbar div { background: green; - margin: 0pt; - padding: 0pt; + margin: 0px; + padding: 0px; } .toolbar-tabs-container button.active { @@ -40,8 +40,8 @@ .toolbar-button-groups-container p { background: #DDD; - padding-top: 2pt; - padding-bottom: 2pt; + padding-top: 2px; + padding-bottom: 2px; } .toolbar-button-groups-container button { diff --git a/project/static/js/editor.js b/project/static/js/editor.js index f7f4cf31..ac34ac5a 100644 --- a/project/static/js/editor.js +++ b/project/static/js/editor.js @@ -85,6 +85,10 @@ Panel.prototype.unload = function(event, data) { if( data == this ) { $.log('unloading', this); $(this.contentDiv).html(''); + + // disconnect the toolbar + $('div.panel-toolbar span.panel-toolbar-extra', this.wrap).empty(); + this.callHook('unload'); this.hooks = null; // flush the hooks return false; @@ -137,6 +141,13 @@ Panel.prototype.connectToolbar = function() $.log('Connecting toolbar', toolbar); if(toolbar.length == 0) return; + // move the extra + var extra_buttons = $('span.panel-toolbar-extra', toolbar); + var placeholder = $('div.panel-toolbar span.panel-toolbar-extra', this.wrap); + placeholder.replaceWith(extra_buttons); + + var action_buttons = $('button', extra_buttons); + // connect group-switch buttons var group_buttons = $('*.toolbar-tabs-container button', toolbar); @@ -165,8 +176,11 @@ Panel.prototype.connectToolbar = function() }); // connect action buttons - var action_buttons = $('*.toolbar-button-groups-container button', toolbar); - action_buttons.each(function() { + var allbuttons = $.makeArray(action_buttons) + $.merge(allbuttons, + $.makeArray($('*.toolbar-button-groups-container button', toolbar)) ); + + $(allbuttons).each(function() { var button = $(this); var hk = button.attr('ui:hotkey'); if(hk) hk = new Hotkey( parseInt(hk) ); diff --git a/project/templates/explorer/editor.html b/project/templates/explorer/editor.html index fe9d93ab..891366b7 100644 --- a/project/templates/explorer/editor.html +++ b/project/templates/explorer/editor.html @@ -26,16 +26,16 @@ {% endblock extrabody %} -{% block breadcrumbs %}Platforma Redakcyjna > plik {{ hash }}{% endblock breadcrumbs %} +{% block breadcrumbs %}Platforma Redakcyjna > plik {{ fileid }}{% endblock breadcrumbs %} {% block header-toolbar %} -
+
+ ui:ajax-action="{% url file_update fileid %}">Update {% endblock %} @@ -58,15 +58,21 @@ {% for n in panel_list %}
- +

+ + + + + + {# Wydruk #} +

diff --git a/project/templates/explorer/panels/dceditor.html b/project/templates/explorer/panels/dceditor.html index a82f796c..a09f9bef 100644 --- a/project/templates/explorer/panels/dceditor.html +++ b/project/templates/explorer/panels/dceditor.html @@ -18,7 +18,7 @@ panel_hooks = { }, saveInfo: function(saveInfo) { var myInfo = { - url: "{% url file_dc fpath %}", + url: "{% url file_dc fileid %}", postData: $('form', this.contentDiv).serialize() }; $.extend(saveInfo, myInfo); diff --git a/project/templates/explorer/panels/htmleditor.html b/project/templates/explorer/panels/htmleditor.html index 3323cf18..3599dfed 100644 --- a/project/templates/explorer/panels/htmleditor.html +++ b/project/templates/explorer/panels/htmleditor.html @@ -1,4 +1,8 @@ +{% load toolbar_tags %} +{% toolbar toolbar_groups toolbar_extra_group %} + {{ html|safe }} +