Browse code

rebranding: asciivaincra!

devnewton authored on 31/01/2016 21:14:08
Showing 40 changed files
... ...
@@ -26,5 +26,5 @@ THE SOFTWARE.
26 26
 
27 27
 ## favicon.png
28 28
 
29
-License: this is a free work, you can copy, distribute, and modify it under the terms of the Free Art License 1.3 (FAL1.3.txt file).
30
-Authors: Geeky Goblin Productions (http://geekygoblin.org/), devnewton <devnewton@bci.im>
31 29
\ No newline at end of file
30
+License: CC-BY
31
+Author: J-Robot, http://opengameart.org/content/pixel-block-font
32 32
\ No newline at end of file
... ...
@@ -1,6 +1,6 @@
1
-# a2html
1
+# asciivaincra
2 2
 
3
-a2html is a KISS converter from text to ascii html powered by java and spring boot.
3
+asciivaincra is a KISS converter from unicode text to escaped ascii html/java/js/... powered by java and spring boot.
4 4
 
5 5
 ## Build, run and deploy manually
6 6
 
... ...
@@ -21,18 +21,18 @@ Please note that a thorough knowledge of Java web application development and ho
21 21
 
22 22
 Run:
23 23
 
24
-    java -jar target/a2html-*.jar
24
+    java -jar target/asciivaincra-*.jar
25 25
 
26 26
 The frontend is now accessible on [locahost:8080](http://localhost:8080).
27 27
 
28 28
 ### Deploy and hosting on a production server
29 29
 
30
-There is several options to deploy and host a2html. Here is one that requires:
30
+There is several options to deploy and host asciivaincra. Here is one that requires:
31 31
 
32 32
 - a domain name (example: mydomain.me).
33 33
 - a web server with http proxy capabilities (example [Cherokee](http://cherokee-project.com/)).
34 34
 
35 35
 #### Deployment
36 36
 
37
-1. Build and launch a2html on the server.
37
+1. Build and launch asciivaincra on the server.
38 38
 2. Configure your web server to act as reverse proxy on http://localhost:8080
... ...
@@ -7,9 +7,9 @@
7 7
         <artifactId>spring-boot-starter-parent</artifactId>
8 8
         <version>1.3.2.RELEASE</version>
9 9
     </parent>
10
-    <artifactId>a2html</artifactId>
10
+    <artifactId>asciivaincra</artifactId>
11 11
     <groupId>im.bci</groupId>
12
-    <name>a2html</name>
12
+    <name>asciivaincra</name>
13 13
     <description>convert text to ascii html</description>
14 14
     <version>1.0-SNAPSHOT</version>
15 15
     <url>http://devnewton.bci.im</url>
... ...
@@ -68,7 +68,7 @@
68 68
                 <groupId>org.springframework.boot</groupId>
69 69
                 <artifactId>spring-boot-maven-plugin</artifactId>
70 70
                 <configuration>
71
-                    <mainClass>im.bci.a2html.A2htmlApplication</mainClass>
71
+                    <mainClass>im.bci.asciivaincra.AsciiVaincraApplication</mainClass>
72 72
                 </configuration>
73 73
             </plugin>
74 74
         </plugins>
75 75
deleted file mode 100644
... ...
@@ -1,32 +0,0 @@
1
-package im.bci.a2html;
2
-
3
-import org.springframework.boot.CommandLineRunner;
4
-import org.springframework.boot.SpringApplication;
5
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6
-import org.springframework.context.annotation.Bean;
7
-import org.springframework.context.annotation.ComponentScan;
8
-import org.springframework.context.annotation.Configuration;
9
-import org.springframework.web.filter.CharacterEncodingFilter;
10
-
11
-@Configuration
12
-@EnableAutoConfiguration
13
-@ComponentScan
14
-public class A2htmlApplication implements CommandLineRunner {
15
-
16
-    @Override
17
-    public void run(String... args) throws Exception {
18
-        System.out.println("Launch passgrid.");
19
-    }
20
-
21
-    @Bean
22
-    CharacterEncodingFilter characterEncodingFilter() {
23
-        CharacterEncodingFilter filter = new CharacterEncodingFilter();
24
-        filter.setEncoding("UTF-8");
25
-        filter.setForceEncoding(true);
26
-        return filter;
27
-    }
28
-
29
-    public static void main(String[] args) throws Exception {
30
-        SpringApplication.run(A2htmlApplication.class, args);
31
-    }
32
-}
33 0
deleted file mode 100644
... ...
@@ -1,38 +0,0 @@
1
-package im.bci.a2html.controllers;
2
-
3
-import im.bci.a2html.converters.Converter;
4
-import org.jsoup.Jsoup;
5
-import org.jsoup.nodes.Document.OutputSettings;
6
-import org.jsoup.nodes.Entities.EscapeMode;
7
-import org.jsoup.safety.Whitelist;
8
-import org.springframework.ui.Model;
9
-import org.springframework.web.bind.annotation.RequestMapping;
10
-import org.springframework.web.bind.annotation.RequestMethod;
11
-import org.springframework.web.bind.annotation.RestController;
12
-
13
-import im.bci.a2html.frontend.ConvertMV;
14
-import im.bci.a2html.frontend.ConvertRQ;
15
-import org.springframework.beans.factory.annotation.Autowired;
16
-import org.unbescape.java.JavaEscape;
17
-import org.unbescape.java.JavaEscapeLevel;
18
-
19
-@RestController
20
-@RequestMapping("/ajax")
21
-public class A2htmlAjaxController {
22
-
23
-    @Autowired
24
-    private Converter[] converters;
25
-
26
-    @RequestMapping(value = "/convert", method = RequestMethod.POST)
27
-    public ConvertMV convert(ConvertRQ rq, Model model) {
28
-        ConvertMV mv = new ConvertMV();
29
-        for (Converter converter : converters) {
30
-            if (rq.getConversion() == converter.getType()) {
31
-                mv.setConvertedText(converter.convert(rq.getText()));
32
-                break;
33
-            }
34
-        }
35
-        return mv;
36
-    }
37
-
38
-}
39 0
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-package im.bci.a2html.controllers;
2
-
3
-import org.springframework.stereotype.Controller;
4
-import org.springframework.ui.Model;
5
-import org.springframework.web.bind.annotation.RequestMapping;
6
-
7
-@Controller
8
-@RequestMapping("/")
9
-public class A2htmlController {
10
-
11
-    @RequestMapping("")
12
-    public String index(Model model) {
13
-        return "index";
14
-    }
15
-}
16 0
deleted file mode 100644
... ...
@@ -1,47 +0,0 @@
1
-package im.bci.a2html.controllers;
2
-
3
-import java.util.Map;
4
-import javax.servlet.http.HttpServletRequest;
5
-import javax.servlet.http.HttpServletResponse;
6
-import org.springframework.beans.factory.annotation.Autowired;
7
-import org.springframework.boot.autoconfigure.web.ErrorAttributes;
8
-import org.springframework.boot.autoconfigure.web.ErrorController;
9
-import org.springframework.stereotype.Controller;
10
-import org.springframework.ui.Model;
11
-import org.springframework.web.bind.annotation.RequestMapping;
12
-import org.springframework.web.context.request.RequestAttributes;
13
-import org.springframework.web.context.request.ServletRequestAttributes;
14
-
15
-import im.bci.a2html.frontend.ErrorMV;
16
-
17
-/**
18
- *
19
- * @author devnewton
20
- */
21
-@Controller
22
-public class CustomErrorController implements ErrorController {
23
-    
24
-    @Autowired
25
-    private ErrorAttributes errorAttributes;
26
-
27
-    @RequestMapping(value = "/error")
28
-    public String error(Model model, HttpServletRequest request, HttpServletResponse response) {
29
-        model.addAttribute("error", buildErrorMV(request, response));
30
-        return "error";
31
-    }
32
-
33
-    public ErrorMV buildErrorMV(HttpServletRequest request, HttpServletResponse response) {
34
-        return new ErrorMV(response.getStatus(), getErrorAttributes(request, true));
35
-    }
36
-
37
-    private Map<String, Object> getErrorAttributes(HttpServletRequest request, boolean includeStackTrace) {
38
-        RequestAttributes requestAttributes = new ServletRequestAttributes(request);
39
-        return errorAttributes.getErrorAttributes(requestAttributes, includeStackTrace);
40
-    }
41
-
42
-    @Override
43
-    public String getErrorPath() {
44
-        return "error";
45
-    }
46
-
47
-}
48 0
deleted file mode 100644
... ...
@@ -1,13 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-
5
-/**
6
- *
7
- * @author devnewton
8
- */
9
-public interface Converter {
10
-    ConversionType getType();
11
-    
12
-    String convert(String text);
13
-}
14 0
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import org.springframework.stereotype.Component;
5
-import org.unbescape.css.CssEscape;
6
-import org.unbescape.css.CssStringEscapeLevel;
7
-import org.unbescape.css.CssStringEscapeType;
8
-
9
-/**
10
- *
11
- * @author devnewton
12
- */
13
-@Component
14
-public class CssConverter implements Converter {
15
-
16
-    @Override
17
-    public ConversionType getType() {
18
-        return ConversionType.TO_CSS;
19
-    }
20
-
21
-    @Override
22
-    public String convert(String text) {
23
-        return CssEscape.escapeCssString(text, CssStringEscapeType.COMPACT_HEXA, CssStringEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
24
-    }
25
-
26
-}
27 0
deleted file mode 100644
... ...
@@ -1,28 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import org.jsoup.Jsoup;
5
-import org.jsoup.nodes.Document;
6
-import org.jsoup.nodes.Entities;
7
-import org.jsoup.safety.Whitelist;
8
-import org.springframework.stereotype.Component;
9
-
10
-/**
11
- *
12
- * @author devnewton
13
- */
14
-@Component
15
-public class HtmlConverter implements Converter {
16
-
17
-    @Override
18
-    public ConversionType getType() {
19
-        return ConversionType.TO_HTML;
20
-    }
21
-
22
-    @Override
23
-    public String convert(String text) {
24
-        String cleaned = Jsoup.clean(text, "", Whitelist.basicWithImages(), new Document.OutputSettings().prettyPrint(false).escapeMode(Entities.EscapeMode.extended).charset("ASCII"));
25
-        return cleaned;
26
-    }
27
-
28
-}
29 0
deleted file mode 100644
... ...
@@ -1,25 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import org.springframework.stereotype.Component;
5
-import org.unbescape.java.JavaEscape;
6
-import org.unbescape.java.JavaEscapeLevel;
7
-
8
-/**
9
- *
10
- * @author devnewton
11
- */
12
-@Component
13
-public class JavaConverter implements Converter {
14
-
15
-    @Override
16
-    public ConversionType getType() {
17
-        return ConversionType.TO_JAVA;
18
-    }
19
-
20
-    @Override
21
-    public String convert(String text) {
22
-        return JavaEscape.escapeJava(text, JavaEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
23
-    }
24
-
25
-}
26 0
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import org.springframework.stereotype.Component;
5
-import org.unbescape.javascript.JavaScriptEscape;
6
-import org.unbescape.javascript.JavaScriptEscapeLevel;
7
-import org.unbescape.javascript.JavaScriptEscapeType;
8
-
9
-/**
10
- *
11
- * @author devnewton
12
- */
13
-@Component
14
-public class JavascriptConverter implements Converter {
15
-
16
-    @Override
17
-    public ConversionType getType() {
18
-        return ConversionType.TO_JAVASCRIPT;
19
-    }
20
-
21
-    @Override
22
-    public String convert(String text) {
23
-        return JavaScriptEscape.escapeJavaScript(text, JavaScriptEscapeType.UHEXA, JavaScriptEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
24
-    }
25
-
26
-}
27 0
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import org.springframework.stereotype.Component;
5
-import org.unbescape.json.JsonEscape;
6
-import org.unbescape.json.JsonEscapeLevel;
7
-import org.unbescape.json.JsonEscapeType;
8
-
9
-/**
10
- *
11
- * @author devnewton
12
- */
13
-@Component
14
-public class JsonConverter implements Converter {
15
-
16
-    @Override
17
-    public ConversionType getType() {
18
-        return ConversionType.TO_JSON;
19
-    }
20
-
21
-    @Override
22
-    public String convert(String text) {
23
-        return JsonEscape.escapeJson(text, JsonEscapeType.UHEXA, JsonEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
24
-    }
25
-
26
-}
27 0
deleted file mode 100644
... ...
@@ -1,25 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import org.springframework.stereotype.Component;
5
-import org.unbescape.properties.PropertiesEscape;
6
-import org.unbescape.properties.PropertiesValueEscapeLevel;
7
-
8
-/**
9
- *
10
- * @author devnewton
11
- */
12
-@Component
13
-public class PropertiesConverter implements Converter {
14
-
15
-    @Override
16
-    public ConversionType getType() {
17
-        return ConversionType.TO_PROPERTIES;
18
-    }
19
-
20
-    @Override
21
-    public String convert(String text) {
22
-        return PropertiesEscape.escapePropertiesValue(text, PropertiesValueEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
23
-    }
24
-
25
-}
26 0
deleted file mode 100644
... ...
@@ -1,24 +0,0 @@
1
-package im.bci.a2html.converters;
2
-
3
-import im.bci.a2html.frontend.ConversionType;
4
-import net.sf.junidecode.Junidecode;
5
-import org.springframework.stereotype.Component;
6
-
7
-/**
8
- *
9
- * @author devnewton
10
- */
11
-@Component
12
-public class TxtConverter implements Converter {
13
-
14
-    @Override
15
-    public ConversionType getType() {
16
-        return ConversionType.TO_TXT;
17
-    }
18
-
19
-    @Override
20
-    public String convert(String text) {
21
-        return Junidecode.unidecode(text);
22
-    }
23
-
24
-}
25 0
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-package im.bci.a2html.frontend;
2
-
3
-/**
4
- *
5
- * @author devnewton
6
- */
7
-public enum ConversionType {
8
-    TO_CSS,
9
-    TO_HTML,
10
-    TO_JAVA,
11
-    TO_JAVASCRIPT,
12
-    TO_JSON,
13
-    TO_PROPERTIES,
14
-    TO_TXT
15
-}
16 0
deleted file mode 100644
... ...
@@ -1,18 +0,0 @@
1
-package im.bci.a2html.frontend;
2
-
3
-import java.io.Serializable;
4
-
5
-public class ConvertMV implements Serializable{
6
-
7
-    private static final long serialVersionUID = 1L;
8
-
9
-    private String convertedText;
10
-
11
-    public String getConvertedText() {
12
-        return convertedText;
13
-    }
14
-
15
-    public void setConvertedText(String convertedText) {
16
-        this.convertedText = convertedText;
17
-    }
18
-}
19 0
deleted file mode 100644
... ...
@@ -1,27 +0,0 @@
1
-package im.bci.a2html.frontend;
2
-
3
-import java.io.Serializable;
4
-
5
-public class ConvertRQ implements Serializable {
6
-
7
-    private static final long serialVersionUID = 1L;
8
-    private String text;
9
-    private ConversionType conversion = ConversionType.TO_HTML;
10
-
11
-    public String getText() {
12
-        return text;
13
-    }
14
-
15
-    public void setText(String text) {
16
-        this.text = text;
17
-    }
18
-
19
-    public ConversionType getConversion() {
20
-        return conversion;
21
-    }
22
-
23
-    public void setConversion(ConversionType conversion) {
24
-        this.conversion = conversion;
25
-    }
26
-
27
-}
28 0
deleted file mode 100644
... ...
@@ -1,68 +0,0 @@
1
-package im.bci.a2html.frontend;
2
-
3
-import java.util.Map;
4
-
5
-/**
6
- *
7
- * @author devnewton
8
- */
9
-public class ErrorMV {
10
-
11
-    public Integer status;
12
-    public String error;
13
-    public String message;
14
-    public String timeStamp;
15
-    public String trace;
16
-
17
-    public ErrorMV(int status, Map<String, Object> errorAttributes) {
18
-        this.status = status;
19
-        this.error = (String) errorAttributes.get("error");
20
-        this.message = (String) errorAttributes.get("message");
21
-        this.timeStamp = errorAttributes.get("timestamp").toString();
22
-        this.trace = (String) errorAttributes.get("trace");
23
-    }
24
-
25
-    public ErrorMV() {
26
-    }
27
-
28
-    public Integer getStatus() {
29
-        return status;
30
-    }
31
-
32
-    public void setStatus(Integer status) {
33
-        this.status = status;
34
-    }
35
-
36
-    public String getError() {
37
-        return error;
38
-    }
39
-
40
-    public void setError(String error) {
41
-        this.error = error;
42
-    }
43
-
44
-    public String getMessage() {
45
-        return message;
46
-    }
47
-
48
-    public void setMessage(String message) {
49
-        this.message = message;
50
-    }
51
-
52
-    public String getTimeStamp() {
53
-        return timeStamp;
54
-    }
55
-
56
-    public void setTimeStamp(String timeStamp) {
57
-        this.timeStamp = timeStamp;
58
-    }
59
-
60
-    public String getTrace() {
61
-        return trace;
62
-    }
63
-
64
-    public void setTrace(String trace) {
65
-        this.trace = trace;
66
-    }
67
-
68
-}
69 0
new file mode 100644
... ...
@@ -0,0 +1,32 @@
1
+package im.bci.asciivaincra;
2
+
3
+import org.springframework.boot.CommandLineRunner;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6
+import org.springframework.context.annotation.Bean;
7
+import org.springframework.context.annotation.ComponentScan;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.web.filter.CharacterEncodingFilter;
10
+
11
+@Configuration
12
+@EnableAutoConfiguration
13
+@ComponentScan
14
+public class AsciiVaincraApplication implements CommandLineRunner {
15
+
16
+    @Override
17
+    public void run(String... args) throws Exception {
18
+        System.out.println("Launch passgrid.");
19
+    }
20
+
21
+    @Bean
22
+    CharacterEncodingFilter characterEncodingFilter() {
23
+        CharacterEncodingFilter filter = new CharacterEncodingFilter();
24
+        filter.setEncoding("UTF-8");
25
+        filter.setForceEncoding(true);
26
+        return filter;
27
+    }
28
+
29
+    public static void main(String[] args) throws Exception {
30
+        SpringApplication.run(AsciiVaincraApplication.class, args);
31
+    }
32
+}
0 33
new file mode 100644
... ...
@@ -0,0 +1,38 @@
1
+package im.bci.asciivaincra.controllers;
2
+
3
+import im.bci.asciivaincra.converters.Converter;
4
+import org.jsoup.Jsoup;
5
+import org.jsoup.nodes.Document.OutputSettings;
6
+import org.jsoup.nodes.Entities.EscapeMode;
7
+import org.jsoup.safety.Whitelist;
8
+import org.springframework.ui.Model;
9
+import org.springframework.web.bind.annotation.RequestMapping;
10
+import org.springframework.web.bind.annotation.RequestMethod;
11
+import org.springframework.web.bind.annotation.RestController;
12
+
13
+import im.bci.asciivaincra.frontend.ConvertMV;
14
+import im.bci.asciivaincra.frontend.ConvertRQ;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.unbescape.java.JavaEscape;
17
+import org.unbescape.java.JavaEscapeLevel;
18
+
19
+@RestController
20
+@RequestMapping("/ajax")
21
+public class AjaxController {
22
+
23
+    @Autowired
24
+    private Converter[] converters;
25
+
26
+    @RequestMapping(value = "/convert", method = RequestMethod.POST)
27
+    public ConvertMV convert(ConvertRQ rq, Model model) {
28
+        ConvertMV mv = new ConvertMV();
29
+        for (Converter converter : converters) {
30
+            if (rq.getConversion() == converter.getType()) {
31
+                mv.setConvertedText(converter.convert(rq.getText()));
32
+                break;
33
+            }
34
+        }
35
+        return mv;
36
+    }
37
+
38
+}
0 39
new file mode 100644
... ...
@@ -0,0 +1,47 @@
1
+package im.bci.asciivaincra.controllers;
2
+
3
+import java.util.Map;
4
+import javax.servlet.http.HttpServletRequest;
5
+import javax.servlet.http.HttpServletResponse;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.boot.autoconfigure.web.ErrorAttributes;
8
+import org.springframework.boot.autoconfigure.web.ErrorController;
9
+import org.springframework.stereotype.Controller;
10
+import org.springframework.ui.Model;
11
+import org.springframework.web.bind.annotation.RequestMapping;
12
+import org.springframework.web.context.request.RequestAttributes;
13
+import org.springframework.web.context.request.ServletRequestAttributes;
14
+
15
+import im.bci.asciivaincra.frontend.ErrorMV;
16
+
17
+/**
18
+ *
19
+ * @author devnewton
20
+ */
21
+@Controller
22
+public class CustomErrorController implements ErrorController {
23
+    
24
+    @Autowired
25
+    private ErrorAttributes errorAttributes;
26
+
27
+    @RequestMapping(value = "/error")
28
+    public String error(Model model, HttpServletRequest request, HttpServletResponse response) {
29
+        model.addAttribute("error", buildErrorMV(request, response));
30
+        return "error";
31
+    }
32
+
33
+    public ErrorMV buildErrorMV(HttpServletRequest request, HttpServletResponse response) {
34
+        return new ErrorMV(response.getStatus(), getErrorAttributes(request, true));
35
+    }
36
+
37
+    private Map<String, Object> getErrorAttributes(HttpServletRequest request, boolean includeStackTrace) {
38
+        RequestAttributes requestAttributes = new ServletRequestAttributes(request);
39
+        return errorAttributes.getErrorAttributes(requestAttributes, includeStackTrace);
40
+    }
41
+
42
+    @Override
43
+    public String getErrorPath() {
44
+        return "error";
45
+    }
46
+
47
+}
0 48
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+package im.bci.asciivaincra.controllers;
2
+
3
+import org.springframework.stereotype.Controller;
4
+import org.springframework.ui.Model;
5
+import org.springframework.web.bind.annotation.RequestMapping;
6
+
7
+@Controller
8
+@RequestMapping("/")
9
+public class IndexController {
10
+
11
+    @RequestMapping("")
12
+    public String index(Model model) {
13
+        return "index";
14
+    }
15
+}
0 16
new file mode 100644
... ...
@@ -0,0 +1,13 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+
5
+/**
6
+ *
7
+ * @author devnewton
8
+ */
9
+public interface Converter {
10
+    ConversionType getType();
11
+    
12
+    String convert(String text);
13
+}
0 14
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import org.springframework.stereotype.Component;
5
+import org.unbescape.css.CssEscape;
6
+import org.unbescape.css.CssStringEscapeLevel;
7
+import org.unbescape.css.CssStringEscapeType;
8
+
9
+/**
10
+ *
11
+ * @author devnewton
12
+ */
13
+@Component
14
+public class CssConverter implements Converter {
15
+
16
+    @Override
17
+    public ConversionType getType() {
18
+        return ConversionType.TO_CSS;
19
+    }
20
+
21
+    @Override
22
+    public String convert(String text) {
23
+        return CssEscape.escapeCssString(text, CssStringEscapeType.COMPACT_HEXA, CssStringEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
24
+    }
25
+
26
+}
0 27
new file mode 100644
... ...
@@ -0,0 +1,28 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import org.jsoup.Jsoup;
5
+import org.jsoup.nodes.Document;
6
+import org.jsoup.nodes.Entities;
7
+import org.jsoup.safety.Whitelist;
8
+import org.springframework.stereotype.Component;
9
+
10
+/**
11
+ *
12
+ * @author devnewton
13
+ */
14
+@Component
15
+public class HtmlConverter implements Converter {
16
+
17
+    @Override
18
+    public ConversionType getType() {
19
+        return ConversionType.TO_HTML;
20
+    }
21
+
22
+    @Override
23
+    public String convert(String text) {
24
+        String cleaned = Jsoup.clean(text, "", Whitelist.basicWithImages(), new Document.OutputSettings().prettyPrint(false).escapeMode(Entities.EscapeMode.extended).charset("ASCII"));
25
+        return cleaned;
26
+    }
27
+
28
+}
0 29
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import org.springframework.stereotype.Component;
5
+import org.unbescape.java.JavaEscape;
6
+import org.unbescape.java.JavaEscapeLevel;
7
+
8
+/**
9
+ *
10
+ * @author devnewton
11
+ */
12
+@Component
13
+public class JavaConverter implements Converter {
14
+
15
+    @Override
16
+    public ConversionType getType() {
17
+        return ConversionType.TO_JAVA;
18
+    }
19
+
20
+    @Override
21
+    public String convert(String text) {
22
+        return JavaEscape.escapeJava(text, JavaEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
23
+    }
24
+
25
+}
0 26
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import org.springframework.stereotype.Component;
5
+import org.unbescape.javascript.JavaScriptEscape;
6
+import org.unbescape.javascript.JavaScriptEscapeLevel;
7
+import org.unbescape.javascript.JavaScriptEscapeType;
8
+
9
+/**
10
+ *
11
+ * @author devnewton
12
+ */
13
+@Component
14
+public class JavascriptConverter implements Converter {
15
+
16
+    @Override
17
+    public ConversionType getType() {
18
+        return ConversionType.TO_JAVASCRIPT;
19
+    }
20
+
21
+    @Override
22
+    public String convert(String text) {
23
+        return JavaScriptEscape.escapeJavaScript(text, JavaScriptEscapeType.UHEXA, JavaScriptEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
24
+    }
25
+
26
+}
0 27
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import org.springframework.stereotype.Component;
5
+import org.unbescape.json.JsonEscape;
6
+import org.unbescape.json.JsonEscapeLevel;
7
+import org.unbescape.json.JsonEscapeType;
8
+
9
+/**
10
+ *
11
+ * @author devnewton
12
+ */
13
+@Component
14
+public class JsonConverter implements Converter {
15
+
16
+    @Override
17
+    public ConversionType getType() {
18
+        return ConversionType.TO_JSON;
19
+    }
20
+
21
+    @Override
22
+    public String convert(String text) {
23
+        return JsonEscape.escapeJson(text, JsonEscapeType.UHEXA, JsonEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
24
+    }
25
+
26
+}
0 27
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import org.springframework.stereotype.Component;
5
+import org.unbescape.properties.PropertiesEscape;
6
+import org.unbescape.properties.PropertiesValueEscapeLevel;
7
+
8
+/**
9
+ *
10
+ * @author devnewton
11
+ */
12
+@Component
13
+public class PropertiesConverter implements Converter {
14
+
15
+    @Override
16
+    public ConversionType getType() {
17
+        return ConversionType.TO_PROPERTIES;
18
+    }
19
+
20
+    @Override
21
+    public String convert(String text) {
22
+        return PropertiesEscape.escapePropertiesValue(text, PropertiesValueEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
23
+    }
24
+
25
+}
0 26
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+package im.bci.asciivaincra.converters;
2
+
3
+import im.bci.asciivaincra.frontend.ConversionType;
4
+import net.sf.junidecode.Junidecode;
5
+import org.springframework.stereotype.Component;
6
+
7
+/**
8
+ *
9
+ * @author devnewton
10
+ */
11
+@Component
12
+public class TxtConverter implements Converter {
13
+
14
+    @Override
15
+    public ConversionType getType() {
16
+        return ConversionType.TO_TXT;
17
+    }
18
+
19
+    @Override
20
+    public String convert(String text) {
21
+        return Junidecode.unidecode(text);
22
+    }
23
+
24
+}
0 25
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+package im.bci.asciivaincra.frontend;
2
+
3
+/**
4
+ *
5
+ * @author devnewton
6
+ */
7
+public enum ConversionType {
8
+    TO_CSS,
9
+    TO_HTML,
10
+    TO_JAVA,
11
+    TO_JAVASCRIPT,
12
+    TO_JSON,
13
+    TO_PROPERTIES,
14
+    TO_TXT
15
+}
0 16
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+package im.bci.asciivaincra.frontend;
2
+
3
+import java.io.Serializable;
4
+
5
+public class ConvertMV implements Serializable{
6
+
7
+    private static final long serialVersionUID = 1L;
8
+
9
+    private String convertedText;
10
+
11
+    public String getConvertedText() {
12
+        return convertedText;
13
+    }
14
+
15
+    public void setConvertedText(String convertedText) {
16
+        this.convertedText = convertedText;
17
+    }
18
+}
0 19
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+package im.bci.asciivaincra.frontend;
2
+
3
+import java.io.Serializable;
4
+
5
+public class ConvertRQ implements Serializable {
6
+
7
+    private static final long serialVersionUID = 1L;
8
+    private String text;
9
+    private ConversionType conversion = ConversionType.TO_HTML;
10
+
11
+    public String getText() {
12
+        return text;
13
+    }
14
+
15
+    public void setText(String text) {
16
+        this.text = text;
17
+    }
18
+
19
+    public ConversionType getConversion() {
20
+        return conversion;
21
+    }
22
+
23
+    public void setConversion(ConversionType conversion) {
24
+        this.conversion = conversion;
25
+    }
26
+
27
+}
0 28
new file mode 100644
... ...
@@ -0,0 +1,68 @@
1
+package im.bci.asciivaincra.frontend;
2
+
3
+import java.util.Map;
4
+
5
+/**
6
+ *
7
+ * @author devnewton
8
+ */
9
+public class ErrorMV {
10
+
11
+    public Integer status;
12
+    public String error;
13
+    public String message;
14
+    public String timeStamp;
15
+    public String trace;
16
+
17
+    public ErrorMV(int status, Map<String, Object> errorAttributes) {
18
+        this.status = status;
19
+        this.error = (String) errorAttributes.get("error");
20
+        this.message = (String) errorAttributes.get("message");
21
+        this.timeStamp = errorAttributes.get("timestamp").toString();
22
+        this.trace = (String) errorAttributes.get("trace");
23
+    }
24
+
25
+    public ErrorMV() {
26
+    }
27
+
28
+    public Integer getStatus() {
29
+        return status;
30
+    }
31
+
32
+    public void setStatus(Integer status) {
33
+        this.status = status;
34
+    }
35
+
36
+    public String getError() {
37
+        return error;
38
+    }
39
+
40
+    public void setError(String error) {
41
+        this.error = error;
42
+    }
43
+
44
+    public String getMessage() {
45
+        return message;
46
+    }
47
+
48
+    public void setMessage(String message) {
49
+        this.message = message;
50
+    }
51
+
52
+    public String getTimeStamp() {
53
+        return timeStamp;
54
+    }
55
+
56
+    public void setTimeStamp(String timeStamp) {
57
+        this.timeStamp = timeStamp;
58
+    }
59
+
60
+    public String getTrace() {
61
+        return trace;
62
+    }
63
+
64
+    public void setTrace(String trace) {
65
+        this.trace = trace;
66
+    }
67
+
68
+}
0 69
deleted file mode 100644
... ...
@@ -1,9 +0,0 @@
1
-$("#convert").click(function () {
2
-    $.ajax({
3
-        url: "/ajax/convert",
4
-        method: "POST",
5
-        data: {text: $("#input").val(), conversion: $('#conversion').val()}
6
-    }).done(function (data) {
7
-        $("#output").val(data.convertedText);
8
-    })
9
-})
10 0
\ No newline at end of file
11 1
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+$("#convert").click(function () {
2
+    $.ajax({
3
+        url: "/ajax/convert",
4
+        method: "POST",
5
+        data: {text: $("#input").val(), conversion: $('#conversion').val()}
6
+    }).done(function (data) {
7
+        $("#output").val(data.convertedText);
8
+    })
9
+})
0 10
\ No newline at end of file
1 11
Binary files a/src/main/resources/static/favicon.png and b/src/main/resources/static/favicon.png differ
2 12
deleted file mode 100644
... ...
@@ -1,39 +0,0 @@
1
-.passgrid {
2
-    font-family: monospace;
3
-    width: 8cm;
4
-    height: 6cm;
5
-    border-collapse: collapse;
6
-    border: 1px solid black;
7
-    float: left;
8
-    page-break-inside : avoid;
9
-    margin: 2mm;
10
-}
11
-.passgrid th {
12
-    background-color: #CCCCFF;
13
-    font-size: 0.8em;
14
-}
15
-
16
-.passgrid td {
17
-    text-align: center;
18
-    vertical-align: middle;
19
-    border-bottom: dotted 1px black;
20
-}
21
-
22
-.passgrid tbody tr:nth-child(odd) td:nth-child(odd) {
23
-    background-color: #CCCCCC;
24
-}
25
-.passgrid tbody tr:nth-child(even) td:nth-child(even) {
26
-    background-color: #CCCCCC;
27
-}
28
-
29
-nav ul {
30
-    list-style-type: none;;
31
-    display: flex;
32
-    padding: 0;
33
-    margin: 8px;
34
-}
35
-
36
-header {
37
-    display: flex;
38
-    align-items: center;
39
-}
40 0
\ No newline at end of file
... ...
@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
     <head>
4
-        <title>a2html</title>
4
+        <title>Ascii vaincra!</title>
5 5
         <meta charset="UTF-8">
6 6
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 7
         <meta name="robots" content="noindex,nofollow">
... ...
@@ -34,6 +34,6 @@
34 34
             <textarea id="output" rows="20" cols="80"></textarea>
35 35
         </fieldset>
36 36
         <script src="/webjars/jquery/3.0.0-alpha1/jquery.js" defer></script>
37
-        <script src="/a2html.js" defer></script>
37
+        <script src="/asciivaincra.js" defer></script>
38 38
     </body>
39 39
 </html>
40 40
\ No newline at end of file