Commit 846a665f by benjaoming

Cleaning up template boiler plate markup

parent 588bcdde
{% extends "wiki/base.html" %} {% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize %} {% load wiki_tags i18n humanize %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "Delete" %} "{{ attachment.current_revision.get_filename }}"{% endblock %} {% block pagetitle %}{% trans "Delete" %} "{{ attachment.current_revision.get_filename }}"{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_contents_tab %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %}
<div class="tabbable tabs-top" style="margin-top: 20px;"> {% if attachment.article == article %}
<ul class="nav nav-tabs"> <h2>{% trans "Delete" %} "{{ attachment.current_revision.get_filename }}"?</h2>
{% with "attachments" as selected %} <p class="lead">
{% include "wiki/includes/article_menu.html" %} {% blocktrans with attachment.original_filename as filename %}
{% endwith %} 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:
<li> {% endblocktrans %}
<h1 style="margin-top: -10px;"> </p>
{{ article.current_revision.title }} <ul>
</h1> {% for a in attachment.articles.all %}
</li> <li style="font-size: 150%;">{{ a.current_revision.title }}</li>
</ul> {% endfor %}
<div class="tab-content"> </ul>
{% if attachment.article == article %} <hr />
<h2>{% trans "Delete" %} "{{ attachment.current_revision.get_filename }}"?</h2> <form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data">
<p class="lead"> {% wiki_form form %}
{% blocktrans with attachment.original_filename as filename %} <div class="form-actions">
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: <a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}" class="btn">
{% endblocktrans %} <span class="icon-arrow-left"></span>
</p> {% trans "Go back" %}
<ul> </a>
{% for a in attachment.articles.all %} <button class="btn btn-danger btn-large">
<li style="font-size: 150%;">{{ a.current_revision.title }}</li> <span class="icon-upload"></span>
{% endfor %} {% trans "Delete it!" %}
</ul> </button>
<hr />
<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 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">
{% wiki_form form %}
<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 "Remove reference" %}
</button>
</div>
</form>
{% endif %}
</div>
</div> </div>
</form>
<div class="tabbable tabs-below" style="margin-top: 20px;"> {% else %}
<ul class="nav nav-tabs"> <h2>{% trans "Remove" %} "{{ attachment.current_revision.get_filename }}"?</h2>
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <p class="lead">
</ul> {% 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 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 "Remove reference" %}
</button>
</div> </div>
</form>
{% endif %}
{% endblock %} {% endblock %}
{% extends "wiki/base.html" %} {% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize %} {% load wiki_tags i18n humanize %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "History of" %} "{{ attachment.current_revision.get_filename }}"{% endblock %} {% block pagetitle %}{% trans "History of" %} "{{ attachment.current_revision.get_filename }}"{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_contents_tab %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %}
<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 "History of" %} "{{ attachment.current_revision.get_filename }}"</h2>
<table class="table table-striped table-bordered">
<tr>
<th>{% trans "Date" %}</th>
<th>{% trans "User" %}</th>
<th>{% trans "Description" %}</th>
<th>{% trans "File" %}</th>
<th>{% trans "Size" %}</th>
<th style="text-align: right">{% trans "Action" %}</th>
</tr>
{% for revision in revisions %}
<tr>
<td>
{{ revision.created }}
{% if revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %}
</td>
<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>
<td>{{ revision.description|default:_("<em>No description</em>")|safe }}</td>
<td>{{ revision.get_filename }}</td>
<td>{{ revision.file.size|filesizeformat }}</td>
<td style="text-align: right">
<form method="POST" action="{% url 'wiki:attachments_revision_change' path=urlpath.path article_id=article.id attachment_id=attachment.id revision_id=revision.id %}">
{% csrf_token %}
<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">
<span class="icon-download"></span>
{% trans "Download" %}
</a>
{% if revision.attachment.article|can_write:user %}
<button{% if revision == attachment.current_revision %} disabled="disabled"{% endif %} class="btn">
<span class="icon-flag"></span>
{% trans "Use this!" %}
</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</table>
<a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
</div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <h2>{% trans "History of" %} "{{ attachment.current_revision.get_filename }}"</h2>
<ul class="nav nav-tabs"> <table class="table table-striped table-bordered">
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <tr>
</ul> <th>{% trans "Date" %}</th>
</div> <th>{% trans "User" %}</th>
<th>{% trans "Description" %}</th>
<th>{% trans "File" %}</th>
<th>{% trans "Size" %}</th>
<th style="text-align: right">{% trans "Action" %}</th>
</tr>
{% for revision in revisions %}
<tr>
<td>
{{ revision.created }}
{% if revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %}
</td>
<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>
<td>{{ revision.description|default:_("<em>No description</em>")|safe }}</td>
<td>{{ revision.get_filename }}</td>
<td>{{ revision.file.size|filesizeformat }}</td>
<td style="text-align: right">
<form method="POST" action="{% url 'wiki:attachments_revision_change' path=urlpath.path article_id=article.id attachment_id=attachment.id revision_id=revision.id %}">
{% csrf_token %}
<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">
<span class="icon-download"></span>
{% trans "Download" %}
</a>
{% if revision.attachment.article|can_write:user %}
<button{% if revision == attachment.current_revision %} disabled="disabled"{% endif %} class="btn">
<span class="icon-flag"></span>
{% trans "Use this!" %}
</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</table>
<a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
{% endblock %} {% endblock %}
{% extends "wiki/base.html" %} {% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize %} {% load wiki_tags i18n humanize %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "Replace" %} "{{ attachment.current_revision.get_filename }}"{% endblock %} {% block pagetitle %}{% trans "Replace" %} "{{ attachment.current_revision.get_filename }}"{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_contents_tab %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %} <h2>{% trans "Replace" %} "{{ attachment.current_revision.get_filename }}"</h2>
<div class="tabbable tabs-top" style="margin-top: 20px;"> {% if attachment.articles.count > 1 %}
<ul class="nav nav-tabs"> <p class="lead">
{% with "attachments" as selected %} {% blocktrans with attachment.original_filename as filename %}
{% include "wiki/includes/article_menu.html" %} 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....
{% endwith %} {% endblocktrans %}
<li> </p>
<h1 style="margin-top: -10px;"> <h3>{% trans "Articles using" %} {{ attachment.current_revision.get_filename }}</h3>
{{ article.current_revision.title }} <ul>
</h1> {% for a in attachment.articles.all %}<li>{{ a.current_revision.title }}</li>{% endfor %}
</li> </ul>
</ul> <hr />
<div class="tab-content"> {% else %}
<h2>{% trans "Replace" %} "{{ attachment.current_revision.get_filename }}"</h2> <p class="lead">
{% if attachment.articles.count > 1 %} {% blocktrans with attachment.original_filename as filename %}
<p class="lead"> 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>.
{% blocktrans with attachment.original_filename as filename %} {% endblocktrans %}
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.... </p>
{% endblocktrans %} {% endif %}
</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>
<hr />
{% else %}
<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>.
{% endblocktrans %}
</p>
{% endif %}
<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 article_id=article.id %}" 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 class="tabbable tabs-below" style="margin-top: 20px;"> <form method="POST" class="form-horizontal" id="attachment_form" enctype="multipart/form-data">
<ul class="nav nav-tabs"> {% wiki_form form %}
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> <div class="form-actions">
</ul> <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-primary">
<span class="icon-upload"></span>
{% trans "Upload replacement" %}
</button>
</div> </div>
</form>
{% endblock %} {% endblock %}
{% extends "wiki/base.html" %} {% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize %} {% load wiki_tags i18n humanize %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "Add file to" %} "{{ article.current_revision.title }}"{% endblock %} {% block pagetitle %}{% trans "Add file to" %} "{{ article.current_revision.title }}"{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_contents_tab %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %} <h2>{% trans "Add attachment from other article" %}</h2>
<div class="tabbable tabs-top" style="margin-top: 20px;"> <form method="GET" action="{% url 'wiki:attachments_search' path=urlpath.path article_id=article.id %}" class="form-search">
<ul class="nav nav-tabs"> {{ search_form.query }}
{% with "attachments" as selected %} <button class="btn">
{% include "wiki/includes/article_menu.html" %} <span class="icon-search"></span>
{% endwith %} {% trans "Search files and articles" %}
<li> </button>
<h1 style="margin-top: -10px;"> </form>
{{ 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 article_id=article.id %}" class="form-search"> {% if attachments %}
{{ search_form.query }} <table class="table table-striped table-bordered">
<button class="btn"> <tr>
<span class="icon-search"></span> <th>{% trans "File" %}</th>
{% trans "Search files and articles" %} <th>{% trans "Main article" %}</th>
<th>{% trans "Date" %}</th>
<th>{% trans "Uploaded by" %}</th>
<th>{% trans "Size" %}</th>
<th style="text-align: right">{% trans "Action" %}</th>
</tr>
{% for attachment in attachments %}
<tr>
<td>
<h4>{{ attachment.original_filename }}</h4>
{{ attachment.current_revision.description|default:_("<em>No description</em>")|safe }}
</td>
<td>
<strong>{{ attachment.article.current_revision.title }}</strong>
</td>
<td>
{{ attachment.current_revision.created }}
{% if attachment.current_revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %}
</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 %}
</td>
<td>{{ attachment.current_revision.file.size|filesizeformat }}</td>
<td style="text-align: right">
<form method="POST" action="{% url 'wiki:attachments_add' path=urlpath.path article_id=article.id attachment_id=attachment.id %}">
{% csrf_token %}
<a href="{% url 'wiki:attachments_download' path=urlpath.path article_id=article.id attachment_id=attachment.id %}" class="btn">
<span class="icon-download"></span>
{% trans "Download" %}
</a>
<button class="btn btn-primary">
<span class="icon-plus"></span>
{% trans "Add to article" %}
</button> </button>
</form> </form>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p><em>{% trans "Your search did not return any results" %}</em></p>
{% endif %}
{% if attachments %} {% with query as appended_value and "query" as appended_key %}
<table class="table table-striped table-bordered"> {% include "wiki/includes/pagination.html" %}
<tr> {% endwith %}
<th>{% trans "File" %}</th>
<th>{% trans "Main article" %}</th>
<th>{% trans "Date" %}</th>
<th>{% trans "Uploaded by" %}</th>
<th>{% trans "Size" %}</th>
<th style="text-align: right">{% trans "Action" %}</th>
</tr>
{% for attachment in attachments %}
<tr>
<td>
<h4>{{ attachment.original_filename }}</h4>
{{ attachment.current_revision.description|default:_("<em>No description</em>")|safe }}
</td>
<td>
<strong>{{ attachment.article.current_revision.title }}</strong>
</td>
<td>
{{ attachment.current_revision.created }}
{% if attachment.current_revision.deleted %}<span class="badge badge-important">{% trans "deleted" %}</span>{% endif %}
</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 %}
</td>
<td>{{ attachment.current_revision.file.size|filesizeformat }}</td>
<td style="text-align: right">
<form method="POST" action="{% url 'wiki:attachments_add' path=urlpath.path article_id=article.id attachment_id=attachment.id %}">
{% csrf_token %}
<a href="{% url 'wiki:attachments_download' path=urlpath.path article_id=article.id attachment_id=attachment.id %}" class="btn">
<span class="icon-download"></span>
{% trans "Download" %}
</a>
<button class="btn btn-primary">
<span class="icon-plus"></span>
{% trans "Add to article" %}
</button>
</form>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p><em>{% trans "Your search did not return any results" %}</em></p>
{% endif %}
{% with query as appended_value and "query" as appended_key %}
{% include "wiki/includes/pagination.html" %}
{% endwith %}
<p>
<a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
</p>
</div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <p>
<ul class="nav nav-tabs"> <a href="{% url 'wiki:attachments_index' path=urlpath.path article_id=article.id %}"><span class="icon-arrow-left"></span> {% trans "Go back" %}</a>
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> </p>
</ul>
</div>
{% endblock %}
{% endblock %}
...@@ -58,6 +58,7 @@ class AttachmentView(ArticleMixin, FormView): ...@@ -58,6 +58,7 @@ class AttachmentView(ArticleMixin, FormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs['attachments'] = self.attachments kwargs['attachments'] = self.attachments
kwargs['search_form'] = forms.SearchForm() kwargs['search_form'] = forms.SearchForm()
kwargs['selected_tab'] = 'attachments'
return super(AttachmentView, self).get_context_data(**kwargs) return super(AttachmentView, self).get_context_data(**kwargs)
...@@ -76,6 +77,7 @@ class AttachmentHistoryView(ArticleMixin, TemplateView): ...@@ -76,6 +77,7 @@ class AttachmentHistoryView(ArticleMixin, TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs['attachment'] = self.attachment kwargs['attachment'] = self.attachment
kwargs['revisions'] = self.attachment.attachmentrevision_set.all().order_by('-revision_number') kwargs['revisions'] = self.attachment.attachmentrevision_set.all().order_by('-revision_number')
kwargs['selected_tab'] = 'attachments'
return super(AttachmentHistoryView, self).get_context_data(**kwargs) return super(AttachmentHistoryView, self).get_context_data(**kwargs)
...@@ -112,6 +114,7 @@ class AttachmentReplaceView(ArticleMixin, FormView): ...@@ -112,6 +114,7 @@ class AttachmentReplaceView(ArticleMixin, FormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs['attachment'] = self.attachment kwargs['attachment'] = self.attachment
kwargs['selected_tab'] = 'attachments'
return super(AttachmentReplaceView, self).get_context_data(**kwargs) return super(AttachmentReplaceView, self).get_context_data(**kwargs)
class AttachmentDownloadView(ArticleMixin, View): class AttachmentDownloadView(ArticleMixin, View):
...@@ -127,7 +130,6 @@ class AttachmentDownloadView(ArticleMixin, View): ...@@ -127,7 +130,6 @@ class AttachmentDownloadView(ArticleMixin, View):
return super(AttachmentDownloadView, self).dispatch(request, article, *args, **kwargs) return super(AttachmentDownloadView, self).dispatch(request, article, *args, **kwargs)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if self.revision: if self.revision:
return send_file(request, self.revision.file.path, return send_file(request, self.revision.file.path,
self.revision.created, self.attachment.original_filename) self.revision.created, self.attachment.original_filename)
...@@ -153,7 +155,10 @@ class AttachmentChangeRevisionView(ArticleMixin, View): ...@@ -153,7 +155,10 @@ class AttachmentChangeRevisionView(ArticleMixin, View):
messages.success(self.request, _(u'Current revision changed for %s.') % self.attachment.original_filename) messages.success(self.request, _(u'Current revision changed for %s.') % self.attachment.original_filename)
return redirect("wiki:attachments_index", path=self.urlpath.path, article_id=self.article.id) return redirect("wiki:attachments_index", path=self.urlpath.path, article_id=self.article.id)
def get_context_data(self, **kwargs):
kwargs['selected_tab'] = 'attachments'
return ArticleMixin.get_context_data(self, **kwargs)
class AttachmentAddView(ArticleMixin, View): class AttachmentAddView(ArticleMixin, View):
...@@ -169,7 +174,7 @@ class AttachmentAddView(ArticleMixin, View): ...@@ -169,7 +174,7 @@ class AttachmentAddView(ArticleMixin, View):
{'att': self.attachment.original_filename, {'att': self.attachment.original_filename,
'art': self.article.current_revision.title}) 'art': self.article.current_revision.title})
return redirect("wiki:attachments_index", path=self.urlpath.path, article_id=self.article.id) return redirect("wiki:attachments_index", path=self.urlpath.path, article_id=self.article.id)
class AttachmentDeleteView(ArticleMixin, FormView): class AttachmentDeleteView(ArticleMixin, FormView):
...@@ -205,6 +210,7 @@ class AttachmentDeleteView(ArticleMixin, FormView): ...@@ -205,6 +210,7 @@ class AttachmentDeleteView(ArticleMixin, FormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs['attachment'] = self.attachment kwargs['attachment'] = self.attachment
kwargs['selected_tab'] = 'attachments'
return super(AttachmentDeleteView, self).get_context_data(**kwargs) return super(AttachmentDeleteView, self).get_context_data(**kwargs)
...@@ -239,4 +245,5 @@ class AttachmentSearchView(ArticleMixin, ListView): ...@@ -239,4 +245,5 @@ class AttachmentSearchView(ArticleMixin, ListView):
kwargs['query'] = self.query kwargs['query'] = self.query
kwargs.update(kwargs_article) kwargs.update(kwargs_article)
kwargs.update(kwargs_listview) kwargs.update(kwargs_listview)
kwargs['selected_tab'] = 'attachments'
return kwargs return kwargs
...@@ -15,23 +15,16 @@ ...@@ -15,23 +15,16 @@
<li style="float: left"> <li style="float: left">
<h1 style="margin-top: -10px;">{{ article.current_revision.title }}</h1> <h1 style="margin-top: -10px;">{{ article.current_revision.title }}</h1>
</li> </li>
{% with "view" as selected %} {% include "wiki/includes/article_menu.html" %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
{% block wiki_contents_tab %}
{% wiki_render article %} {% wiki_render article %}
{% endblock %}
</div> </div>
</div> </div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <p style="margin-top: 20px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></p>
<ul class="nav nav-tabs">
{% with "view" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul>
</div>
{% endblock %} {% endblock %}
{% extends "wiki/base.html" %} {% extends "wiki/article.html" %}
{% load wiki_tags i18n %} {% load wiki_tags i18n %}
{% load url from future %} {% load url from future %}
{% block pagetitle %}{% trans "Edit" %}: {{ article.current_revision.title }}{% endblock %} {% block pagetitle %}{% trans "Edit" %}: {{ article.current_revision.title }}{% endblock %}
{% block wiki_breadcrumbs %} {% block wiki_contents_tab %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %}
<div class="tabbable tabs-top" style="margin-top: 20px;"> <form method="POST" class="form-horizontal">
<ul class="nav nav-tabs"> {% include "wiki/includes/editor.html" %}
{% with "edit" as selected %} <div class="form-actions">
{% include "wiki/includes/article_menu.html" %} <button type="submit" name="preview" value="1" class="btn btn-large" onclick="$('#previewModal').modal('show'); this.form.target='previewWindow'; this.form.action='{% url 'wiki:preview' path=urlpath.path article_id=article.id %}'">
{% endwith %} <span class="icon-eye-open"></span>
<li> {% trans "Preview" %}
<h1 style="margin-top: -10px;"> </button>
{{ article.current_revision.title }} <button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='{% url 'wiki:edit' path=urlpath.path article_id=article.id %}'">
</h1> <span class="icon-ok"></span>
</li> {% trans "Save changes" %}
</ul> </button>
<div class="tab-content">
<a href="{% url 'wiki:delete' path=urlpath.path article_id=article.id %}" class="pull-right btn btn-danger">
<form method="POST" class="form-horizontal"> <span class="icon-trash"></span>
{% include "wiki/includes/editor.html" %} {% trans "Delete article" %}
<div class="form-actions"> </a>
<button type="submit" name="preview" value="1" class="btn btn-large" onclick="$('#previewModal').modal('show'); this.form.target='previewWindow'; this.form.action='{% url 'wiki:preview' path=urlpath.path article_id=article.id %}'">
<span class="icon-eye-open"></span> </div>
{% trans "Preview" %} <div class="modal hide fade" id="previewModal" style="width: 80%; min-height: 500px; margin-left: -40%;">
</button> <div class="modal-body">
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='{% url 'wiki:edit' path=urlpath.path article_id=article.id %}'"> <iframe name="previewWindow" style="width: 100%; min-height: 400px; border: 0;" frameborder="0"></iframe>
<span class="icon-ok"></span>
{% trans "Save changes" %}
</button>
<a href="{% url 'wiki:delete' path=urlpath.path article_id=article.id %}" class="pull-right btn btn-danger">
<span class="icon-trash"></span>
{% trans "Delete article" %}
</a>
</div>
<div class="modal hide fade" id="previewModal" style="width: 80%; min-height: 500px; margin-left: -40%;">
<div class="modal-body">
<iframe name="previewWindow" style="width: 100%; min-height: 400px; border: 0;" frameborder="0"></iframe>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-large" data-dismiss="modal">
<span class="icon-circle-arrow-left"></span>
{% trans "Back to editor" %}
</a>
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='{% url 'wiki:edit' path=urlpath.path article_id=article.id %}'">
<span class="icon-ok"></span>
{% trans "Save changes" %}
</button>
</div>
</div>
</form>
</div>
</div> </div>
<div class="modal-footer">
<div class="tabbable tabs-below" style="margin-top: 20px;"> <a href="#" class="btn btn-large" data-dismiss="modal">
<ul class="nav nav-tabs"> <span class="icon-circle-arrow-left"></span>
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li> {% trans "Back to editor" %}
</ul> </a>
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='{% url 'wiki:edit' path=urlpath.path article_id=article.id %}'">
<span class="icon-ok"></span>
{% trans "Save changes" %}
</button>
</div> </div>
</div>
</form>
{% endblock %} {% endblock %}
{% load i18n wiki_tags %}{% load url from future %} {% load i18n wiki_tags %}{% load url from future %}
{% with selected_tab as selected %}
{% 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 %}">
...@@ -36,3 +38,5 @@ ...@@ -36,3 +38,5 @@
{% trans "View" %} {% trans "View" %}
</a> </a>
</li> </li>
{% endwith %}
...@@ -20,14 +20,17 @@ from django.core.urlresolvers import reverse ...@@ -20,14 +20,17 @@ from django.core.urlresolvers import reverse
from django.db import transaction from django.db import transaction
from wiki.core.exceptions import NoRootURL from wiki.core.exceptions import NoRootURL
class ArticleView(ArticleMixin, TemplateView, ): class ArticleView(ArticleMixin, TemplateView):
template_name="wiki/article.html" template_name="wiki/article.html"
@method_decorator(get_article(can_read=True)) @method_decorator(get_article(can_read=True))
def dispatch(self, request, article, *args, **kwargs): def dispatch(self, request, article, *args, **kwargs):
return super(ArticleView, self).dispatch(request, article, *args, **kwargs) return super(ArticleView, self).dispatch(request, article, *args, **kwargs)
def get_context_data(self, **kwargs):
kwargs['selected_tab'] = 'view'
return ArticleMixin.get_context_data(self, **kwargs)
class Create(FormView, ArticleMixin): class Create(FormView, ArticleMixin):
...@@ -181,6 +184,7 @@ class Edit(FormView, ArticleMixin): ...@@ -181,6 +184,7 @@ class Edit(FormView, ArticleMixin):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs['edit_form'] = kwargs.pop('form', None) kwargs['edit_form'] = kwargs.pop('form', None)
kwargs['editor'] = editors.editor kwargs['editor'] = editors.editor
kwargs['selected_tab'] = 'edit'
return super(Edit, self).get_context_data(**kwargs) return super(Edit, self).get_context_data(**kwargs)
...@@ -200,6 +204,7 @@ class History(ListView, ArticleMixin): ...@@ -200,6 +204,7 @@ class History(ListView, ArticleMixin):
kwargs_listview = ListView.get_context_data(self, **kwargs) kwargs_listview = ListView.get_context_data(self, **kwargs)
kwargs.update(kwargs_article) kwargs.update(kwargs_article)
kwargs.update(kwargs_listview) kwargs.update(kwargs_listview)
kwargs['selected_tab'] = 'history'
return kwargs return kwargs
@method_decorator(get_article(can_read=True)) @method_decorator(get_article(can_read=True))
...@@ -267,6 +272,7 @@ class Settings(ArticleMixin, TemplateView): ...@@ -267,6 +272,7 @@ class Settings(ArticleMixin, TemplateView):
return redirect('wiki:settings', article_id=self.article.id) return redirect('wiki:settings', article_id=self.article.id)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs['selected_tab'] = 'settings'
kwargs['forms'] = self.forms kwargs['forms'] = self.forms
return super(Settings, self).get_context_data(**kwargs) return super(Settings, self).get_context_data(**kwargs)
......
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