<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' %>
<%
	boolean wantHtml = preferences.getBoolean("show-rich-texts") || request.getParameter("wantHtml") != null;
        boolean popupComment = request.getParameter("popupComment") != null ||
            request.getAttribute("popupComment") != null;
	boolean footnoteDisplay = request.getParameter("footnote") != null ||
	    request.getAttribute("footnote") != null;
        boolean inlineImages = preferences.getBoolean("inline-images");
	int conferenceNumber = ((Integer) request.getAttribute("conferenceNumber")).intValue();
	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();
        out.println("<a name=\"text" + textNumber + "\"></a>");

	Text text = null;
	try {
	    text = lyskom.getText(textNumber);
	} catch (RpcFailure ex1) {
	    if (ex1.getError() == Rpc.E_no_such_text) {
		out.println("<p class=\"statusError\">Fel: text " + 
		    textNumber + " finns inte.</p>");
		return;
	    }
	}
%>
	<p class="boxed">
 	<span class="text">
	<tt>
<%
	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";
	byte[] subjectBytes = text.getSubject();
	// a bit clumsy but it allows us to always fallback on the default
	// system encoding, and if neither iso-8859-1 nor the text-specifies
	// charset is supported, it will be indicated by appending the
	// name in brackets
	String subject = new String(subjectBytes);
	try {
	    subject = new String(subjectBytes, "iso-8859-1");
	    subject = new String(subjectBytes, charset);
	} catch (UnsupportedEncodingException ex1) {
	    subject = subject + " [" + charset + "]";
	}
	int[] commented = text.getCommented();
	int[] comments = text.getComments();
	int[] footnoted = text.getFootnoted();
	int[] footnotes = text.getFootnotes();
	List auxMxAuthor = Arrays.asList(text.getAuxData(AuxItem.tagMxAuthor));
	List auxMxFrom = Arrays.asList(text.getAuxData(AuxItem.tagMxFrom));
	List auxMxTo = Arrays.asList(text.getAuxData(AuxItem.tagMxTo));
	List auxMxCc = Arrays.asList(text.getAuxData(AuxItem.tagMxCc));
	List auxMxDate = Arrays.asList(text.getAuxData(AuxItem.tagMxDate));
	List auxMxMimePartIn = Arrays.asList(text.getAuxData(AuxItem.tagMxMimePartIn));


        out.println(jsTitle(serverShort(lyskom) + ": text " + text.getNo() + " av " + 
		lookupName(lyskom, text.getStat().getAuthor()) +
		": " + subject));
	boolean printAuthor = false;
	if (footnoteDisplay) {
	    for (int i=0; i < footnoted.length; i++)
	    	if (lyskom.getTextStat(footnoted[i]).getAuthor() != text.getStat().getAuthor())
		    printAuthor = true;
	}
	out.print("Text nummer " + textLink(request, lyskom, text.getNo(), printAuthor));
	if (footnoteDisplay) {
	    for (int i=0; i < footnoted.length; i++) {	    
		out.print(", fotnot till " + textLink(request, lyskom, footnoted[i], printAuthor));
	    }
	    out.println(", skapad " + df.format(text.getCreationTime()) + "<br/>");
	} else {
	    out.print(" av ");
	    if (auxMxAuthor.size() > 0) {
	    	out.print(htmlize(((Hollerith) auxMxAuthor.get(0)).getContentString()));
	    }
	    if (auxMxFrom.size() > 0) {
	    	String email = ((Hollerith) auxMxFrom.get(0)).getContentString();
	    	out.print(" &lt;<a href=\"mailto:");
	    	out.print(htmlize(email));
	    	out.print("\">");
	    	out.print(htmlize(email));
	    	out.println("</a>>");
	    }
	    if (auxMxAuthor.size() == 0 && auxMxFrom.size() == 0) {
	    	out.println(lookupName(lyskom, text.getAuthor(), true));
	    }
	
%>	[ <a title="Markera text" href="<%=myURI(request)%>?mark=<%=text.getNo()%>">M</a>
        <a title="Avmarkera text" href="<%=myURI(request)%>?unmark=<%=text.getNo()%>">A</a>
        <a title="Personligt svar" href="<%=myURI(request)%>?privateReply=<%=text.getNo()%>">p</a>
	<% if (text.getAuthor() == lyskom.getMyPerson().getNo()) { %>
        <a title="Fotnotera" href="<%=myURI(request)%>?footnoteTo=<%=text.getNo()%>&dispatchToComposer">F</a>
        <% }
	   if (text.getCommented() != null && text.getCommented().length > 0) { %>
        <a title="terse urinlgg" href="<%=myURI(request)%>?reviewOriginal=<%=text.getNo()%>">u</a>
	<% } %>
	]<br/>
	Skapad <%= df.format(text.getCreationTime()) %><br/>
<%
	}
%>
<%	if (debug) {
	    Hollerith[] creatingSoftware = text.getStat().getAuxData(AuxItem.tagCreatingSoftware);
	    for (int i=0; i < creatingSoftware.length; i++) {
	    	out.println("Klient: " + lyskom.toString(creatingSoftware[i].getContents()) + "<br/>");
            }
%>
	    Datatyp: <%= rawContentType %><br/>
<%	}<commit_msg>*** empty log message ***<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' %>
<%
	boolean wantHtml = preferences.getBoolean("show-rich-texts") || request.getParameter("wantHtml") != null;
        boolean popupComment = request.getParameter("popupComment") != null ||
            request.getAttribute("popupComment") != null;
	boolean footnoteDisplay = request.getParameter("footnote") != null ||
	    request.getAttribute("footnote") != null;
        boolean inlineImages = preferences.getBoolean("inline-images");
	int conferenceNumber = ((Integer) request.getAttribute("conferenceNumber")).intValue();
	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();
        out.println("<a name=\"text" + textNumber + "\"></a>");

	Text text = null;
	try {
	    text = lyskom.getText(textNumber);
	} catch (RpcFailure ex1) {
	    if (ex1.getError() == Rpc.E_no_such_text) {
		out.println("<p class=\"statusError\">Fel: text " + 
		    textNumber + " finns inte.</p>");
		return;
	    }
	}
%>
	<p class="boxed">
 	<span class="text">
	<tt>
<%
	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";
	byte[] subjectBytes = text.getSubject();
	// a bit clumsy but it allows us to always fallback on the default
	// system encoding, and if neither iso-8859-1 nor the text-specifies
	// charset is supported, it will be indicated by appending the
	// name in brackets
	String subject = new String(subjectBytes);
	try {
	    subject = new String(subjectBytes, "iso-8859-1");
	    subject = new String(subjectBytes, charset);
	} catch (UnsupportedEncodingException ex1) {
	    subject = subject + " [" + charset + "]";
	}
	int[] commented = text.getCommented();
	int[] comments = text.getComments();
	int[] footnoted = text.getFootnoted();
	int[] footnotes = text.getFootnotes();
	List auxMxAuthor = Arrays.asList(text.getAuxData(AuxItem.tagMxAuthor));
	List auxMxFrom = Arrays.asList(text.getAuxData(AuxItem.tagMxFrom));
	List auxMxTo = Arrays.asList(text.getAuxData(AuxItem.tagMxTo));
	List auxMxCc = Arrays.asList(text.getAuxData(AuxItem.tagMxCc));
	List auxMxDate = Arrays.asList(text.getAuxData(AuxItem.tagMxDate));
	List auxMxMimePartIn = Arrays.asList(text.getAuxData(AuxItem.tagMxMimePartIn));


        out.println(jsTitle(serverShort(lyskom) + ": text " + text.getNo() + " av " + 
		lookupName(lyskom, text.getStat().getAuthor()) +
		": " + subject));
	boolean printAuthor = false;
	if (footnoteDisplay) {
	    for (int i=0; i < footnoted.length; i++)
	    	if (lyskom.getTextStat(footnoted[i]).getAuthor() != text.getStat().getAuthor())
		    printAuthor = true;
	}
	out.print("Text nummer " + textLink(request, lyskom, text.getNo(), printAuthor));
	if (footnoteDisplay) {
	    for (int i=0; i < footnoted.length; i++) {	    
		out.print(", fotnot till " + textLink(request, lyskom, footnoted[i], printAuthor));
	    }
	    out.println(", skapad " + df.format(text.getCreationTime()) + "<br/>");
	} else {
	    out.print(" av ");
	    if (auxMxAuthor.size() > 0) {
	    	out.print(htmlize(((Hollerith) auxMxAuthor.get(0)).getContentString()));
	    }
	    if (auxMxFrom.size() > 0) {
	    	String email = ((Hollerith) auxMxFrom.get(0)).getContentString();
	    	out.print(" &lt;<a href=\"mailto:");
	    	out.print(htmlize(email));
	    	out.print("\">");
	    	out.print(htmlize(email));
	    	out.println("</a>>");
	    }
	    if (auxMxAuthor.size() == 0 && auxMxFrom.size() == 0) {
	    	out.println(lookupName(lyskom, text.getAuthor(), true));
	    }
	
%>	[ <a title="Markera text" href="<%=myURI(request)%>?mark=<%=text.getNo()%>">M</a>
        <a title="Avmarkera text" href="<%=myURI(request)%>?unmark=<%=text.getNo()%>">A</a>
        <a title="Personligt svar" href="<%=myURI(request)%>?privateReply=<%=text.getNo()%>">p</a>
	<% if (text.getAuthor() == lyskom.getMyPerson().getNo()) { %>
        <a title="Fotnotera" href="<%=myURI(request)%>?footnoteTo=<%=text.getNo()%>&dispatchToComposer">F</a>
        <% }
	   if (text.getCommented() != null && text.getCommented().length > 0) { %>
        <a title="terse urinlgg" href="<%=myURI(request)%>?reviewOriginal=<%=text.getNo()%>">u</a>
	<% } %>
	]<br/>
	Skapad <%= df.format(text.getCreationTime()) %><br/>
<%
	}

	if (debug) {
	    Hollerith[] creatingSoftware = text.getStat().getAuxData(AuxItem.tagCreatingSoftware);
	    for (int i=0; i < creatingSoftware.length; i++) {
	    	out.println("Klient: " + lyskom.toString(creatingSoftware[i].getContents()) + "<br/>");
            }
	    out.println("Datatyp: " + rawContentType + "<br/>");
	}

{'fraction_non_alphanumeric': 0.18630380360171203, 'fraction_numerical': 0.006783493499152063, 'mean_word_length': 4.319587628865979, 'pattern_counts': {'":': 4, '<': 104, '<?xml version=': 0, '>': 108, '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': '4005659', 'n_tokens_mistral': 4523, 'n_tokens_neox': 4242, 'n_words': 756}