From 58e0903a3f0e1e105a11638b18b588e9eb6a8b9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Sun, 11 Apr 2010 01:44:04 +0200 Subject: [PATCH] Key shortcuts in source editor work as expected, but only with "Alt" key. Support for other modifiers was removed as it didn't really worked too good on all browsers. --- apps/toolbar/admin.py | 53 +---- .../{toolbar.yaml => initial_data.yaml} | 207 ++++++------------ apps/toolbar/migrations/0001_initial.py | 93 ++++++++ ...ld_button_key_mod__chg_field_button_key.py | 52 +++++ .../0003_button_key_rename_to_accesskey.py | 47 ++++ apps/toolbar/migrations/__init__.py | 0 apps/toolbar/models.py | 30 +-- apps/toolbar/templates/toolbar/button.html | 6 +- .../wiki/templates/wiki/document_details.html | 1 + platforma/static/js/wiki/main.js | 4 + platforma/static/js/wiki/source_editor.js | 24 ++ 11 files changed, 301 insertions(+), 216 deletions(-) rename apps/toolbar/fixtures/{toolbar.yaml => initial_data.yaml} (91%) create mode 100644 apps/toolbar/migrations/0001_initial.py create mode 100644 apps/toolbar/migrations/0002_auto__del_field_button_key_mod__chg_field_button_key.py create mode 100644 apps/toolbar/migrations/0003_button_key_rename_to_accesskey.py create mode 100644 apps/toolbar/migrations/__init__.py diff --git a/apps/toolbar/admin.py b/apps/toolbar/admin.py index 93fedbba..7edd26b5 100644 --- a/apps/toolbar/admin.py +++ b/apps/toolbar/admin.py @@ -5,46 +5,7 @@ from django.utils import simplejson as json from toolbar import models -#class ButtonGroupAdmin(admin.ModelAdmin): -# list_display = ('name', 'slug', 'position',) -# search_fields = ('name', 'slug',) -# 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 - - def format_output(self, widgets): - out = u'' - out += u'

' + widgets[0] + u' Alt

' - out += u'

' + widgets[1] + u' Ctrl

' - out += u'

' + widgets[2] + u' Shift

' - return out - -class KeyModField(forms.MultiValueField): - - def __init__(self): - super(KeyModField, self).__init__(\ - fields = tuple(forms.BooleanField() for x in xrange(0, 3)), \ - widget = KeyModSelector()) - - def compress(self, dl): - v = int(dl[0]) | (int(dl[1]) << 1) | (int(dl[2]) << 2) - print "COMPRESS", v - return v - - class ButtonAdminForm(forms.ModelForm): - key_mod = KeyModField() - class Meta: model = models.Button @@ -52,24 +13,16 @@ class ButtonAdminForm(forms.ModelForm): value = self.cleaned_data['params'] try: return json.dumps(json.loads(value)) - except Exception, e: + except ValueError, e: raise forms.ValidationError(e) class ButtonAdmin(admin.ModelAdmin): form = ButtonAdminForm - list_display = ('slug', 'label', 'tooltip', 'hotkey_name') + list_display = ('slug', 'label', 'tooltip', 'accesskey') list_display_links = ('slug',) list_editable = ('label', 'tooltip',) prepopulated_fields = {'slug': ('label',)} admin.site.register(models.Button, ButtonAdmin) admin.site.register(models.ButtonGroup) -admin.site.register(models.Scriptlet) - -#class ButtonAdmin(admin.ModelAdmin): -# list_display = ('label', 'action', 'key', 'position',) -# list_filter = ('group',) -# search_fields = ('label', 'action', 'key',) -# filter_horizontal = ('group',) -# list_editable = ('position',) - +admin.site.register(models.Scriptlet) \ No newline at end of file diff --git a/apps/toolbar/fixtures/toolbar.yaml b/apps/toolbar/fixtures/initial_data.yaml similarity index 91% rename from apps/toolbar/fixtures/toolbar.yaml rename to apps/toolbar/fixtures/initial_data.yaml index bcc039f6..723732d2 100644 --- a/apps/toolbar/fixtures/toolbar.yaml +++ b/apps/toolbar/fixtures/initial_data.yaml @@ -39,8 +39,7 @@ pk: 17 - fields: group: [14, 12] - key: a - key_mod: 1 + accesskey: a label: akapit link: '' params: '{"tag": "akap"}' @@ -51,8 +50,7 @@ pk: 39 - fields: group: [14] - key: '' - key_mod: 0 + accesskey: '' label: akapit cd. link: '' params: '{"tag": "akap_cd"}' @@ -63,8 +61,7 @@ pk: 40 - fields: group: [14] - key: d - key_mod: 1 + accesskey: d label: akapit dialogowy link: '' params: '{"tag": "akap_dialog"}' @@ -75,8 +72,7 @@ pk: 41 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: akt link: '' params: '{"tag": "akt"}' @@ -87,8 +83,7 @@ pk: 14 - fields: group: [13] - key: '' - key_mod: 0 + accesskey: '' label: autor link: '' params: '{"tag": "autor_utworu"}' @@ -99,8 +94,7 @@ pk: 32 - fields: group: [2] - key: '' - key_mod: 0 + accesskey: '' label: Podstawowa link: '' params: '[["fulltextregexp", {"exprs": [["\ufeff", ""], ["$[\\s]*\\d+[\\s]*^", @@ -116,8 +110,7 @@ pk: 4 - fields: group: [2] - key: '' - key_mod: 0 + accesskey: '' label: "zamiana cudzys\u0142ow\xF3w 1" link: '' params: '{"exprs": [["\u00ab|\u201e", ",,"], ["\u00bb", "\""], ["([^=])\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", @@ -130,8 +123,7 @@ pk: 89 - fields: group: [2] - key: '' - key_mod: 0 + accesskey: '' label: "zamiana cudzys\u0142ow\xF3w 2" link: '' params: '{"exprs": [["\u00bb|\u201e", ",,"], ["\u00ab", "\""], ["([^=])\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", @@ -144,8 +136,7 @@ pk: 77 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: "cz\u0119\u015B\u0107/ksi\u0119ga" link: '' params: '{"tag": "naglowek_czesc"}' @@ -156,8 +147,7 @@ pk: 10 - fields: group: [13, 22] - key: '' - key_mod: 0 + accesskey: '' label: dedykacja link: '' params: '{"tag": "dedykacja"}' @@ -168,8 +158,7 @@ pk: 74 - fields: group: [12] - key: '' - key_mod: 0 + accesskey: '' label: didaskalia link: '' params: '{"tag": "didaskalia"}' @@ -180,8 +169,7 @@ pk: 62 - fields: group: [22] - key: '' - key_mod: 0 + accesskey: '' label: "didaskalia pocz\u0105tkowe" link: '' params: '{"tag": "miejsce_czas"}' @@ -192,8 +180,7 @@ pk: 79 - fields: group: [12] - key: '' - key_mod: 0 + accesskey: '' label: didaskalia tekstowe link: '' params: '{"tag": "didask_tekst"}' @@ -204,8 +191,7 @@ pk: 63 - fields: group: [21] - key: '' - key_mod: 0 + accesskey: '' label: "d\u0142ugi cyt. poet." link: '' params: '{"tag": "poezja_cyt"}' @@ -216,8 +202,7 @@ pk: 67 - fields: group: [21] - key: '' - key_mod: 0 + accesskey: '' label: "d\u0142ugi cytat" link: '' params: '{"tag": "dlugi_cyt"}' @@ -228,8 +213,7 @@ pk: 42 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: dramat wiersz. link: '' params: '{"tag": "dramat_wierszowany_l"}' @@ -240,8 +224,7 @@ pk: 20 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: "dramat wiersz./w. \u0142am" link: '' params: '{"tag": "dramat_wierszowany_lp"}' @@ -252,8 +235,7 @@ pk: 22 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: "dramat wsp\xF3\u0142czesny" link: '' params: '{"tag": "dramat_wspolczesny"}' @@ -264,8 +246,7 @@ pk: 21 - fields: group: [13] - key: '' - key_mod: 0 + accesskey: '' label: "dzie\u0142o nadrz\u0119dne" link: '' params: '{"tag": "dzielo_nadrzedne"}' @@ -276,8 +257,7 @@ pk: 38 - fields: group: [27] - key: '' - key_mod: 0 + accesskey: '' label: extra link: '' params: '{"tag": "extra"}' @@ -288,8 +268,7 @@ pk: 96 - fields: group: [] - key: '' - key_mod: 0 + accesskey: '' label: Wydrukuj link: print/html params: '[]' @@ -300,8 +279,7 @@ pk: 87 - fields: group: [12] - key: k - key_mod: 1 + accesskey: k label: kwestia link: '' params: '{"tag": "kwestia"}' @@ -312,8 +290,7 @@ pk: 82 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: liryka link: '' params: '{"tag": "liryka_l"}' @@ -324,8 +301,7 @@ pk: 23 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: "liryka/w. \u0142am" link: '' params: '{"tag": "liryka_lp"}' @@ -336,8 +312,7 @@ pk: 24 - fields: group: [22] - key: '' - key_mod: 0 + accesskey: '' label: "lista os\xF3b" link: '' params: '{"tag": "lista_osob"}' @@ -348,8 +323,7 @@ pk: 93 - fields: group: [22] - key: '' - key_mod: 0 + accesskey: '' label: 'typ osoby ' link: '' params: '{"tag": "lista_osoba", "attrs": {"typ": ""}}' @@ -360,8 +334,7 @@ pk: 78 - fields: group: [15] - key: '' - key_mod: 0 + accesskey: '' label: matemat. link: '' params: '{"tag": "mat"}' @@ -372,8 +345,7 @@ pk: 47 - fields: group: [13, 22] - key: '' - key_mod: 0 + accesskey: '' label: motto link: '' params: '{"tag": "motto"}' @@ -384,8 +356,7 @@ pk: 75 - fields: group: [13, 22] - key: '' - key_mod: 0 + accesskey: '' label: motto podpis link: '' params: '{"tag": "motto_podpis"}' @@ -396,8 +367,7 @@ pk: 37 - fields: group: [12] - key: '' - key_mod: 0 + accesskey: '' label: "nag\u0142\xF3wek kwestii" link: '' params: '{"tag": "naglowek_osoba"}' @@ -408,8 +378,7 @@ pk: 16 - fields: group: [22] - key: '' - key_mod: 0 + accesskey: '' label: "nag\u0142\xF3wek listy" link: '' params: '{"tag": "naglowek_listy"}' @@ -420,8 +389,7 @@ pk: 94 - fields: group: [13] - key: '' - key_mod: 0 + accesskey: '' label: nazwa utworu link: '' params: '{"tag": "nazwa_utworu"}' @@ -432,8 +400,7 @@ pk: 33 - fields: group: [13] - key: '' - key_mod: 0 + accesskey: '' label: nota link: '' params: '{"tag": "nota"}' @@ -444,8 +411,7 @@ pk: 35 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: opowiadanie link: '' params: '{"tag": "opowiadanie"}' @@ -456,8 +422,7 @@ pk: 18 - fields: group: [12] - key: b - key_mod: 1 + accesskey: b label: osoba link: '' params: '{"tag": "osoba"}' @@ -468,8 +433,7 @@ pk: 64 - fields: group: [22] - key: '' - key_mod: 0 + accesskey: '' label: osoba na liscie link: '' params: '{"tag": "lista_osoba"}' @@ -480,8 +444,7 @@ pk: 95 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: "podrozdzia\u0142" link: '' params: '{"tag": "naglowek_podrozdzial"}' @@ -492,8 +455,7 @@ pk: 12 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: "podtytu\u0142" link: '' params: '{"tag": "podtytul"}' @@ -504,8 +466,7 @@ pk: 34 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: "powie\u015B\u0107" link: '' params: '{"tag": "powiesc"}' @@ -516,8 +477,7 @@ pk: 19 - fields: group: [] - key: '' - key_mod: 0 + accesskey: '' label: Wydrukuj link: print/xml params: '[]' @@ -528,8 +488,7 @@ pk: 86 - fields: group: [26] - key: '' - key_mod: 0 + accesskey: '' label: przypis autorski link: '' params: '{"tag": "pa"}' @@ -540,8 +499,7 @@ pk: 68 - fields: group: [26] - key: '' - key_mod: 0 + accesskey: '' label: przypis edytorski link: '' params: '{"tag": "pe"}' @@ -552,8 +510,7 @@ pk: 71 - fields: group: [26] - key: '' - key_mod: 0 + accesskey: '' label: przypis redaktorski link: '' params: '{"tag": "pr"}' @@ -564,8 +521,7 @@ pk: 70 - fields: group: [26] - key: '' - key_mod: 0 + accesskey: '' label: "przypis t\u0142umacza" link: '' params: '{"tag": "pt"}' @@ -576,8 +532,7 @@ pk: 69 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: "rozdzia\u0142" link: '' params: '{"tag": "naglowek_rozdzial"}' @@ -588,8 +543,7 @@ pk: 11 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: scena link: '' params: '{"tag": "naglowek_scena"}' @@ -600,8 +554,7 @@ pk: 15 - fields: group: [16] - key: '' - key_mod: 0 + accesskey: '' label: asterysk link: '' params: '{"nocontent": "true", "tag": "sekcja_asterysk"}' @@ -612,8 +565,7 @@ pk: 54 - fields: group: [16] - key: '' - key_mod: 0 + accesskey: '' label: linia link: '' params: '{"nocontent": "true", "tag": "separator_linia"}' @@ -624,8 +576,7 @@ pk: 55 - fields: group: [16] - key: '' - key_mod: 0 + accesskey: '' label: "\u015Bwiat\u0142o" link: '' params: '{"nocontent": "true", "tag": "sekcja_swiatlo"}' @@ -636,8 +587,7 @@ pk: 53 - fields: group: [15] - key: '' - key_mod: 0 + accesskey: '' label: "s\u0142owo obce" link: '' params: '{"tag": "slowo_obce"}' @@ -648,8 +598,7 @@ pk: 46 - fields: group: [1] - key: '' - key_mod: 0 + accesskey: '' label: "\u015Br\xF3dtytu\u0142" link: '' params: '{"tag": "srodtytul"}' @@ -660,8 +609,7 @@ pk: 13 - fields: group: [2] - key: '' - key_mod: 0 + accesskey: '' label: "Usu\u0144 spacj\u0119" link: '' params: '{"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "], ["(,,)\\s+", "$1"], @@ -673,8 +621,7 @@ pk: 3 - fields: group: [12, 17] - key: s - key_mod: 1 + accesskey: s label: strofa link: '' params: '{"tag": "strofa"}' @@ -685,8 +632,7 @@ pk: 81 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: "tag g\u0142\xF3wny" link: '' params: '{"tag": "utwor"}' @@ -697,8 +643,7 @@ pk: 17 - fields: group: [2] - key: u - key_mod: 5 + accesskey: u label: "A\u2193" link: '' params: '[]' @@ -709,8 +654,7 @@ pk: 76 - fields: group: [15] - key: '' - key_mod: 0 + accesskey: '' label: "tytu\u0142 dzie\u0142a" link: '' params: '{"tag": "tytul_dziela"}' @@ -721,8 +665,7 @@ pk: 92 - fields: group: [15] - key: '' - key_mod: 0 + accesskey: '' label: "tytu\u0142 dzie\u0142a typ 1" link: '' params: '{"tag": "tytul_dziela", "attrs": {"typ": "1"}}' @@ -733,8 +676,7 @@ pk: 45 - fields: group: [27] - key: '' - key_mod: 0 + accesskey: '' label: uwaga link: '' params: '{"tag": "uwaga"}' @@ -745,8 +687,7 @@ pk: 51 - fields: group: [14, 17] - key: '' - key_mod: 0 + accesskey: '' label: wers akap. link: '' params: '{"tag": "wers_akap"}' @@ -757,8 +698,7 @@ pk: 83 - fields: group: [12, 17] - key: '' - key_mod: 0 + accesskey: '' label: wers cd. link: '' params: '{"tag": "wers_cd"}' @@ -769,8 +709,7 @@ pk: 85 - fields: group: [12, 17] - key: w - key_mod: 1 + accesskey: w label: "wers mocno wci\u0119ty" link: '' params: '{"tag": "wers_wciety", "attrs": {"typ": ""}}' @@ -781,8 +720,7 @@ pk: 84 - fields: group: [12, 17] - key: q - key_mod: 1 + accesskey: q label: "wers wci\u0119ty" link: '' params: '{"tag": "wers_wciety", "attrs": {"typ": "1"}}' @@ -793,8 +731,7 @@ pk: 91 - fields: group: [15] - key: '' - key_mod: 0 + accesskey: '' label: www link: '' params: '{"tag": "www"}' @@ -805,8 +742,7 @@ pk: 48 - fields: group: [15] - key: '' - key_mod: 0 + accesskey: '' label: "wyr\xF3\u017Cnienie" link: '' params: '{"tag": "wyroznienie"}' @@ -817,8 +753,7 @@ pk: 44 - fields: group: [11] - key: '' - key_mod: 0 + accesskey: '' label: wywiad link: '' params: '{"tag": "wywiad"}' @@ -829,8 +764,7 @@ pk: 25 - fields: group: [21] - key: '' - key_mod: 0 + accesskey: '' label: "wywiad odpowied\u017A" link: '' params: '{"tag": "wywiad_odp"}' @@ -841,8 +775,7 @@ pk: 73 - fields: group: [21] - key: '' - key_mod: 0 + accesskey: '' label: wywiad pytanie link: '' params: '{"tag": "wywiad_pyt"}' @@ -853,8 +786,7 @@ pk: 72 - fields: group: [2] - key: '' - key_mod: 0 + accesskey: '' label: "Zamie\u0144 dywiz" link: '' params: '{"exprs": [["(\\s)-(\\s)", "$1---$2"], ["^(\\s*)-(\\s)", "$1---$2"], @@ -867,8 +799,7 @@ pk: 2 - fields: group: [16] - key: '' - key_mod: 0 + accesskey: '' label: "zast\u0119pnik wersu" link: '' params: '{"tag": "zastepnik_wersu"}' diff --git a/apps/toolbar/migrations/0001_initial.py b/apps/toolbar/migrations/0001_initial.py new file mode 100644 index 00000000..974ea662 --- /dev/null +++ b/apps/toolbar/migrations/0001_initial.py @@ -0,0 +1,93 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding model 'ButtonGroup' + db.create_table('toolbar_buttongroup', ( + ('position', self.gf('django.db.models.fields.IntegerField')(default=0)), + ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)), + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=32)), + )) + db.send_create_signal('toolbar', ['ButtonGroup']) + + # Adding model 'Button' + db.create_table('toolbar_button', ( + ('key_mod', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, blank=True)), + ('scriptlet', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['toolbar.Scriptlet'], null=True, blank=True)), + ('tooltip', self.gf('django.db.models.fields.CharField')(max_length=120, blank=True)), + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('link', self.gf('django.db.models.fields.CharField')(default='', max_length=256, blank=True)), + ('key', self.gf('django.db.models.fields.CharField')(max_length=1, blank=True)), + ('params', self.gf('django.db.models.fields.TextField')(default='[]')), + ('label', self.gf('django.db.models.fields.CharField')(max_length=32)), + ('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50, db_index=True)), + )) + db.send_create_signal('toolbar', ['Button']) + + # Adding M2M table for field group on 'Button' + db.create_table('toolbar_button_group', ( + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), + ('button', models.ForeignKey(orm['toolbar.button'], null=False)), + ('buttongroup', models.ForeignKey(orm['toolbar.buttongroup'], null=False)) + )) + db.create_unique('toolbar_button_group', ['button_id', 'buttongroup_id']) + + # Adding model 'Scriptlet' + db.create_table('toolbar_scriptlet', ( + ('code', self.gf('django.db.models.fields.TextField')()), + ('name', self.gf('django.db.models.fields.CharField')(max_length=64, primary_key=True)), + )) + db.send_create_signal('toolbar', ['Scriptlet']) + + + def backwards(self, orm): + + # Deleting model 'ButtonGroup' + db.delete_table('toolbar_buttongroup') + + # Deleting model 'Button' + db.delete_table('toolbar_button') + + # Removing M2M table for field group on 'Button' + db.delete_table('toolbar_button_group') + + # Deleting model 'Scriptlet' + db.delete_table('toolbar_scriptlet') + + + models = { + 'toolbar.button': { + 'Meta': {'object_name': 'Button'}, + 'group': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['toolbar.ButtonGroup']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '1', 'blank': 'True'}), + 'key_mod': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1', 'blank': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'link': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}), + 'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}), + 'scriptlet': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['toolbar.Scriptlet']", 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}), + 'tooltip': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}) + }, + 'toolbar.buttongroup': { + 'Meta': {'object_name': 'ButtonGroup'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'position': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}) + }, + 'toolbar.scriptlet': { + 'Meta': {'object_name': 'Scriptlet'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'primary_key': 'True'}) + } + } + + complete_apps = ['toolbar'] diff --git a/apps/toolbar/migrations/0002_auto__del_field_button_key_mod__chg_field_button_key.py b/apps/toolbar/migrations/0002_auto__del_field_button_key_mod__chg_field_button_key.py new file mode 100644 index 00000000..09ddd323 --- /dev/null +++ b/apps/toolbar/migrations/0002_auto__del_field_button_key_mod__chg_field_button_key.py @@ -0,0 +1,52 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Deleting field 'Button.key_mod' + db.delete_column('toolbar_button', 'key_mod') + + # Changing field 'Button.key' + db.alter_column('toolbar_button', 'key', self.gf('django.db.models.fields.CharField')(max_length=1, null=True)) + + def backwards(self, orm): + + # Adding field 'Button.key_mod' + db.add_column('toolbar_button', 'key_mod', self.gf('django.db.models.fields.PositiveIntegerField')(default=1, blank=True), keep_default=False) + + # Changing field 'Button.key' + db.alter_column('toolbar_button', 'key', self.gf('django.db.models.fields.CharField')(max_length=1, blank=True)) + + models = { + 'toolbar.button': { + 'Meta': {'object_name': 'Button'}, + 'group': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['toolbar.ButtonGroup']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'link': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}), + 'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}), + 'scriptlet': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['toolbar.Scriptlet']", 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}), + 'tooltip': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}) + }, + 'toolbar.buttongroup': { + 'Meta': {'object_name': 'ButtonGroup'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'position': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}) + }, + 'toolbar.scriptlet': { + 'Meta': {'object_name': 'Scriptlet'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'primary_key': 'True'}) + } + } + + complete_apps = ['toolbar'] diff --git a/apps/toolbar/migrations/0003_button_key_rename_to_accesskey.py b/apps/toolbar/migrations/0003_button_key_rename_to_accesskey.py new file mode 100644 index 00000000..0d2e9068 --- /dev/null +++ b/apps/toolbar/migrations/0003_button_key_rename_to_accesskey.py @@ -0,0 +1,47 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Deleting field 'Button.key' + db.rename_column('toolbar_button', 'key', 'accesskey') + + + + def backwards(self, orm): + db.rename_column('toolbar_button', 'accesskey', 'key') + + + models = { + 'toolbar.button': { + 'Meta': {'object_name': 'Button'}, + 'accesskey': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True'}), + 'group': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['toolbar.ButtonGroup']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'link': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}), + 'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}), + 'scriptlet': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['toolbar.Scriptlet']", 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}), + 'tooltip': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}) + }, + 'toolbar.buttongroup': { + 'Meta': {'object_name': 'ButtonGroup'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'position': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}) + }, + 'toolbar.scriptlet': { + 'Meta': {'object_name': 'Scriptlet'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'primary_key': 'True'}) + } + } + + complete_apps = ['toolbar'] diff --git a/apps/toolbar/migrations/__init__.py b/apps/toolbar/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/toolbar/models.py b/apps/toolbar/models.py index 6a20263e..d736c027 100644 --- a/apps/toolbar/models.py +++ b/apps/toolbar/models.py @@ -56,8 +56,8 @@ class Button(models.Model): link = models.CharField(max_length = 256, blank = True, default = '') # ui related stuff - key = models.CharField(blank = True, max_length = 1) - key_mod = models.PositiveIntegerField(blank = True, default = 1) + accesskey = models.CharField(null = True, max_length = 1) + tooltip = models.CharField(blank = True, max_length = 120) # Why the button is restricted to have the same position in each group ? @@ -68,32 +68,15 @@ class Button(models.Model): ordering = ('slug',) verbose_name, verbose_name_plural = _('button'), _('buttons') - @property - def hotkey_code(self): - return ord(self.key.upper()) | (self.key_mod << 8) - - @property - def hotkey_name(self): - if not self.key: - return '' - - mods = [] - if self.key_mod & 0x01: mods.append('Alt') - if self.key_mod & 0x02: mods.append('Ctrl') - if self.key_mod & 0x04: mods.append('Shift') - mods.append(str(self.key)) - return '[' + '+'.join(mods) + ']' - @property def full_tooltip(self): - return self.tooltip + (' ' + self.hotkey_name if self.key else '') + return u"%s %s" % (self.tooltip, "[Alt+%s]" % self.accesskey if self.accesskey else "") def to_dict(self): return { 'label': self.label, - 'tooltip': (self.tooltip or '') + self.hotkey_name(), - 'key': self.key, - 'key_mod': self.key_mod, + 'tooltip': self.tooltip, + 'accesskey': self.accesskey, 'params': self.params, 'scriptlet_id': self.scriptlet_id } @@ -105,8 +88,5 @@ class Scriptlet(models.Model): name = models.CharField(max_length = 64, primary_key = True) code = models.TextField() - # TODO: add this later and remap code property to this - # code_min = models.TextField() - def __unicode__(self): return _(u'javascript') + u':' + self.name diff --git a/apps/toolbar/templates/toolbar/button.html b/apps/toolbar/templates/toolbar/button.html index 92c51a18..2ecb1ab9 100644 --- a/apps/toolbar/templates/toolbar/button.html +++ b/apps/toolbar/templates/toolbar/button.html @@ -4,9 +4,9 @@ {% if button.link %} diff --git a/apps/wiki/templates/wiki/document_details.html b/apps/wiki/templates/wiki/document_details.html index cbed276c..9031d19d 100644 --- a/apps/wiki/templates/wiki/document_details.html +++ b/apps/wiki/templates/wiki/document_details.html @@ -5,6 +5,7 @@ {% load compressed %} {% compressed_css 'detail' %} {% endblock %} + {% block extrabody %}