You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by dblotsky <gi...@git.apache.org> on 2016/04/22 06:15:11 UTC

[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

GitHub user dblotsky opened a pull request:

    https://github.com/apache/cordova-docs/pull/584

    CB-11127 Improving internal linking

    Relevant changes:
    - added a new data file, `all-pages.yml`, which stores a list of valid links on the site
    - version dropdowns and out-of-date alerts now use the new data file to only link to valid pages
    - redirects are now a dictionary instead of a list, which is more flexible and easier to work with
    
    Miscellaneous changes:
    - refactored Makefile dependencies to properly rebuild some files when necessary
    - refactored `docs.html` to be a bit more readable

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/MSOpenTech/cordova-docs CB-11127

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-docs/pull/584.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #584
    
----
commit 1184b339bc869e87919b2720c057e9b57a9022d2
Author: Dmitry Blotsky <dm...@gmail.com>
Date:   2016-04-13T02:40:03Z

    CB-11127 Improving internal linking

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60784438
  
    --- Diff: www/.htaccess ---
    @@ -61,14 +63,14 @@ RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest$ {{site.baseurl}}/docs/$1/latest/ [R
     #
     #     docs/*/XX/* -> docs/*/YY/*
     #
    -{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect.old}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect.new}}/$2 [R=302,L]
    +{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect[0]}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect[1]}}/$2 [R=302,L]
    --- End diff --
    
    The resulting `.htaccess` file has too many spaces if we add an extra space like this:
    
        {% for ... %}
        RewriteRule ...
        {% endfor %}
    
    because it will render as:
    
        RewriteRule ...
        
        RewriteRule ...
    
    We can still refactor it from this:
    
        {% for ... %}RewriteRule ... 
        {% endfor %}
    
    to this:
    
        {% for ... %}
        RewriteRule ... {% endfor %}
    
    Which do you think is better?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by sarangan12 <gi...@git.apache.org>.
Github user sarangan12 commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60771353
  
    --- Diff: www/.htaccess ---
    @@ -61,14 +63,14 @@ RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest$ {{site.baseurl}}/docs/$1/latest/ [R
     #
     #     docs/*/XX/* -> docs/*/YY/*
     #
    -{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect.old}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect.new}}/$2 [R=302,L]
    +{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect[0]}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect[1]}}/$2 [R=302,L]
     {% endfor %}
     
     # 302 (temporary):
     #
     #     docs/XX/* -> docs/YY/*
     #
    -{% for redirect in site.data.redirects.language-renames %}RewriteRule ^.*docs/{{redirect.old}}/((?:\d+\.(?:\d+\.\d+|x))|dev|latest)/(.*)$ {{site.baseurl}}/docs/{{redirect.new}}/$1/$2 [R=302,L]
    +{% for redirect in site.data.redirects.language-renames %}RewriteRule ^.*docs/{{redirect[0]}}/((?:\d+\.(?:\d+\.\d+|x))|dev|latest)/(.*)$ {{site.baseurl}}/docs/{{redirect[1]}}/$1/$2 [R=302,L]
    --- End diff --
    
    Nitpick: Alignment


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60783856
  
    --- Diff: tools/bin/gen_pages_dict.js ---
    @@ -0,0 +1,120 @@
    +// Licensed to the Apache Software Foundation (ASF) under one
    +// or more contributor license agreements.  See the NOTICE file
    +// distributed with this work for additional information
    +// regarding copyright ownership.  The ASF licenses this file
    +// to you under the Apache License, Version 2.0 (the
    +// "License"); you may not use this file except in compliance
    +// with the License.  You may obtain a copy of the License at
    +//
    +//     http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing,
    +// software distributed under the License is distributed on an
    +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +// KIND, either express or implied.  See the License for the
    +// specific language governing permissions and limitations
    +// under the License.
    +
    +"use strict";
    +
    +var fs       = require("fs");
    +var path     = require("path");
    +var yaml     = require("js-yaml");
    +var walk     = require("walk");
    +var glob     = require("glob");
    +var Q        = require("q");
    +var optimist = require("optimist");
    +
    +var util = require("./util");
    +
    +// constants
    +var LATEST_ALIAS_URI = "/latest/";
    +
    +// helpers
    +function pathToURI(filePath, rootPath) {
    +    return filePath
    +        .replace(new RegExp("^" + rootPath), "")
    +        .replace(new RegExp("\\.md$"), ".html");
    +}
    +
    +function pagesFromRedirects(redirects, languages) {
    +    var pages = {};
    +
    +    // add docs redirects
    +    if (typeof redirects.docs !== "undefined") {
    +        for (var redirectSource in redirects.docs) {
    +
    +            // add an entry for the redirect's source, once for each language
    +            for (var i = 0; i < languages.length; i++) {
    +                var language = languages[i];
    +                var pagePath = "/docs/" + language + "/" + redirectSource;
    +
    +                pages[pagePath] = true;
    +            }
    +        }
    +    }
    +
    +    return pages;
    +}
    +
    +function isInLatestDocs(uri, latestVersion) {
    +    return uri.indexOf("/" + latestVersion + "/") !== (-1);
    +}
    +
    +// main
    +function main () {
    +
    +    // get args
    +    var argv = optimist
    +        .usage("Usage: $0 [options]")
    +        .demand("languages").describe("languages", "comma-separated list of docs languages")
    +        .demand("latestVersion").describe("latestVersion", "the current latest docs version")
    +        .demand("siteRoot").describe("siteRoot", "the source ToC for the given directory")
    +        .string("redirectsFile").describe("redirectsFile", "file containing redirects for the website").default("redirectsFile", null)
    +        .argv;
    +
    +    var siteRootPath      = argv.siteRoot;
    +    var redirectsFilePath = argv.redirectsFile;
    +    var latestVersion     = argv.latestVersion;
    +    var languages         = argv.languages.split(",");
    +
    +    // pages to return
    +    var pages = {};
    +
    +    // add pages for redirects if a redirects file was passed
    +    if (redirectsFilePath !== null) {
    +
    +        var redirectsString = fs.readFileSync(redirectsFilePath);
    +        var redirects       = yaml.load(redirectsString);
    +        var redirectsPages  = pagesFromRedirects(redirects, languages);
    +
    +        pages = redirectsPages;
    +    }
    +
    +    // add entries for all Markdown files in the site root
    +    var allMarkdownFiles = path.join(siteRootPath, "**/*.md");
    +    glob(allMarkdownFiles, function (error, filePaths) {
    +        for (var i = 0; i < filePaths.length; i++) {
    +            var filePath = filePaths[i];
    +            var fileURI  = pathToURI(filePath, siteRootPath);
    +
    +            // add the page
    +            pages[fileURI] = true;
    +
    +            // also add /latest/ version for pages in latest docs
    +            if (isInLatestDocs(fileURI, latestVersion)) {
    +                var latestURI = fileURI.replace("/" + latestVersion + "/", LATEST_ALIAS_URI);
    --- End diff --
    
    This replaces `/6.x/` with `/latest/`, so it accounts for the slashes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60784540
  
    --- Diff: www/.htaccess ---
    @@ -61,14 +63,14 @@ RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest$ {{site.baseurl}}/docs/$1/latest/ [R
     #
     #     docs/*/XX/* -> docs/*/YY/*
     #
    -{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect.old}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect.new}}/$2 [R=302,L]
    +{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect[0]}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect[1]}}/$2 [R=302,L]
     {% endfor %}
     
     # 302 (temporary):
     #
     #     docs/XX/* -> docs/YY/*
     #
    -{% for redirect in site.data.redirects.language-renames %}RewriteRule ^.*docs/{{redirect.old}}/((?:\d+\.(?:\d+\.\d+|x))|dev|latest)/(.*)$ {{site.baseurl}}/docs/{{redirect.new}}/$1/$2 [R=302,L]
    +{% for redirect in site.data.redirects.language-renames %}RewriteRule ^.*docs/{{redirect[0]}}/((?:\d+\.(?:\d+\.\d+|x))|dev|latest)/(.*)$ {{site.baseurl}}/docs/{{redirect[1]}}/$1/$2 [R=302,L]
    --- End diff --
    
    Oh, sorry. Just saw your comment before.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by sarangan12 <gi...@git.apache.org>.
Github user sarangan12 commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60771040
  
    --- Diff: tools/bin/gen_pages_dict.js ---
    @@ -0,0 +1,120 @@
    +// Licensed to the Apache Software Foundation (ASF) under one
    +// or more contributor license agreements.  See the NOTICE file
    +// distributed with this work for additional information
    +// regarding copyright ownership.  The ASF licenses this file
    +// to you under the Apache License, Version 2.0 (the
    +// "License"); you may not use this file except in compliance
    +// with the License.  You may obtain a copy of the License at
    +//
    +//     http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing,
    +// software distributed under the License is distributed on an
    +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +// KIND, either express or implied.  See the License for the
    +// specific language governing permissions and limitations
    +// under the License.
    +
    +"use strict";
    +
    +var fs       = require("fs");
    +var path     = require("path");
    +var yaml     = require("js-yaml");
    +var walk     = require("walk");
    +var glob     = require("glob");
    +var Q        = require("q");
    +var optimist = require("optimist");
    +
    +var util = require("./util");
    +
    +// constants
    +var LATEST_ALIAS_URI = "/latest/";
    +
    +// helpers
    +function pathToURI(filePath, rootPath) {
    +    return filePath
    +        .replace(new RegExp("^" + rootPath), "")
    +        .replace(new RegExp("\\.md$"), ".html");
    +}
    +
    +function pagesFromRedirects(redirects, languages) {
    +    var pages = {};
    +
    +    // add docs redirects
    +    if (typeof redirects.docs !== "undefined") {
    +        for (var redirectSource in redirects.docs) {
    +
    +            // add an entry for the redirect's source, once for each language
    +            for (var i = 0; i < languages.length; i++) {
    +                var language = languages[i];
    +                var pagePath = "/docs/" + language + "/" + redirectSource;
    +
    +                pages[pagePath] = true;
    +            }
    +        }
    +    }
    +
    +    return pages;
    +}
    +
    +function isInLatestDocs(uri, latestVersion) {
    +    return uri.indexOf("/" + latestVersion + "/") !== (-1);
    +}
    +
    +// main
    +function main () {
    +
    +    // get args
    +    var argv = optimist
    +        .usage("Usage: $0 [options]")
    +        .demand("languages").describe("languages", "comma-separated list of docs languages")
    +        .demand("latestVersion").describe("latestVersion", "the current latest docs version")
    +        .demand("siteRoot").describe("siteRoot", "the source ToC for the given directory")
    +        .string("redirectsFile").describe("redirectsFile", "file containing redirects for the website").default("redirectsFile", null)
    +        .argv;
    +
    +    var siteRootPath      = argv.siteRoot;
    +    var redirectsFilePath = argv.redirectsFile;
    +    var latestVersion     = argv.latestVersion;
    +    var languages         = argv.languages.split(",");
    +
    +    // pages to return
    +    var pages = {};
    +
    +    // add pages for redirects if a redirects file was passed
    +    if (redirectsFilePath !== null) {
    +
    +        var redirectsString = fs.readFileSync(redirectsFilePath);
    +        var redirects       = yaml.load(redirectsString);
    +        var redirectsPages  = pagesFromRedirects(redirects, languages);
    +
    +        pages = redirectsPages;
    +    }
    +
    +    // add entries for all Markdown files in the site root
    +    var allMarkdownFiles = path.join(siteRootPath, "**/*.md");
    +    glob(allMarkdownFiles, function (error, filePaths) {
    +        for (var i = 0; i < filePaths.length; i++) {
    +            var filePath = filePaths[i];
    +            var fileURI  = pathToURI(filePath, siteRootPath);
    +
    +            // add the page
    +            pages[fileURI] = true;
    +
    +            // also add /latest/ version for pages in latest docs
    +            if (isInLatestDocs(fileURI, latestVersion)) {
    +                var latestURI = fileURI.replace("/" + latestVersion + "/", LATEST_ALIAS_URI);
    --- End diff --
    
    LATEST_ALIAS_URI has a '/' in the beginning. Here I see that "/" is added before LATEST_ALIAS_URI. So, would that be changing the path as **//**latest/. Is this what we want?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60783503
  
    --- Diff: www/.htaccess ---
    @@ -61,14 +63,14 @@ RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest$ {{site.baseurl}}/docs/$1/latest/ [R
     #
     #     docs/*/XX/* -> docs/*/YY/*
     #
    -{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect.old}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect.new}}/$2 [R=302,L]
    +{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect[0]}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect[1]}}/$2 [R=302,L]
     {% endfor %}
     
     # 302 (temporary):
     #
     #     docs/XX/* -> docs/YY/*
     #
    -{% for redirect in site.data.redirects.language-renames %}RewriteRule ^.*docs/{{redirect.old}}/((?:\d+\.(?:\d+\.\d+|x))|dev|latest)/(.*)$ {{site.baseurl}}/docs/{{redirect.new}}/$1/$2 [R=302,L]
    +{% for redirect in site.data.redirects.language-renames %}RewriteRule ^.*docs/{{redirect[0]}}/((?:\d+\.(?:\d+\.\d+|x))|dev|latest)/(.*)$ {{site.baseurl}}/docs/{{redirect[1]}}/$1/$2 [R=302,L]
    --- End diff --
    
    Alignment with what?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on the pull request:

    https://github.com/apache/cordova-docs/pull/584#issuecomment-213545334
  
    @riknoll @rakatyal please also give this a look when you have a moment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by sarangan12 <gi...@git.apache.org>.
Github user sarangan12 commented on the pull request:

    https://github.com/apache/cordova-docs/pull/584#issuecomment-213546506
  
    Got it.... LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by sarangan12 <gi...@git.apache.org>.
Github user sarangan12 commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/584#discussion_r60771293
  
    --- Diff: www/.htaccess ---
    @@ -61,14 +63,14 @@ RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest$ {{site.baseurl}}/docs/$1/latest/ [R
     #
     #     docs/*/XX/* -> docs/*/YY/*
     #
    -{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect.old}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect.new}}/$2 [R=302,L]
    +{% for redirect in site.data.redirects.version-renames %}RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect[0]}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect[1]}}/$2 [R=302,L]
    --- End diff --
    
    NitPick: Alignment. Whouldn't this be better 
    
    {% for redirect in site.data.redirects.version-renames %}
                   RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/{{redirect[0]}}/(.*)$ {{site.baseurl}}/docs/$1/{{redirect[1]}}/$2 [R=302,L]


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by riknoll <gi...@git.apache.org>.
Github user riknoll commented on the pull request:

    https://github.com/apache/cordova-docs/pull/584#issuecomment-213622636
  
    LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


[GitHub] cordova-docs pull request: CB-11127 Improving internal linking

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-docs/pull/584


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org