You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2015/11/21 04:21:23 UTC
[5/5] docs commit: CB-10056 Making latest version more important,
and dev version _less_ important.
CB-10056 Making latest version more important, and dev version _less_ important.
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/aa9e3195
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/aa9e3195
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/aa9e3195
Branch: refs/heads/master
Commit: aa9e3195a60a7bec986467d42aa717d685c1dfa9
Parents: cb0c09b
Author: Dmitry Blotsky <dm...@gmail.com>
Authored: Fri Nov 20 19:06:23 2015 -0800
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Fri Nov 20 19:06:23 2015 -0800
----------------------------------------------------------------------
Makefile | 15 +++++++--
gulpfile.js | 10 +++---
tools/bin/gen_defaults.js | 73 +++++++++++++++++++++++++++---------------
3 files changed, 65 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/aa9e3195/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index e750eee..d9ba501 100644
--- a/Makefile
+++ b/Makefile
@@ -66,6 +66,7 @@ DEV_CONFIG = _dev.yml
PROD_CONFIG = _prod.yml
DOCS_EXCLUDE_CONFIG = _nodocs.yml
PLUGINS_SRC = $(PLUGINS_SRC_DIR)/app.js
+VERSION_FILE = VERSION
# NOTE:
# the .scss files are separate because they combine into MAIN_STYLE_FILE,
@@ -99,6 +100,12 @@ TOC_FILES = $(addprefix $(TOC_DIR)/,$(addsuffix -generated.yml,$(DOCS_V
# the order of config files matters to Jekyll
JEKYLL_CONFIGS = $(MAIN_CONFIG) $(DEFAULTS_CONFIG) $(VERSION_CONFIG)
+ifdef WINDOWS
+LATEST_DOCS_VERSION = $(shell type $(VERSION_FILE))
+else
+LATEST_DOCS_VERSION = $(shell cat $(VERSION_FILE))
+endif
+
# convenience targets
help usage default:
@echo ""
@@ -122,6 +129,8 @@ help usage default:
@echo ""
debug:
+ @echo "LATEST_DOCS_VERSION: " $(LATEST_DOCS_VERSION)
+ @echo ""
@echo "OS: " $(OS)
@echo ""
@echo "SCSS_SRC: " $(SCSS_SRC)
@@ -174,10 +183,10 @@ $(PLUGINS_APP): $(PLUGINS_SRC) Makefile
$(LANGUAGES_DATA): $(BIN_DIR)/gen_languages.js Makefile
$(NODE) $(BIN_DIR)/gen_languages.js $(DOCS_DIR) > $@
-$(DEFAULTS_CONFIG): $(BIN_DIR)/gen_defaults.js Makefile
- $(NODE) $(BIN_DIR)/gen_defaults.js $(DOCS_DIR) > $@
+$(DEFAULTS_CONFIG): $(BIN_DIR)/gen_defaults.js $(VERSION_FILE) Makefile
+ $(NODE) $(BIN_DIR)/gen_defaults.js $(DOCS_DIR) "$(LATEST_DOCS_VERSION)" > $@
-$(VERSION_CONFIG): VERSION Makefile
+$(VERSION_CONFIG): $(VERSION_FILE) Makefile
sed -e "s/^/$(VERSION_VAR_NAME): /" < $< > $@
$(TOC_FILES): $(BIN_DIR)/toc.js Makefile
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/aa9e3195/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index b94eac2..eed3ce0 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2,6 +2,7 @@
// dependencies
var path = require("path");
+var fs = require("fs");
var fse = require("fs-extra");
var child_process = require("child_process");
@@ -66,9 +67,10 @@ var VERSION_VAR_NAME = "latest_docs_version";
var PROD_BY_DEFAULT = false;
// compute/get/set/adjust passed options
-gutil.env.prod = gutil.env.prod || PROD_BY_DEFAULT;
-gutil.env.dev = !gutil.env.prod;
-gutil.env.outDir = gutil.env.prod ? PROD_DIR : DEV_DIR;
+gutil.env.prod = gutil.env.prod || PROD_BY_DEFAULT;
+gutil.env.dev = !gutil.env.prod;
+gutil.env.outDir = gutil.env.prod ? PROD_DIR : DEV_DIR;
+gutil.env.latestDocsVersion = fs.readFileSync(VERSION_FILE, 'utf-8');
// helpers
function execPiped(command, args, fileName) {
@@ -217,7 +219,7 @@ gulp.task("version", function () {
});
gulp.task("defaults", function () {
- return execPiped("node", [bin("gen_defaults.js"), DOCS_DIR], DEFAULTS_CONFIG_FILE)
+ return execPiped("node", [bin("gen_defaults.js"), DOCS_DIR, gutil.env.latestDocsVersion], DEFAULTS_CONFIG_FILE)
.pipe(gulp.dest(ROOT_DIR));
});
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/aa9e3195/tools/bin/gen_defaults.js
----------------------------------------------------------------------
diff --git a/tools/bin/gen_defaults.js b/tools/bin/gen_defaults.js
index a4082c6..741adef 100644
--- a/tools/bin/gen_defaults.js
+++ b/tools/bin/gen_defaults.js
@@ -24,33 +24,46 @@ var yaml = require("js-yaml");
var util = require("./util");
// constants
+var USAGE = "Usage: gen_defaults.js [docsRoot] [latestVersion]"
+
var DEV_VERSION_NAME = "dev";
-// page change frequency for sitemap.xml
+// constants for sitemap.xml
// reference:
// http://www.sitemaps.org/protocol.html#xmlTagDefinitions
-var DEV_CHANGE_FREQUENCY = "daily";
-var DEV_PAGE_PRIORITY = 0.8;
+var LATEST_CHANGE_FREQUENCY = "monthly";
+var LATEST_PAGE_PRIORITY = 0.8;
+
var DEFAULT_CHANGE_FREQUENCY = "monthly";
-var DEFAULT_PAGE_PRIORITY = DEV_PAGE_PRIORITY / 2;
+var DEFAULT_PAGE_PRIORITY = LATEST_PAGE_PRIORITY / 2;
+
+var DEV_CHANGE_FREQUENCY = "daily";
+var DEV_PAGE_PRIORITY = LATEST_PAGE_PRIORITY / 4;
function main () {
- var rootDir = process.argv[2];
- var config = {"defaults": []};
+ var rootDir = process.argv[2];
+ var latestVersionName = process.argv[3];
+
+ var config = {"defaults": []};
if (!rootDir) {
- console.error("Please specify a directory from which to generate.");
+ console.error(USAGE);
+ console.error("Please specify the docs root directory from which to generate defaults.");
process.exit(1);
}
- // go through directory that contains all languages
+ if (!latestVersionName) {
+ console.error(USAGE);
+ console.error("Please specify the latest version of the docs.");
+ process.exit(1);
+ }
+
+ // set defaults for each language
util.listdirsSync(rootDir).forEach(function (langName) {
var langPath = path.join(rootDir, langName);
-
- // define language scope
- config.defaults.push({
+ var languageDefaults = {
scope: {
path: "docs/" + langName
},
@@ -58,33 +71,41 @@ function main () {
language: langName,
layout: "docs-" + langName
}
- });
+ };
+
+ config.defaults.push(languageDefaults);
+ // set defaults for each version
util.listdirsSync(langPath).forEach(function (versionName) {
- var manual = util.manualTocfileName(langName, versionName);
- var generated = util.generatedTocfileName(langName, versionName);
+ var manualToc = util.manualTocfileName(langName, versionName);
+ var generatedToc = util.generatedTocfileName(langName, versionName);
+
+ var changeFrequency = DEFAULT_CHANGE_FREQUENCY;
+ var pagePriority = DEFAULT_PAGE_PRIORITY;
+
+ // adjust priority and frequency based on version
+ if (versionName === latestVersionName) {
+ changeFrequency = LATEST_CHANGE_FREQUENCY;
+ pagePriority = LATEST_PAGE_PRIORITY;
+ } else if (versionName == DEV_VERSION_NAME) {
+ changeFrequency = DEV_CHANGE_FREQUENCY;
+ pagePriority = DEV_PAGE_PRIORITY;
+ }
var versionDefaults = {
scope: {
path: "docs/" + langName + "/" + versionName
},
values: {
- version: versionName,
- manual_toc: manual.replace(".yml", ""),
- generated_toc: generated.replace(".yml", "")
+ version: versionName,
+ manual_toc: manualToc.replace(".yml", ""),
+ generated_toc: generatedToc.replace(".yml", ""),
+ change_frequency: changeFrequency,
+ priority: pagePriority,
}
};
- if (versionName === DEV_VERSION_NAME) {
- versionDefaults.values.change_frequency = DEV_CHANGE_FREQUENCY;
- versionDefaults.values.priority = DEV_PAGE_PRIORITY;
- } else {
- versionDefaults.values.change_frequency = DEFAULT_CHANGE_FREQUENCY;
- versionDefaults.values.priority = DEFAULT_PAGE_PRIORITY
- }
-
- // define version scope
config.defaults.push(versionDefaults);
});
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org