Skip to content

Commit 58ebac9

Browse files
committed
Add sitemapid to the controller + improve siteamp_* methods.
1 parent d11f428 commit 58ebac9

2 files changed

Lines changed: 32 additions & 26 deletions

File tree

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- added: `NOSQL('users').backups([filter(doc)], callback(err, response))` returns all backups
1717
- added: `SchemaOptions.invalid(name, [value], [path], [index])` alias to `$.errors.push() + callback()`
1818
- added: `SchemaOptions.success()` alias to `callback(SUCCESS(value))`
19+
- added: `controller.sitemapid` contains a sitemap identificator
1920

2021
- updated: `sitemap` routing can contain an additional path, e.g. `#sitemapid/path/`
2122
- updated: `F.localize()` supports sitemap routing

index.js

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,6 @@ F.web = F.route = function(url, funcExecute, flags, length, language) {
16151615
else
16161616
url += tmp;
16171617
}
1618-
16191618
} else
16201619
throw new Error('Sitemap item "' + url + '" not found.');
16211620
} else
@@ -9522,9 +9521,11 @@ Controller.prototype = {
95229521

95239522
get viewname() {
95249523
var name = this.req.path[this.req.path.length - 1];
9525-
if (!name || name === '/')
9526-
name = 'index';
9527-
return name;
9524+
return !name || name === '/' ? 'index' : name;
9525+
},
9526+
9527+
get sitemapid() {
9528+
return this.$sitemapid || this.route.sitemap;
95289529
}
95299530
};
95309531

@@ -10112,20 +10113,16 @@ Controller.prototype.$author = function(value) {
1011210113
};
1011310114

1011410115
Controller.prototype.sitemap_navigation = function(name, language) {
10115-
return F.sitemap_navigation(name, language || this.language);
10116+
return F.sitemap_navigation(name || this.sitemapid, language || this.language);
1011610117
};
1011710118

1011810119
Controller.prototype.sitemap_url = function(name, a, b, c, d, e, f) {
10119-
if (!name)
10120-
name = this.repository[REPOSITORY_SITEMAP];
10121-
var item = F.sitemap(name, true, this.language);
10120+
var item = F.sitemap(name || this.sitemapid, true, this.language);
1012210121
return item ? item.url.format(a, b, c, d, e, f) : '';
1012310122
};
1012410123

1012510124
Controller.prototype.sitemap_name = function(name, a, b, c, d, e, f) {
10126-
if (!name)
10127-
name = this.repository[REPOSITORY_SITEMAP];
10128-
var item = F.sitemap(name, true, this.language);
10125+
var item = F.sitemap(name || this.sitemapid, true, this.language);
1012910126
return item ? item.name.format(a, b, c, d, e, f) : '';
1013010127
};
1013110128

@@ -10134,6 +10131,9 @@ Controller.prototype.sitemap_change = function(name, type, a, b, c, d, e, f) {
1013410131
var self = this;
1013510132
var sitemap = self.repository[REPOSITORY_SITEMAP];
1013610133

10134+
if (!name)
10135+
name = self.sitemapid;
10136+
1013710137
if (!sitemap)
1013810138
sitemap = self.sitemap(name);
1013910139

@@ -10173,9 +10173,13 @@ Controller.prototype.sitemap_change = function(name, type, a, b, c, d, e, f) {
1017310173

1017410174
Controller.prototype.sitemap_replace = function(name, title, url) {
1017510175
var self = this;
10176-
var sitemap = self.repository[REPOSITORY_SITEMAP];
10177-
if (!sitemap)
10178-
sitemap = self.sitemap(name);
10176+
10177+
if (!name)
10178+
name = self.sitemapid;
10179+
10180+
// var sitemap = self.repository[REPOSITORY_SITEMAP];
10181+
//if (!sitemap)
10182+
var sitemap = self.sitemap(name);
1017910183

1018010184
if (!sitemap.$cloned) {
1018110185
sitemap = U.clone(sitemap);
@@ -10199,31 +10203,32 @@ Controller.prototype.sitemap_replace = function(name, title, url) {
1019910203
};
1020010204

1020110205
// Arguments: name, type, value, format
10202-
Controller.prototype.$sitemap_change = function() {
10203-
this.sitemap_change.apply(this, arguments);
10206+
Controller.prototype.$sitemap_change = function(a, b, c, d, e, f, g, h) {
10207+
this.sitemap_change(a, b, c, d, e, f, g, h);
1020410208
return '';
1020510209
};
1020610210

10207-
// Arguments: name, title, url, format
10208-
Controller.prototype.$sitemap_replace = function() {
10209-
this.sitemap_replace.apply(this, arguments);
10211+
// Arguments: name, title, url
10212+
Controller.prototype.$sitemap_replace =function(a, b, c) {
10213+
this.sitemap_replace(a, b, c);
1021010214
return '';
1021110215
};
1021210216

1021310217
Controller.prototype.sitemap = function(name) {
1021410218
var self = this;
1021510219
var sitemap;
1021610220

10217-
if (name instanceof Array) {
10218-
self.repository[REPOSITORY_SITEMAP] = name;
10219-
return self;
10220-
}
10221-
1022210221
if (!name) {
1022310222
sitemap = self.repository[REPOSITORY_SITEMAP];
1022410223
return sitemap ? sitemap : self.repository.sitemap || EMPTYARRAY;
1022510224
}
1022610225

10226+
if (name instanceof Array) {
10227+
self.repository[REPOSITORY_SITEMAP] = name;
10228+
return self;
10229+
}
10230+
10231+
self.$sitemapid = name;
1022710232
sitemap = F.sitemap(name, false, self.language);
1022810233
self.repository[REPOSITORY_SITEMAP] = sitemap;
1022910234
if (!self.repository[REPOSITORY_META_TITLE]) {
@@ -10236,9 +10241,9 @@ Controller.prototype.sitemap = function(name) {
1023610241
};
1023710242

1023810243
// Arguments: name
10239-
Controller.prototype.$sitemap = function() {
10244+
Controller.prototype.$sitemap = function(name) {
1024010245
var self = this;
10241-
self.sitemap.apply(self, arguments);
10246+
self.sitemap(name);
1024210247
return '';
1024310248
};
1024410249

0 commit comments

Comments
 (0)