Index: doxia-decoration-model/src/main/mdo/decoration.mdo =================================================================== --- doxia-decoration-model/src/main/mdo/decoration.mdo (revision 1056136) +++ doxia-decoration-model/src/main/mdo/decoration.mdo (working copy) @@ -79,6 +79,15 @@ true + i18nBanner + Modify the i18n banner display properties. + 1.1.0+ + + I18nBanner + + true + + publishDate Modify the date published display properties. 1.0.0+ @@ -211,6 +220,32 @@ + I18nBanner + The i18n banner to assist with switching among available site locales. + 1.1.0+ + + + position + + Where to place the i18n banner (defaults to right). Acceptable values are: + left, right, navigation-top, navigation-bottom, bottom. + + 1.1.0+ + String + true + right + + + show + Flag to show or hide the i18n banner (defaults to true). + 1.1.0+ + boolean + true + true + + + + Banner Banner logo on the masthead of the site. 1.0.0+ Index: doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/HeadVerifier.java =================================================================== --- doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/HeadVerifier.java (revision 1056136) +++ doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/HeadVerifier.java (working copy) @@ -23,6 +23,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlLink; import com.gargoylesoftware.htmlunit.html.HtmlMeta; import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlScript; import com.gargoylesoftware.htmlunit.html.HtmlStyle; import com.gargoylesoftware.htmlunit.html.HtmlTitle; @@ -78,6 +79,10 @@ HtmlLink link = (HtmlLink) elementIterator.next(); assertNotNull( link ); + HtmlScript script = (HtmlScript) elementIterator.next(); + assertNotNull( script ); + assertEquals( script.getAttributeValue( "type" ), "text/javascript" ); + meta = (HtmlMeta) elementIterator.next(); assertEquals( meta.getAttributeValue( "name" ), "author" ); assertEquals( meta.getAttributeValue( "content" ).trim(), "John Doe" ); Index: doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/javascript/common.js =================================================================== --- doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/javascript/common.js (revision 0) +++ doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/javascript/common.js (revision 0) @@ -0,0 +1,82 @@ + +var changeSiteLocale = function() {}; + +/** + * Initializes necessary js state for changing site locale + * (assumes the document is rendered). + * + * @param currLocale Current site locale string id (e.g. 'fr') - required. + * @param defaultLocale Default locale string (e.g. 'ru'); if this value + * is not present, 'en' locale is assumed. + */ +function initI18nBannerJs( currLocale, defaultLocale ) +{ + if ( !currLocale ) + { + throw new Error( 'Project site locale is not set!' ); + } + + defaultLocale = defaultLocale || 'en'; + + var isI18nBannerVisible = false; + + /** + * Changes browser location to the new locale. + * + * @param newLocale New locale string id (e.g. 'ru'). + */ + changeSiteLocale = function( newLocale ) + { + + if ( !currLocale || currLocale != newLocale ) + { + var relativeUrl = currLocale == defaultLocale ? './' : '../'; + if ( newLocale != defaultLocale ) + { + relativeUrl += newLocale + '/'; + } + window.location.href = relativeUrl; + } + return false; + }; + + // Function to toggle visibility of the site locales panel. + var togglei18nBanner = function ( e ) + { + document.getElementById( 'i18nBanner' ).style.display = isI18nBannerVisible ? 'none' : ''; + isI18nBannerVisible = !isI18nBannerVisible; + if ( window.event ) + { + window.event.cancelBubble = true; + } + else + { + e.stopPropagation(); + } + }; + + // Function to add a mouseup event handler to an element. + var attachMouseUpEvent = function( node, handler ) + { + if ( node.addEventListener ) + { + node.addEventListener( 'mouseup', handler, false ); + } + else + { + node.attachEvent( 'onmouseup', handler ); + } + }; + + // Attaching listener for changing site locale. + var linkEl = document.getElementById( 'i18nBannerLink' ); + attachMouseUpEvent( linkEl, togglei18nBanner ); + + attachMouseUpEvent( window.document.body, function( e ) + { + if ( isI18nBannerVisible ) + { + togglei18nBanner( e ); + } + } ); +} Index: doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm =================================================================== --- doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm (revision 1056136) +++ doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm (working copy) @@ -108,6 +108,57 @@ #end #end ## +#macro ( i18nBannerLink $position $i18nBanner $locale $moreContent ) + #if ( $showI18nBanner && $position == $i18nBanner.position ) + #set ( $isMore = $moreContent.trim().isEmpty() == false ) + #set ( $prefix = "" ) + #set ( $postfix = "" ) + #if ( $position.equalsIgnoreCase( "left" ) || + $position.equalsIgnoreCase( "navigation-top" ) || + $position.equalsIgnoreCase( "navigation-bottom" ) ) + #if ( $isMore ) + #set ( $postfix = "|" + $moreContent ) + #end + #else + #if ( $isMore ) + #set ( $prefix = $moreContent + "|" ) + #end + #end + $prefix + ## TODO: The title string must be i18zed. + + $locale.language + + $postfix + #else + $moreContent + #end +#end +## +#macro ( i18nBannerList $position $i18nBanner $locale $locales ) + #if ( $showI18nBanner && $position == $i18nBanner.position ) + #set ( $positionClass = "i18nBannerRight" ) + #if ( $i18nBanner.position.equalsIgnoreCase( "left" ) || + $i18nBanner.position.equalsIgnoreCase( "navigation-top" ) || + $i18nBanner.position.equalsIgnoreCase( "navigation-bottom" ) ) + #set ( $positionClass = "i18nBannerLeft" ) + #end + + #end +#end +## #macro ( breadcrumbs $breadcrumbs ) #foreach( $item in $breadcrumbs ) #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) ) @@ -293,6 +344,7 @@ #if ( $publishDate && $publishDate.position ) #set ( $datePosition = $publishDate.position ) #else + ## If changing default to 'right', make sure you adjust i18nBannerLink template. #set ( $datePosition = "left" ) #end ## @@ -330,7 +382,6 @@ #end #elseif ( $datePosition.equalsIgnoreCase("left") ) -
$i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday #if ( $versionPosition.equalsIgnoreCase( $position ) )  | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} @@ -338,7 +389,6 @@ #if ( $breadcrumbs && $breadcrumbs.size() > 0 ) | #breadcrumbs( $breadcrumbs ) #end -
#end #elseif ( $versionPosition.equalsIgnoreCase( $position ) ) #if ( ( $versionPosition.equalsIgnoreCase( "right" ) ) || ( $versionPosition.equalsIgnoreCase( "bottom" ) ) ) @@ -348,18 +398,14 @@ $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #elseif ( $versionPosition.equalsIgnoreCase("left") ) -
$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #if ( $breadcrumbs && $breadcrumbs.size() > 0 ) | #breadcrumbs( $breadcrumbs ) #end -
#end #elseif ( $position.equalsIgnoreCase( "left" ) ) #if ( $breadcrumbs && $breadcrumbs.size() > 0 ) -
#breadcrumbs( $breadcrumbs ) -
#end #end #end @@ -450,6 +496,10 @@ #end #end ## +#if ( $decoration.i18nBanner && $decoration.i18nBanner.show && $supportedLocales.size() > 1 ) + ## The i18nBanner is available by default and only when we have more than one locale. + #set ( $showI18nBanner = true ) +#end @@ -460,6 +510,7 @@ @import url("$relativePath/css/site.css"); + #foreach( $author in $authors ) #end @@ -488,7 +539,11 @@ $headContent #googleAnalytics( $decoration.googleAnalyticsAccountId ) - +
+ + #i18nBannerList( "navigation-top" $decoration.i18nBanner $locale $supportedLocales ) + + #i18nBannerList( "navigation-bottom" $decoration.i18nBanner $locale $supportedLocales )
@@ -520,10 +592,15 @@
Index: doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/css/maven-base.css =================================================================== --- doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/css/maven-base.css (revision 1056136) +++ doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/css/maven-base.css (working copy) @@ -49,9 +49,11 @@ padding: 3px 10px 3px 10px; } #leftColumn { - width: 170px; - float:left; - overflow: auto; + left: 0; /* Only for IE <=7. */ + overflow: visible; + padding: 4px 4px 4px 8px; + position: absolute; + width: 170px; } #bodyColumn { margin-right: 1.5em; @@ -60,8 +62,14 @@ #legend { padding: 8px 0 8px 0; } + +#navcolumnTop, #navcolumnBottom { + font-size: x-small; +} + #navcolumn { - padding: 8px 4px 0 8px; + margin-bottom: 4px; + margin-top: 4px; } #navcolumn h5 { margin: 0; @@ -94,7 +102,7 @@ } #navcolumn img { margin-top: 10px; - margin-bottom: 3px; + margin-bottom: 7px; } #poweredBy img { display:block; @@ -112,7 +120,11 @@ margin: 0px; } #lastPublished { + display: inline-block; font-size: x-small; + /* IE7 hack to support inline-block. */ + *display: inline; + zoom: 1; } .navSection { margin-bottom: 2px; @@ -141,11 +153,35 @@ margin: 0px; padding: 0px; } -#navcolumn img.imageLink, .imageLink { - padding-left: 0px; - padding-bottom: 0px; - padding-top: 0px; - padding-right: 2px; - border: 0px; - margin: 0px; + +.i18nBanner li { + font-size: x-small; } + +a#i18nBannerLink:hover, .i18nBanner li { + cursor: pointer; +} + +.i18nBanner { + color: #3366AA; + list-style: none outside none; + margin: 0; + padding: 0; +} + +#i18nBanner { + background-color: #EEEEEE; + border: 1px solid #AAAAAA; + font-size: x-small; + margin-right: 10px; + padding: 2px 7px 5px 0; +} + +.i18nBannerRight { + float: right; +} + +.i18nBannerLeft { + position: absolute; + z-index: 100; +} Index: doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/resources.txt =================================================================== --- doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/resources.txt (revision 1056136) +++ doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/resources.txt (working copy) @@ -5,3 +5,4 @@ images/logos/build-by-maven-black.png css/maven-base.css css/print.css +javascript/common.js