https://bugzilla.wikimedia.org/show_bug.cgi?id=43313

       Web browser: ---
            Bug ID: 43313
           Summary: Crumbs contain (disambiguation) in names which
                    duplicates locations already in breadcrumb path
           Product: MediaWiki extensions
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: GeoCrumbs
          Assignee: wikibugs-l@lists.wikimedia.org
          Reporter: carlb...@hotmail.com
    Classification: Unclassified
   Mobile Platform: ---

Moving this issue from [[voy:Wikivoyage talk:Breadcrumb navigation#Remove
parenthesis at display]]...

In [[voy:Hamilton (Ohio)]], the GeoCrumb trail looks like:

North America > United States of America > Midwest (United States of America) >
Ohio > Southwest Ohio > Butler County (Ohio) > Hamilton (Ohio)

This is redundantly redundant; the same path could be expressed succinctly as:

North America > United States of America > Midwest > Ohio > Southwest Ohio >
Butler County > Hamilton

We already _know_ this is in Ohio because " > Ohio > " is in the trail, so any
" (Ohio)" disambiguators in the town and county names can be hidden from the
user without losing anything useful.


The breadcrumb trail is generated in GeoCrumbs.class.php in function
makeTrail().

Adding code to this function to keep a $nameStack of place names already in the
path and then hiding these where they appear in (brackets) elsewhere in the
same trail would give:

        public function makeTrail( Title $title ) {
                $breadcrumbs = array();

                // avoid cyclic trails & define emergency break
                $nameStack = array();
                $idStack = array();
                $cnt = 20;

                while ( $title && $cnt-- ) {
                        $link = Linker::link( $title, $title->getSubpageText()
);

                        // mark redirects with italics.
                        if ( $title->isRedirect() ) {
                                $link = Html::rawElement( 'i', array(), $link
);
                        }
                        array_unshift( $breadcrumbs, $link );

                        if ( in_array( $title->getArticleID(), $idStack ) ) {
                                $breadcrumbs[0] = Html::rawElement( 'strike',
array(), $breadcrumbs[0] );
                                break;
                        }

                        $nameStack[] = $title->getText();
                        $idStack[] = $title->getArticleID();
                        $title = $this->getParentRegion( $title );
                }

                // hide (disambiguator) in displayed titles if already in path
                foreach ($nameStack as $bname) {
                        foreach ($breadcrumbs as &$crumb)
                           $crumb = str_replace(" (" . $bname .
")</a>","</a>",$crumb);
                }

                return $breadcrumbs;
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to