From b3154a4f81c3a077d8e14ecc5a6826adb60f0548 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Marek=20St=C4=99pniowski?= <marek@stepniowski.com>
Date: Fri, 7 Aug 2009 13:28:31 +0200
Subject: [PATCH] =?utf8?q?=20-=20Dodanie=20przycisku=20obejmuj=C4=85cego?=
 =?utf8?q?=20zaznaczony=20tekst=20tagiem=20<rozdzial>=20(testowo).=20=20-?=
 =?utf8?q?=20Dodanie=20mo=C5=BCliwo=C5=9Bci=20ustalenia=20autora=20i=20wpi?=
 =?utf8?q?sania=20opisu=20zmian=20przy=20zapisywaniu=20pliku.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 apps/explorer/forms.py                   |  2 ++
 apps/explorer/views.py                   |  2 +-
 project/templates/explorer/file_xml.html | 11 +++++++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/apps/explorer/forms.py b/apps/explorer/forms.py
index 2d1c99a2..fd460ac1 100644
--- a/apps/explorer/forms.py
+++ b/apps/explorer/forms.py
@@ -5,6 +5,8 @@ from explorer import models
 
 class BookForm(forms.Form):
     text = forms.CharField(widget=forms.Textarea)
+    commit_message = forms.CharField()
+    user = forms.CharField()
     
 
 class ImageFoldersForm(forms.Form):
diff --git a/apps/explorer/views.py b/apps/explorer/views.py
index b8d00cf7..4a78e019 100644
--- a/apps/explorer/views.py
+++ b/apps/explorer/views.py
@@ -22,7 +22,7 @@ def file_xml(request, path):
         form = forms.BookForm(request.POST)
         if form.is_valid():
             repo.add_file(path, form.cleaned_data['text'])
-            repo.commit()
+            repo.commit(message=form.cleaned_data['commit_message'], user=form.cleaned_data['user'])
             return HttpResponseRedirect(request.get_full_path())
     else:
         form = forms.BookForm()
diff --git a/project/templates/explorer/file_xml.html b/project/templates/explorer/file_xml.html
index 3f50659c..66e128de 100644
--- a/project/templates/explorer/file_xml.html
+++ b/project/templates/explorer/file_xml.html
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 
 {% block extrahead %}
-    <script src="/static/js/jquery.lazyload.js" type="text/javascript" charset="utf-8"></script>
+    <script src="/static/js/jquery.fieldselection.js" type="text/javascript" charset="utf-8"></script>
     <script type="text/javascript" charset="utf-8">        
         function aboveViewport(container, element, treshold) {
             return $(container).offset().top >= $(element).offset().top + $(element).height() + treshold;
@@ -44,6 +44,12 @@
             });
             
             setTimeout(checkScroll, 2000);
+            
+            $('#rozdzial-button').click(function(event) {
+                console.log($('#id_text').getSelection().text);
+                $('#id_text').replaceSelection('<rozdzial>' + $('#id_text').getSelection().text + '</rozdzial>', true);
+                event.preventDefault();
+            });
         });
     </script>
 {% endblock extrahead %}
@@ -59,7 +65,8 @@
         </div>
     </div>
     <form action="." method="post" accept-charset="utf-8">
+        <a href="#" id="rozdzial-button">Rodział</a>
         {{ form.text }}
-        <p><input type="submit" value="Zapisz"/></p>
+        <p>Użytkownik: {{ form.user }} Opis zmian: {{ form.commit_message }} <input type="submit" value="Zapisz"/></p>
     </form>
 {% endblock maincontent %}    
-- 
2.20.1