Add w repo chyba dziala.
print "SAVING DC"
# zapisz
- repo._add_file(path, document.serialize())
+ repo._write_file(path, document.serialize())
repo._commit( \
message=(form.cleaned_data['commit_message'] or 'Lokalny zapis platformy.'), \
user=request.user.username )
# Display the main editor view
@login_required
-def display_editor(request, path):
+@with_repo
+def display_editor(request, path, repo):
+ path = unicode(path).encode("utf-8")
+ if not repo.file_exists(path, models.user_branch(request.user)):
+ try:
+ data = repo.get_file(path, 'default')
+ print type(data)
+
+ def new_file():
+ repo._add_file(path, data)
+ repo._commit(message='File import from default branch',
+ user=request.user.username)
+
+ repo.in_branch(new_file, models.user_branch(request.user) )
+ except hg.RepositoryException, e:
+ return direct_to_templace(request, 'explorer/file_unavailble.html',\
+ extra_context = { 'path': path, 'error': e })
+
return direct_to_template(request, 'explorer/editor.html', extra_context={
'hash': path,
'panel_list': ['lewy', 'prawy'],
return self.in_branch(lambda: self._get_file(path), branch)
def _get_file(self, path):
+ if not self._file_exists(path):
+ raise RepositoryException("File not availble in this branch.")
+
return self.repo.wread(path)
-
+
+ def file_exists(self, path, branch):
+ return self.in_branch(lambda: self._file_exists(path), branch)
+
+ def _file_exists(self, path):
+ return self.repo.dirstate[path] != "?"
+
+ def write_file(self, path, value, branch):
+ return self.in_branch(lambda: self._write_file(path, value), branch)
+
+ def _write_file(self, path, value):
+ return self.repo.wwrite(path, value, [])
+
def add_file(self, path, value, branch):
return self.in_branch(lambda: self._add_file(path, value), branch)
def _add_file(self, path, value):
- return self.repo.wwrite(path, value.encode('utf-8'), [])
+ self._write_file(path, value)
+ return self.repo.add( [path] )
def _commit(self, message, user=None):
return self.repo.commit(text=message, user=user)
background: #AAA;
position: absolute;
top: 0px; left:0px; right: 0px;
- height: 40pt;
+ height: auto;
padding: 1pt;
margin: 0pt;
}
panel_hooks = null;
self.connectToolbar();
self.callHook('load');
+ self.callHook('toolbarResized');
},
error: function(request, textStatus, errorThrown) {
$.log('ajax', url, this.target, 'error:', textStatus, errorThrown);
else
$(this).show();
});
+ self.callHook('toolbarResized');
}
});
});
{% load toolbar_tags %}
-<div class="iframe-container" style="position: absolute; top: 41pt; left:0px; right:0px; bottom: 0px;">
+<div class="iframe-container" style="position: absolute; top: 40px; left:0px; right:0px; bottom: 0px;">
<textarea name="text">{{ text }}</textarea>
</div>
var panel = self.contentDiv;
var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
- $('textarea', panel).attr('id', textareaId);
+ $('textarea', panel).attr('id', textareaId);
var texteditor = CodeMirror.fromTextArea(textareaId, {
parserfile: 'parsexml.js',
texteditor.grabKeys(
$.fbind(self, self.hotkeyPressed),
$.fbind(self, self.isHotkey) );
+
}
})
}
};
$.extend(saveInfo, myInfo);
- }
+ },
+
+ toolbarResized: function() {
+ $('.iframe-container', self.contentDiv).css('top',
+ $('.toolbar', self.contentDiv).outerHeight() );
+ }
};
</script>