<commit_before><%@ page language='java' import='nu.dll.lyskom.*, com.oreilly.servlet.multipart.*, java.util.*,
				 java.net.*, java.io.*, java.text.*,java.util.regex.*' %>
<%@ page pageEncoding='iso-8859-1' contentType='text/html; charset=utf-8' %>
<%@ page import='javax.mail.BodyPart, javax.mail.MessagingException, javax.mail.internet.*' %>
<%@ include file='kom.jsp' %>
<%@ include file='prefs_inc.jsp' %>
<%

	log("text.jsp start.");
	boolean wantHtml = preferences.getBoolean("show-rich-texts") || request.getParameter("wantHtml") != null;
        boolean popupComment = request.getParameter("popupComment") != null ||
            request.getAttribute("popupComment") != null ||
	    preferences.getBoolean("comment-in-new-window");
	boolean footnoteDisplay = request.getParameter("footnote") != null ||
	    request.getAttribute("footnote") != null;
        boolean inlineImages = preferences.getBoolean("inline-images");
	Integer conferenceNumberObj = (Integer) request.getAttribute("conferenceNumber");
	int conferenceNumber = conferenceNumberObj != null ? conferenceNumberObj.intValue() : 0;
	Debug.println("conferenceNumber: " + conferenceNumber);

        LinkedList reviewList = (LinkedList) lyskom.getAttribute("lyskom.review-list");
        LinkedList textNumbers = (LinkedList) request.getAttribute("text-numbers");
	if (reviewList == null) reviewList = new LinkedList();
	if (textNumbers == null) textNumbers = new LinkedList();

	int textNumber = ((Integer) request.getAttribute("text")).intValue();
	log("text.jsp text number: " + textNumber);	
        out.println("<a name=\"text" + textNumber + "\"></a>");

	MimeText text = null;

	try {
	    text = new MimeText(lyskom.getText(textNumber));
	} catch (RpcFailure ex1) {
	    if (ex1.getError() == Rpc.E_no_such_text) {
		out.println("<p class=\"statusError\">Fel: text " + 
		    textNumber + " finns inte.</div>");
		return;
	    }
	}
        int depthOnPage = 0;
        Integer lastTextDisplayed = (Integer) request.getAttribute("last-text-displayed");
	Integer parent = null;
        if (preferences.getBoolean("indent-comments-on-page")) {
	    parent = (Integer) request.getAttribute("text-" + 
		text.getNo() + "-commented");
	    if (parent == null) {
		parent = (Integer) request.getAttribute("text-" + text.getNo() +
			"-footnoted");
	    }
	    if (parent != null) {
		depthOnPage = ((Integer) request.getAttribute("text-" +
			parent + "-depth")).intValue()+1;
	    }
	}
	if (depthOnPage > preferences.getInt("max-indent")) {
	    depthOnPage = preferences.getInt("max-indent");
	}
	if (Debug.ENABLED) Debug.println("text " + text.getNo() + " page depth: " + depthOnPage + ", parent: " + parent);
        request.setAttribute("text-" + text.getNo() + "-depth", new Integer(depthOnPage));
        request.setAttribute("last-text-displayed", new Integer(text.getNo()));
 	out.println("<div class=\"text\" style=\"margin-left: " + depthOnPage + "em;\">");

	List viewedTexts = (List) request.getAttribute("viewedTexts");
	if (viewedTexts == null) {
	    viewedTexts = new LinkedList();
	    request.setAttribute("viewedTexts", viewedTexts);
	}
	viewedTexts.add(new Integer(text.getNo()));

	boolean noComments = text.getAuxItems(AuxItem.tagNoComments).size() > 0;
	String contentType = text.getStat().getContentType();
	if (request.getParameter("forceContentType") != null)
	    contentType = request.getParameter("forceContentType");

	ContentType contentTypeObj = new ContentType(contentType);

	Hollerith[] ctdata = text.getStat().getAuxData(AuxItem.tagContentType);
	String rawContentType = (ctdata != null && ctdata.length > 0) ? new String(text.getStat().getAuxData(AuxItem.tagContentType)[0].getContents(), "us-ascii") : "text/x-kom-basic";
	String charset = text.getCharset();
	if (charset == null) charset = "iso-8859-1";
	if (charset.equals("us-ascii")) charset = "iso-8859-1"; // some broken elisp clients lie...
	if (contentType.equals("x-kom/text")) contentType = "text/x-kom-basic";<commit_msg>transmogrify x-kom/text -> text/x-kom-basic a bit earlier (before the ContentType object is created)<commit_after><%@ page language='java' import='nu.dll.lyskom.*, com.oreilly.servlet.multipart.*, java.util.*,
				 java.net.*, java.io.*, java.text.*,java.util.regex.*' %>
<%@ page pageEncoding='iso-8859-1' contentType='text/html; charset=utf-8' %>
<%@ page import='javax.mail.BodyPart, javax.mail.MessagingException, javax.mail.internet.*' %>
<%@ include file='kom.jsp' %>
<%@ include file='prefs_inc.jsp' %>
<%

	log("text.jsp start.");
	boolean wantHtml = preferences.getBoolean("show-rich-texts") || request.getParameter("wantHtml") != null;
        boolean popupComment = request.getParameter("popupComment") != null ||
            request.getAttribute("popupComment") != null ||
	    preferences.getBoolean("comment-in-new-window");
	boolean footnoteDisplay = request.getParameter("footnote") != null ||
	    request.getAttribute("footnote") != null;
        boolean inlineImages = preferences.getBoolean("inline-images");
	Integer conferenceNumberObj = (Integer) request.getAttribute("conferenceNumber");
	int conferenceNumber = conferenceNumberObj != null ? conferenceNumberObj.intValue() : 0;
	Debug.println("conferenceNumber: " + conferenceNumber);

        LinkedList reviewList = (LinkedList) lyskom.getAttribute("lyskom.review-list");
        LinkedList textNumbers = (LinkedList) request.getAttribute("text-numbers");
	if (reviewList == null) reviewList = new LinkedList();
	if (textNumbers == null) textNumbers = new LinkedList();

	int textNumber = ((Integer) request.getAttribute("text")).intValue();
	log("text.jsp text number: " + textNumber);	
        out.println("<a name=\"text" + textNumber + "\"></a>");

	MimeText text = null;

	try {
	    text = new MimeText(lyskom.getText(textNumber));
	} catch (RpcFailure ex1) {
	    if (ex1.getError() == Rpc.E_no_such_text) {
		out.println("<p class=\"statusError\">Fel: text " + 
		    textNumber + " finns inte.</div>");
		return;
	    }
	}
        int depthOnPage = 0;
        Integer lastTextDisplayed = (Integer) request.getAttribute("last-text-displayed");
	Integer parent = null;
        if (preferences.getBoolean("indent-comments-on-page")) {
	    parent = (Integer) request.getAttribute("text-" + 
		text.getNo() + "-commented");
	    if (parent == null) {
		parent = (Integer) request.getAttribute("text-" + text.getNo() +
			"-footnoted");
	    }
	    if (parent != null) {
		depthOnPage = ((Integer) request.getAttribute("text-" +
			parent + "-depth")).intValue()+1;
	    }
	}
	if (depthOnPage > preferences.getInt("max-indent")) {
	    depthOnPage = preferences.getInt("max-indent");
	}
	if (Debug.ENABLED) Debug.println("text " + text.getNo() + " page depth: " + depthOnPage + ", parent: " + parent);
        request.setAttribute("text-" + text.getNo() + "-depth", new Integer(depthOnPage));
        request.setAttribute("last-text-displayed", new Integer(text.getNo()));
 	out.println("<div class=\"text\" style=\"margin-left: " + depthOnPage + "em;\">");

	List viewedTexts = (List) request.getAttribute("viewedTexts");
	if (viewedTexts == null) {
	    viewedTexts = new LinkedList();
	    request.setAttribute("viewedTexts", viewedTexts);
	}
	viewedTexts.add(new Integer(text.getNo()));

	boolean noComments = text.getAuxItems(AuxItem.tagNoComments).size() > 0;
	String contentType = text.getStat().getContentType();
	if (request.getParameter("forceContentType") != null)
	    contentType = request.getParameter("forceContentType");

	if (contentType.equals("x-kom/text")) contentType = "text/x-kom-basic";
	ContentType contentTypeObj = new ContentType(contentType);

	Hollerith[] ctdata = text.getStat().getAuxData(AuxItem.tagContentType);
	String rawContentType = (ctdata != null && ctdata.length > 0) ? new String(text.getStat().getAuxData(AuxItem.tagContentType)[0].getContents(), "us-ascii") : "text/x-kom-basic";
	String charset = text.getCharset();
	if (charset == null) charset = "iso-8859-1";
	if (charset.equals("us-ascii")) charset = "iso-8859-1"; // some broken elisp clients lie...
{'fraction_non_alphanumeric': 0.17387532531912256, 'fraction_numerical': 0.005948692526955013, 'mean_word_length': 4.41974479516454, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4117892', 'n_tokens_mistral': 2640, 'n_tokens_neox': 2493, 'n_words': 474}