7 Replies Latest reply on Aug 27, 2007 2:07 PM by thomh

    Changing the scheme for document URLs

      We have a question about Documents and their URLs. Specifically, we are looking to change the URL for documents. Currently, a document URL looks like:

       

      /docs/DOC-NNNN

       

       

      We would like this to instead be:

       

       

      /space_path/document_title

       

       

      So for a document titled foobar in a sub-space located in /foobar1_space/foobar2_space/foobar_space, we would like this to be the URL:

       

       

      /foobar1_space/foobar2_space/foobar_space/foobar

       

       

      Of course, if special characters are used in the document title, those would have to be escaped, etc. Can you give us an idea of how hard this would be, if it's possible at all.

       

       

      Thanks in advance!

        • Re: Changing the scheme for document URLs

          You do run into an issue where uniqueness is not required on document titles, I believe that was the limitation holding us back from implementing it in this way. Perhaps if there are multiple documents with the same title - the user could be taken to a disambiguation page though this could present other issues as well.

            • Re: Changing the scheme for document URLs

               

              Thanks, Alex. We are interested in pursuing this even if we have to check for uniqueness of document titles - at the space level - when they are created. Can you think of any clever ways to change the URL scheme for documents?

               

               

                • Re: Changing the scheme for document URLs

                  The way you mentioned is probably adequate you could likely check the blog code to be consistent with how blog titles are URI encoded for an example on how to do it.

                  • Re: Changing the scheme for document URLs

                    hi thomh,

                     

                    The code that produces the stub part of the blog URL lives in BlogUtils. Here is the method:

                        public static String makeURLSafe(String str) {
                            String trimmed = str.trim();
                            return trimmed
                                .replaceAll("([\\p{Punct}]+)", "")
                                .replaceAll("([^0-9A-Za-z\\-]+)", "-")
                                .toLowerCase();
                        }

                     

                    The interesting part is that if you use a recursive community url (ie: /foo/bar/widget) then you'll have to make sure that not only is there not a document with that same name as the document you're posting, but that there isn't a child community with the same name. Example Community structure:

                     

                    Foo > Bar > Widget = /community/foo/bar/widget

                     

                    Create a document called 'competitors' and to access that document you'd request this URL:

                     

                    /community/foo/bar/widget/competitors

                     

                    But now what happens if you want to create a space called 'Competitors'? 

                     

                    Cheers,

                     

                    AJ