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