"message": "You must first update your branch to the latest version."
})
- if base_doc.parentof(doc) or base_doc.has_parent_from(doc):
+ if not base_doc.would_share():
return response.SuccessAllOk().django_response({
"result": "no-op"
})
style = etree.parse(style_filename)
- data = u'<chunk>%s</chunk>' % LINE_SWAP_EXPR.sub(u'<br />\n', data)
+ data = u'<chunk><%s>%s</%s></chunk>' % (tag, LINE_SWAP_EXPR.sub(u'<br />\n', data), tag)
log.info(data)
doc = etree.parse( StringIO(data) )
}
result = doc.xslt(style, **opts)
- log.info( str(doc), str(result) )
-
- return HttpResponse( librarian.serialize_children(result.getroot()) )
\ No newline at end of file
+ return HttpResponse( librarian.serialize_children(result.getroot()[0]) )
\ No newline at end of file
"""List all documents in the library."""
pass
- def document_for_rev(self, rev):
+ def document_for_revision(self, rev):
"""Retrieve a document in the specified revision."""
pass
def parentof(self, other):
return self._revision.parentof(other._revision)
+ def parent(self):
+ return self._library.document_for_revision(self._revision.parent())
+
def has_parent_from(self, other):
return self._revision.has_parent_from(other._revision)
shared = self.shared()
- if shared.parentof(self):
+ if shared.ancestorof(self):
return True
if shared.has_parent_from(self):
raise wlrepo.UpdateException("Revision %s has children." % self.revision)
shared = self.shared()
-
- # the shared version comes from our version
- if self.parentof(self.shared()):
- return self
-
- # no changes since last update
+ # *
+ # /|
+ # * |
+ # | |
+ #
+ # we carry the latest version
if shared.ancestorof(self):
- return self
+ return self
- # last share was from this branch
- if shared.has_parent_from(self):
+ # *
+ # |\
+ # | *
+ # | |
+ #
+ # We just shared
+ if self.parentof(shared):
return self
- if self._revision.merge_with(sv._revision, user=user,\
+ # s s S
+ # | | |
+ # *<-S *<-*
+ # | | | .
+ #
+ # This is ok (s - shared, S - self)
+
+ if self._revision.merge_with(shared._revision, user=user,\
message="$AUTO$ Personal branch update."):
return self.latest()
else:
raise wlrepo.UpdateException("Merge failed.")
finally:
- lock.release()
+ lock.release()
- def share(self, message):
- lock = self.library.lock()
- try:
- # nothing to do
- if self.ismain():
- return self
+ def would_share(self):
+ if self.ismain():
+ return False
- shared = self.shared()
+ shared = self.shared()
- # we just did this - move on
- if self.parentof(shared):
- return shared
+ # we just did this - move on
+ if self.parentof(shared):
+ return False
+
+ # *
+ # /|
+ # * *
+ # |\|
+ # | *
+ # | |
+ # Situation above is ok - what we don't want, is:
+ # *
+ # /|
+ # * |
+ # |\|
+ # | *
+ # | |
+ # We want to prevent stuff like this.
+ if self.parent().parentof(shared):
+ return False
- # No changes since update
- if shared.parentof(self):
- return shared
+ def share(self, message):
+ lock = self.library.lock()
+ try:
+ if not self.would_share():
+ return self.shared()
+
# The good situation
#
# * local
def ospath(self):
return self._ospath.decode('utf-8')
- def document_for_rev(self, revision):
+ def document_for_revision(self, revision):
if revision is None:
raise ValueError("Revision can't be None.")
finally:
lock.release()
+ def parent(self):
+ parents = self._changectx.parents()
+
+ if len(parents) == 1:
+ return parents[0]
+
+ return parents[0] if (parents[0].branch() == self.branch()) else parents[1]
+
def __eq__(self, other):
return self._changectx.node() == other._changectx.node()
/* Style widoku HTML. Nie należy tu ustawiać position ani marginesów */
-@namespace wl2o "";
-
.htmlview {
counter-reset: main;
font-size: 16px;
padding: 3em;
}
+.htmlview * {
+ position: relative;
+}
+
.htmlview div {
max-width: 36em;
}
counter-increment: main;
}
-/* .htmlview *[wl2o\:editable] {
- background-color: pink;
+.htmlview *[x-editable] {
+ border: 2px solid white;
+ padding: 5px;
}
-.htmlview *[wl2o\:editable] *[wl2o\:editable] {
- background-color: red;
-} */
+/* focused editable element */
+.htmlview *[x-editable]:hover,
+.htmlview *[x-editable][x-open]
+{
+ background-color: #dfdfdf;
+ border: 2px solid black;
+}
+
+.htmlview *[x-editable] *.context-menu {
+ position: absolute;
+ top: -24px;
+ left: -2px;
+ height: 24px;
+
+ text-align: center;
+
+ font-size: 14px;
+ line-height: 24px;
+ font-weight: normal;
+ font-style: normal;
+
+ background-color: #dfdfdf;
+ margin: 0px;
+ padding: 0px;
+ border-top: 2px solid black;
+ border-left: 2px solid black;
+ border-right: 2px solid black;
+
+ display: none;
+ overflow: hidden;
+
+ -moz-border-radius-topright: 5px;
+ -moz-border-radius-topleft: 5px;
+
+ -webkit-border-top-right-radius: 5px;
+ -webkit-border-top-left-radius: 5px;
+}
+
+.htmlview *[x-editable] *.context-menu * {
+ padding: 5px;
+}
+
+.htmlview *[x-editable] *.context-menu *:hover {
+ background-color: yellow;
+}
+
+.htmlview *[x-editable]:hover *.context-menu {
+ display: block;
+}
+
+.htmlview *[x-editable][x-open] *.context-menu {
+ display: none;
+}
.htmlview .annotation:hover {
background-color: #dfdfdf;
getXMLPart: function(elem, callback)
{
- var path = elem.attr('wl2o:path');
+ var path = elem.attr('x-pointer');
if(!this.xmlParts[path])
this.loadXMLPart(elem, callback);
else
loadXMLPart: function(elem, callback)
{
- var path = elem.attr('wl2o:path');
+ var path = elem.attr('x-pointer');
var self = this;
$.ajax({
putXMLPart: function(elem, data) {
var self = this;
- var path = elem.attr('wl2o:path');
+ var path = elem.attr('x-pointer');
this.xmlParts[path] = data;
this.set('state', 'dirty');
$('.htmlview', this.element).html(this.model.get('data'));
this.modelStateChanged('state', this.model.get('state'));
- this.model.load();
+ this.model.load();
},
modelDataChanged: function(property, value) {
$('.htmlview', this.element).html(value);
this.updatePrintLink();
+
+ $("*[x-editable]").each(function() {
+ var e = $('<span class="context-menu"><span class="edit-button">Edytuj</span><span>Przypisy</span></span>');
+ e.appendTo(this);
+ });
},
updatePrintLink: function() {
this.updatePrintLink();
this.element.bind('click', this.itemClicked.bind(this));
+ // this.element.bind('mouseover', this.itemHover.bind(this));
},
reload: function() {
this._super();
},
+ itemHover: function(event)
+ {
+ var $e = $(event.target);
+ if( $e.attr('x-editable') == 'editable' ) {
+ console.log('over:', $e[0]);
+ $e.css({'background-color': 'grey'});
+ }
+
+ },
+
itemClicked: function(event)
{
var self = this;
var editableContent = null;
var $e = $(event.target);
- var n = 0;
+ if($e.hasClass('edit-button'))
+ this.openForEdit($e);
+ },
+
+ openForEdit: function($e)
+ {
+ var n = 0;
- while( ($e[0] != this.element[0]) && !($e.attr('wl2o:editable'))
+ while( ($e[0] != this.element[0]) && !($e.attr('x-editable'))
&& n < 50)
{
// console.log($e, $e.parent(), this.element);
n += 1;
}
- if(!$e.attr('wl2o:editable'))
+ if(!$e.attr('x-editable'))
return true;
-
- // start edition on this node
-
+ var $origin = $e;
+ console.log("editable: ", $e);
+
+ // start edition on this node
var $overlay = $(
'<div class="html-editarea">\n\
<p class="html-editarea-toolbar">\n\
var y = $e[0].offsetTop;
var w = $e.outerWidth();
var h = $e.innerHeight();
- $overlay.css({position: 'absolute', height: h, left: "5%", top: y, width: "90%"});
- $e.offsetParent().append($overlay);
+ $overlay.css({position: 'absolute', height: 1.2*h, left: x, top: y, width: w});
+ // $e.offsetParent().append($overlay);
- // load the original XML content
- console.log($e, $e.offsetParent(), $overlay);
+
- $('.html-editarea-cancel-button', $overlay).click(function() {
+ /* $('.html-editarea-cancel-button', $overlay).click(function() {
$overlay.remove();
});
// put the part back to the model
self.model.putXMLPart($e, $('textarea', $overlay).val());
- });
-
- $('textarea', $overlay).focus(function() {
- $overlay.css('z-index', 3000);
- }).blur(function() {
- $overlay.css('z-index', 2000);
- });
+ }); */
this.model.getXMLPart($e, function(path, data) {
$('textarea', $overlay).val(data);
});
-
+
+ $origin.attr('x-open', 'open');
return false;
}
<form method="POST" action="{% url django.contrib.auth.views.login %}">
{{ form.as_p }}
<p><input type="submit" value="Login" /></p>
-<input type="hidden" name="next" value="{{ next }}" />
+<input type="hidden" name="next" value="{{ next|urlencode }}" />
</form>
</div>