[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"/>
|
---|
[29934] | 7 | <title>NZ Flag Design @ The University of Waikato (<%=request.getParameter("pub-name")%>)</title>
|
---|
[29917] | 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"/>
|
---|
[29934] | 17 | <link rel="shortcut icon" href="lib-slider/nzflag-icon64-padded.png"/>
|
---|
[29917] | 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");
|
---|
[29930] | 133 | String desc = request.getParameter("desc").replace("\n"," ").replace("\r"," ");
|
---|
[29917] | 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");
|
---|
[29930] | 166 | desc = request.getParameter("desc").replace("\n"," ").replace("\r"," ").replace(" "," ");
|
---|
[29917] | 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>
|
---|
[29934] | 226 | <div id="fb-root"></div>
|
---|
| 227 | <script>(function(d, s, id) {
|
---|
| 228 | var js, fjs = d.getElementsByTagName(s)[0];
|
---|
| 229 | if (d.getElementById(id)) return;
|
---|
| 230 | js = d.createElement(s); js.id = id;
|
---|
| 231 | js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=538218162984944";
|
---|
| 232 | fjs.parentNode.insertBefore(js, fjs);
|
---|
| 233 | }(document, 'script', 'facebook-jssdk'));</script>
|
---|
| 234 |
|
---|
[29917] | 235 | <div data-role="page" id="innovation-story-01" class="demo-page">
|
---|
| 236 |
|
---|
| 237 | <div data-role="content">
|
---|
| 238 |
|
---|
| 239 | <a target="_parent" href="../index.html" class="back-button back-left"></a>
|
---|
| 240 |
|
---|
| 241 | <div class="story-page" id="static-info-page">
|
---|
| 242 | <!-- put custom content here -->
|
---|
| 243 |
|
---|
| 244 | <div class="story-title" style="margin-left: 25px;">
|
---|
| 245 |
|
---|
[29934] | 246 | <h1 class="center">My Design '<%=request.getParameter("pub-name")%>' @ The University of Waikato</h1>
|
---|
[29917] | 247 |
|
---|
[29934] | 248 | <p class="center" style="margin: 6px;">— The New Zealand Flag Debate</p>
|
---|
[29917] | 249 |
|
---|
| 250 | <div class="center" style="height: 220px; position: relative;">
|
---|
| 251 | <div style="display: inline-block; position: relative;">
|
---|
| 252 | <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" />
|
---|
| 253 | </div>
|
---|
| 254 | <div style="height: 200px; font-size: 300%; display: inline-block;" class="vertical-alignXX">VS</div>
|
---|
| 255 | <div style="display: inline-block; position: relative">
|
---|
[29934] | 256 | <div>
|
---|
| 257 | <a id="myflag-svg" data-ajax="false" ><img id="myflag-png" height="200" style="border: none;"/></a>
|
---|
| 258 | </div>
|
---|
| 259 |
|
---|
| 260 | <div class="fb-like"
|
---|
| 261 | style="position: absolute; left:10px; width:200px;"
|
---|
| 262 | data-href="http://www.greenstone.org/nz-flag-design/main-form/my-design.jsp?pub-name=<%=request.getParameter("pub-name")%>"
|
---|
| 263 | data-layout="standard" data-action="like" data-show-faces="false" data-share="false"></div>
|
---|
| 264 |
|
---|
| 265 | </div>
|
---|
[29917] | 266 | </div>
|
---|
[29934] | 267 |
|
---|
[29917] | 268 | </div>
|
---|
| 269 |
|
---|
| 270 |
|
---|
[29934] | 271 | <center>
|
---|
[29917] | 272 |
|
---|
| 273 | <script type="text/javascript">
|
---|
| 274 |
|
---|
| 275 | var published_id = "<%= request.getParameter("pub-name") %>";
|
---|
| 276 | var name = "<%= name %>";
|
---|
| 277 | var email = "<%= email %>";
|
---|
| 278 | var desc = "<%= desc %>";
|
---|
| 279 |
|
---|
| 280 | document.write(" <div style=\"width: 500px; background: #181818; padding: 5px; margin: 10px;\">");
|
---|
| 281 | document.write(" <p>Designer: " + name + "<p/>");
|
---|
| 282 | document.write(" <p>Email: " + email + "<p/>");
|
---|
| 283 | document.write(" <p>Description: " + desc + "<p/>");
|
---|
| 284 | document.write(" </div>");
|
---|
| 285 |
|
---|
| 286 |
|
---|
| 287 | var a2a_config = a2a_config || {};
|
---|
[29934] | 288 | a2a_config.linkname = "NZ Flag Design @ University of Waikato (" + published_id + ")";
|
---|
[29917] | 289 |
|
---|
| 290 | var base_url = location.protocol + '//' + location.host + location.pathname;
|
---|
| 291 |
|
---|
| 292 | a2a_config.linkurl = base_url + "?pub-name=" + published_id
|
---|
| 293 |
|
---|
| 294 | </script>
|
---|
| 295 |
|
---|
[29934] | 296 |
|
---|
| 297 | </center>
|
---|
| 298 |
|
---|
| 299 |
|
---|
| 300 | <div style="clear:both;"></div>
|
---|
| 301 |
|
---|
| 302 |
|
---|
| 303 |
|
---|
[29917] | 304 | <!-- AddToAny BEGIN -->
|
---|
| 305 | <center>
|
---|
[29934] | 306 | <p>
|
---|
| 307 | Share this design:
|
---|
| 308 | </p>
|
---|
| 309 |
|
---|
[29917] | 310 | <div class="a2a_kit a2a_kit_size_32 a2a_default_style" style="width: 260px;">
|
---|
| 311 | <a class="a2a_dd" href="https://www.addtoany.com/share_save"></a>
|
---|
| 312 | <a class="a2a_button_email"></a>
|
---|
| 313 | <a class="a2a_button_facebook"></a>
|
---|
| 314 | <a class="a2a_button_google_plus"></a>
|
---|
| 315 | <a class="a2a_button_google_gmail"></a>
|
---|
| 316 | <a class="a2a_button_twitter"></a>
|
---|
| 317 | <a class="a2a_button_tumblr"></a>
|
---|
| 318 | </div>
|
---|
| 319 | </center>
|
---|
| 320 |
|
---|
| 321 | <script type="text/javascript" src="//static.addtoany.com/menu/page.js"></script>
|
---|
| 322 | <!-- AddToAny END -->
|
---|
| 323 |
|
---|
| 324 |
|
---|
[29934] | 325 |
|
---|
[29917] | 326 | <center>
|
---|
| 327 | <p style="font-size: 200%;">
|
---|
| 328 | <i>
|
---|
| 329 | <a href="../index.html">Interactive Flag Design Website</a> by:
|
---|
| 330 | <a target="_blank" href="http://cosi.cms.waikato.ac.nz">The Centre for Open Source Innovation</a>
|
---|
[29934] | 331 | <a target="_blank" href="http://cosi.cms.waikato.ac.nz">(COSI)</a><br />
|
---|
| 332 | at the <a href="http://www.waikato.ac.nz">University of Waikato</a>
|
---|
[29917] | 333 | </i>
|
---|
| 334 | </p>
|
---|
| 335 | </center>
|
---|
| 336 |
|
---|
| 337 |
|
---|
| 338 | </div>
|
---|
| 339 | <!-- end of putting custom content -->
|
---|
| 340 |
|
---|
| 341 | </div> <!-- end story-page-->
|
---|
| 342 |
|
---|
| 343 | </div><!-- /content -->
|
---|
| 344 |
|
---|
| 345 | </div><!-- /page -->
|
---|
| 346 |
|
---|
| 347 | <script>
|
---|
| 348 | $(document).ready( function() {
|
---|
| 349 |
|
---|
| 350 | var my_flag_png = "<%= "../published/" + pub_name + "/" + my_flag_png %>";
|
---|
| 351 | var my_flag_svg = "<%= "../published/" + pub_name + "/" + my_flag_svg %>";
|
---|
| 352 |
|
---|
| 353 | $('#myflag-png').attr("src", my_flag_png);
|
---|
| 354 | $('#myflag-svg').attr("href", my_flag_svg);
|
---|
| 355 |
|
---|
| 356 | });
|
---|
| 357 |
|
---|
| 358 | </script>
|
---|
| 359 |
|
---|
| 360 | </body>
|
---|
| 361 | </html>
|
---|
| 362 |
|
---|
| 363 |
|
---|
| 364 |
|
---|
| 365 |
|
---|
| 366 |
|
---|
| 367 |
|
---|