<commit_before><?php

include_once 'database.php';
include_once 'tohtml.php';

function awsToTex( $aws, $with_picture = true )
{
    // First sanities the html before it can be converted to pdf.
    foreach( $aws as $key => $value )
    {
        // See this 
        // http://stackoverflow.com/questions/9870974/replace-nbsp-characters-that-are-hidden-in-text
        $value = htmlentities( $value, null, 'utf-8' );
        $value = str_replace( '&nbsp;', '', $value );
        $value = preg_replace( '/\s+/', ' ', $value );
        $value = html_entity_decode( trim( $value ) );
        $aws[ $key ] = $value;
    }

    $speaker = __ucwords__( loginToText( $aws[ 'speaker' ] , false ));

    $supervisors = array( __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'supervisor_1' ] ), false ))
                ,  __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'supervisor_2' ] ), false ))
            );
    $supervisors = array_filter( $supervisors );

    $tcm = array( );
    array_push( $tcm, __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_1' ] ), false ))
            , __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_2' ] ), false ))
            ,  __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_3' ] ), false ))
            , __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_4' ] ), false ))
        );
    $tcm = array_filter( $tcm );

    $title = __ucwords__( $aws[ 'title' ]);
    $abstract = $aws[ 'abstract' ];

    // Add user image.
    $imagefile = $_SESSION[ 'conf' ]['data']['user_imagedir'] . '/' . 
        $aws['speaker'] . '.png';
    if( ! file_exists( $imagefile ) )
        $imagefile = __DIR__ . '/data/null.png';

    $speakerImg = '\includegraphics[width=5cm]{' . $imagefile . '}';

    // Date and plate
    $dateAndPlace =  humanReadableDate( $aws[ 'date' ] ) .  
            ', 4:00pm at \textbf{Hapus (LH1)}';
    $dateAndPlace = '\faCalendarCheckO \quad ' . $dateAndPlace;

    $head = '\begin{tikzpicture}[ every node/.style={rectangle
        ,inner sep=1pt,node distance=5mm,text width=0.65\textwidth} ]';
    $head .= '\node[text width=5cm] (image) at (0,0) {' . $speakerImg . '};';
    $head .= '\node[above right=of image] (schedule)  {\hfill ' . 
                $dateAndPlace . '};';
    $head .= '\node[right=of image] (title) { ' .  '{\LARGE ' . $title . '} };';
    $head .= '\node[below=of title] (author) { ' .  '{' . $speaker . '} };';
    $head .= '\end{tikzpicture}';


    // Do not generate the preamble.
    $tex = array( "\documentclass[]{article}"
        , "\usepackage[margin=20mm,a4paper]{geometry}"
        , "\usepackage[]{graphicx}"
        , "\usepackage[]{amsmath,amssymb}"
        , "\usepackage{tikz}"
        , "\usepackage{fontawesome}"
        , '\usepackage{fancyhdr}'
        , '\linespread{1.2}'
        , '\pagestyle{fancy}'
        , '\pagenumbering{gobble}'
        , '\lhead{\textsc{Annual Work Seminar} }'
        , '\rhead{National Center for Biological Sciences, Bangalore \\\\ 
            TATA Institute of Fundamental Research, Mumbai}'
        , '\usetikzlibrary{calc,positioning,arrows}'
        //, '\usepackage[T1]{fontenc}'
        , '\usepackage[utf8]{inputenc}'
        , '\usepackage[]{lmodern}'
        , '\begin{document}'
        );

    // Header
    $tex[] = $head;

    $tex[] = '\par';

    // remove html formating before converting to tex.
    file_put_contents( '/tmp/abstract.html', $abstract );
    $cmd = 'python ' . __DIR__ . '/html2other.py';
    $texAbstract = `$cmd /tmp/abstract.html tex`;
    if( strlen(trim($texAbstract)) > 10 )
        $abstract = $texAbstract;

    //$tex[] = $dateAndPlace;

    // Title and abstract
    $tex[] = '{\large ' . $abstract . '}';

    $extra = '\begin{table}[ht!]';
    $extra .= '\begin{tabular}{ll}';
    $extra .= '\textbf{Supervisor(s)} & ' . implode( ",", $supervisors) . '\\\\';
    $extra .= '\textbf{Thesis Committee Member(s)} & ' . implode( ", ", $tcm ) . '\\\\';
    $extra .= '\end{tabular}';
    $extra .= '\end{table}';

    $tex[] = $extra;
    $tex[] = '\end{document}';
    return implode( "\n", $tex );
}

if( ! array_key_exists( 'speaker', $_GET ) )
{
    echo printInfo( 'Invalid request' );
}
else <commit_msg>People need to fix their formatting.<commit_after><?php

include_once 'database.php';
include_once 'tohtml.php';

function awsToTex( $aws, $with_picture = true )
{
    // First sanities the html before it can be converted to pdf.
    foreach( $aws as $key => $value )
    {
        // See this 
        // http://stackoverflow.com/questions/9870974/replace-nbsp-characters-that-are-hidden-in-text
        $value = htmlentities( $value, null, 'utf-8' );
        $value = str_replace( '&nbsp;', '', $value );
        $value = preg_replace( '/\s+/', ' ', $value );
        $value = html_entity_decode( trim( $value ) );
        $aws[ $key ] = $value;
    }

    $speaker = __ucwords__( loginToText( $aws[ 'speaker' ] , false ));

    $supervisors = array( __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'supervisor_1' ] ), false ))
                ,  __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'supervisor_2' ] ), false ))
            );
    $supervisors = array_filter( $supervisors );

    $tcm = array( );
    array_push( $tcm, __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_1' ] ), false ))
            , __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_2' ] ), false ))
            ,  __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_3' ] ), false ))
            , __ucwords__( 
        loginToText( findAnyoneWithEmail( $aws[ 'tcm_member_4' ] ), false ))
        );
    $tcm = array_filter( $tcm );

    $title = __ucwords__( $aws[ 'title' ]);
    $abstract = $aws[ 'abstract' ];

    // Add user image.
    $imagefile = $_SESSION[ 'conf' ]['data']['user_imagedir'] . '/' . 
        $aws['speaker'] . '.png';
    if( ! file_exists( $imagefile ) )
        $imagefile = __DIR__ . '/data/null.png';

    $speakerImg = '\includegraphics[width=5cm]{' . $imagefile . '}';

    // Date and plate
    $dateAndPlace =  humanReadableDate( $aws[ 'date' ] ) .  
            ', 4:00pm at \textbf{Hapus (LH1)}';
    $dateAndPlace = '\faCalendarCheckO \quad ' . $dateAndPlace;

    $head = '\begin{tikzpicture}[ every node/.style={rectangle
        ,inner sep=1pt,node distance=5mm,text width=0.65\textwidth} ]';
    $head .= '\node[text width=5cm] (image) at (0,0) {' . $speakerImg . '};';
    $head .= '\node[above right=of image] (schedule)  {\hfill ' . 
                $dateAndPlace . '};';
    $head .= '\node[right=of image] (title) { ' .  '{\LARGE ' . $title . '} };';
    $head .= '\node[below=of title] (author) { ' .  '{' . $speaker . '} };';
    $head .= '\end{tikzpicture}';


    // Do not generate the preamble.
    $tex = array( "\documentclass[]{article}"
        , "\usepackage[margin=20mm,a4paper]{geometry}"
        , "\usepackage[]{graphicx}"
        , "\usepackage[]{amsmath,amssymb}"
        , "\usepackage{tikz}"
        , "\usepackage{fontawesome}"
        , '\usepackage{fancyhdr}'
        , '\linespread{1.2}'
        , '\pagestyle{fancy}'
        , '\pagenumbering{gobble}'
        , '\lhead{\textsc{Annual Work Seminar} }'
        , '\rhead{National Center for Biological Sciences, Bangalore \\\\ 
            TATA Institute of Fundamental Research, Mumbai}'
        , '\usetikzlibrary{calc,positioning,arrows}'
        //, '\usepackage[T1]{fontenc}'
        , '\usepackage[utf8]{inputenc}'
        , '\usepackage[]{lmodern}'
        , '\begin{document}'
        );

    // Header
    $tex[] = $head;

    $tex[] = '\par';

    // remove html formating before converting to tex.
    file_put_contents( '/tmp/abstract.html', $abstract );
    $cmd = 'python ' . __DIR__ . '/html2other.py';
    $texAbstract = `$cmd /tmp/abstract.html tex`;
    if( strlen(trim($texAbstract)) > 10 )
        $abstract = $texAbstract;

    //$tex[] = $dateAndPlace;

    // Title and abstract
    //$tex[] = '\begin{minipage}{\textwidth} \resizebox{\textwidth}{!} {';
    $tex[] = '{\large ' . $abstract . '}';

    $extra = '\begin{table}[ht!]';
    $extra .= '\begin{tabular}{ll}';
    $extra .= '\textbf{Supervisor(s)} & ' . implode( ",", $supervisors) . '\\\\';
    $extra .= '\textbf{Thesis Committee Member(s)} & ' . implode( ", ", $tcm ) . '\\\\';
    $extra .= '\end{tabular}';
    $extra .= '\end{table}';

    $tex[] = $extra;
    //$tex[] = '}\end{minipage}';
    $tex[] = '\end{document}';
    return implode( "\n", $tex );
}

if( ! array_key_exists( 'speaker', $_GET ) )
{
    echo printInfo( 'Invalid request' );
}
else 
{'fraction_non_alphanumeric': 0.19234285714285715, 'fraction_numerical': 0.008457142857142858, 'mean_word_length': 2.4836783439490446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6773680', 'n_tokens_mistral': 3052, 'n_tokens_neox': 2909, 'n_words': 582}