1 {% extends "base.html" %}
4 <script src="{{STATIC_URL}}js/lib/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script>
5 <script src="{{STATIC_URL}}js/lib/jquery.splitter.js" type="text/javascript" charset="utf-8"></script>
6 <script src="{{STATIC_URL}}js/lib/jquery.form.js" type="text/javascript" charset="utf-8"></script>
7 <script type="text/javascript" charset="utf-8">
9 function serialize(element) {
10 if (element.nodeType == 3) {
11 return [$.trim(element.nodeValue)];
17 result.push(element.tagName);
19 var ns = element.tagName.indexOf(':');
20 if (ns != -1 && $.browser.mozilla) {
21 result.push(' xmlns:');
22 result.push(element.tagName.substring(0, ns));
24 result.push(element.namespaceURI);
28 if (element.attributes) {
29 for (var i=0; i < element.attributes.length; i++) {
30 var attr = element.attributes[i];
32 result.push(attr.name);
34 result.push(attr.value);
41 for (var i=0; i < element.childNodes.length; i++) {
42 var child = element.childNodes[i];
43 result = result.concat(serialize(child));
47 result.push(element.tagName);
50 if (element.tagName == 'akap') {
51 result.push('\n\n\n');
52 } else if (element.tagName == 'rdf:RDF') {
53 result.push('\n\n\n\n\n');
54 } else if (element.tagName.indexOf('dc:') != -1) {
63 var editor = CodeMirror.fromTextArea('id_text', {
64 parserfile: 'parsexml.js',
65 path: "{{ STATIC_URL }}js/lib/codemirror/",
66 stylesheet: "{{ STATIC_URL }}css/xmlcolors.css",
75 $('#splitter').splitter({
84 $(window).resize(function() {
85 $('iframe').height($(window).height() - $('#tabs').outerHeight());
90 $('.vsplitbar').dblclick(function() {
91 if ($('#sidebar').width() == 0) {
92 $('#splitter').trigger('resize', [$(window).width() - 480]);
94 $('#splitter').trigger('resize', [$(window).width()]);
98 loadSuccess = function() {
99 if (this.get('state') != 'loading') {
100 alert('erroneous state:', this.get('state'));
106 messageCenter.addMessage('success', 'xmlload', 'Wczytałem HTML :-)');
109 function createXSLT(xsl) {
110 var p = new XSLTProcessor();
111 p.importStylesheet(xsl);
115 function transform() {
117 url: '{{ STATIC_URL }}xsl/wl2html_client.xsl',
119 success: function(data) {
121 var parser = new DOMParser();
122 var serializer = new XMLSerializer();
123 var htmlXSL = createXSLT(data);
125 doc = editor.getCode().replace(/\/\s+/g, '<br />');
126 doc = parser.parseFromString(doc, 'text/xml');
127 console.log('xml', doc);
128 doc = htmlXSL.transformToFragment(doc, document);
129 console.log('after transform', doc);
130 $('#simple-editor').html(doc.firstChild);
132 error: function() {alert('Error loading XSL!')}
136 function reverseTransform () {
138 url: '{{ STATIC_URL }}xsl/html2wl_client.xsl',
140 success: function(data) {
142 var parser = new DOMParser();
143 var serializer = new XMLSerializer();
144 var xsl = createXSLT(data);
146 doc = serializer.serializeToString($('#simple-editor div').get(0))
147 doc = parser.parseFromString(doc, 'text/xml');
148 console.log('xml',doc, doc.documentElement);
149 doc = xsl.transformToDocument(doc);
150 console.log('after transform', doc, doc.documentElement);
151 doc = serialize(doc.documentElement).join('');
152 // doc = serializer.serializeToString(doc.documentElement)
155 error: function() {alert('Error loading XSL!')}
159 $('#save-button').click(function(event) {
160 event.preventDefault();
161 console.log(editor.getCode(), $('form input[name=text]').get(0));
162 $('form textarea[name=text]').val(editor.getCode());
163 $('form').ajaxSubmit(function() {
168 $('#simple-view-tab').click(function() {
169 $(this).addClass('active');
170 $('#source-view-tab').removeClass('active');
171 $('#source-editor').hide();
172 $('#simple-editor').show();
176 $('#source-view-tab').click(function() {
177 $(this).addClass('active');
178 $('#simple-view-tab').removeClass('active');
179 $('#simple-editor').hide();
180 $('#source-editor').show();
186 <style type="text/css" media="screen">
196 background: #EEE url(/static/img/gallery.png) no-repeat scroll center center;
197 border-left: 1px solid #999;
202 background-color: #DDD;
218 background-color: #C1C1C1;
219 background-image: -webkit-gradient(linear, left top, left bottom, from(#C1C1C1), color-stop(0.9, #A2A2A2));
220 font: 11px Helvetica, Verdana, sans-serif;
227 font: 17px Helvetica, Verdana, sans-serif;
230 padding: 3px 6px 2px 6px;
241 border-bottom: 1px solid #777;
245 -webkit-user-select: none;
249 padding: 5px 12px 3px 12px;
250 border: 1px solid #999;
251 -webkit-border-radius: 4px;
252 -webkit-border-bottom-left-radius: 0;
253 -webkit-border-bottom-right-radius: 0;
256 /* text-shadow: #CCC 1px 1px 1px;*/
258 background-color: #C1C1C1;
259 -webkit-box-shadow: 1px -1px 2px rgba(127, 127, 127, 0.25);
265 background-color: #FFF;
266 background-image: none;
267 /* background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.25, #C1C1C1), to(#FFFFFF)); */
268 border-bottom: 1px solid #FFF;
273 {% block maincontent %}
274 <form action="{% url wiki.views.document_detail document.name|urlencode %}" method="post" accept-charset="utf-8">
276 <div id="tools" style="float: right;">Wersja: {{ document.revision }}<button style="margin-left: 6px" id="save-button">Zapisz</button></div>
277 <h1>{{ document.name }}</h1>
279 <li id="simple-view-tab">Widok prosty</li>
280 <li id="source-view-tab" class="active">Widok zaawansowany</li>
282 <div style="clear: both"></div>
286 <div id="source-editor">
288 <input type="hidden" name="name" value="{{ document.name }}" />
289 <input type="hidden" name="author" value="annonymous" />
290 <input type="hidden" name="comment" value="no comment" />
291 <input type="hidden" name="revision" value="{{ document.revision }}" />
293 <div id="simple-editor" style="display: none">
297 <div id="sidebar" style="width: 200px">
298 <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
299 <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>