cleanly applied pushstate changes, new URL structure

pull/263/head
Justin Richer 12 years ago
parent 56dcb33d35
commit 33f11cb98f

@ -29,7 +29,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/ */
@Controller @Controller
@RequestMapping("/")
@PreAuthorize("hasRole('ROLE_USER')") // TODO: this probably shouldn't be here @PreAuthorize("hasRole('ROLE_USER')") // TODO: this probably shouldn't be here
public class ManagerController { public class ManagerController {
@ -46,8 +45,9 @@ public class ManagerController {
return "home"; return "home";
} }
@RequestMapping("admin/manage") @RequestMapping("manage/**")
public String showClientManager() { public String showClientManager() {
// TODO: move view
return "admin/manage"; return "admin/manage";
} }

@ -8,6 +8,7 @@
<script type="text/javascript" src="resources/js/underscore-min.js"></script> <script type="text/javascript" src="resources/js/underscore-min.js"></script>
<script type="text/javascript" src="resources/js/backbone-min.js"></script> <script type="text/javascript" src="resources/js/backbone-min.js"></script>
<script type="text/javascript" src="resources/js/backbone.validations.js"></script> <script type="text/javascript" src="resources/js/backbone.validations.js"></script>
<script type="text/javascript" src="resources/js/purl.js"></script>
<c:if test="${js != null || js != ''}"> <c:if test="${js != null || js != ''}">
<script type="text/javascript" src="${js}"></script> <script type="text/javascript" src="${js}"></script>
</c:if> </c:if>

@ -5,14 +5,14 @@
<ul class="nav nav-list"> <ul class="nav nav-list">
<security:authorize ifAnyGranted="ROLE_ADMIN"> <security:authorize ifAnyGranted="ROLE_ADMIN">
<li class="nav-header">Administrative</li> <li class="nav-header">Administrative</li>
<li><a href="admin/manage/#clients">Manage Clients</a></li> <li><a href="manage/#admin/clients">Manage Clients</a></li>
<li><a href="admin/manage/#white_list">White Lists</a></li> <li><a href="manage/#admin/white_list">White Lists</a></li>
<li><a href="#">Black Lists</a></li> <li><a href="manage/#admin/black_list">Black Lists</a></li>
</security:authorize> </security:authorize>
<li class="nav-header">Personal</li> <li class="nav-header">Personal</li>
<li><a href="#">Manage Sites</a></li> <li><a href="manage/#user/grants">Manage Sites</a></li>
<li><a href="#">Manage Active Tokens</a></li> <li><a href="manage/#user/tokens">Manage Active Tokens</a></li>
<li><a href="#">Manage Profiles</a></li> <li><a href="manage/#user/profile">Manage Profiles</a></li>
</ul> </ul>
</div><!--/.well --> </div><!--/.well -->
</div><!--/span--> </div><!--/span-->

@ -8,20 +8,20 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</a> </a>
<a class="brand" style="padding-left: 35px" href="#">OpenID Connect Server</a> <a class="brand" style="padding-left: 35px" href="">OpenID Connect Server</a>
<div class="nav-collapse"> <div class="nav-collapse">
<ul class="nav"> <ul class="nav">
<li class="active"><a href="#">Home</a></li> <li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li> <li><a href="about">About</a></li>
<li><a href="#contact">Statistics</a></li> <li><a href="stats">Statistics</a></li>
<li><a href="#contact">Contact</a></li> <li><a href="contact">Contact</a></li>
</ul> </ul>
<p class="navbar-text pull-right"> <p class="navbar-text pull-right">
<security:authentication property="authorities" var="roles"/> <security:authentication property="authorities" var="roles"/>
<security:authorize access="hasRole('ROLE_USER')"> <security:authorize access="hasRole('ROLE_USER')">
Logged in as <a href="#">${ userInfo.preferredUsername }</a> Logged in as <a href="home">${ userInfo.preferredUsername }</a>
</security:authorize> </security:authorize>
</p> </p>
</div><!--/.nav-collapse --> </div><!--/.nav-collapse -->

@ -90,7 +90,7 @@
model = new URIModel({item:input_value}); model = new URIModel({item:input_value});
} else { } else {
model = new Backbone.Model({item:input_value}); model = new Backbone.Model({item:input_value});
model.validate = function() { if(!this.get("item")) return "value can't be null" }; model.validate = function() { if(!this.get("item")) return "value can't be null"; };
} }
// if it's valid and doesn't already exist // if it's valid and doesn't already exist
@ -558,10 +558,10 @@
var AppRouter = Backbone.Router.extend({ var AppRouter = Backbone.Router.extend({
routes:{ routes:{
"clients":"listClients", "admin/clients":"listClients",
"client/new":"newClient", "admin/client/new":"newClient",
"client/:id":"editClient", "admin/client/:id":"editClient",
"white_list":"whiteList", "admin/white_list":"whiteList",
'*path': 'listClients' '*path': 'listClients'
}, },
@ -584,10 +584,13 @@
startAfter:function (collections) { startAfter:function (collections) {
// Start history when required collections are loaded // Start history when required collections are loaded
var start = _.after(collections.length, _.once(function () { var start = _.after(collections.length, _.once(function () {
Backbone.history.start() var baseUrl = $.url($('base').attr('href'));
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
})); }));
_.each(collections, function (collection) { _.each(collections, function (collection) {
collection.bind('reset', start, Backbone.history) collection.bind('reset', start, Backbone.history);
}); });
}, },
@ -595,8 +598,8 @@
this.breadCrumbView.collection.reset(); this.breadCrumbView.collection.reset();
this.breadCrumbView.collection.add([ this.breadCrumbView.collection.add([
{text:"Home", href:"/"}, {text:"Home", href:""},
{text:"Manage Clients", href:"admin/manage/#clients"} {text:"Manage Clients", href:"manage/#admin/clients"}
]); ]);
$('#content').html(this.clientListView.render().el); $('#content').html(this.clientListView.render().el);
@ -608,9 +611,9 @@
this.breadCrumbView.collection.reset(); this.breadCrumbView.collection.reset();
this.breadCrumbView.collection.add([ this.breadCrumbView.collection.add([
{text:"Home", href:"/"}, {text:"Home", href:""},
{text:"Manage Clients", href:"admin/manage/#clients"}, {text:"Manage Clients", href:"manage/#admin/clients"},
{text:"New", href:"#"} {text:"New", href:""}
]); ]);
var client = new ClientModel(); var client = new ClientModel();
@ -631,9 +634,9 @@
this.breadCrumbView.collection.reset(); this.breadCrumbView.collection.reset();
this.breadCrumbView.collection.add([ this.breadCrumbView.collection.add([
{text:"Home", href:"/"}, {text:"Home", href:""},
{text:"Manage Clients", href:"admin/manage/#clients"}, {text:"Manage Clients", href:"manage/#admin/clients"},
{text:"Edit", href:"#"} {text:"Edit", href:"manage/#admin/client/" + id}
]); ]);
var client = this.clientList.get(id); var client = this.clientList.get(id);
@ -681,6 +684,11 @@
app = new AppRouter(); app = new AppRouter();
$('a[href*="#"').on('click', function(event) {
event.preventDefault();
app.navigate(this.hash.slice(1), {trigger: true});
});
}); });

Loading…
Cancel
Save