2026-02-11 23:22:20 +01:00
package ins.frontend ;
import ins.frontend.utils.WebApp ;
2026-02-22 17:21:23 +01:00
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket ;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags ;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader ;
2026-02-11 23:22:20 +01:00
import org.openautonomousconnection.webserver.api.Route ;
import org.openautonomousconnection.webserver.api.WebPage ;
import org.openautonomousconnection.webserver.api.WebPageContext ;
2026-02-22 17:21:23 +01:00
import org.openautonomousconnection.webserver.utils.HeaderMaps ;
2026-02-11 23:22:20 +01:00
import org.openautonomousconnection.webserver.utils.Html ;
2026-02-22 17:21:23 +01:00
import java.util.Map ;
2026-02-11 23:22:20 +01:00
/ * *
2026-02-22 17:21:23 +01:00
* Landing page for INS registrar frontend ( v1 . 0 . 1 ) .
2026-02-11 23:22:20 +01:00
* /
2026-02-22 17:21:23 +01:00
@Route ( path = " /index.html " )
2026-03-02 18:41:19 +01:00
public final class index extends WebPage {
2026-02-11 23:22:20 +01:00
@Override
2026-02-22 17:21:23 +01:00
public WebResourceResponsePacket handle ( WebPageContext ctx ) {
2026-02-11 23:22:20 +01:00
WebApp . init ( ) ;
2026-02-22 17:21:23 +01:00
2026-02-11 23:22:20 +01:00
String html = Html . page ( " OAC INS Registrar " , """
2026-02-22 17:21:23 +01:00
< div class = " card " >
< h2 > OAC INS Registrar < / h2 >
2026-03-02 18:41:19 +01:00
< p class = " muted " >What you want to do? You can checkout the source of this site here: https://repo.open-autonomous-connection.org/open-autonomous-connection/INSServer/</p>
2026-02-22 17:21:23 +01:00
< div class = " col " ><a href= " info . html " >Info</a></div><br />
< div class = " row " >
< div class = " col " ><a href= " login . html " >Login</a></div>
< div class = " col " ><a href= " register . html " >Register</a></div>
< div class = " col " ><a href= " dashboard . html " >Dashboard</a></div>
< / div >
< / div >
2026-02-11 23:22:20 +01:00
" " " );
2026-02-22 17:21:23 +01:00
byte [ ] body = Html . utf8 ( html ) ;
Map < String , String > headers = HeaderMaps . mutable ( ) ;
headers . put ( " content-length " , String . valueOf ( body . length ) ) ;
return new WebResourceResponsePacket ( outHeader ( ctx ) , 200 , " text/html; charset=utf-8 " , headers , body , null ) ;
}
private WebPacketHeader outHeader ( WebPageContext ctx ) {
WebPacketHeader in = ( ctx ! = null & & ctx . request ! = null ) ? ctx . request . getHeader ( ) : null ;
if ( in = = null ) {
return new WebPacketHeader ( 0 , 0 , 0 , 0 , WebPacketFlags . RESOURCE , System . currentTimeMillis ( ) ) ;
}
return new WebPacketHeader (
in . getRequestId ( ) ,
in . getTabId ( ) ,
in . getPageId ( ) ,
in . getFrameId ( ) ,
in . getFlags ( ) | WebPacketFlags . RESOURCE ,
System . currentTimeMillis ( )
) ;
2026-02-11 23:22:20 +01:00
}
2026-02-22 17:21:23 +01:00
}