This repository has been archived by the owner on Oct 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
225 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- '0.12' | ||
- '4' | ||
- '4.0' | ||
- 'node' | ||
- 'iojs' | ||
before_install: | ||
- npm install -g grunt-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## v0.1.0 | ||
* replaced `grunt.template.today()` with `moment()` to fit `W3C Datetime` standart | ||
* allow to set custom time format #note: see [moment.js](http://momentjs.com/) | ||
* [js-standard-style](https://github.com/feross/standard) | ||
* code rewrited in ES6 and requres node v4.0.0 or higher | ||
* general improvements to gruntfile (coffee, jit-grunt) | ||
* upgraded `xmlbuilder` to 3.1.0 | ||
* new `pretty` option #note: false by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2015 LotusTM | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module.exports = (grunt) -> | ||
'use strict' | ||
|
||
# Track execution time | ||
require('time-grunt') grunt | ||
|
||
# Load grunt tasks automatically | ||
require('jit-grunt') grunt | ||
|
||
grunt.initConfig | ||
pkg: grunt.file.readJSON 'package.json' | ||
|
||
path: | ||
temp: 'temp' | ||
test: 'test' | ||
fixtures: '<%= path.test %>/fixtures' | ||
|
||
clean: | ||
test: | ||
'<%= path.temp %>' | ||
|
||
sitemap_xml: | ||
default_options: | ||
files: [ | ||
cwd: '<%= path.fixtures %>' | ||
src: '{,**/}*.html' | ||
dest: '<%= path.temp %>/sitemap.xml' | ||
] | ||
custom_options: | ||
options: | ||
root: 'true', | ||
stripIndex: false, | ||
fileName: 'map', | ||
lastMod: grunt.template.today('yyyy-mm-dd'), | ||
priority: '0.1', | ||
changeFreq: 'monthly' | ||
pretty: true | ||
files: [ | ||
cwd: '<%= path.fixtures %>' | ||
src: '{,**/}*.{html,htm}' | ||
dest: '<%= path.temp %>/map.xml' | ||
] | ||
|
||
grunt.loadTasks 'tasks' | ||
|
||
### | ||
A task for scss and js linting | ||
### | ||
grunt.registerTask 'test', [ | ||
'clean' | ||
'sitemap_xml' | ||
] | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"name": "grunt-sitemap-xml", | ||
"description": "Grunt plugin for generating XML sitemaps for search engine indexing", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/LotusTM/grunt-sitemap-xml", | ||
"author": "LotusTM <npm@2bad.me>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/LotusTM/grunt-sitemap-xml.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/LotusTM/grunt-sitemap-xml/issues" | ||
}, | ||
"keywords": [ | ||
"generator", | ||
"google", | ||
"grunt", | ||
"gruntplugin", | ||
"plugin", | ||
"seo", | ||
"sitemap", | ||
"xml" | ||
], | ||
"dependencies": { | ||
"chalk": "^1.1.1", | ||
"moment": "^2.10.6", | ||
"xmlbuilder": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^4.1.3", | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-clean": "^0.6.0", | ||
"grunt-contrib-jshint": "^0.11.3", | ||
"jit-grunt": "^0.9.1", | ||
"standard": "^5.3.1", | ||
"time-grunt": "^1.2.1" | ||
}, | ||
"files": [ | ||
"tasks", | ||
"CHANGELOG.md", | ||
"LICENSE-MIT" | ||
], | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "standard && grunt test" | ||
}, | ||
"engines": { | ||
"node": ">=4.0" | ||
}, | ||
"standard": { | ||
"parser": "babel-eslint" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* grunt-sitemap-xml | ||
* https://github.com/LotusTM/grunt-sitemap-xml | ||
* | ||
* Copyright (c) 2015 LotusTM | ||
* Licensed under the MIT license. | ||
*/ | ||
'use strict' | ||
|
||
const chalk = require('chalk') | ||
const moment = require('moment') | ||
const builder = require('xmlbuilder') | ||
|
||
module.exports = function (grunt) { | ||
// Read package.json | ||
const pkg = this.config.data.pkg || grunt.file.readJSON('package.json') | ||
|
||
grunt.registerMultiTask('sitemap_xml', 'Grunt task for generating sitemap.xml for search engine indexing', function () { | ||
let sitemap, root, url, message | ||
|
||
const options = this.options({ | ||
siteRoot: pkg.homepage, | ||
stripIndex: true, | ||
fileName: 'sitemap', | ||
lastMod: moment().format('YYYY-MM-DDTHH:mm:ssZ'), | ||
priority: '0.5', | ||
changeFreq: 'weekly', | ||
pretty: false | ||
}) | ||
|
||
// Resolve options.siteRoot, add '/' if needed | ||
if (options.siteRoot) { | ||
root = (options.siteRoot.slice(-1) === '/') ? options.siteRoot : options.siteRoot + '/' | ||
} else { | ||
grunt.fail.warn('Please set siteRoot variable in options or homepage property in package.json.') | ||
} | ||
|
||
// Build XML string | ||
let urlset = builder.create('urlset', { | ||
version: '1.0', | ||
encoding: 'UTF-8' | ||
}) | ||
|
||
urlset.att('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9') | ||
.att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance') | ||
.att('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd') | ||
|
||
// Iterate over all specified file groups | ||
this.files.forEach(file => { | ||
file.src.forEach(filepath => { | ||
// Strip index.html | ||
filepath = (options.stripIndex) ? filepath.replace('index.html', '') : filepath | ||
|
||
// Create XML node for each entry | ||
url = urlset.ele('url') | ||
|
||
url.ele('loc', root + filepath) | ||
url.ele('lastmod', options.lastMod) | ||
url.ele('changefreq', options.changeFreq) | ||
url.ele('priority', options.priority) | ||
|
||
// for debug purpose | ||
message = `loc: ${root + filepath}\nlastmod: ${options.lastMod}\nchangefreq: ${options.changeFreq}\npriority: ${options.priority}\n` | ||
grunt.verbose.writeln(message) | ||
}) | ||
|
||
// Format XML sitemap | ||
sitemap = urlset.end({ | ||
pretty: options.pretty | ||
}) | ||
|
||
// Write the destination file. | ||
grunt.file.write(file.dest, sitemap) | ||
// Print a success message. | ||
grunt.log.writeln(`File ${chalk.cyan(file.dest)} created.`) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
blog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
news |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
short |