localsettings.py
dev.sqlite
requirements.pybundle
+*~
# Python garbage
*.pyc
from django.utils.translation import ugettext_lazy as _
DOCUMENT_TAGS = (
- ("source", _("Tekst źródłowy")),
- ("first_correction", _("Po autokorekcie")),
- ("tagged", _("Tekst otagowany")),
- ("second_correction", _("Po korekcie")),
- ("source_annotations", _("Sprawdzone przypisy źródła")),
- ("language_updates", _("Uwspółcześnienia")),
- ("ready_to_publish", _("Tekst do publikacji")),
+ ("source", _(u"Tekst źródłowy")),
+ ("first_correction", _(u"Po autokorekcie")),
+ ("tagged", _(u"Tekst otagowany")),
+ ("second_correction", _(u"Po korekcie")),
+ ("source_annotations", _(u"Sprawdzone przypisy źródła")),
+ ("language_updates", _(u"Uwspółcześnienia")),
+ ("ready_to_publish", _(u"Tekst do publikacji")),
)
DOCUMENT_TAGS_DICT = dict(DOCUMENT_TAGS)
DOCUMENT_STAGES = (
- ("first_correction", _("Autokorekta")),
- ("tagged", _("Tagowanie")),
- ("second_correction", _("Korekta")),
- ("source_annotations", _("Przypisy źródła")),
- ("language_updates", _("Uwspółcześnienia")),
+ ("first_correction", _(u"Autokorekta")),
+ ("tagged", _(u"Tagowanie")),
+ ("second_correction", _(u"Korekta")),
+ ("source_annotations", _(u"Przypisy źródła")),
+ ("language_updates", _(u"Uwspółcześnienia")),
)
DOCUMENT_STAGES_DICT = dict(DOCUMENT_STAGES)
class DocumentTextSaveForm(forms.Form):
- """if
+ """
Form for saving document's text:
* name - document's storage identifier.
kwargs.pop('mimetype', None)
data = json.dumps(data, cls=ExtendedEncoder)
- print data
super(JSONResponse, self).__init__(data, mimetype="application/json", **kwargs)
return Document(self, name=name, text=text, revision=rev)
def get_by_tag(self, name, tag):
- text, rev = self.vstorage.page_text(name, tag)
+ text, rev = self.vstorage.page_text_by_tag(name, tag)
return Document(self, name=name, text=text, revision=rev)
def get_or_404(self, *args, **kwargs):
def diff_replace(match):
return """<span class="diff_mark diff_mark_%s">""" % NAMES[match.group(1)]
+
def filter_line(line):
return DIFF_RE.sub(diff_replace, html_escape(line)).replace('\x01', '</span>')
+
def format_changeset(a, b, change):
return (a[0], filter_line(a[1]), b[0], filter_line(b[1]), change)
+
def html_diff_table(la, lb, context=None):
all_changes = difflib._mdiff(la, lb)
{% endblock leftcolumn %}
</div>
<div id="wiki_layout_right_column">
- {% block rightcolumn %}
+ {% block rightcolumn %}
{% endblock rightcolumn %}
</div>
{% endblock maincontent %}
\ No newline at end of file
{% block leftcolumn %}
<form enctype="multipart/form-data" method="POST" action="">
{{ form.as_p }}
-
+
<p><button type="submit">Stwórz utwór</button></p>
</form>
{% endblock leftcolumn %}
-{% block rightcolumn %}
+{% block rightcolumn %}
{% endblock rightcolumn %}
\ No newline at end of file
<div id="history-view-editor" class="editor" style="display: none">
<div class="toolbar">
- <button type="button" id="make-diff-button">Porównaj</button>
+ <button type="button" id="make-diff-button">Porównaj</button>
<button type="button" id="tag-changeset-button">Oznacz wersje</button>
- </div>
+ </div>
<div id="history-view">
<p class="message-box" style="display:none;"></p>
-
+
<table id="changes-list-container">
- <tbody id="changes-list">
+ <tbody id="changes-list">
</tbody>
<tbody style="display: none;">
- <tr class="entry row-stub">
+ <tr class="entry row-stub">
<td data-stub-value="version"></td>
<td>
<span data-stub-value="description"></span>
<br />
<span data-stub-value="author"></span>, <span data-stub-value="date"></span>
</td>
- <td data-stub-value="tag">
+ <td data-stub-value="tag">
</td>
</tr>
</tbody>
- </table>
+ </table>
</div>
</div>
<span data-ui-error-for="{{ forms.text_save.comment.name }}"> </span>
</p>
{{forms.text_save.comment }}
-
-
-
+
+
+
{% if request.user.is_anonymous %}
<p>
- {{ forms.text_save.author.label }}:
+ {{ forms.text_save.author.label }}:
{{ forms.text_save.author }}
<span class="help_text">{{ forms.text_save.author.help_text }}</span>
<span data-ui-error-for="{{ forms.text_save.author.name }}"> </span>
</p>
{% else %}
<p>
- {{ forms.text_save.stage_completed.label }}:
+ {{ forms.text_save.stage_completed.label }}:
{{ forms.text_save.stage_completed }}
<span class="help_text">{{ forms.text_save.stage_completed.help_text }}</span>
<span data-ui-error-for="{{ forms.text_save.stage_completed.name }}"> </span>
</p>
{% endif %}
-
-
+
+
{% for f in forms.text_save.hidden_fields %}
{{ f }}
{% endfor %}
-
+
<p data-ui-error-for="__all__"> </p>
-
+
<p class="action_area">
<button type="submit" class"ok" data-ui-action="save">Zapisz</button>
<button type="button" class="cancel" data-ui-action="cancel">Anuluj</button>
- </p>
- </form>
+ </p>
+ </form>
</div>
</div> -->
<div id="summary-view">
<img class="book-cover" src="{{MEDIA_URL}}images/empty.png">
-
+
<h2>
<label for="title">Tytuł:</label>
<span data-ui-editable="true" data-edit-target="meta.displayTitle"
<span data-ui-editable="true" data-edit-target="meta.galleryLink"
>{{ document_meta.gallery}}</span>
</p>
-
- <p><button type="button">Publikuj na wolnelektury.pl</button></p>
+
+ <p><button type="button" id="publish_button">Publikuj na wolnelektury.pl</button></p>
</div>
</div>
\ No newline at end of file
<div id="add_tag_dialog" class="dialog" data-ui-jsclass="AddTagDialog">
<form method="POST" action="#">
{% for field in forms.add_tag.visible_fields %}
- <p>{{ field.label_tag }} {{ field }} <span data-ui-error-for="{{ field.name }}"> </span></p>
- <p>{{ field.help_text }}</p>
+ <p>{{ field.label_tag }} {{ field }} <span data-ui-error-for="{{ field.name }}"> </span></p>
+ <p>{{ field.help_text }}</p>
{% endfor %}
-
-
- {% for f in forms.text_save.hidden_fields %}
+
+ {% for f in forms.add_tag.hidden_fields %}
{{ f }}
{% endfor %}
- <p data-ui-error-for="__all__"> </p>
-
+ <p data-ui-error-for="__all__"> </p>
+
<p class="action_area">
<button type="submit" class"ok" data-ui-action="save">Zapisz</button>
<button type="button" class="cancel" data-ui-action="cancel">Anuluj</button>
- </p>
+ </p>
</form>
</div>
'document_diff', name="wiki_diff"),
url(r'^(?P<name>[^/]+)/tags$',
'document_add_tag', name="wiki_add_tag"),
- url(r'^(?P<name>[^/]+)/tags$',
- 'document_publish'),
+ url(r'^(?P<name>[^/]+)/publish$', 'document_publish'),
url(r'^(?P<name>[^/]+)$',
'document_detail', name="wiki_details"),
)
'document_meta': document.meta,
'forms': {
"text_save": DocumentTextSaveForm(prefix="textsave"),
- "add_tag": DocumentTagForm(prefix="addtag")
+ "add_tag": DocumentTagForm(prefix="addtag"),
},
})
self.repo.remove([repo_file])
self._commit([repo_file], text, user)
-# @with_working_copy_locked
-# def _open_page(self, title):
-# if title not in self:
-# raise DocumentNotFound()
-#
-# path = self._title_to_file(title)
-# logger.debug("Opening page %s", path)
-# try:
-# return self.repo.wfile(path, 'rb')
-# except IOError:
-# logger.exception("Failed to open page %s", title)
-# raise DocumentNotFound()
-
def page_text(self, title, revision=None):
"""Read unicode text of a page."""
ctx = self._find_filectx(title, revision)
def page_text_by_tag(self, title, tag):
"""Read unicode text of a taged page."""
- tag = u"{title}#{tag}".format(**locals()).encode('utf-8')
fname = self._title_to_file(title)
+ tag = u"{fname}#{tag}".format(**locals()).encode('utf-8')
try:
ctx = self.repo[tag][fname]
return ctx.data().decode(self.charset, 'replace'), ctx.filerev()
except IndexError:
- raise DocumentNotFound()
+ raise DocumentNotFound(fname)
@with_working_copy_locked
def page_file_meta(self, title):
def page_meta(self, title):
"""Get page's revision, date, last editor and his edit comment."""
if not title in self:
- raise DocumentNotFound()
+ raise DocumentNotFound(title)
filectx_tip = self._find_filectx(title)
if filectx_tip is None:
- raise DocumentNotFound()
+ raise DocumentNotFound(title)
rev = filectx_tip.filerev()
filectx = filectx_tip.filectx(rev)
date = datetime.datetime.fromtimestamp(filectx.date()[0])
def _find_filectx(self, title, rev=None):
"""Find the last revision in which the file existed."""
-
repo_file = self._title_to_file(title)
-
changectx = self._changectx() # start with tip
stack = [changectx]
return fctx
except (IndexError, LookupError) as e:
- raise DocumentNotFound()
+ raise DocumentNotFound(title)
def page_history(self, title):
"""Iterate over the page's history."""
@with_working_copy_locked
def add_page_tag(self, title, rev, tag, user, doctag=True):
+ ctitle = self._title_to_file(title)
+
if doctag:
- tag = u"{title}#{tag}".format(**locals()).encode('utf-8')
+ tag = u"{ctitle}#{tag}".format(**locals()).encode('utf-8')
- message = u"Assigned tag {tag!r} to version {rev!r} of {title!r}".format(**locals()).encode('utf-8')
+ message = u"Assigned tag {tag!r} to version {rev!r} of {ctitle!r}".format(**locals()).encode('utf-8')
fctx = self._find_filectx(title, rev)
self.repo.tag(
# prepare request
rq = urllib2.Request(self.base_url + path + ".json")
- # will send POST when there is data, GET otherwise
+ # will send POST when there is data, GET otherwise
if data is not None:
rq.add_data(json.dumps(data))
rq.add_header("Content-Type", "application/json")
# dialogs
'js/wiki/dialog_save.js',
+ 'js/wiki/dialog_addtag.js',
# views
'js/wiki/view_history.js',
# -*- coding: utf-8
-
def settings(request):
from django.conf import settings
- return {'MEDIA_URL': settings.MEDIA_URL,
- 'STATIC_URL': settings.STATIC_URL,
- 'REDMINE_URL': settings.REDMINE_URL}
+ return {
+ 'MEDIA_URL': settings.MEDIA_URL,
+ 'STATIC_URL': settings.STATIC_URL,
+ }
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'ife@x^_lak+x84=lxtr!-ur$5g$+s6xt85gbbm@e_fk6q3r8=+'
+SESSION_COOKIE_NAME = "redakcja_sessionid"
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
WL_API_CONFIG = {
"URL": "http://localhost:7000/api/",
- "AUTH_REALM": "wlapi",
+ "AUTH_REALM": "WL API",
"AUTH_USER": "platforma",
"AUTH_PASSWD": "platforma",
}
/* fill out hidden fields */
this.$form = $('form', element);
- $("input[name='id']", this.$form).val(CurrentDocument.id);
- $("input[name='revision']", this.$form).val(options.revision);
+ $("input[name='addtag-id']", this.$form).val(CurrentDocument.id);
+ $("input[name='addtag-revision']", this.$form).val(options.revision);
$.wiki.cls.GenericDialog.call(this, element);
};
/* fill out hidden fields */
this.$form = $('form', element);
- $("input[name='id']", this.$form).val(CurrentDocument.id);
- $("input[name='parent_revision']", this.$form).val(CurrentDocument.revision);
+ $("input[name='textsave-id']", this.$form).val(CurrentDocument.id);
+ $("input[name='textsave-parent_revision']", this.$form).val(CurrentDocument.revision);
$.wiki.cls.GenericDialog.call(this, element);
};
var $stub = $('#history-view .row-stub');
changes_list.html('');
- var tags = $('select#id_addtag_tag option');
+ var tags = $('select#id_addtag-tag option');
$.each(data, function(){
$.wiki.renderStub({
$.blockUI({message: "Oczekiwanie na odpowiedź serwera..."});
self.doc.publish({
success: function(doc, data) {
- $.blockUI({message: "Udało się", timeout: 2000});
+ $.blockUI({message: "Udało się.", timeout: 2000});
},
failure: function(doc, message) {
$.blockUI({
timeout: 5000
});
}
-
+
});
});
-
+
old_callback.call(this);
};
function reverse() {
var vname = arguments[0];
var base_path = "/documents";
-
+
if (vname == "ajax_document_text") {
var path = "/" + arguments[1] + "/text";
-
- if (arguments[2] !== undefined)
+
+ if (arguments[2] !== undefined)
path += "/" + arguments[2];
-
+
return base_path + path;
}
-
+
if (vname == "ajax_document_history") {
-
+
return base_path + "/" + arguments[1] + "/history";
}
-
+
if (vname == "ajax_document_gallery") {
-
+
return base_path + "/gallery/" + arguments[1];
}
-
- if (vname == "ajax_document_diff")
+
+ if (vname == "ajax_document_diff")
return base_path + "/" + arguments[1] + "/diff";
-
+
if (vname == "ajax_document_addtag")
return base_path + "/" + arguments[1] + "/tags";
-
+
if (vname == "ajax_publish")
return base_path + "/" + arguments[1] + "/publish";
-
- console.log("Couldn't reverse match:", vname);
+
+ console.log("Couldn't reverse match:", vname);
return "/404.html";
};
-
+
/*
* Document Abstraction
*/
this._context_lock = -1;
this._lock_count = 0;
};
-
+
WikiDocument.prototype.triggerDocumentChanged = function() {
$(document).trigger('wlapi_document_changed', this);
};
dataType: 'json',
success: function(data) {
var changed = false;
-
-if (self.text === null || self.revision !== data.revision) {
+
+ if (self.text === null || self.revision !== data.revision) {
self.text = data.text;
self.revision = data.revision;
self.gallery = data.gallery;
changed = true;
self.triggerDocumentChanged();
};
-
+
self.has_local_changes = false;
params['success'](self, changed);
},
WikiDocument.prototype.save = function(params) {
params = $.extend({}, noops, params);
var self = this;
-
+
if (!self.has_local_changes) {
- console.log("Abort: no changes.");
+ console.log("Abort: no changes.");
return params['success'](self, false, "Nie ma zmian do zapisania.");
};
-
+
// Serialize form to dictionary
var data = {};
$.each(params['form'].serializeArray(), function() {
data[this.name] = this.value;
});
+
var metaComment = '<!--';
metaComment += '\n\tgallery:' + self.galleryLink;
metaComment += '\n-->\n'
-
+
data['textsave-text'] = metaComment + self.text;
-
+
$.ajax({
url: reverse("ajax_document_text", self.id),
type: "POST",
data: data,
success: function(data) {
var changed = false;
-
+
if (data.text) {
self.text = data.text;
self.revision = data.revision;
changed = true;
self.triggerDocumentChanged();
};
-
+
params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna"));
},
error: function(xhr) {
try {
params['failure'](self, $.parseJSON(xhr.responseText));
- }
+ }
catch (e) {
params['failure'](self, {
"__message": "<p>Nie udało się zapisać - błąd serwera.</p>"
});
};
-
+
}
});
}; /* end of save() */
else {
try {
params.failure(self, xhr.responseText);
- }
+ }
catch (e) {
- params.failure(self, "Nie udało się - błąd serwera.");
- };
+ params.failure(self, "Nie udało się - błąd serwera.");
+ };
};
-
+
}
});
};
params = $.extend({}, noops, params);
var self = this;
var data = {
- "id": self.id,
+ "addtag-id": self.id,
};
+
/* unpack form */
$.each(params.form.serializeArray(), function() {
data[this.name] = this.value;
});
+
$.ajax({
url: reverse("ajax_document_addtag", self.id),
type: "POST",
success: function(data) {
params.success(self, data.message);
},
- error: function(xhr) {
+ error: function(xhr) {
if (xhr.status == 403 || xhr.status == 401) {
params.failure(self, {
"__all__": ["Nie masz uprawnień lub nie jesteś zalogowany."]
else {
try {
params.failure(self, $.parseJSON(xhr.responseText));
- }
+ }
catch (e) {
params.failure(self, {
"__all__": ["Nie udało się - błąd serwera."]
});
};
-
+
};
-
+
}
});
};
url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
- url(r'^$', 'redirect_to', {'url': '/documents/'}),
+ url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}),
url(r'^documents/', include('wiki.urls')),
)