Commit c619639c by benjaoming

Making more agile url patterns that are agnostic to either receiving a path or…

Making more agile url patterns that are agnostic to either receiving a  path or an article_id. The path takes precedence over the article_id, except for the root article which needs to be forced in the template. Prettyfying the article revision list.
parent 24ea6718
...@@ -27,7 +27,7 @@ class AttachmentPreprocessor(markdown.preprocessors.Preprocessor): ...@@ -27,7 +27,7 @@ class AttachmentPreprocessor(markdown.preprocessors.Preprocessor):
attachment = models.Attachment.objects.get(article=self.markdown.article, attachment = models.Attachment.objects.get(article=self.markdown.article,
id=attachment_id) id=attachment_id)
url = reverse('wiki:attachments_download', kwargs={'article_id': self.markdown.article.id, url = reverse('wiki:attachments_download', kwargs={'article_id': self.markdown.article.id,
'attachment_id':attachment.id}) 'attachment_id':attachment.id,})
line = line.replace(m.group(1), u"""<span class="attachment"><a href="%s" title="%s">%s</a>""" % line = line.replace(m.group(1), u"""<span class="attachment"><a href="%s" title="%s">%s</a>""" %
(url, _(u"Click to download file"), attachment.original_filename)) (url, _(u"Click to download file"), attachment.original_filename))
new_text.append(line) new_text.append(line)
......
...@@ -10,83 +10,76 @@ ...@@ -10,83 +10,76 @@
{% block wiki_contents %} {% block wiki_contents %}
{% article_for_object urlpath as article %} <div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
{% if article %} {% with "attachments" as selected %}
<div class="tabbable tabs-top" style="margin-top: 40px;"> {% include "wiki/includes/article_menu.html" %}
<ul class="nav nav-tabs"> {% endwith %}
{% with "attachments" as selected %} <li>
{% include "wiki/includes/article_menu.html" %} <h1 style="margin-top: -10px;">
{% endwith %} {{ article.current_revision.title }}
<li> </h1>
<h1 style="margin-top: -10px;"> </li>
{{ article.current_revision.title }} </ul>
</h1> <div class="tab-content">
</li> {% if attachment.article == article %}
</ul> <h2>{% trans "Delete" %} "{{ attachment.current_revision.get_filename }}"?</h2>
<div class="tab-content"> <p class="lead">
{% if attachment.article == article %} {% blocktrans with attachment.original_filename as filename %}
<h2>{% trans "Delete" %} "{{ attachment.current_revision.get_filename }}"?</h2> The file may be referenced on other articles. Deleting it means that they will loose their references to this file. The following articles reference this file:
<p class="lead"> {% endblocktrans %}
{% blocktrans with attachment.original_filename as filename %} </p>
The file may be referenced on other articles. Deleting it means that they will loose their references to this file. The following articles reference this file: <ul>
{% endblocktrans %} {% for a in attachment.articles.all %}
</p> <li style="font-size: 150%;">{{ a.current_revision.title }}</li>
<ul> {% endfor %}
{% for a in attachment.articles.all %} </ul>
<li style="font-size: 150%;">{{ a.current_revision.title }}</li> <hr />
{% endfor %} <form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data">
</ul> {% wiki_form form %}
<hr /> <div class="form-actions">
<a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}" class="btn">
<span class="icon-arrow-left"></span>
{% trans "Go back" %}
</a>
<button class="btn btn-danger btn-large">
<span class="icon-upload"></span>
{% trans "Delete it!" %}
</button>
</div>
</form>
{% else %}
<h2>{% trans "Remove" %} "{{ attachment.current_revision.get_filename }}"?</h2>
<p class="lead">
{% blocktrans with attachment.original_filename as filename %}
You can remove a reference to a file, but it will retain its references on other articles.
{% endblocktrans %}
</p>
<form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data"> <form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data">
{% wiki_form form %} {% wiki_form form %}
<div class="form-actions"> <div class="form-actions">
<a href="{% url 'wiki:attachments_index' path=urlpath.path %}" class="btn"> <a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}" class="btn">
<span class="icon-arrow-left"></span> <span class="icon-arrow-left"></span>
{% trans "Go back" %} {% trans "Go back" %}
</a> </a>
<button class="btn btn-danger btn-large"> <button class="btn btn-danger btn-large">
<span class="icon-upload"></span> <span class="icon-upload"></span>
{% trans "Delete it!" %} {% trans "Remove reference" %}
</button> </button>
</div> </div>
</form> </form>
{% else %} {% endif %}
<h2>{% trans "Remove" %} "{{ attachment.current_revision.get_filename }}"?</h2>
<p class="lead">
{% blocktrans with attachment.original_filename as filename %}
You can remove a reference to a file, but it will retain its references on other articles.
{% endblocktrans %}
</p>
<form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data">
{% wiki_form form %}
<div class="form-actions">
<a href="{% url 'wiki:attachments_index' path=urlpath.path %}" class="btn">
<span class="icon-arrow-left"></span>
{% trans "Go back" %}
</a>
<button class="btn btn-danger btn-large">
<span class="icon-upload"></span>
{% trans "Remove reference" %}
</button>
</div>
</form>
{% endif %}
</div>
</div> </div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -10,74 +10,67 @@ ...@@ -10,74 +10,67 @@
{% block wiki_contents %} {% block wiki_contents %}
{% article_for_object urlpath as article %} <div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
{% if article %} {% with "attachments" as selected %}
<div class="tabbable tabs-top" style="margin-top: 40px;"> {% include "wiki/includes/article_menu.html" %}
<ul class="nav nav-tabs"> {% endwith %}
{% with "attachments" as selected %} <li>
{% include "wiki/includes/article_menu.html" %} <h1 style="margin-top: -10px;">
{% endwith %} {{ article.current_revision.title }}
<li> </h1>
<h1 style="margin-top: -10px;"> </li>
{{ article.current_revision.title }} </ul>
</h1> <div class="tab-content">
</li> <h2>{% trans "History of" %} "{{ attachment.current_revision.get_filename }}"</h2>
</ul> <table class="table table-striped table-bordered">
<div class="tab-content"> <tr>
<h2>{% trans "History of" %} "{{ attachment.current_revision.get_filename }}"</h2> <th>{% trans "Date" %}</th>
<table class="table table-striped table-bordered"> <th>{% trans "User" %}</th>
<tr> <th>{% trans "Description" %}</th>
<th>{% trans "Date" %}</th> <th>{% trans "File" %}</th>
<th>{% trans "User" %}</th> <th>{% trans "Size" %}</th>
<th>{% trans "Description" %}</th> <th style="text-align: right">{% trans "Action" %}</th>
<th>{% trans "File" %}</th> </tr>
<th>{% trans "Size" %}</th> {% for revision in revisions %}
<th style="text-align: right">{% trans "Action" %}</th> <tr>
</tr> <td>
{% for revision in revisions %} {{ revision.created }}
<tr> {% if revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %}
<td> </td>
{{ revision.created }} <td>
{% if revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %} {% if revision.user %}{{ revision.user }}{% else %}{% if user|is_moderator %}{{ revision.ip_address|default:"anonymous (IP not logged)" }}{% else %}{% trans "anonymous (IP logged)" %}{% endif %}{% endif %}
</td> </td>
<td> <td>{{ revision.description|default:_("<em>No description</em>")|safe }}</td>
{% if revision.user %}{{ revision.user }}{% else %}{% if user|is_moderator %}{{ revision.ip_address|default:"anonymous (IP not logged)" }}{% else %}{% trans "anonymous (IP logged)" %}{% endif %}{% endif %} <td>{{ revision.get_filename }}</td>
</td> <td>{{ revision.file.size|filesizeformat }}</td>
<td>{{ revision.description|default:_("<em>No description</em>")|safe }}</td> <td style="text-align: right">
<td>{{ revision.get_filename }}</td> <form method="POST" action="{% url 'wiki:attachments_revision_change' path=urlpath.path article_id=article.id attachment_id=attachment.id revision_id=revision.id %}">
<td>{{ revision.file.size|filesizeformat }}</td> {% csrf_token %}
<td style="text-align: right"> <a href="{% url 'wiki:attachments_download' path=urlpath.path article_id=article.id attachment_id=attachment.id revision_id=revision.id %}" class="btn btn-primary">
<form method="POST" action="{% url 'wiki:attachments_revision_change' path=urlpath.path attachment_id=attachment.id revision_id=revision.id %}"> <span class="icon-download"></span>
{% csrf_token %} {% trans "Download" %}
<a href="{% url 'wiki:attachments_download' path=urlpath.path attachment_id=attachment.id revision_id=revision.id %}" class="btn btn-primary"> </a>
<span class="icon-download"></span> {% if revision.attachment.article|can_write:user %}
{% trans "Download" %} <button{% if revision == attachment.current_revision %} disabled="disabled"{% endif %} class="btn">
</a> <span class="icon-flag"></span>
{% if revision.attachment.article|can_write:user %} {% trans "Use this!" %}
<button{% if revision == attachment.current_revision %} disabled="disabled"{% endif %} class="btn"> </button>
<span class="icon-flag"></span> {% endif %}
{% trans "Use this!" %} </form>
</button> </td>
{% endif %} </tr>
</form> {% endfor %}
</td> </table>
</tr> <a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
{% endfor %}
</table>
<a href="{% url 'wiki:attachments_index' path=urlpath.path %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
</div>
</div> </div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -9,68 +9,60 @@ ...@@ -9,68 +9,60 @@
{% endblock %} {% endblock %}
{% block wiki_contents %} {% block wiki_contents %}
<div class="tabbable tabs-top" style="margin-top: 20px;">
{% article_for_object urlpath as article %} <ul class="nav nav-tabs">
{% with "attachments" as selected %}
{% if article %} {% include "wiki/includes/article_menu.html" %}
<div class="tabbable tabs-top" style="margin-top: 40px;"> {% endwith %}
<ul class="nav nav-tabs"> <li>
{% with "attachments" as selected %} <h1 style="margin-top: -10px;">
{% include "wiki/includes/article_menu.html" %} {{ article.current_revision.title }}
{% endwith %} </h1>
<li> </li>
<h1 style="margin-top: -10px;"> </ul>
{{ article.current_revision.title }} <div class="tab-content">
</h1> <h2>{% trans "Replace" %} "{{ attachment.current_revision.get_filename }}"</h2>
</li> {% if attachment.articles.count > 1 %}
<p class="lead">
{% blocktrans with attachment.original_filename as filename %}
Replacing an attachment means adding a new file that will be used in its place. All references to the file will be replaced by the one you upload and the file will be downloaded as <strong>{{ filename }}</strong>. Please note that this attachment is in use on other articles, you may distort contents. However, do not hestitate to take advantage of this and make replacements for the listed articles where necessary. This way of working is more efficient....
{% endblocktrans %}
</p>
<h3>{% trans "Articles using" %} {{ attachment.current_revision.get_filename }}</h3>
<ul>
{% for a in attachment.articles.all %}<li>{{ a.current_revision.title }}</li>{% endfor %}
</ul> </ul>
<div class="tab-content"> <hr />
<h2>{% trans "Replace" %} "{{ attachment.current_revision.get_filename }}"</h2> {% else %}
{% if attachment.articles.count > 1 %} <p class="lead">
<p class="lead"> {% blocktrans with attachment.original_filename as filename %}
{% blocktrans with attachment.original_filename as filename %} Replacing an attachment means adding a new file that will be used in its place. All references to the file will be replaced by the one you upload and the file will be downloaded as <strong>{{ filename }}</strong>.
Replacing an attachment means adding a new file that will be used in its place. All references to the file will be replaced by the one you upload and the file will be downloaded as <strong>{{ filename }}</strong>. Please note that this attachment is in use on other articles, you may distort contents. However, do not hestitate to take advantage of this and make replacements for the listed articles where necessary. This way of working is more efficient.... {% endblocktrans %}
{% endblocktrans %} </p>
</p> {% endif %}
<h3>{% trans "Articles using" %} {{ attachment.current_revision.get_filename }}</h3>
<ul> <form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data">
{% for a in attachment.articles.all %}<li>{{ a.current_revision.title }}</li>{% endfor %} {% wiki_form form %}
</ul> <div class="form-actions">
<hr /> <a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}" class="btn">
{% else %} <span class="icon-arrow-left"></span>
<p class="lead"> {% trans "Go back" %}
{% blocktrans with attachment.original_filename as filename %} </a>
Replacing an attachment means adding a new file that will be used in its place. All references to the file will be replaced by the one you upload and the file will be downloaded as <strong>{{ filename }}</strong>. <button class="btn btn-primary">
{% endblocktrans %} <span class="icon-upload"></span>
</p> {% trans "Upload replacement" %}
{% endif %} </button>
</div>
<form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data"> </form>
{% wiki_form form %}
<div class="form-actions">
<a href="{% url 'wiki:attachments_index' path=urlpath.path %}" class="btn">
<span class="icon-arrow-left"></span>
{% trans "Go back" %}
</a>
<button class="btn btn-primary">
<span class="icon-upload"></span>
{% trans "Upload replacement" %}
</button>
</div>
</form>
</div>
</div> </div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -10,97 +10,90 @@ ...@@ -10,97 +10,90 @@
{% block wiki_contents %} {% block wiki_contents %}
{% article_for_object urlpath as article %} <div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
{% with "attachments" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
<li>
<h1 style="margin-top: -10px;">
{{ article.current_revision.title }}
</h1>
</li>
</ul>
<div class="tab-content">
<h2>{% trans "Add existing attachment to" %} {{ article.current_revision.title }}</h2>
{% if article %} <form method="GET" action="{% url 'wiki:attachments_search' path=urlpath.path article_id=article.id %}" class="form-search">
<div class="tabbable tabs-top" style="margin-top: 40px;"> {{ search_form.query }}
<ul class="nav nav-tabs"> <button class="btn">
{% with "attachments" as selected %} <span class="icon-search"></span>
{% include "wiki/includes/article_menu.html" %} {% trans "Search files and articles" %}
{% endwith %} </button>
<li> </form>
<h1 style="margin-top: -10px;">
{{ article.current_revision.title }}
</h1>
</li>
</ul>
<div class="tab-content">
<h2>{% trans "Add existing attachment to" %} {{ article.current_revision.title }}</h2>
<form method="GET" action="{% url 'wiki:attachments_search' path=urlpath.path %}" class="form-search">
{{ search_form.query }}
<button class="btn">
<span class="icon-search"></span>
{% trans "Search files and articles" %}
</button>
</form>
{% if attachments %} {% if attachments %}
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<tr> <tr>
<th>{% trans "File" %}</th> <th>{% trans "File" %}</th>
<th>{% trans "Main article" %}</th> <th>{% trans "Main article" %}</th>
<th>{% trans "Date" %}</th> <th>{% trans "Date" %}</th>
<th>{% trans "Uploaded by" %}</th> <th>{% trans "Uploaded by" %}</th>
<th>{% trans "Size" %}</th> <th>{% trans "Size" %}</th>
<th style="text-align: right">{% trans "Action" %}</th> <th style="text-align: right">{% trans "Action" %}</th>
</tr> </tr>
{% for attachment in attachments %} {% for attachment in attachments %}
<tr> <tr>
<td> <td>
<h4>{{ attachment.original_filename }}</h4> <h4>{{ attachment.original_filename }}</h4>
{{ attachment.current_revision.description|default:_("<em>No description</em>")|safe }} {{ attachment.current_revision.description|default:_("<em>No description</em>")|safe }}
</td> </td>
<td> <td>
<strong>{{ attachment.article.current_revision.title }}</strong> <strong>{{ attachment.article.current_revision.title }}</strong>
</td> </td>
<td> <td>
{{ attachment.current_revision.created }} {{ attachment.current_revision.created }}
{% if attachment.current_revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %} {% if attachment.current_revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %}
</td> </td>
<td> <td>
{% if attachment.current_revision.user %}{{ attachment.current_revision.user }}{% else %}{% if user|is_moderator %}{{ attachment.current_revision.ip_address|default:"anonymous (IP not logged)" }}{% else %}{% trans "anonymous (IP logged)" %}{% endif %}{% endif %} {% if attachment.current_revision.user %}{{ attachment.current_revision.user }}{% else %}{% if user|is_moderator %}{{ attachment.current_revision.ip_address|default:"anonymous (IP not logged)" }}{% else %}{% trans "anonymous (IP logged)" %}{% endif %}{% endif %}
</td> </td>
<td>{{ attachment.current_revision.file.size|filesizeformat }}</td> <td>{{ attachment.current_revision.file.size|filesizeformat }}</td>
<td style="text-align: right"> <td style="text-align: right">
<form method="POST" action="{% url 'wiki:attachments_add' path=urlpath.path attachment_id=attachment.id %}"> <form method="POST" action="{% url 'wiki:attachments_add' path=urlpath.path article_id=article.id attachment_id=attachment.id %}">
{% csrf_token %} {% csrf_token %}
<a href="{% url 'wiki:attachments_download' path=urlpath.path attachment_id=attachment.id %}" class="btn"> <a href="{% url 'wiki:attachments_download' path=urlpath.path article_id=article.id attachment_id=attachment.id %}" class="btn">
<span class="icon-download"></span> <span class="icon-download"></span>
{% trans "Download" %} {% trans "Download" %}
</a> </a>
<button class="btn btn-primary"> <button class="btn btn-primary">
<span class="icon-plus"></span> <span class="icon-plus"></span>
{% trans "Add to article" %} {% trans "Add to article" %}
</button> </button>
</form> </form>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% else %} {% else %}
<p><em>{% trans "Your search did not return any results" %}</em></p> <p><em>{% trans "Your search did not return any results" %}</em></p>
{% endif %} {% endif %}
{% with query as appended_value and "query" as appended_key %} {% with query as appended_value and "query" as appended_key %}
{% include "wiki/includes/pagination.html" %} {% include "wiki/includes/pagination.html" %}
{% endwith %} {% endwith %}
<p> <p>
<a href="{% url 'wiki:attachments_index' path=urlpath.path %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a> <a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
</p> </p>
</div>
</div> </div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{% load wiki_tags i18n %} {% load wiki_tags i18n %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% article_for_object urlpath as article %}{{ article.current_revision.title }}{% endblock %} {% block pagetitle %}{{ article.current_revision.title }}{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_breadcrumbs %}
{% include "wiki/includes/breadcrumbs.html" %} {% include "wiki/includes/breadcrumbs.html" %}
...@@ -10,36 +10,28 @@ ...@@ -10,36 +10,28 @@
{% block wiki_contents %} {% block wiki_contents %}
{% article_for_object urlpath as article %} <div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
{% if article %} <li style="float: left">
<div class="tabbable tabs-top" style="margin-top: 20px;"> <h1 style="margin-top: -10px;">{{ article.current_revision.title }}</h1>
<ul class="nav nav-tabs"> </li>
<li style="float: left"> {% with "view" as selected %}
<h1 style="margin-top: -10px;">{{ article.current_revision.title }}</h1> {% include "wiki/includes/article_menu.html" %}
</li> {% endwith %}
{% with "view" as selected %} </ul>
{% include "wiki/includes/article_menu.html" %} <div class="tab-content">
{% endwith %} {% wiki_render article %}
</ul>
<div class="tab-content">
{% wiki_render article %}
</div>
</div> </div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
{% with "view" as selected %} {% with "view" as selected %}
{% include "wiki/includes/article_menu.html" %} {% include "wiki/includes/article_menu.html" %}
{% endwith %} {% endwith %}
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{% load wiki_tags i18n %} {% load wiki_tags i18n %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "Edit" %}: {% article_for_object urlpath as article %}{{ article.current_revision.title }}{% endblock %} {% block pagetitle %}{% trans "Edit" %}: {{ article.current_revision.title }}{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_breadcrumbs %}
{% include "wiki/includes/breadcrumbs.html" %} {% include "wiki/includes/breadcrumbs.html" %}
...@@ -10,10 +10,7 @@ ...@@ -10,10 +10,7 @@
{% block wiki_contents %} {% block wiki_contents %}
{% article_for_object urlpath as article %} <div class="tabbable tabs-top" style="margin-top: 20px;">
{% if article %}
<div class="tabbable tabs-top" style="margin-top: 40px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
{% with "edit" as selected %} {% with "edit" as selected %}
{% include "wiki/includes/article_menu.html" %} {% include "wiki/includes/article_menu.html" %}
...@@ -69,10 +66,6 @@ ...@@ -69,10 +66,6 @@
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -3,17 +3,26 @@ ...@@ -3,17 +3,26 @@
{% for plugin in plugins %} {% for plugin in plugins %}
{% if plugin.article_tab %} {% if plugin.article_tab %}
<li class="pull-right{% if selected == plugin.slug %} active{% endif %}"> <li class="pull-right{% if selected == plugin.slug %} active{% endif %}">
<a href="{% url 'wiki:plugin_url' urlpath.path plugin.slug %}"> {% if urlpath %}
<a href="{% url 'wiki:plugin_url' path=urlpath.path slug=plugin.slug %}">
<span class="{{ plugin.article_tab.1 }}"></span> <span class="{{ plugin.article_tab.1 }}"></span>
{{ plugin.article_tab.0 }} {{ plugin.article_tab.0 }}
</a> </a>
</li> {% else %}
<a href="{% url 'wiki:plugin' slug=plugin.slug article_id=article.id %}">
<span class="{{ plugin.article_tab.1 }}"></span>
{{ plugin.article_tab.0 }}
</a>
{% endif %}
</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if urlpath %}
<li class="pull-right{% if selected == "settings" %} active{% endif %}"> <li class="pull-right{% if selected == "settings" %} active{% endif %}">
{% if not user.is_anonymous %} {% if not user.is_anonymous %}
<a href="{% url 'wiki:settings_url' urlpath.path %}"> <a href="{% url 'wiki:settings_url' path=urlpath.path %}">
<span class="icon-wrench"></span> <span class="icon-wrench"></span>
{% trans "Settings" %} {% trans "Settings" %}
</a> </a>
...@@ -38,3 +47,32 @@ ...@@ -38,3 +47,32 @@
</a> </a>
</li> </li>
{% else %}
<li class="pull-right{% if selected == "settings" %} active{% endif %}">
{% if not user.is_anonymous %}
<a href="{% url 'wiki:settings' article_id=article.id %}">
<span class="icon-wrench"></span>
{% trans "Settings" %}
</a>
{% endif %}
</li>
<li class="pull-right{% if selected == "history" %} active{% endif %}">
<a href="{% url 'wiki:history' article_id=article.id %}">
<span class="icon-time"></span>
{% trans "Changes" %}
</a>
</li>
<li class="pull-right{% if selected == "edit" %} active{% endif %}">
<a href="{% url 'wiki:edit' article_id=article.id %}">
<span class="icon-edit"></span>
{% trans "Edit" %}
</a>
</li>
<li class="pull-right{% if selected == "view" %} active{% endif %}">
<a href="{% url 'wiki:get' article_id=article.id %}">
<span class="icon-home"></span>
{% trans "View" %}
</a>
</li>
{% endif %}
{% load i18n %}{% load url from future %} {% load i18n %}{% load url from future %}
{% if urlpath %}
<ul class="breadcrumb pull-left" class=""> <ul class="breadcrumb pull-left" class="">
{% for ancestor in urlpath.get_ancestors.all %} {% for ancestor in urlpath.get_ancestors.all %}
<span class="divider">/</span> <span class="divider">/</span>
<li><a href="{% url 'wiki:get_url' ancestor.path %}">{{ ancestor.article.current_revision.title }}</a></li> <li><a href="{% url 'wiki:get_url' ancestor.path %}">{{ ancestor.article.current_revision.title }}</a></li>
{% endfor %} {% endfor %}
<span class="divider">/</span> <span class="divider">/</span>
<li class="active"><a href="{% url 'wiki:get_url' urlpath.path %}">{{ urlpath.article.current_revision.title }}</a></li> <li class="active"><a href="{% url 'wiki:get_url' urlpath.path %}">{{ article.current_revision.title }}</a></li>
<span class="divider">/</span> <span class="divider">/</span>
</ul> </ul>
<div class="pull-left" style="margin-left: 10px;"> <div class="pull-left" style="margin-left: 10px;">
...@@ -35,7 +36,5 @@ ...@@ -35,7 +36,5 @@
{% trans "Add article" %} {% trans "Add article" %}
</a> </a>
</div> </div>
<div style="clear: both"></div> <div style="clear: both"></div>
{% endif %}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{% load wiki_tags i18n %} {% load wiki_tags i18n %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "Settings" %}: {% article_for_object urlpath as article %}{{ article.current_revision.title }}{% endblock %} {% block pagetitle %}{% trans "Settings" %}: {{ article.current_revision.title }}{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_breadcrumbs %}
{% include "wiki/includes/breadcrumbs.html" %} {% include "wiki/includes/breadcrumbs.html" %}
...@@ -10,49 +10,42 @@ ...@@ -10,49 +10,42 @@
{% block wiki_contents %} {% block wiki_contents %}
{% article_for_object urlpath as article %} <div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
{% with "settings" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
<li>
<h1 style="margin-top: -10px;">
{{ article.current_revision.title }}
</h1>
</li>
</ul>
<div class="tab-content">
{% for form in forms %}
<form method="POST" class="form-horizontal" id="settings_form" action="?f={{form.action}}">
<h2>{{ form.settings_form_headline }}</h2>
<div class="well">
{% wiki_form form %}
</div>
<div class="form-actions">
<button type="submit" name="save" value="1" class="btn btn-large btn-primary">
<span class="icon-ok"></span>
{% trans "Save changes" %}
</button>
</div>
</form>
{% endfor %}
{% if article %}
<div class="tabbable tabs-top" style="margin-top: 40px;">
<ul class="nav nav-tabs">
{% with "settings" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
<li>
<h1 style="margin-top: -10px;">
{{ article.current_revision.title }}
</h1>
</li>
</ul>
<div class="tab-content">
{% for form in forms %}
<form method="POST" class="form-horizontal" id="settings_form" action="?f={{form.action}}">
<h2>{{ form.settings_form_headline }}</h2>
<div class="well">
{% wiki_form form %}
</div>
<div class="form-actions">
<button type="submit" name="save" value="1" class="btn btn-large btn-primary">
<span class="icon-ok"></span>
{% trans "Save changes" %}
</button>
</div>
</form>
{% endfor %}
</div>
</div> </div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</div> </div>
{% else %}
{% trans "An article for this path does not exist." %}
{% endif %}
{% endblock %} {% endblock %}
...@@ -26,14 +26,14 @@ urlpatterns += patterns('', ...@@ -26,14 +26,14 @@ urlpatterns += patterns('',
url('^_revision/merge/(?P<article_id>\d+)/(?P<revision_id>\d+)/preview/$', 'wiki.views.article.merge', name='merge_revision_preview', kwargs={'preview': True}), url('^_revision/merge/(?P<article_id>\d+)/(?P<revision_id>\d+)/preview/$', 'wiki.views.article.merge', name='merge_revision_preview', kwargs={'preview': True}),
# Paths decided by article_ids # Paths decided by article_ids
url('^(?P<article_id>\d+)/create/$', article.Create.as_view(), name='create_url'), url('^(?P<article_id>\d+)/$', article.ArticleView.as_view(), name='get'),
url('^(?P<article_id>\d+)/edit/$', article.Edit.as_view(), name='edit_url'), url('^(?P<article_id>\d+)/edit/$', article.Edit.as_view(), name='edit'),
url('^(?P<article_id>\d+)/preview/$', 'wiki.views.article.preview', name='preview_url'), url('^(?P<article_id>\d+)/preview/$', 'wiki.views.article.preview', name='preview'),
url('^(?P<article_id>\d+)/history/$', article.History.as_view(), name='history_url'), url('^(?P<article_id>\d+)/history/$', article.History.as_view(), name='history'),
url('^(?P<article_id>\d+)/settings/$', article.Settings.as_view(), name='settings_url'), url('^(?P<article_id>\d+)/settings/$', article.Settings.as_view(), name='settings'),
url('^(?P<article_id>\d+)/revision/change/(?P<revision_id>\d+)/$', 'wiki.views.article.change_revision', name='change_revision_url'), url('^(?P<article_id>\d+)/revision/change/(?P<revision_id>\d+)/$', 'wiki.views.article.change_revision', name='change_revision'),
url('^(?P<article_id>\d+)/revision/merge/(?P<revision_id>\d+)/$', 'wiki.views.article.merge', name='merge_revision_url'), url('^(?P<article_id>\d+)/revision/merge/(?P<revision_id>\d+)/$', 'wiki.views.article.merge', name='merge_revision'),
url('^(?P<article_id>\d+)/plugin/(?P<slug>\w+)/$', article.Plugin.as_view(), name='plugin_url'), url('^(?P<article_id>\d+)/plugin/(?P<slug>\w+)/$', article.Plugin.as_view(), name='plugin'),
) )
...@@ -42,6 +42,8 @@ for plugin in plugins_registry._cache.values(): ...@@ -42,6 +42,8 @@ for plugin in plugins_registry._cache.values():
plugin_urlpatterns = getattr(plugin, 'urlpatterns', None) plugin_urlpatterns = getattr(plugin, 'urlpatterns', None)
if slug and plugin_urlpatterns: if slug and plugin_urlpatterns:
urlpatterns += patterns('', urlpatterns += patterns('',
url('^(?P<path>.+/|)_plugin/'+slug+'/', include(plugin_urlpatterns)),
url('^(?P<article_id>\d+)(?P<path>)/plugin/'+slug+'/', include(plugin_urlpatterns)),
url('^(?P<article_id>\d+)/plugin/'+slug+'/', include(plugin_urlpatterns)), url('^(?P<article_id>\d+)/plugin/'+slug+'/', include(plugin_urlpatterns)),
) )
...@@ -57,13 +59,6 @@ urlpatterns += patterns('', ...@@ -57,13 +59,6 @@ urlpatterns += patterns('',
url('^(?P<path>.+/|)_plugin/(?P<slug>\w+)/$', article.Plugin.as_view(), name='plugin_url'), url('^(?P<path>.+/|)_plugin/(?P<slug>\w+)/$', article.Plugin.as_view(), name='plugin_url'),
) )
for plugin in plugins_registry._cache.values():
slug = getattr(plugin, 'slug', None)
plugin_urlpatterns = getattr(plugin, 'urlpatterns', None)
if slug and plugin_urlpatterns:
urlpatterns += patterns('',
url('^(?P<path>.+/|)_plugin/'+slug+'/', include(plugin_urlpatterns)),
)
urlpatterns += patterns('', urlpatterns += patterns('',
url('^(?P<path>.+/|)$', article.ArticleView.as_view(), name='get_url'), url('^(?P<path>.+/|)$', article.ArticleView.as_view(), name='get_url'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment