package votorola.s.wic.server; // Copyright 2009-2010, 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
import java.net.*;
import java.util.List;
import org.apache.wicket.markup.html.basic.*;
import org.apache.wicket.markup.html.link.*;
import org.apache.wicket.model.*;
import votorola.a.*;
import votorola.a.web.wic.*;
import votorola.g.*;
import votorola.g.lang.*;
import votorola.g.locale.*;
import votorola.g.net.*;
import votorola.g.web.wic.*;
import votorola.g.util.*;
import votorola.s.wic.count.*;
import static votorola.a.voter.IDPair.NOBODY;
/** Home page of the Votorola server.
*
* @see WP_Server.html
*/
@ThreadRestricted("wicket") @org.apache.wicket.devutils.stateless.StatelessComponent
public final class WP_Server extends VPageHTML implements TabbedPage
{
/** Constructs a WP_Server.
*/
public WP_Server() // bookmarkable page iff constructor public & (default|PageParameter)
{
final VRequestCycle cycle = VRequestCycle.get();
add( new WC_NavigationHead( "navHead", WP_Server.this, cycle ));
add( new WC_NavPile( "navPile", navTab(cycle), cycle ));
final BundleFormatter bunW = cycle.bunW();
// Title
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
final String shortTitle = bunW.l( "s.wic.server.WP_Server.tab.shortTitle" );
final VoteServer vS = VOWicket.get().vsRun().voteServer();
{
final Model titleModel = new Model( shortTitle + " " + vS.serverName()
+ "/" + vS.name() );
add( new Label( "title", titleModel ));
add( new Label( "h", titleModel ));
}
// General facilities
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
final String wikiLocation = vS.pollwiki().uri().toASCIIString();
{
final ExternalLink tr = new ExternalLink( "wiki", wikiLocation ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.wiki" )));
tr.add( new ExternalLink( "td", wikiLocation, URIX.httpStripped( wikiLocation )));
// ordinary link nested in JavaScript link
add( tr );
}
add( new Label( "thServer", shortTitle ));
add( new Label( "tdServer", URIX.httpStripped( VSession.uriStripped(
cycle.uriFor(WP_Server.class).toString() ))));
{
final String location = "http://reluk.ca/project/votorola/home.html";
final ExternalLink tr = new ExternalLink( "software", location ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.software" )));
tr.add( new ExternalLink( "td", location, "Votorola" ));
// ordinary link nested in JavaScript link
add( tr );
}
add( new Label( "thVersion", bunW.l( "s.wic.server.WP_Server.version" )));
add( new Label( "tdVersion", Votorola.VERSION ));
// Polling facilities
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add( new Label( "hPolling", bunW.l( "s.wic.server.WP_Server.hPolling" )));
{
final String location = cycle.uriFor( WP_Votespace.class ).toString();
final ExternalLink tr = new ExternalLink( "vote-server", location ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.count.WP_CountEngine.tab.shortTitle" )));
tr.add( new ExternalLink( "td", location, URIX.httpStripped( VSession.uriStripped( // ordinary link nested in JavaScript link
location ))));
add( tr );
}
final String votorolaLoc = vS.votorolaURI().toASCIIString();
{
final String location = votorolaLoc + "/in/vomir/";
final ExternalLink tr = new ExternalLink( "mirror", location ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.hPolling.mirror" )));
tr.add( new ExternalLink( "td", location, URIX.httpStripped( location )));
// ordinary link nested in JavaScript link
add( tr );
}
{
final String location = votorolaLoc + "/out/vocount/";
final ExternalLink tr = new ExternalLink( "count", location ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.hPolling.count" )));
tr.add( new ExternalLink( "td", location, URIX.httpStripped( location )));
// ordinary link nested in JavaScript link
add( tr );
}
// Registry
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add( new Label( "hRegistry", bunW.l( "s.wic.server.WP_Server.hRegistry" )));
{
final String location = votorolaLoc + "/out/votrace/";
final ExternalLink tr = new ExternalLink( "trace", location ); // JavaScript link
tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.hRegistry.trace" )));
tr.add( new ExternalLink( "td", location, URIX.httpStripped( location )));
// ordinary link nested in JavaScript link
add( tr );
}
// = = =
setCacheable( true );
setCacheDuration( CACHE_DURATION_YEAR );
}
// ````````````````````````````````````````````````````````````````````````````````````
// init for early use
/** The navigation tab that fetches the server page, an instance of WP_Server.
*/
static final NavTab NAV_TAB = new NavTab()
{
private final Bookmark bookmark = new Bookmark( WP_Server.class );
public @Override Bookmark bookmark() { return bookmark; }
public String shortTitle( VRequestCycle cycle )
{
return cycle.bunW().l( "s.wic.server.WP_Server.tab.shortTitle" );
}
};
// ------------------------------------------------------------------------------------
/** The bar for navigating among the server pages.
*/
public static NavBar navBar() { return navBar; }
private static final NavBar navBar = new NavBar()
{
public SuperTab superTab() { return superTab; }
private final SuperTab superTab = new SuperTab( this )
{
public String shortTitle( VRequestCycle cycle ) { return "(Server)"; } // top row of tabs, hidden
};
public List tabList() { return tabList; }
private final ArrayListU tabList = new ArrayListU( new NavTab[]
{
NAV_TAB.setNavBar( this ),
WP_Activity.NAV_TAB.setNavBar( this ),
});
};
// - T a b b e d - P a g e ------------------------------------------------------------
/** @see #NAV_TAB
*/
public NavTab navTab( VRequestCycle _cycle ) { return NAV_TAB; }
}