[29917] | 1 | <%@ page contentType="text/html; charset=UTF-8" %>
|
---|
| 2 | <!DOCTYPE html>
|
---|
| 3 | <html id="story">
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
---|
| 6 | <meta name="viewport" content="width=device-width, initial-scale=1"/>
|
---|
| 7 | <title>NZ Flag Design @ The University of Waikato</title>
|
---|
| 8 |
|
---|
| 9 | <script src="css/source-sans-pro.js"></script>
|
---|
| 10 | <link href="css/styles.css" rel="stylesheet"/>
|
---|
| 11 | <link href="css/storystyle.css" rel="stylesheet"/>
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | <link rel="stylesheet" href="lib-slider/css/jquery.mobile-1.3.0.css"/>
|
---|
| 15 | <link rel="stylesheet" href="lib-slider/css/jqm-demos.css"/>
|
---|
| 16 | <link rel="stylesheet" href="lib-slider/css/swipe-page.css"/>
|
---|
| 17 | <link rel="shortcut icon" href="lib-slider/favicon.ico"/>
|
---|
| 18 |
|
---|
| 19 | <script src="lib/jquery-1.8.2.min.js"></script>
|
---|
| 20 |
|
---|
| 21 | <script src="lib-slider/js/jquery.mobile.demos.js"></script>
|
---|
| 22 | <script src="lib-slider/js/jquery.mobile-1.3.0.js"></script>
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 |
|
---|
[29919] | 26 | <%@ page import="java.io.*,java.util.*,java.awt.image.*,javax.imageio.*,javax.xml.bind.DatatypeConverter,java.nio.file.*,org.json.*" %>
|
---|
[29917] | 27 |
|
---|
| 28 | <%!
|
---|
[29919] | 29 |
|
---|
| 30 |
|
---|
| 31 | private static void copyFile(File source, File dest)
|
---|
| 32 | throws IOException {
|
---|
| 33 | InputStream input = null;
|
---|
| 34 | OutputStream output = null;
|
---|
| 35 | try {
|
---|
| 36 | input = new FileInputStream(source);
|
---|
| 37 | output = new FileOutputStream(dest);
|
---|
| 38 | byte[] buf = new byte[1024];
|
---|
| 39 | int bytesRead;
|
---|
| 40 | while ((bytesRead = input.read(buf)) > 0) {
|
---|
| 41 | output.write(buf, 0, bytesRead);
|
---|
| 42 | }
|
---|
| 43 | } finally {
|
---|
| 44 | input.close();
|
---|
| 45 | output.close();
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | /*
|
---|
| 49 | private static void copyFileChannels(File source, File dest)
|
---|
| 50 | throws IOException {
|
---|
| 51 | FileChannel inputChannel = null;
|
---|
| 52 | FileChannel outputChannel = null;
|
---|
| 53 | try {
|
---|
| 54 | inputChannel = new FileInputStream(source).getChannel();
|
---|
| 55 | outputChannel = new FileOutputStream(dest).getChannel();
|
---|
| 56 | outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
|
---|
| 57 | } finally {
|
---|
| 58 | inputChannel.close();
|
---|
| 59 | outputChannel.close();
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | */
|
---|
| 64 | /*
|
---|
| 65 | public static void copyFile_JAVA17( File from, File to ) throws IOException {
|
---|
[29917] | 66 | Files.copy( from.toPath(), to.toPath() );
|
---|
| 67 | }
|
---|
[29919] | 68 | */
|
---|
[29917] | 69 |
|
---|
| 70 | public static void publishFile(File myFlagFile, File pubFlagFile)
|
---|
| 71 | {
|
---|
| 72 | try {
|
---|
| 73 | copyFile(myFlagFile,pubFlagFile);
|
---|
| 74 | }
|
---|
| 75 | catch (Exception e) {
|
---|
| 76 | e.printStackTrace();
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | public String publishFlag(HttpServletRequest request)
|
---|
| 81 | {
|
---|
| 82 | String doc_base = getServletContext().getRealPath("/");
|
---|
| 83 | File render_dir = new File(doc_base,"render-3d");
|
---|
| 84 | File render_images_dir = new File(render_dir,"images");
|
---|
| 85 |
|
---|
| 86 | String png_filename = null;
|
---|
| 87 | String svg_filename = null;
|
---|
| 88 |
|
---|
| 89 | String myid = request.getParameter("myid");
|
---|
| 90 | if (myid == null) {
|
---|
| 91 | png_filename = "flag.png";
|
---|
| 92 | svg_filename = "flag.svg";
|
---|
| 93 | }
|
---|
| 94 | else {
|
---|
| 95 | png_filename = "flag-" + myid + ".png";
|
---|
| 96 | svg_filename = "flag-" + myid + ".svg";
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | File full_my_png_file = new File(render_images_dir,png_filename);
|
---|
| 100 | File full_my_svg_file = new File(render_images_dir,svg_filename);
|
---|
| 101 |
|
---|
| 102 | File pub_dir = new File(doc_base,"published");
|
---|
| 103 | String pub_name = request.getParameter("pub-name");
|
---|
| 104 | if (pub_name == null) {
|
---|
| 105 | pub_name = "tmp";
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | File my_pub_dir = new File(pub_dir,pub_name);
|
---|
| 109 | if (!my_pub_dir.exists()) {
|
---|
| 110 | my_pub_dir.mkdir();
|
---|
| 111 | }
|
---|
| 112 | File full_pub_my_png_file = new File(my_pub_dir,"myflag.png");
|
---|
| 113 | File full_pub_my_svg_file = new File(my_pub_dir,"myflag.svg");
|
---|
| 114 |
|
---|
| 115 | publishFile(full_my_png_file,full_pub_my_png_file);
|
---|
| 116 | publishFile(full_my_svg_file,full_pub_my_svg_file);
|
---|
| 117 |
|
---|
| 118 | return pub_name;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | void savePubInfo(HttpServletRequest request, String pub_name)
|
---|
| 123 | {
|
---|
| 124 | String doc_base = getServletContext().getRealPath("/");
|
---|
| 125 | File pub_dir = new File(doc_base,"published");
|
---|
| 126 | File my_pub_dir = new File(pub_dir,pub_name);
|
---|
| 127 |
|
---|
| 128 | File full_pub_json_file = new File(my_pub_dir,"pubinfo.json");
|
---|
| 129 |
|
---|
| 130 | try {
|
---|
| 131 | String name = request.getParameter("name");
|
---|
| 132 | String email = request.getParameter("email");
|
---|
| 133 | String desc = request.getParameter("desc");
|
---|
| 134 |
|
---|
| 135 | BufferedWriter bw = new BufferedWriter(new FileWriter(full_pub_json_file));
|
---|
| 136 | bw.write("{ \"name\": \"" + name + "\", \"email\": \"" + email + "\", \"desc\": \"" + desc + "\"}");
|
---|
| 137 | bw.close();
|
---|
| 138 | }
|
---|
| 139 | catch (Exception e) {
|
---|
| 140 | e.printStackTrace();
|
---|
| 141 | }
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | %>
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | <%
|
---|
| 148 |
|
---|
| 149 | String action = request.getParameter("action");
|
---|
| 150 |
|
---|
| 151 | String my_flag_png = "myflag.png";
|
---|
| 152 | String my_flag_svg = "myflag.svg";
|
---|
| 153 |
|
---|
| 154 | String pub_name = null;
|
---|
| 155 |
|
---|
| 156 | String name = null;
|
---|
| 157 | String email = null;
|
---|
| 158 | String desc = null;
|
---|
| 159 |
|
---|
| 160 |
|
---|
| 161 | if ((action != null) && action.equals("publish")) {
|
---|
| 162 | pub_name = publishFlag(request);
|
---|
| 163 | savePubInfo(request,pub_name);
|
---|
| 164 | name = request.getParameter("name");
|
---|
| 165 | email = request.getParameter("email");
|
---|
| 166 | desc = request.getParameter("desc");
|
---|
| 167 | }
|
---|
| 168 | else {
|
---|
| 169 | // read in JSON file and get details
|
---|
| 170 | // set them up as Java variables for producing the page through Javascript
|
---|
| 171 |
|
---|
| 172 | pub_name = request.getParameter("pub-name");
|
---|
| 173 | if (pub_name == null) {
|
---|
| 174 | pub_name = "tmp";
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | String doc_base = getServletContext().getRealPath("/");
|
---|
| 178 | File pub_dir = new File(doc_base,"published");
|
---|
| 179 | File my_pub_dir = new File(pub_dir,pub_name);
|
---|
| 180 | File full_pub_json_file = new File(my_pub_dir,"pubinfo.json");
|
---|
| 181 |
|
---|
| 182 | String everything = null;
|
---|
| 183 | BufferedReader br = new BufferedReader(new FileReader(full_pub_json_file));
|
---|
| 184 | try {
|
---|
| 185 |
|
---|
| 186 | StringBuilder sb = new StringBuilder();
|
---|
| 187 | String line = br.readLine();
|
---|
| 188 |
|
---|
[29918] | 189 | String line_sep = System.getProperty("line.separator");
|
---|
[29917] | 190 | while (line != null) {
|
---|
| 191 | sb.append(line);
|
---|
[29918] | 192 | sb.append(line_sep);
|
---|
[29917] | 193 | line = br.readLine();
|
---|
| 194 | }
|
---|
| 195 | everything = sb.toString();
|
---|
| 196 | }
|
---|
| 197 | catch (Exception e) {
|
---|
| 198 | e.printStackTrace();
|
---|
| 199 | }
|
---|
| 200 | finally {
|
---|
| 201 | br.close();
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | JSONObject obj = new JSONObject(everything);
|
---|
| 205 | name = obj.getString("name");
|
---|
| 206 | email = obj.getString("email");
|
---|
| 207 | desc = obj.getString("desc");
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 | %>
|
---|
| 212 |
|
---|
| 213 | <style>
|
---|
| 214 | .vertical-align {
|
---|
| 215 | position: relative;
|
---|
| 216 | top: 50%;
|
---|
| 217 | -webkit-transform: translateY(-50%);
|
---|
| 218 | -ms-transform: translateY(-50%);
|
---|
| 219 | transform: translateY(-50%);
|
---|
| 220 | }
|
---|
| 221 | </style>
|
---|
| 222 |
|
---|
| 223 | </head>
|
---|
| 224 |
|
---|
| 225 | <body>
|
---|
| 226 | <div data-role="page" id="innovation-story-01" class="demo-page">
|
---|
| 227 |
|
---|
| 228 | <div data-role="content">
|
---|
| 229 |
|
---|
| 230 | <a target="_parent" href="../index.html" class="back-button back-left"></a>
|
---|
| 231 |
|
---|
| 232 | <div class="story-page" id="static-info-page">
|
---|
| 233 | <!-- put custom content here -->
|
---|
| 234 |
|
---|
| 235 | <div class="story-title" style="margin-left: 25px;">
|
---|
| 236 |
|
---|
| 237 | <h1 class="center">My Design @ The University of Waikato</h1>
|
---|
| 238 |
|
---|
| 239 | <p class="center" style="margin: 6px;">-- The New Zealand Flag Debate</p>
|
---|
| 240 |
|
---|
| 241 | <div class="center" style="height: 220px; position: relative;">
|
---|
| 242 | <div style="display: inline-block; position: relative;">
|
---|
| 243 | <img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Flag_of_New_Zealand.svg/250px-Flag_of_New_Zealand.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Flag_of_New_Zealand.svg/375px-Flag_of_New_Zealand.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Flag_of_New_Zealand.svg/500px-Flag_of_New_Zealand.svg.png 2x" data-file-width="1200" data-file-height="600" height="200" widthXX="350" />
|
---|
| 244 | </div>
|
---|
| 245 | <div style="height: 200px; font-size: 300%; display: inline-block;" class="vertical-alignXX">VS</div>
|
---|
| 246 | <div style="display: inline-block; position: relative">
|
---|
| 247 | <a id="myflag-svg" data-ajax="false" ><img id="myflag-png" height="200" style="border: none;"/></a>
|
---|
| 248 | </div>
|
---|
| 249 | </div>
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 |
|
---|
| 253 | <script type="text/javascript">
|
---|
| 254 |
|
---|
| 255 | var published_id = "<%= request.getParameter("pub-name") %>";
|
---|
| 256 | var name = "<%= name %>";
|
---|
| 257 | var email = "<%= email %>";
|
---|
| 258 | var desc = "<%= desc %>";
|
---|
| 259 |
|
---|
| 260 | document.write("<center>");
|
---|
| 261 | document.write(" <div style=\"width: 500px; background: #181818; padding: 5px; margin: 10px;\">");
|
---|
| 262 | document.write(" <p>Designer: " + name + "<p/>");
|
---|
| 263 | document.write(" <p>Email: " + email + "<p/>");
|
---|
| 264 | document.write(" <p>Description: " + desc + "<p/>");
|
---|
| 265 | document.write(" </div>");
|
---|
| 266 | document.write("</center>");
|
---|
| 267 |
|
---|
| 268 |
|
---|
| 269 | var a2a_config = a2a_config || {};
|
---|
| 270 | a2a_config.linkname = "NZ Flag Design @ University of Waikato";
|
---|
| 271 |
|
---|
| 272 | var base_url = location.protocol + '//' + location.host + location.pathname;
|
---|
| 273 |
|
---|
| 274 | a2a_config.linkurl = base_url + "?pub-name=" + published_id
|
---|
| 275 |
|
---|
| 276 | </script>
|
---|
| 277 |
|
---|
| 278 | <!-- AddToAny BEGIN -->
|
---|
| 279 | <center>
|
---|
| 280 | <div class="a2a_kit a2a_kit_size_32 a2a_default_style" style="width: 260px;">
|
---|
| 281 | <a class="a2a_dd" href="https://www.addtoany.com/share_save"></a>
|
---|
| 282 | <a class="a2a_button_email"></a>
|
---|
| 283 | <a class="a2a_button_facebook"></a>
|
---|
| 284 | <a class="a2a_button_google_plus"></a>
|
---|
| 285 | <a class="a2a_button_google_gmail"></a>
|
---|
| 286 | <a class="a2a_button_twitter"></a>
|
---|
| 287 | <a class="a2a_button_tumblr"></a>
|
---|
| 288 | </div>
|
---|
| 289 | </center>
|
---|
| 290 |
|
---|
| 291 | <script type="text/javascript" src="//static.addtoany.com/menu/page.js"></script>
|
---|
| 292 | <!-- AddToAny END -->
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | <center>
|
---|
| 296 | <p style="font-size: 200%;">
|
---|
| 297 | <i>
|
---|
| 298 | <a href="../index.html">Interactive Flag Design Website</a> by:
|
---|
| 299 | <a target="_blank" href="http://cosi.cms.waikato.ac.nz">The Centre for Open Source Innovation</a>
|
---|
| 300 | <a target="_blank" href="http://cosi.cms.waikato.ac.nz">(COSI)</a> at the <a href="http://www.waikato.ac.nz">University of Waikato</a>
|
---|
| 301 | </i>
|
---|
| 302 | </p>
|
---|
| 303 | </center>
|
---|
| 304 |
|
---|
| 305 |
|
---|
| 306 | </div>
|
---|
| 307 | <!-- end of putting custom content -->
|
---|
| 308 |
|
---|
| 309 | </div> <!-- end story-page-->
|
---|
| 310 |
|
---|
| 311 | </div><!-- /content -->
|
---|
| 312 |
|
---|
| 313 | </div><!-- /page -->
|
---|
| 314 |
|
---|
| 315 | <script>
|
---|
| 316 | $(document).ready( function() {
|
---|
| 317 |
|
---|
| 318 | var my_flag_png = "<%= "../published/" + pub_name + "/" + my_flag_png %>";
|
---|
| 319 | var my_flag_svg = "<%= "../published/" + pub_name + "/" + my_flag_svg %>";
|
---|
| 320 |
|
---|
| 321 | $('#myflag-png').attr("src", my_flag_png);
|
---|
| 322 | $('#myflag-svg').attr("href", my_flag_svg);
|
---|
| 323 |
|
---|
| 324 | });
|
---|
| 325 |
|
---|
| 326 | </script>
|
---|
| 327 |
|
---|
| 328 | </body>
|
---|
| 329 | </html>
|
---|
| 330 |
|
---|
| 331 |
|
---|
| 332 |
|
---|
| 333 |
|
---|
| 334 |
|
---|
| 335 |
|
---|