Browse code

add bsv (bald separated values) backend

devnewton authored on 16/02/2018 12:52:53
Showing 3 changed files
... ...
@@ -104,6 +104,19 @@ public class LegacyController {
104 104
 			return null;
105 105
 		}
106 106
 	}
107
+        
108
+        @RequestMapping(path = "/bsv", method = RequestMethod.GET)
109
+	public String bsv(@RequestParam(value = "room", required = false) String room,
110
+			@RequestParam(value = "last", required = false) Long lastId, WebRequest webRequest, Model model,
111
+			HttpServletResponse response) {
112
+		if (get(lastId, room, webRequest, model, LegacyUtils.bsvEscaper)) {
113
+			response.setContentType("text/plain");
114
+			response.setHeader("Content-Disposition", "attachment; filename=\"backend.bsv\"");
115
+			return "bouchot/legacy/bsv";
116
+		} else {
117
+			return null;
118
+		}
119
+	}
107 120
 
108 121
 	private boolean get(Long lastId, String room, WebRequest webRequest, Model model, LegacyUtils.Escaper escaper) {
109 122
 		DateTime end = DateTime.now(DateTimeZone.UTC).plusHours(1);
... ...
@@ -74,6 +74,15 @@ public class LegacyUtils {
74 74
 
75 75
         }
76 76
     };
77
+        static final Escaper bsvEscaper = new Escaper() {
78
+
79
+        @Override
80
+        public String escape(String s) {
81
+            return s.replaceAll("[\u001E\u001F]", "");
82
+
83
+        }
84
+    };
85
+
77 86
 
78 87
     private static final Pattern urlPattern = Pattern.compile("(((https?|ftp|gopher)://)|(data:))[^\\s]+");
79 88
 
80 89
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+{{#each board.posts}}{{this.id}}{{this.time}}{{this.info}}{{{this.message}}}{{/each}}
0 2
\ No newline at end of file