Skip to content

Commit 1317bea

Browse files
author
DABURON Vincent
committed
add file size after <a href= link
1 parent b032962 commit 1317bea

4 files changed

Lines changed: 54 additions & 13 deletions

File tree

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ The maven groupId, artifactId and version, this plugin is in the **Maven Central
4242
```xml
4343
<groupId>io.github.vdaburon</groupId>
4444
<artifactId>create-html-for-files-in-directory</artifactId>
45-
<version>1.1</version>
45+
<version>1.2</version>
4646
```
47-
Just include the plugin in your `pom.xml` and execute `mvn verify`.
47+
Just include the plugin in your `pom.xml` and execute `mvn verify` <br>
48+
or individual launch `mvn -Dgraph_width=950 exec:java@create_html_page_for_files_in_directory`
4849

4950
```xml
5051
<project>
@@ -56,7 +57,7 @@ Just include the plugin in your `pom.xml` and execute `mvn verify`.
5657
<dependency>
5758
<groupId>io.github.vdaburon</groupId>
5859
<artifactId>create-html-for-files-in-directory</artifactId>
59-
<version>1.1</version>
60+
<version>1.2</version>
6061
</dependency>
6162
</dependencies>
6263

@@ -97,15 +98,22 @@ Just include the plugin in your `pom.xml` and execute `mvn verify`.
9798
## Simple jar tool
9899
This tool is a java jar, so it's could be use as simple jar (look at [Release](https://github.com/vdaburon/CreateHtmlForFilesInDirectory/releases) to download jar file)
99100
<pre>
100-
java -cp create-html-for-files-in-directory-&lt;version&gt;.jar io.github.vdaburon.jmeter.utils.HtmlGraphVisualizationGenerator jmeter/results index.html
101+
java -Dimage_width=900 -cp create-html-for-files-in-directory-&lt;version&gt;.jar io.github.vdaburon.jmeter.utils.HtmlGraphVisualizationGenerator jmeter/results index.html
102+
or
103+
java -Dimage_width=900 -jar create-html-for-files-in-directory-&lt;version&gt;-jar-with-dependencies.jar jmeter/results index.html
101104
</pre>
102105

103106
## Link to others projects
104-
Usally this plugin is use with [jmeter-graph-tool-maven-plugin](https://github.com/vdaburon/jmeter-graph-tool-maven-plugin)
105-
107+
Usally this plugin is use with [jmeter-graph-tool-maven-plugin](https://github.com/vdaburon/jmeter-graph-tool-maven-plugin)<br>
106108
and this plugin [csv-report-to-html](https://github.com/vdaburon/JMReportCsvToHtml)
107-
108109
1) The **jmeter-graph-tool-maven-plugin** create the report csv files and graphs
109110
2) The **csv-report-to-html** create the **html table report** from the csv file
110111
3) The **create-html-for-files-in-directory** create a page html this links to images and files in a directory to show and add links
111112

113+
## Versions
114+
Version 1.2 add the file size after the "&lt;a ref=" link
115+
116+
Version 1.1 add link (a href) to jtl and xml files
117+
118+
Version 1.0 initial version
119+

doc/images/html_extract.png

38.2 KB
Loading

pom.xml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.vdaburon</groupId>
88
<artifactId>create-html-for-files-in-directory</artifactId>
9-
<version>1.1</version>
9+
<version>1.2</version>
1010
<packaging>jar</packaging>
1111
<name>Create html page for files in directory</name>
1212
<description>A tool that creates an html page for files in the directory to display graphics and link files</description>
@@ -100,6 +100,32 @@
100100
</execution>
101101
</executions>
102102
</plugin>
103+
<plugin>
104+
<!-- create the uber jar : mvn clean package -->
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-assembly-plugin</artifactId>
107+
<version>3.5.0</version>
108+
<executions>
109+
<execution>
110+
<phase>package</phase>
111+
<goals>
112+
<goal>single</goal>
113+
</goals>
114+
<configuration>
115+
<archive>
116+
<manifest>
117+
<mainClass>
118+
io.github.vdaburon.jmeter.utils.HtmlGraphVisualizationGenerator
119+
</mainClass>
120+
</manifest>
121+
</archive>
122+
<descriptorRefs>
123+
<descriptorRef>jar-with-dependencies</descriptorRef>
124+
</descriptorRefs>
125+
</configuration>
126+
</execution>
127+
</executions>
128+
</plugin>
103129
<plugin>
104130
<groupId>org.apache.maven.plugins</groupId>
105131
<artifactId>maven-gpg-plugin</artifactId>

src/main/java/io/github/vdaburon/jmeter/utils/HtmlGraphVisualizationGenerator.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.IOException;
77
import java.nio.file.Files;
88
import java.nio.file.Paths;
9+
import java.text.DecimalFormat;
10+
import java.text.DecimalFormatSymbols;
911
import java.text.SimpleDateFormat;
1012
import java.util.ArrayList;
1113
import java.util.Arrays;
@@ -25,7 +27,7 @@ public static void main(String[] args) {
2527

2628
if (args.length != 2) {
2729
System.err.println("Usage HtmlGraphVisualizationGenerator dirWithFiles fileOutHtml");
28-
System.err.println("E.g. java -jar create-html-for-files-in-directory-<version>.jar -Dimage_width=1024 c:/jmeter/dir_results index.html");
30+
System.err.println("E.g. java -Dimage_width=1024 -jar create-html-for-files-in-directory-<version>.jar c:/jmeter/dir_results index.html");
2931
System.exit(1);
3032
}
3133
String dirWithFiles = args[0];
@@ -71,7 +73,7 @@ public static void main(String[] args) {
7173
out.write("<body><br/><br/>");
7274
out.write(LINE_SEP);
7375

74-
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
76+
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH'h'mm'm'ss's'", Locale.getDefault());
7577
String sDate = dateformat.format(new Date());
7678

7779
out.write("<h1> Generated date " + sDate + "</h1><br/>");
@@ -86,13 +88,18 @@ public static void main(String[] args) {
8688

8789
// folderRead = c:\dir1\dir2\dirIn, f = c:\dir1\dir2\dirIn\logo.gif => nameRelative = logo.gif (remove the folderRead path)
8890
String nameRelative = f.getCanonicalPath().substring(fDirWithFiles.getCanonicalPath().length() + 1);
91+
8992
out.write("<h2>" + nameRelative + "</h2><br/>");
9093
out.write(LINE_SEP);
91-
92-
94+
9395
if (name.endsWith("csv") || name.endsWith("jtl") || name.endsWith("xml") ||name.endsWith("gz") || name.endsWith("zip") || name.endsWith("log")) {
96+
long lengthBytes = f.length();
97+
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
98+
symbols.setGroupingSeparator(' ');
99+
100+
DecimalFormat formatter = new DecimalFormat("###,###.##", symbols);
94101
// link to the file
95-
out.write("<a href='" + nameRelative + "'>" + nameRelative + "</a><br/><br/>");
102+
out.write("<a href='" + nameRelative + "'>" + nameRelative + "</a>&nbsp;&nbsp;&nbsp;File size=" + formatter.format(lengthBytes) + " Bytes<br/><br/>");
96103
}
97104

98105
if (name.endsWith("gif") || name.endsWith("png") || name.endsWith("bmp") || name.endsWith("jpg") || name.endsWith("jpeg")) {

0 commit comments

Comments
 (0)