<link rel="stylesheet" href="style.css">

<h1 id="fancyboi">Välkommen till Datorföreningen vid LU & LTH </h1>

<p><a href="./bli-medlem">Bli medlem? Följ dessa enkla steg.</a></p>

<p class="advisory">NYHET: Nu kan du ansöka om medlemskap på eget behag genom <a href='ssh://signup.dflund.se:1337'>ssh -p 1337 signup.dflund.se</a></p>

<div class="grid">
    <div class="row">

          <div class="colright">
            <p>
            Datorföreningen vid Lunds Universitet och
            Lunds Tekniska Högskola är
            mera känd som DF <strong>[ˈdeːɛf]</strong>.
            Föreningens syfte är att främja datorkunnande,
            datoranvändande och allt som hör därtill.
            Vi utvecklar spetskompetens utöver
            de möjligheter som finns inom LU/LTH:s kurser.
            </p>

            <hr>
            <p>
        #!
	


        # Set the number of posts you want to extract
        num_posts=6
        
        # Initialize a counter
        post_count=0
        
        # Create a temporary file to store the posts
        tmp_file=$(mktemp)
        
        # Initialize a variable to keep track of the character count
        char_count=0
        
        # Flag to indicate that a post should be skipped
        skip_post=0
        
        # Read the input file (news.md)
        while IFS= read -r line; do
            if [ "$line" = "---" ]; then
                post_count=$((post_count + 1))
                char_count=0
                skip_post=0
        	echo "" >> $tmp_file
        	echo "---" >> $tmp_file
                if [ "$post_count" -gt "$num_posts" ]; then
                    break
                fi
            elif [ "$skip_post" -eq 0 ]; then
                line_length=$(echo -n "$line" | wc -m)
                char_count=$((char_count + line_length))
        
                if [ "$char_count" -ge 300 ]; then
                    # Truncate the line to 300 characters
                    line=$(echo -n "$line" | cut -c 1-300)
                    skip_post=1
                	post_count=$((post_count + 1))
                fi
                echo "$line" >> "$tmp_file"
                if [ "$skip_post" -eq 1 ]; then
                    sed -i -e '$a<a href="./driftinfo">Läs mer</a>' $tmp_file
                    post_count=$((post_count - 1)) #ugly hack
                fi
            fi
        done < "sysgrp.md"


		# Generate HTML using lowdown for the extracted posts
		lowdown --html-no-skiphtml --html-no-escapehtml "$tmp_file"
            

		#!
            </p>
	<p><a href="./driftinfo">All driftinfo</a></p>

        </div>

        <div class="colleft">

        #!
        
        # Set the number of posts you want to extract
        num_posts=2
        
        # Initialize a counter
        post_count=0
       
        # Create a temporary file to store the posts
        tmp_file=$(mktemp)
        
        # Initialize a variable to keep track of the character count
        char_count=0
        
        # Flag to indicate that a post should be skipped
        skip_post=0
        
        # Read the input file (news.md)
        while IFS= read -r line; do
            if [ "$line" = "---" ]; then
                post_count=$((post_count + 1))
                char_count=0
                skip_post=0
        	echo "" >> $tmp_file
        	echo "---" >> $tmp_file
                if [ "$post_count" -gt "$num_posts" ]; then
                    break
                fi
            elif [ "$skip_post" -eq 0 ]; then
                line_length=$(echo -n "$line" | wc -m)
                char_count=$((char_count + line_length))
        
                if [ "$char_count" -ge 800 ]; then
                    # Truncate the line to 800 characters
                    line=$(echo -n "$line" | cut -c 1-800)
                    skip_post=1
                	post_count=$((post_count + 1))
                fi
                echo "$line" >> "$tmp_file"
                if [ "$skip_post" -eq 1 ]; then
                    sed -i -e '$a<a href="./news">Läs mer</a>' $tmp_file
                    post_count=$((post_count - 1)) #ugly hack
                fi
            fi
        done < "news.md"
	
    	# Generate HTML using lowdown for the extracted posts
	    lowdown --html-no-skiphtml --html-no-escapehtml "$tmp_file"

        #!
	<p><a href="./news">Äldre nyheter</a></p>
        </div>

    </div>

    <div class="col">

        <h3>här hittar du våra medlemmars hemsidor</h3>
        <p>listan innehåller inte de med standard medlemssidan</p>
        <p>om du inte ser dig själv här så skriv något på din sida och vänta någon timme.</p>

        <ul class="user-list">
        #!
        userlist_file="./userlist"
        # Check if the userlist file exists
        if [ -e "$userlist_file" ]; then
            # Read each line from the userlist file
            while IFS= read -r user; do
            #!
            <li><a href="/~$user/">~$user</a></li>
            #!
        done < "$userlist_file"

        fi 
        #!
</ul>

    </div>


</div>
