package com.thinksincode.tailstreamer.controller;

import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class MainController {
    
    @Autowired
    private FileTailService fileTailService;
    
    @RequestMapping("/")
    public String index(Model model) {
        model.addAttribute("file", fileTailService.getFileName());
        model.addAttribute("filePath", fileTailService.getFilePath());
        model.addAttribute("version", TailStreamer.VERSION);
        return "index";
    }
}

@@ -405,20 +405,137 @@
 oller %7B%0A
+%0A
     
+/** The maximum filename length before truncation occurs. */%0A    private static final int MAX_FILENAME_LENGTH = 50;%0A
 %0A    @Au
@@ -691,16 +691,30 @@
 %22file%22, 
+maybeTruncate(
 fileTail
@@ -735,16 +735,17 @@
 eName())
+)
 ;%0A      
@@ -870,16 +870,16 @@
 RSION);%0A
-
         
@@ -899,11 +899,396 @@
 %22;%0A    %7D
+%0A%0A    private String maybeTruncate(String fileName) %7B%0A        if (fileName.length() %3C= MAX_FILENAME_LENGTH) %7B%0A            return fileName;%0A        %7D else %7B%0A            String extension = fileName.substring(fileName.lastIndexOf('.'));%0A            return fileName.substring(0, MAX_FILENAME_LENGTH) + %22...%22 + fileName.substring(fileName.length() - extension.length() - 1);%0A        %7D%0A    %7D
 %0A%7D%0A

Truncate filename if it exceeds 50 characters