001package 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.
002
003import java.net.*;
004import java.util.List;
005import org.apache.wicket.markup.html.basic.*;
006import org.apache.wicket.markup.html.link.*;
007import org.apache.wicket.model.*;
008import votorola.a.*;
009import votorola.a.web.wic.*;
010import votorola.g.*;
011import votorola.g.lang.*;
012import votorola.g.locale.*;
013import votorola.g.net.*;
014import votorola.g.web.wic.*;
015import votorola.g.util.*;
016import votorola.s.wic.count.*;
017
018import static votorola.a.voter.IDPair.NOBODY;
019
020
021/** Home page of the Votorola server.
022  *
023  *     @see <a href='../../../../../../s/wic/server/WP_Server.html' target='_top'>WP_Server.html</a>
024  */
025  @ThreadRestricted("wicket") @org.apache.wicket.devutils.stateless.StatelessComponent
026public final class WP_Server extends VPageHTML implements TabbedPage
027{
028
029
030    /** Constructs a WP_Server.
031      */
032    public WP_Server() // bookmarkable page iff constructor public & (default|PageParameter)
033    {
034        final VRequestCycle cycle = VRequestCycle.get();
035        add( new WC_NavigationHead( "navHead", WP_Server.this, cycle ));
036        add( new WC_NavPile( "navPile", navTab(cycle), cycle ));
037
038        final BundleFormatter bunW = cycle.bunW();
039
040      // Title
041      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
042        final String shortTitle = bunW.l( "s.wic.server.WP_Server.tab.shortTitle" );
043        final VoteServer vS = VOWicket.get().vsRun().voteServer();
044        {
045            final Model<String> titleModel = new Model<String>( shortTitle + " " + vS.serverName()
046              + "/" + vS.name() );
047            add( new Label( "title", titleModel ));
048            add( new Label( "h", titleModel ));
049        }
050
051      // General facilities
052      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
053        final String wikiLocation = vS.pollwiki().uri().toASCIIString();
054        {
055            final ExternalLink tr = new ExternalLink( "wiki", wikiLocation ); // JavaScript link
056            tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.wiki" )));
057            tr.add( new ExternalLink( "td", wikiLocation, URIX.httpStripped( wikiLocation )));
058              // ordinary link nested in JavaScript link
059            add( tr );
060        }
061        add( new Label( "thServer", shortTitle ));
062        add( new Label( "tdServer", URIX.httpStripped( VSession.uriStripped(
063          cycle.uriFor(WP_Server.class).toString() ))));
064        {
065            final String location = "http://reluk.ca/project/votorola/home.html";
066            final ExternalLink tr = new ExternalLink( "software", location ); // JavaScript link
067            tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.software" )));
068            tr.add( new ExternalLink( "td", location, "Votorola" ));
069              // ordinary link nested in JavaScript link
070            add( tr );
071        }
072        add( new Label( "thVersion", bunW.l( "s.wic.server.WP_Server.version" )));
073        add( new Label( "tdVersion", Votorola.VERSION ));
074
075      // Polling facilities
076      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
077        add( new Label( "hPolling", bunW.l( "s.wic.server.WP_Server.hPolling" )));
078        {
079            final String location = cycle.uriFor( WP_Votespace.class ).toString();
080            final ExternalLink tr = new ExternalLink( "vote-server", location ); // JavaScript link
081            tr.add( new Label( "th", bunW.l( "s.wic.count.WP_CountEngine.tab.shortTitle" )));
082            tr.add( new ExternalLink( "td", location, URIX.httpStripped( VSession.uriStripped( // ordinary link nested in JavaScript link
083              location ))));
084            add( tr );
085        }
086        final String votorolaLoc = vS.votorolaURI().toASCIIString();
087        {
088            final String location = votorolaLoc + "/in/vomir/";
089            final ExternalLink tr = new ExternalLink( "mirror", location ); // JavaScript link
090            tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.hPolling.mirror" )));
091            tr.add( new ExternalLink( "td", location, URIX.httpStripped( location )));
092              // ordinary link nested in JavaScript link
093            add( tr );
094        }
095        {
096            final String location = votorolaLoc + "/out/vocount/";
097            final ExternalLink tr = new ExternalLink( "count", location ); // JavaScript link
098            tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.hPolling.count" )));
099            tr.add( new ExternalLink( "td", location, URIX.httpStripped( location )));
100              // ordinary link nested in JavaScript link
101            add( tr );
102        }
103
104      // Registry
105      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106        add( new Label( "hRegistry", bunW.l( "s.wic.server.WP_Server.hRegistry" )));
107        {
108            final String location = votorolaLoc + "/out/votrace/";
109            final ExternalLink tr = new ExternalLink( "trace", location ); // JavaScript link
110            tr.add( new Label( "th", bunW.l( "s.wic.server.WP_Server.hRegistry.trace" )));
111            tr.add( new ExternalLink( "td", location, URIX.httpStripped( location )));
112              // ordinary link nested in JavaScript link
113            add( tr );
114        }
115
116      // = = =
117        setCacheable( true );
118        setCacheDuration( CACHE_DURATION_YEAR );
119    }
120
121
122
123   // ````````````````````````````````````````````````````````````````````````````````````
124   // init for early use
125
126
127    /** The navigation tab that fetches the server page, an instance of WP_Server.
128      */
129    static final NavTab NAV_TAB = new NavTab()
130    {
131        private final Bookmark bookmark = new Bookmark( WP_Server.class );
132        public @Override Bookmark bookmark() { return bookmark; }
133        public String shortTitle( VRequestCycle cycle )
134        {
135            return cycle.bunW().l( "s.wic.server.WP_Server.tab.shortTitle" );
136        }
137    };
138
139
140
141   // ------------------------------------------------------------------------------------
142
143
144    /** The bar for navigating among the server pages.
145      */
146    public static NavBar navBar() { return navBar; }
147
148
149        private static final NavBar navBar = new NavBar()
150        {
151
152            public SuperTab superTab() { return superTab; }
153
154                private final SuperTab superTab = new SuperTab( this )
155                {
156                    public String shortTitle( VRequestCycle cycle ) { return "(Server)"; } // top row of tabs, hidden
157                };
158
159
160            public List<NavTab> tabList() { return tabList; }
161
162                private final ArrayListU<NavTab> tabList = new ArrayListU<NavTab>( new NavTab[]
163                {
164                    NAV_TAB.setNavBar( this ),
165                    WP_Activity.NAV_TAB.setNavBar( this ),
166                });
167
168        };
169
170
171
172   // - T a b b e d - P a g e ------------------------------------------------------------
173
174
175    /** @see #NAV_TAB
176      */
177    public NavTab navTab( VRequestCycle _cycle ) { return NAV_TAB; }
178
179
180
181}