Helper do nazw utworów.
authorŁukasz Rekucki <lrekucki@gmail.com>
Fri, 11 Sep 2009 14:14:37 +0000 (16:14 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Fri, 11 Sep 2009 14:14:37 +0000 (16:14 +0200)
Przycisk do wydzielania.

apps/explorer/fixtures/przyciski.xml
apps/explorer/templatetags/__init__.py [new file with mode: 0755]
apps/explorer/templatetags/explorer_tags.py [new file with mode: 0755]

index 2065b15..afa1deb 100755 (executable)
       <object pk="24"/>
     </field>
   </object>
+  <object pk="88" model="toolbar.button">
+    <field type="CharField" name="label">Wydziel</field>
+    <field type="SlugField" name="slug">split-text-from-xmleditor</field>
+    <field type="TextField" name="params">[]</field>
+    <field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">show_splitmodal</field>
+    <field type="CharField" name="link"/>
+    <field type="CharField" name="key"/>
+    <field type="PositiveIntegerField" name="key_mod">0</field>
+    <field type="CharField" name="tooltip"/>
+    <field to="toolbar.buttongroup" name="group" rel="ManyToManyRel">
+      <object pk="23"/>
+    </field>
+  </object>
   <object pk="77" model="toolbar.button">
     <field type="CharField" name="label">Zamień cudzysłowy</field>
     <field type="SlugField" name="slug">zamien-cudzyslowy</field>
@@ -1177,4 +1190,39 @@ if (!text) {
 
 panel.fireEvent('contentChanged');</field>
   </object>
+  <object pk="show_splitmodal" model="toolbar.scriptlet">
+    <field type="TextField" name="code">var cm = panel.texteditor;
+
+cm.focus();
+
+var text = cm.selection();
+
+if(!text) return;
+
+
+
+cm.replaceSelection('&lt;include-tag-placeholder /&gt;');
+
+var fulltext = cm.getCode();
+
+
+
+$('#split-dialog').jqmShow({
+
+    selection: text, fulltext: fulltext,
+
+    success: function(uri) {
+
+        editor.refreshPanels();
+
+    },
+
+    failure: function() { cm.undo(); } 
+
+}) ;
+
+
+
+</field>
+  </object>
 </django-objects>
diff --git a/apps/explorer/templatetags/__init__.py b/apps/explorer/templatetags/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/apps/explorer/templatetags/explorer_tags.py b/apps/explorer/templatetags/explorer_tags.py
new file mode 100755 (executable)
index 0000000..a797b3a
--- /dev/null
@@ -0,0 +1,14 @@
+from django import template
+# from toolbar import models
+register = template.Library()
+
+from django.template.defaultfilters import stringfilter
+
+@register.filter(name='bookname')
+@stringfilter
+def bookname(fileid):
+    return ', '.join(\
+            ' '.join(s.capitalize() for s in part.split('_'))\
+        for part in fileid.split('$'))
+
+