Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/undeclared-var
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Bea authored May 20, 2019
2 parents 2110236 + 4d1e3e2 commit 65110c3
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 271 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
88 changes: 88 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Changelog

## 2.5.0

Added a configuration option to remove `siteMapPriority` field globally

## 2.4.7

per Google's guidelines a `<link>` should contain an `<xhtml:link hreflang>` for every locale, including the locale of the `<link>` itself, which was formerly excluded. Thanks to Fredrik Ekelund for this contribution.

## 2.4.6

never generate a priority below 0.1.

## 2.4.5

clone the priority field before adding it so we do not get into issues with `arrangeFields`.

## 2.4.4

Fixes issue where children of unpublished top-level pages were left out of the site map. Additional documentation improvements.

## 2.4.3

fix for apps not using apostrophe-workflow, removing workflow-related xml tags that were left in the sitemap.

## 2.4.1

fix for static sitemap generation of workflow-driven sites without the `perLocale` option, along with new unit tests to verify this has no negative impact on "simple" sites. Also uses the newly exported `destroy` mechanism in its unit testing so we can use Mocha 5 and know that Apostrophe is truly freeing all resources in `apos.destroy`.

## 2.4.0

adds ability to exclude page types in addition to piece types.

## 2.3.3

a bug that broke static sitemap file generation in the absence of workflow was fixed.

## 2.3.2

a bug that broke the sitemap generator in the absence of workflow was fixed. Thanks to Peter Shaw.

## 2.3.1

a bug that broke the sitemap generator in the presence of private workflow locales was fixed. Thanks to Albert R. Timashev.

## 2.3.0

sitemaps for sites localized with the `apostrophe-workflow` module now include pointers to alternate language versions of each document.

## 2.2.1

* The command line `node app apostrophe-site-map:map --update-cache` can be used to update the sitemap that will be sent from Apostrophe's internal cache without waiting for the cache to expire. If the task is scheduled to run more often then once an hour, then a search engine will never be asked to wait a long time to generate it. For sites with many pages and pieces this can be critical.

## 2.2.0

* `piecesPerBatch` option for performance. Still defaults to processing 100 pieces at a time.
* Support for the `hostname` option of `apostrophe-workflow`.

## 2.1.1

short-lived bug affecting command line tasks.

## 2.1.0

sitemaps are now served dynamically. They are stored in Apostrophe's cache for a configurable period of time. There is no need to run a command line task, or mess around with static files. Please note that you must remove existing static sitemap files first. See the documentation for important recommendations. Thanks to Michelin for their support of this work.

The documentation has also been overhauled thoroughly to be completely accurate for Apostrophe 2.x.

## 2.0.4

workflow-aware; new features providing compatibility with the apostrophe-workflow module.

## 2.0.3

documentation updates.

## 2.0.1-2.0.2

minor bug fixes.

## 2.0.0

initial port to Apostrophe 2.x.

## 2.2.0

enhance performances with many pieces
59 changes: 10 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ Alternatively, you can set the `sitemap` option to `false` when configuring any

You can also explicitly set it to `true` if you wish to have sitemaps for a piece type that is normally excluded, like `apostrophe-users`. Of course this will only help if they have a `_url` property when fetched, usually via a corresponding module that extends `apostrophe-pieces-pages`.

## Removing the `siteMapPriority` field globally

You may wish to not include the `siteMapPriority` field on any pieces or pages. To do this, add a `noPriority` option set to `true` when configuring `apostrophe-site-map` in your `app.js`:

```javascript
{
'apostrophe-site-map': { noPriority: true }
}
```

## Integration with the `apostrophe-workflow` module

If you are using the `apostrophe-workflow` module, the sitemap module will automatically fetch content for the live versions of all configured locales.
Expand Down Expand Up @@ -232,52 +242,3 @@ modules: {
}
}
```

## Changelog

2.4.7: Fixes a bug in the `exclude-types` argument usage.

2.4.6: never generate a priority below 0.1.

2.4.5: clone the priority field before adding it so we do not get into issues with `arrangeFields`.

2.4.4: Fixes issue where children of unpublished top-level pages were left out of the site map. Additional documentation improvements.

2.4.3: fix for apps not using apostrophe-workflow, removing workflow-related xml tags that were left in the sitemap.

2.4.1: fix for static sitemap generation of workflow-driven sites without the `perLocale` option, along with new unit tests to verify this has no negative impact on "simple" sites. Also uses the newly exported `destroy` mechanism in its unit testing so we can use Mocha 5 and know that Apostrophe is truly freeing all resources in `apos.destroy`.

2.4.0: adds ability to exclude page types in addition to piece types.

2.3.3: a bug that broke static sitemap file generation in the absence of workflow was fixed.

2.3.2: a bug that broke the sitemap generator in the absence of workflow was fixed. Thanks to Peter Shaw.

2.3.1: a bug that broke the sitemap generator in the presence of private workflow locales was fixed. Thanks to Albert R. Timashev.

2.3.0: sitemaps for sites localized with the `apostrophe-workflow` module now include pointers to alternate language versions of each document.

2.2.1:

* The command line `node app apostrophe-site-map:map --update-cache` can be used to update the sitemap that will be sent from Apostrophe's internal cache without waiting for the cache to expire. If the task is scheduled to run more often then once an hour, then a search engine will never be asked to wait a long time to generate it. For sites with many pages and pieces this can be critical.

2.2.0:

* `piecesPerBatch` option for performance. Still defaults to processing 100 pieces at a time.
* Support for the `hostname` option of `apostrophe-workflow`.

2.1.1: short-lived bug affecting command line tasks.

2.1.0: sitemaps are now served dynamically. They are stored in Apostrophe's cache for a configurable period of time. There is no need to run a command line task, or mess around with static files. Please note that you must remove existing static sitemap files first. See the documentation for important recommendations. Thanks to Michelin for their support of this work.

The documentation has also been overhauled thoroughly to be completely accurate for Apostrophe 2.x.

2.0.4: workflow-aware; new features providing compatibility with the apostrophe-workflow module.

2.0.3: documentation updates.

2.0.1-2.0.2: minor bug fixes.

2.0.0: initial port to Apostrophe 2.x.

2.2.0: enhance performances with many pieces
8 changes: 8 additions & 0 deletions arrangeFields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Configuration for field grouping

module.exports = {
name: 'siteMap',
label: 'Site Map',
fields: ['siteMapPriority'],
last: true
};
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,15 @@ module.exports = {
});

each(function(entry) {
entry.url['xhtml:link'] = [];
if (self.workflow) {
entry.url['xhtml:link'] = [{
_attributes: {
rel: 'alternate',
hreflang: entry.url.workflowLocale,
href: entry.url.loc
}
}];
}
var alternatives = alternativesByGuid[entry.url.workflowGuid];
_.each(alternatives, function(alternative) {
if (alternative === entry) {
Expand Down
16 changes: 14 additions & 2 deletions lib/modules/apostrophe-site-map-custom-pages/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var _ = require('@sailshq/lodash');
var field = require('../../../siteMapPriorityField.js');
const _ = require('@sailshq/lodash');
const field = require('../../../siteMapPriorityField.js');
const arrange = require('../../../arrangeFields.js');

module.exports = {
improve: 'apostrophe-custom-pages',
Expand All @@ -8,6 +9,17 @@ module.exports = {
options.addFields = [
_.clone(field)
].concat(options.addFields || []);
options.arrangeFields = [
_.clone(arrange)
].concat(options.arrangeFields || []);
}
},
afterConstruct: function(self) {
self.on('apostrophe:modulesReady', 'adjustSchemaForSiteMapPriority', function() {
const siteMap = self.apos.modules['apostrophe-site-map'];
if (siteMap.options.noPriority === true) {
self.schema = self.schema.filter(item => item.name !== 'siteMapPriority');
}
});
}
};
16 changes: 14 additions & 2 deletions lib/modules/apostrophe-site-map-pieces/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var _ = require('@sailshq/lodash');
var field = require('../../../siteMapPriorityField.js');
const _ = require('@sailshq/lodash');
const field = require('../../../siteMapPriorityField.js');
const arrange = require('../../../arrangeFields.js');

module.exports = {
improve: 'apostrophe-pieces',
Expand All @@ -17,6 +18,17 @@ module.exports = {
options.addFields = [
_.clone(field)
].concat(options.addFields || []);
options.arrangeFields = [
_.clone(arrange)
].concat(options.arrangeFields || []);
}
},
afterConstruct: function(self) {
self.on('apostrophe:modulesReady', 'adjustSchemaForSiteMapPriority', function() {
const siteMap = self.apos.modules['apostrophe-site-map'];
if (siteMap.options.noPriority === true) {
self.schema = self.schema.filter(item => item.name !== 'siteMapPriority');
}
});
}
};
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "apostrophe-site-map",
"version": "2.4.7",
"version": "2.5.2",
"description": "Generate site maps for sites powered by the Apostrophe CMS.",
"main": "index.js",
"dependencies": {
"@sailshq/lodash": "^3.10.3",
"async": "^1.5.2",
"moment": "^2.19.2"
"moment": "^2.24.0"
},
"devDependencies": {
"apostrophe": "^2.41.0",
"apostrophe-workflow": "^2.4.1",
"apostrophe": "^2.85.0",
"apostrophe-workflow": "^2.18.0",
"cheerio": "^1.0.0-rc.2",
"mocha": "^5.1.1"
},
"scripts": {
Expand Down
Loading

0 comments on commit 65110c3

Please sign in to comment.