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

Finish URL design

This commit is contained in:
Daniel Pan
2015-04-11 17:35:02 +08:00
parent 6680e8e88e
commit fd3a150717
8 changed files with 57 additions and 47 deletions

View File

@@ -47,14 +47,14 @@
{% block nav %}
<ul class="nav">
<li class="nav-item">
<a href="{{ SITE_ROOT }}libs/" class="a {% block cur_myhome %}{% endblock %}">{% trans "My Home" %}</a>
<a href="{{ SITE_ROOT }}#my-libs/" class="a {% block cur_myhome %}{% endblock %}">{% trans "My Home" %}</a>
</li>
<li class="nav-item nav-item-group" {% if grps %}style="position:relative;"{% endif %}>
<a href="{% url 'group_list' %}" class="a {% block cur_group %}{% endblock %}" {% if grps %}id="top-nav-grp"{% endif %}>{% trans "Groups" %}{% if grps %} <span class="icon-caret-down"></span>{% endif %}</a>
</li>
{% if user.permissions.can_view_org %}
<li class="nav-item">
<a href="{{ SITE_ROOT }}libs/#org" class="a {% block cur_pubinfo %}{% endblock %}">{% trans "Organization" %}</a>
<a href="{{ SITE_ROOT }}#org/" class="a {% block cur_pubinfo %}{% endblock %}">{% trans "Organization" %}</a>
</li>
{% endif %}
<li class="nav-item">

View File

@@ -55,7 +55,7 @@
<% } %>
<% } %>
</td>
<td><a href="#/group/<%= group_id %>/<%= id %>"><%- name %></a></td>
<td><a href="#/group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td>
<td class="alc">
<% if (app.pageOptions.isGroupStaff) { %>
<img src="<%= app.config.mediaUrl%>img/delete-orange.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
@@ -77,7 +77,7 @@
<% } %>
<% } %>
</td>
<td><a href="#org/<%= id %>"><%- name %></a></td>
<td><a href="#org/lib/<%= id %>"><%- name %></a></td>
<td class="alc">
<% if (show_unshare_btn) { %>
<img src="<%= app.config.mediaUrl%>img/delete-orange.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
@@ -146,10 +146,13 @@
<% } %>
</script>
<script type="text/template" id="path-bar-tmpl">
<a href="#" class="path-link normal">{% trans "Libraries" %}</a> /
<% if (category) { %>
<a href="#<%= category %>" class="path-link normal"><% if (category == 'my-libs') { %>{% trans "Mine" %}<% } %><% if (category == 'shared-libs') { %>{% trans "Shared" %}<% } %><% if (category == 'my-sub-libs') { %>{% trans "Sub-libraries" %}<% } %></a> /
<% if (context == 'group') { %>
<a href="#<%= category %>/" class="path-link normal">{% trans "Libraries" %}</a> /
<% } else if (context == 'org') { %>
<a href="#<%= category %>/" class="path-link normal">{% trans "Libraries" %}</a> /
<% } else { %>
<a href="#" class="path-link normal">{% trans "Libraries" %}</a> /
<a href="#<%= category %>/" class="path-link normal"><% if (category == 'my-libs') { %>{% trans "Mine" %}<% } %><% if (category == 'shared-libs') { %>{% trans "Shared" %}<% } %><% if (category == 'my-sub-libs') { %>{% trans "Sub-libraries" %}<% } %></a> /
<% } %>
<% if (path == '/') { %>
<%- repo_name %> /

View File

@@ -31,7 +31,7 @@
{% endif %}
</div>
<ul class="side-tabnav-tabs">
<li class="tab tab-cur"><a href="{% url 'myhome' %}#" class="lib">{% trans "Libraries" %}</a></li>
<li class="tab tab-cur"><a href="{{ SITE_ROOT }}#my-libs/" class="lib">{% trans "Libraries" %}</a></li>
<li class="tab {% block cur_stars %}{% endblock %}"><a href="{% url 'starred' %}" class="star">{% trans "Starred" %}</a></li>
{% if events_enabled %}
<li class="tab {% block cur_activities %}{% endblock %}"><a href="{% url 'activities' %}" class="activity">{% trans "Activities" %}</a></li>
@@ -67,12 +67,12 @@
<div class="hd">
<ul class="tab-tabs-nav fleft">
{% if user.permissions.can_add_repo %}
<li class="tab"><a href="#my-libs" class="a" id="mylib-tab">{% trans "Mine" %}</a></li>
<li class="tab"><a href="#my-libs/" class="a" id="mylib-tab">{% trans "Mine" %}</a></li>
{% if sub_lib_enabled %}
<li class="tab"><a href="#my-sub-libs" class="a" id="sublib-tab">{% trans "Sub-libraries" %}</a></li>
<li class="tab"><a href="#my-sub-libs/" class="a" id="sublib-tab">{% trans "Sub-libraries" %}</a></li>
{% endif %}
{% endif %}
<li class="tab"><a href="#shared-libs" class="a" id="shared-lib-tab">{% trans "Shared" %}</a></li>
<li class="tab"><a href="#shared-libs/" class="a" id="shared-lib-tab">{% trans "Shared" %}</a></li>
</ul>
<div class="fright">
<button id="repo-create" class=""><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>

View File

@@ -38,7 +38,7 @@ urlpatterns = patterns('',
(r'^accounts/', include('seahub.base.registration_urls')),
(r'^$', myhome),
url(r'^$', libraries, name='libraries'),
#url(r'^home/$', direct_to_template, { 'template': 'home.html' } ),
url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
url(r'^home/my/$', myhome, name='myhome'),

View File

@@ -7,22 +7,22 @@ define([
'app/views/group',
'app/views/organization',
'app/views/group-nav',
], function($, Backbone, Common, MyHomeView, GroupView, orgView,
], function($, Backbone, Common, MyHomeView, GroupView, OrgView,
GroupNavView) {
"use strict";
var Router = Backbone.Router.extend({
routes: {
'my-libs': 'showMyRepos',
'my-libs/': 'showMyRepos',
'my-libs/lib/:repo_id(/*path)': 'showMyRepoDir',
'my-sub-libs': 'showMySubRepos',
'my-sub-libs/': 'showMySubRepos',
'my-sub-libs/lib/:repo_id(/*path)': 'showMySubRepoDir',
'shared-libs': 'showSharedRepos',
'shared-libs/': 'showSharedRepos',
'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir',
'group/:group_id/': 'showGroupRepos',
'group/:group_id/:repo_id(/*path)': 'showGroupRepoDir',
'org': 'showOrgRepos',
'org/:repo_id(/*path)': 'showOrgRepoDir',
'group/:group_id/lib/:repo_id(/*path)': 'showGroupRepoDir',
'org/': 'showOrgRepos',
'org/lib/:repo_id(/*path)': 'showOrgRepoDir',
// Default
'*actions': 'defaultAction'
@@ -35,27 +35,31 @@ define([
this.myHomeView = new MyHomeView();
this.groupView = new GroupView();
this.orgView = new orgView();
this.orgView = new OrgView();
this.currentView = this.myHomeView;
this.groupNavView = new GroupNavView();
},
showMyRepos: function() {
switchCurrentView: function(newView) {
if (this.currentView != newView) {
this.currentView.hide();
this.currentView = this.myHomeView;
this.currentView = newView;
}
},
showMyRepos: function() {
this.switchCurrentView(this.myHomeView);
this.myHomeView.showMyRepos();
},
showMySubRepos: function() {
this.currentView.hide();
this.currentView = this.myHomeView;
this.switchCurrentView(this.myHomeView);
this.myHomeView.showMySubRepos();
},
showSharedRepos: function() {
this.currentView.hide();
this.currentView = this.myHomeView;
this.switchCurrentView(this.myHomeView);
this.myHomeView.showSharedRepos();
},
@@ -65,8 +69,7 @@ define([
} else {
path = '/';
}
this.currentView.hide();
this.currentView = this.myHomeView;
this.switchCurrentView(this.myHomeView);
this.myHomeView.showDir('my-libs', repo_id, path);
},
@@ -76,8 +79,7 @@ define([
} else {
path = '/';
}
this.currentView.hide();
this.currentView = this.myHomeView;
this.switchCurrentView(this.myHomeView);
this.myHomeView.showDir('my-sub-libs', repo_id, path);
},
@@ -87,14 +89,12 @@ define([
} else {
path = '/';
}
this.currentView.hide();
this.currentView = this.myHomeView;
this.switchCurrentView(this.myHomeView);
this.myHomeView.showDir('shared-libs', repo_id, path);
},
showGroupRepos: function(group_id) {
this.currentView.hide();
this.currentView = this.groupView;
this.switchCurrentView(this.groupView);
this.groupView.showRepoList(group_id);
},
@@ -104,14 +104,12 @@ define([
} else {
path = '/';
}
this.currentView.hide();
this.currentView = this.groupView;
this.switchCurrentView(this.groupView);
this.groupView.showDir(group_id, repo_id, path);
},
showOrgRepos: function() {
this.currentView.hide();
this.currentView = this.orgView;
this.switchCurrentView(this.orgView);
this.orgView.showRepoList();
},
@@ -121,8 +119,7 @@ define([
} else {
path = '/';
}
this.currentView.hide();
this.currentView = this.orgView;
this.switchCurrentView(this.orgView);
this.orgView.showDir(repo_id, path);
},
@@ -130,6 +127,7 @@ define([
// We have no matching route, lets just log what the URL was
console.log('No route:', actions);
this.switchCurrentView(this.myHomeView);
this.myHomeView.showMyRepos();
}
});

View File

@@ -225,12 +225,20 @@ define([
},
renderPath: function() {
var dir = this.dir,
path = dir.path,
obj = {
var dir = this.dir;
var path = dir.path;
var context = 'my';
if (dir.category.startsWith('org')) {
context = 'org';
} else if (dir.category.startsWith('group')) {
context = 'group';
}
var obj = {
path: path,
repo_name: dir.repo_name,
category: dir.category
category: dir.category,
context: context
};
var path_list = path.substr(1).split('/');

View File

@@ -91,7 +91,7 @@ define([
showDir: function(group_id, repo_id, path) {
this.group_id = group_id;
this.hideRepoList();
this.dirView.showDir('', repo_id, path);
this.dirView.showDir('group/' + this.group_id, repo_id, path);
},
createRepo: function() {
@@ -141,6 +141,7 @@ define([
},
hide: function() {
console.log("hide group view");
this.hideRepoList();
this.dirView.hide();
}

View File

@@ -75,7 +75,7 @@ define([
showDir: function(repo_id, path) {
var path = path || '/';
this.hideRepoList();
this.dirView.showDir('', repo_id, path);
this.dirView.showDir('org', repo_id, path);
// this.dirent_list = new app.DirentListView({id: id, path: path});
// $('#my-own-repos table').children().remove();
// $('#my-own-repos table').append(this.dirent_list.render().el);