1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 05:39:59 +00:00

[wiki] improved ui & fixed bugs

This commit is contained in:
llj
2013-03-15 16:57:33 +08:00
parent f9ac102378
commit d1039e16d5
4 changed files with 91 additions and 122 deletions

View File

@@ -7,7 +7,6 @@
{% block title_panel %}
<div class="tabnav">
<div class="grp-profile fright">
{% grp_avatar group.props.id 24 %}<span class="name">{{ group.group_name }}</span>
@@ -25,65 +24,52 @@
{% endblock %}
{% block main_panel %}
<div id="wiki-home" class="">
{% if not wiki_exists %}
<div class="empty-tips">
<h2 class="center-contents">{% trans "This group currently has no wiki" %}</h2>
<p>Wiki is a normal library with pre-defined file/folder structure. It enables group members to manage project documents or take notes using a simplified markup language called Markdown.<a id="wiki-create" href="#">{% trans "Create Wiki Now." %}</a></p>
</div>
<form id="wiki-create-form" action="" method="post" class="hide">
<h3>{% trans "Create Wiki"%}</h3>
<label>{% trans "Name"%}</label><br/>
<input id="repo-name" type="text" name="repo_name" value="" maxlength="{{max_file_name}}"/><br />
<label>{% trans "Description"%}</label><br/>
<textarea id="repo-desc" name="repo_desc"></textarea>
<p class="error hide"></p>
<input type="submit" id="wiki-create-submit" value="{% trans "Submit"%}" class="submit"/>
</form>
{% else %}
<ul class="wiki-nav" id="">
<li><a href="{% url 'group_wiki' group.id %}">{% trans "Home" %}</a></li>
<li><a href="{% url 'group_wiki_pages' group.id %}">{% trans "Pages" %}</a></li>
</ul>
{% if not wiki_exists %}
<div class="empty-tips">
<h2 class="center-contents">{% trans "This group currently has no wiki" %}</h2>
<p>{% trans "Wiki is a normal library with pre-defined file/folder structure. It enables group members to manage project documents or take notes using a simplified markup language called Markdown." %}</p>
<a id="wiki-create" href="#">{% trans "Create Wiki Now" %}</a>
</div>
<form id="wiki-create-form" action="" method="post" class="hide">
<h3>{% trans "Create Wiki"%}</h3>
<label>{% trans "Name"%}</label><br/>
<input id="repo-name" type="text" name="repo_name" value="" maxlength="{{max_file_name}}"/><br />
<label>{% trans "Description"%}</label><br/>
<textarea id="repo-desc" name="repo_desc"></textarea><br/>
<p class="error hide"></p>
<input type="submit" id="wiki-create-submit" value="{% trans "Submit"%}" class="submit" />
</form>
<button id="page-create" class="fright">{% trans "New Page" %}</button>
<button id="page-delete" class="fright" data-url="{% url 'group_wiki_page_delete' group.id page %}">{% trans "Delete Page" %}</button>
<button id="page-edit" class="fright">{% trans "Edit Page" %}</button>
{% else %}
<div class="wiki-top ovhd">
<button id="page-create" class="op-btn">{% trans "New Page" %}</button>
<button id="page-delete" class="op-btn" data-url="{% url 'group_wiki_page_delete' group.id page %}">{% trans "Delete Page" %}</button>
<button id="page-edit" class="op-btn">{% trans "Edit Page" %}</button>
<ul class="wiki-nav fleft">
<li class="item">{% trans "Home" %}</li>
<li class="item"><a href="{% url 'group_wiki_pages' group.id %}" class="link">{% trans "Pages" %}</a></li>
</ul>
</div>
<div id="wiki-area" class="article">
<h1>{{ page|capfirst }}</h1>
<div id="wiki-content"></div>
</div>
<form id="page-create-form" action="{% url 'group_wiki_page_new' group.id %}" method="post" class="hide">
<h3>{% trans "New Page"%}</h3>
<label>{% trans "Name"%}</label><br/>
<input id="page-name" type="text" name="page_name" value="" maxlength="{{max_file_name}}"/><br />
<p class="error hide"></p>
<input type="submit" id="page-create-submit" value="{% trans "Submit"%}" class="submit"/>
</form>
{% endif %}
</div> <!--END wiki-home-->
<div id="wiki-area" class="article">
<h1>{{ page|capfirst }}</h1>
<div id="wiki-content"></div><!--content will be offered by js-->
</div>
<form id="page-create-form" action="{% url 'group_wiki_page_new' group.id %}" method="post" class="hide">
<h3>{% trans "New Page"%}</h3>
<label>{% trans "Name"%}</label><br/>
<input id="page-name" type="text" name="page_name" value="" maxlength="{{max_file_name}}"/><br />
<p class="error hide"></p>
<input type="submit" id="page-create-submit" value="{% trans "Submit"%}" class="submit"/>
</form>
{% endif %}
{% endblock main_panel %}
{% block left_panel %}
{% endblock %}
{% block right_panel %}
{% endblock %}
{% block extra_script %}
<script type="text/javascript" src="{{MEDIA_URL}}js/showdown.js"></script>
<script type="text/javascript">
{% if wiki_exists %}
var converter = new Showdown.converter();
$('#wiki-content').html(converter.makeHtml('{{ content|escapejs }}')).children(':first').css('margin-top', '0');
@@ -101,21 +87,20 @@ $('#page-list').click(function () {
});
addConfirmTo($('#page-delete'), {
'title': 'Delete page',
'title': 'Delete Page',
'con': 'Are you sure you want to delete this page?'
});
{% else %}
$('#wiki-create').click(function() {
$('#wiki-create-form').modal({appendTo: '#main', autoResize: true});
return false;
});
$('#wiki-create-submit').click(function () {
// if (!$.trim($('#repo-name').val()) || !$.trim($('#repo-desc').val())) {
// apply_form_error('wiki-create-form', '{% trans 'Name and description can not be blank.' %}');
// return false;
// }
if (!$.trim($('#repo-name').val()) || !$.trim($('#repo-desc').val())) {
apply_form_error('wiki-create-form', '{% trans 'Name and description can not be blank.' %}');
return false;
}
var submit_btn = $(this);
disable(submit_btn);
@@ -123,7 +108,7 @@ $('#wiki-create-submit').click(function () {
url: '{% url 'group_wiki_create' group.id %}',
type: 'POST',
dataType: 'json',
cache: 'false',
cache: false,
beforeSend: prepareCSRFToken,
data: {
'repo_name': $('#repo-name').val(),
@@ -144,6 +129,5 @@ $('#wiki-create-submit').click(function () {
return false;
});
{% endif %} // END if wiki_exists
</script>
{% endblock %}

View File

@@ -5,72 +5,49 @@
{% block nav_group_class %}class="cur"{% endblock %}
{% block title_panel %}
{% endblock %}
{% block main_panel %}
<div class="tabnav">
<div class="grp-profile fright">
{% grp_avatar group.props.id 24 %}<span class="name">{{ group.group_name }}</span>
</div>
<ul class="tabnav-tabs">
<li class="tabnav-tab"><a href="{% url 'group_info' group.id %}">{% trans "Libraries" %}</a></li>
<li class="tabnav-tab"><a href="{% url 'group_discus' group.id %}">{% trans "Discussions" %}</a></li>
<li class="tabnav-tab"><a href="{% url 'group_discuss' group.id %}">{% trans "Discussion" %}</a></li>
<li class="tabnav-tab tabnav-tab-cur">{% trans "Wiki" %}</li>
{% if is_staff %}
<li class="tabnav-tab"><a href="{% url 'group_manage' group.id %}">{% trans "Admin" %}</a></li>
{% endif %}
</ul>
<div class="fright">
{% grp_avatar group.props.id 24 %} <span style="font-size: 16px; font-weight:bold; margin: 0 6px;">{{ group.group_name }}</span>
</div>
</div>
<div id="">
<ul class="wiki-nav" id="">
<li><a href="{% url 'group_wiki' group.id %}">{% trans "Home" %}</a></li>
<li><a href="{% url 'group_wiki_pages' group.id %}">{% trans "Pages" %}</a></li>
</ul>
<div class="wiki-top ovhd">
<button id="page-create" class="op-btn">{% trans "New Page" %}</button>
<ul class="wiki-nav fleft">
<li class="item"><a href="{% url 'group_wiki' group.id %}" class="link">{% trans "Home" %}</a></li>
<li class="item">{% trans "Pages" %}</li>
</ul>
</div>
<button id="page-create" class="fright">{% trans "New Page" %}</button>
<ul id="wiki-pages">
{% for page in pages %}
<li><a href="{% url 'group_wiki' group.id page %}">{{ page }}</a></li>
{% endfor %}
</ul>
<div id="wiki-area" class="article">
<h1>Pages</h1>
<div id="wiki-content">
{% for page in pages %}
<ul>
<li><a href="{% url 'group_wiki' group.id page %}">{{ page }}</a></li>
</ul>
{% endfor %}
</div>
</div>
<form id="page-create-form" action="{% url 'group_wiki_page_new' group.id %}" method="post" class="hide">
<form id="page-create-form" action="{% url 'group_wiki_page_new' group.id %}" method="post" class="hide">
<h3>{% trans "New Page"%}</h3>
<label>{% trans "Name"%}</label><br/>
<input id="page-name" type="text" name="page_name" value="" maxlength="{{max_file_name}}"/><br />
<p class="error hide"></p>
<input type="submit" id="page-create-submit" value="{% trans "Submit"%}" class="submit"/>
</form>
</div>
<input type="submit" id="page-create-submit" value="{% trans "Submit"%}" class="submit" />
</form>
{% endblock main_panel %}
{% block left_panel %}
{% endblock %}
{% block right_panel %}
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$('#page-create').click(function() {
$('#page-create-form').modal({appendTo: '#main', autoResize: true});
})
</script>
{% endblock %}

View File

@@ -1138,7 +1138,7 @@ def convert_wiki_link(content, group, repo_id, username):
(reverse('group_wiki', args=[group.id, linkname.replace('/', '-')]), linkname)
token = web_get_access_token(repo_id, obj_id, 'view', username)
return '<img src="%s" />' % gen_file_get_url(token, filename)
return '<img src="%s" alt="%s" />' % (gen_file_get_url(token, filename), filename)
else:
from base.templatetags.seahub_tags import file_icon_filter
@@ -1146,8 +1146,8 @@ def convert_wiki_link(content, group, repo_id, username):
path = "/" + linkname
icon = file_icon_filter(linkname)
s = reverse('repo_view_file', args=[repo_id]) + '?p=' + path
a_tag = '''<a href='%s' target='_blank'><img class="wiki-link-icon" src="%simg/file/%s" />%s</a>'''
return a_tag % (s, MEDIA_URL, icon, linkname)
a_tag = '''<img src="%simg/file/%s" alt="%s" class="vam" /> <a href='%s' target='_blank' class="vam">%s</a>'''
return a_tag % (MEDIA_URL, icon, icon, s, linkname)
return re.sub(r'\[\[(.+)\]\]', repl, content)
@@ -1211,9 +1211,12 @@ def group_wiki_pages(request, group):
if ext == '.md':
pages.append(name)
is_staff = True if check_group_staff(group.id, request.user) else False
return render_to_response("group/group_wiki_pages.html", {
"group": group,
"pages": pages,
"is_staff": is_staff,
}, context_instance=RequestContext(request))
@login_required

View File

@@ -1745,7 +1745,8 @@ textarea:-moz-placeholder {/* for FF */
#md-view {
width:756px;
}
#md-view h2 {
#md-view h2,
#wiki-content h2 {
border-bottom: 1px solid #ccc;
}
#svg-view {
@@ -2016,31 +2017,35 @@ textarea:-moz-placeholder {/* for FF */
}
/* wiki page */
.wiki-nav li{
display: inline-block;
.wiki-top {
text-align:right;
padding-bottom:8px;
border-bottom:1px solid #eee;
}
#wiki-area.article {
.wiki-top .op-btn {
margin-left:3px;
}
.wiki-nav .item {
float:left;
font-size:15px;
margin:4px 5px 0 10px;
}
.wiki-nav .link {
font-weight:normal;
}
#wiki-area {
padding: 0 0;
}
#wiki-create-form {
width: 262px;
}
#wiki-create-form input[type="text"]{
width: 100%;
}
#wiki-create-form textarea {
width: 100%;
}
#page-edit {
margin-right:6px;
#wiki-pages {
list-style-type:disc;
padding-left:2em;
margin-top:1.6em;
}
.wiki-page-missing {
color:red;
}
.wiki-link-icon {
margin: 0 3px -5px 0;
}
/* search */
.search-form {
padding-left:5px;
height:24px;