view src/global/web/Index.java @ 27:22a701699b2a

add Disk.jtp
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 02 Jul 2020 16:00:09 -0600
parents e0c501fb5229
children 5ea557eece1f
line wrap: on
line source


package global.web;

import fschmidt.util.servlet.JtpContext;
import fschmidt.util.servlet.ServletUtils;
import global.HtmlGlobalUtils;
import global.Site;
import nabble.view.web.more.ForumStart;
import nabble.view.web.more.MailingListRequest;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


public final class Index extends HttpServlet {

	private static final Logger logger = LoggerFactory.getLogger(Index.class);

//	private static boolean hasJobsAtNabble = Init.get("hasJobsAtNabble",false);

	public static String path() {
		return "/";
	}

	protected void service(HttpServletRequest request,HttpServletResponse response)
		throws ServletException, IOException
	{
		JtpContext jtpContext = (JtpContext)getServletContext().getAttribute(JtpContext.attrName);
		jtpContext.setEtag(request,response,"x");
		PrintWriter out = response.getWriter();

		out.print( "\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n	<head>\r\n		" );
 HtmlGlobalUtils.head(request, response, "Free Forum &bull; Embeddable Web Apps"); 
		out.print( "\r\n		<link rel=\"canonical\" href=\"https://www.nabble.com/\">\r\n		<meta name=\"description\" content=\"Create a free forum online in less than one minute. All forums are embeddable and fully customizable with scripting language. Choose a unique style and build a discussion board for your community.\" />\r\n		<meta name=\"keywords\" content=\"free forum, free mailing list, mailing list archive, free photo gallery, free newspaper, free blog, best forum, free message board, message board hosting, bulletin board, customizable, private forum, phpBB, vBulletin, hosted, communities\">\r\n		<meta name=\"google-site-verification\" content=\"SUurO4gVJ46SZyzANkH4pJBGH8q-6Bv5P-ZgRBH8Cck\" />\r\n		<style>\r\n			div[actions] i.fa.fa-chevron-right {\r\n				color: #DDD;\r\n				float: right;\r\n			}\r\n			a[fixed] {\r\n				margin-top: -3em;\r\n				position: absolute;\r\n				right: 1em;\r\n				text-decoration: none;\r\n				background-color: #555;\r\n				border-radius: .5em;\r\n				padding: .5em;\r\n				color: #D0D0D0;\r\n				text-shadow: 0px 1px 1px black;\r\n				border-bottom: 1px dotted #757474;\r\n			}\r\n			@media (max-width: 950px) {\r\n				div[footer] {\r\n					padding-bottom: 5em;\r\n				}\r\n			}\r\n			div[note] {\r\n				margin-top: 1em;\r\n				text-align: right;\r\n			}\r\n		</style>\r\n		<script async=\"true\" src=\"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>\r\n		<script>\r\n			 (adsbygoogle = window.adsbygoogle || []).push({\r\n				  google_ad_client: \"ca-pub-6750305871516672\",\r\n				  enable_page_level_ads: true\r\n			 });\r\n		</script>\r\n	</head>\r\n	<body lato>\r\n		" );
 HtmlGlobalUtils.header(request,response); 
		out.print( "\r\n		<div full>\r\n			<div content center>\r\n			<span style=\"display:inline-block\">\r\n				<div col1 center>\r\n					<h1 oswald>Free Forum Hosting &amp; Online Web Apps!</h1>\r\n					<h2 lato gray>Clean Look <span light>&bull;</span> Embeddable <span light>&bull;</span> Customizable</h2>\r\n					<img src=\"/assets/images/home.png\" alt=\"Free forum hosting and online embeddable apps\"/>\r\n				</div>\r\n				<div col2 actions>\r\n					<ul>\r\n						<li><a href=\"" );
		out.print( (HtmlGlobalUtils.nabbleContextUrl) );
		out.print( (ForumStart.path("forum")) );
		out.print( "\" title=\"Click to create a free forum\">Create Free Forum</a> <i class=\"fa fa-chevron-right\"></i></li>\r\n						<li><a href=\"" );
		out.print( (HtmlGlobalUtils.nabbleContextUrl) );
		out.print( (MailingListRequest.path()) );
		out.print( "\" title=\"Click to archive a mailing list\">Archive Mailing List</a> <i class=\"fa fa-chevron-right\"></i></li>\r\n						<li><a href=\"" );
		out.print( (HtmlGlobalUtils.nabbleContextUrl) );
		out.print( (ForumStart.path("gallery")) );
		out.print( "\" title=\"Click to create a free photo gallery\">Create Photo Gallery</a> <i class=\"fa fa-chevron-right\"></i></li>\r\n						<li><a href=\"" );
		out.print( (HtmlGlobalUtils.nabbleContextUrl) );
		out.print( (ForumStart.path("newspaper")) );
		out.print( "\" title=\"Click to create a free newspaper\">Create News Site</a> <i class=\"fa fa-chevron-right\"></i></li>\r\n						<li><a href=\"" );
		out.print( (HtmlGlobalUtils.nabbleContextUrl) );
		out.print( (ForumStart.path("blog")) );
		out.print( "\" title=\"Click to create a free blog\">Create Blog</a> <i class=\"fa fa-chevron-right\"></i></li>\r\n					</ul>\r\n				</div>\r\n				<div note>\r\n					To prevent spam, new forums and other apps will only be visible to registered users.\r\n				</div>\r\n			</span>\r\n			</div>\r\n			<div content paddingTop>\r\n				<div col33 center>\r\n					<h2 oswald>Multi Language</h2>\r\n					<ul floating>\r\n						<li>English</li>\r\n						<li>Čeština (Czech Republic)</li>\r\n						<li>Español</li>\r\n						<li>Français</li>\r\n						<li>Polski</li>\r\n						<li>Português (Brasil)</li>\r\n						<li>Svenska</li>\r\n						<li>Türkçe</li>\r\n						<li>Русский</li>\r\n						<li>Ελληνικά</li>\r\n						<li>中文 (简体)</li>\r\n						<li><a href=\"http://support.nabble.com/Nabble-Translations-f6669344.html\">Translate to other languages</a> &raquo;</li>\r\n					</ul>\r\n				</div>\r\n				<div col33 center>\r\n					<h2 oswald>Embed into any Website</h2>\r\n					<p lineHeight marginHorizontal>All Nabble apps are naturally embeddable, which means that they can be easily displayed inside any web page.\r\n					</p>\r\n				</div>\r\n				<div col33 center>\r\n					<h2 oswald>Fully Customizable</h2>\r\n					<p lineHeight marginHorizontal>All Nabble apps are built with NAML, a scripting language that gives you full control over the app pages.</p>\r\n				</div>\r\n			</div>\r\n			<div content center paddingTop>\r\n				<h2 oswald>Browse Active Nabble Apps</h2>\r\n				" );
 topSites(out); 
		out.print( "\r\n			</div>\r\n		</div>\r\n		" );
 HtmlGlobalUtils.footer(request,response); 
		out.print( "\r\n" );
/*
		out.print( "\r\n		<a fixed href=\"http://www.blasma.com\">Help design a new forum <i class=\"fa fa-chevron-right\"></i></a>\r\n" );
*/
		out.print( "\r\n	</body>\r\n</html>\r\n" );

	}

	static Query query = new TermQuery(new Term(Site.EMBARRASSING_FLD,"false"));

	private static void topSites(PrintWriter out)
		throws ServletException, IOException
	{
		IndexSearcher searcher;
		TopDocs hits;
		try {
			searcher = new IndexSearcher(Site.dir());
			hits = searcher.search( query, 60, Site.SORT_BY_VALUE );
		} catch(IOException e) {
			logger.error("Index error", e);
			
		out.print( "[Rebuilding Index]" );

			return;
		}
		try {
			
		out.print( "\r\n<ul floating center>\r\n" );

			for( ScoreDoc sd : hits.scoreDocs ) {
				Site site = new Site( searcher.doc(sd.doc) );
				
		out.print( "\r\n<li>" );
		out.print( (site.link()) );
		out.print( "</li>\r\n" );

			}
				
		out.print( "\r\n</ul>\r\n<div style=\"padding-top:.5em;clear:both\">\r\n<a bold href=\"" );
		out.print( (RootForums.path()) );
		out.print( "\" title=\"View more active forums and apps\">View More</a></b> <i class=\"fa fa-chevron-right\"></i>\r\n</div>\r\n" );

		} finally {
			searcher.close();
		}
	}

}