Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get rid of duplicate names in URLs #31

Open
dreh23 opened this issue Jul 10, 2015 · 1 comment
Open

how to get rid of duplicate names in URLs #31

dreh23 opened this issue Jul 10, 2015 · 1 comment

Comments

@dreh23
Copy link
Member

dreh23 commented Jul 10, 2015

From @mrchristian on May 31, 2015 21:7

hi

currently URLs have duplicate names in URLs

docs/book_liberation_manifesto/Book_Liberation_Manifesto.html

either we rename HTML files index.html or we have serving remove directory name above

S

Copied from original issue: hybrid-publishing-lab/hybrid-publishing-research#31

@dreh23
Copy link
Member Author

dreh23 commented Jul 10, 2015

This is more complicated than I anticipated. I got a something running with grunt-contrib-rewrite, but it's more complicated. The example below kind of works. But I can't get the regexp working so we need an entry for every article. Kind of ugly:

  string = "/docs/one_of_the_resources/one-of-the-resources.html";
  console.log(string.match(/\/[^/]+$/)[0]);
  // => one-of-the-resources.html

And the Gruntfile would look like this:

    var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
    .....
    connect: {

        rules: [
            {from: '/documentation.html', to: '/docs/documentation/documentation.html'}
        ],
        server: {
            options: {
                port: port,
                base: './dist',
                livereload: 35005,
                open: true,
                middleware: function (connect, options) {
                    var middlewares = [];

                    // RewriteRules support 
                    middlewares.push(rewriteRulesSnippet);

                    if (!Array.isArray(options.base)) {
                        options.base = [options.base];
                    }

                    var directory = options.directory || options.base[options.base.length - 1];
                    options.base.forEach(function (base) {
                        // Serve static files. 
                        middlewares.push(connect.static(base));
                    });

                    // Make directory browse-able. 
                    //middlewares.push(connect.directory(directory));

                    return middlewares;
                }
            }
        }
    },
    ....
    jshint: {
            globals: {
                ....
                require: false,
                ....
            }
        },
    ....
    grunt.registerTask( 'serve', [ 'configureRewriteRules', 'connect:server', 'watch'] );

I would like to postpone this to another milestone.

@dreh23 dreh23 self-assigned this Jul 10, 2015
@dreh23 dreh23 added this to the v0.0.3 milestone Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant