Skip to content

Commit

Permalink
Item13069: fixing client-side url rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Nov 6, 2014
1 parent 8ac0880 commit fa21687
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 46 deletions.
6 changes: 6 additions & 0 deletions pub/System/AngularSkin/app.uncompressed.css
Expand Up @@ -21,6 +21,12 @@
body #loading-bar .bar {
background-color: #b91f1f;
height:5px;
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-topright: 5px;
-moz-border-radius-bottomright: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
body #loading-bar .peg {
height:5px;
Expand Down
55 changes: 32 additions & 23 deletions pub/System/AngularSkin/directives.uncompressed.js
Expand Up @@ -24,10 +24,9 @@ app.directive('foswikiContents', [
$anchorScroll,
foswikiService
) {

var viewScriptUrl = foswiki.getScriptUrl("origview"),
angularScriptUrl = foswiki.getScriptUrl("angular"),
urlFilter = new RegExp("^"+viewScriptUrl+"(?=/[A-Z])"),
urlFilter = new RegExp("^"+viewScriptUrl+"/([A-Z_]\\w+(?:/[A-Z_]\\w+)*)/([^\/#]+)"),
anchorFilter = new RegExp("^"+angularScriptUrl+"/[A-Z].*#"),
excludeFilter = new RegExp(foswiki.getPreference("ANGULAR_EXCLUDE"));

Expand All @@ -36,32 +35,42 @@ app.directive('foswikiContents', [

// view urls
content.find("a").filter(function() {
var href = this.href;
return urlFilter.test(href) && !excludeFilter.test(href);
}).each(function() {

var $this = angular.element(this),
var href = this.href,
search = this.search,
href = this.href.replace(viewScriptUrl, angularScriptUrl),
ignore = false;
web, topic,
match = true;

// find view urls
if (!urlFilter.test(href)) {
match = false;
} else {

// test excludeFilter
web = RegExp.$1;
topic = RegExp.$2;

if (search) {
search.replace(/^\?/, '').split('&').map(function(val) {
var param = val.split('=');
if (excludeFilter.test(web+"."+topic)) {
match = false;
} else {

// ignore links to that have a contenttype param. these are pdf links
if (param[0] === "contenttype") {
ignore = true;
}
});
if (search) {
search.replace(/^\?/, '').split('&').map(function(val) {
var param = val.split('=');
if (param[0] === "contenttype") {
match = false;
}
});
}
}
}

if (ignore) {
//$log.debug("ignoring ",href);
} else {
$log.debug("rewriting url ",this.href,"to", href);
$this.attr("href", href);
}
return match;
}).each(function() {

var href = this.href.replace(viewScriptUrl, angularScriptUrl);
//$log.debug("rewriting url ",this.href,"to", href);
this.href = href;
});

// view forms
Expand Down Expand Up @@ -160,7 +169,7 @@ if (0) {
}

if (content) {
//_rewriteUrls(content);
_rewriteUrls(content);
content.find(".foswikiCurrentTopicLink").on("click", function() {
$rootScope.forceReload = (new Date()).getTime();
$rootScope.$apply();
Expand Down
6 changes: 6 additions & 0 deletions pub/System/AngularSkin/pkg.uncompressed.css
Expand Up @@ -3179,6 +3179,12 @@ Copyright (c) 2014 Daniel Eden
body #loading-bar .bar {
background-color: #b91f1f;
height:5px;
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-topright: 5px;
-moz-border-radius-bottomright: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
body #loading-bar .peg {
height:5px;
Expand Down
55 changes: 32 additions & 23 deletions pub/System/AngularSkin/pkg.uncompressed.js
Expand Up @@ -384,10 +384,9 @@ app.directive('foswikiContents', [
$anchorScroll,
foswikiService
) {

var viewScriptUrl = foswiki.getScriptUrl("origview"),
angularScriptUrl = foswiki.getScriptUrl("angular"),
urlFilter = new RegExp("^"+viewScriptUrl+"(?=/[A-Z])"),
urlFilter = new RegExp("^"+viewScriptUrl+"/([A-Z_]\\w+(?:/[A-Z_]\\w+)*)/([^\/#]+)"),
anchorFilter = new RegExp("^"+angularScriptUrl+"/[A-Z].*#"),
excludeFilter = new RegExp(foswiki.getPreference("ANGULAR_EXCLUDE"));

Expand All @@ -396,32 +395,42 @@ app.directive('foswikiContents', [

// view urls
content.find("a").filter(function() {
var href = this.href;
return urlFilter.test(href) && !excludeFilter.test(href);
}).each(function() {

var $this = angular.element(this),
var href = this.href,
search = this.search,
href = this.href.replace(viewScriptUrl, angularScriptUrl),
ignore = false;
web, topic,
match = true;

if (search) {
search.replace(/^\?/, '').split('&').map(function(val) {
var param = val.split('=');
// find view urls
if (!urlFilter.test(href)) {
match = false;
} else {

// test excludeFilter
web = RegExp.$1;
topic = RegExp.$2;

if (excludeFilter.test(web+"."+topic)) {
match = false;
} else {

// ignore links to that have a contenttype param. these are pdf links
if (param[0] === "contenttype") {
ignore = true;
}
});
if (search) {
search.replace(/^\?/, '').split('&').map(function(val) {
var param = val.split('=');
if (param[0] === "contenttype") {
match = false;
}
});
}
}
}

if (ignore) {
//$log.debug("ignoring ",href);
} else {
$log.debug("rewriting url ",this.href,"to", href);
$this.attr("href", href);
}
return match;
}).each(function() {

var href = this.href.replace(viewScriptUrl, angularScriptUrl);
//$log.debug("rewriting url ",this.href,"to", href);
this.href = href;
});

// view forms
Expand Down Expand Up @@ -520,7 +529,7 @@ if (0) {
}

if (content) {
//_rewriteUrls(content);
_rewriteUrls(content);
content.find(".foswikiCurrentTopicLink").on("click", function() {
$rootScope.forceReload = (new Date()).getTime();
$rootScope.$apply();
Expand Down

0 comments on commit fa21687

Please sign in to comment.