|
@@ -6,9 +6,112 @@
|
|
|
<description>Recent content in Posts on Pleasant Programmer</description>
|
|
|
<generator>Hugo -- gohugo.io</generator>
|
|
|
<language>en-us</language>
|
|
|
- <lastBuildDate>Sun, 15 Jan 2017 19:31:00 +0800</lastBuildDate>
|
|
|
+ <lastBuildDate>Sun, 19 Nov 2017 22:00:00 +0800</lastBuildDate>
|
|
|
<atom:link href="http://pleasantprogrammer.com/posts/rss.xml" rel="self" type="application/rss+xml" />
|
|
|
|
|
|
+ <item>
|
|
|
+ <title>Audventure</title>
|
|
|
+ <link>http://pleasantprogrammer.com/posts/audventure.html</link>
|
|
|
+ <pubDate>Sun, 19 Nov 2017 22:00:00 +0800</pubDate>
|
|
|
+
|
|
|
+ <guid>http://pleasantprogrammer.com/posts/audventure.html</guid>
|
|
|
+ <description>
|
|
|
+
|
|
|
+<p>Sometime around 2013 I wrote a clone of the GBA game <a href="https://www.nintendo.co.jp/n08/bit_g/">bit Generations
|
|
|
+SoundVoyager</a> called
|
|
|
+<a href="https://audventure.pleasantprogrammer.com">audventure</a>. SoundVoyager is
|
|
|
+actually a collection of mini-games where sound is the main focus. You can
|
|
|
+actually play the game blind, and at some point, that&rsquo;s pretty much what
|
|
|
+happens.</p>
|
|
|
+
|
|
|
+<h2 id="sound-catcher">sound catcher</h2>
|
|
|
+
|
|
|
+<p>The signature mini-game in SoundVoyager is sound catcher. In the mini-game, you
|
|
|
+can only move left and right at the bottom of the stage, while a &ldquo;sound&rdquo; falls
|
|
|
+from the top. Your goal is to catch the sound which is signified by a green dot.
|
|
|
+When you catch it, the sound or beat becomes part of the BGM and a new dot
|
|
|
+appears with a different sound.</p>
|
|
|
+
|
|
|
+<p>You can of course use your eyes and move accordingly, but if you put on
|
|
|
+earphones, you can actually hear where the dot is, either on your left or right,
|
|
|
+with it getting louder as it gets close to you. As you collect more sounds, the
|
|
|
+dot gets more and more transparent. Eventually (and this is where it gets fun),
|
|
|
+you won&rsquo;t be able to see the sounds anymore and will have to rely mostly on your
|
|
|
+ears.</p>
|
|
|
+
|
|
|
+<p>You can see what the original game looks like in <a href="https://www.youtube.com/watch?v=C12WRgfIOC8">this
|
|
|
+video</a> or you can play it under
|
|
|
+<em>sound safari</em> in <a href="https://audventure.pleasantprogrammer.com">audventure</a>.</p>
|
|
|
+
|
|
|
+<h2 id="webaudio-vs-flash">WebAudio vs Flash</h2>
|
|
|
+
|
|
|
+<p>At the time I wrote audventure, only Chrome supported WebAudio. Also, the API
|
|
|
+looked (and still looks) quite complicated. Flash on the other hand, was
|
|
|
+starting to die, but still well-supported so I went with that. For the most
|
|
|
+part, it worked okay though Chrome actually had timing issues when playing
|
|
|
+sounds. Now, it doesn&rsquo;t work in any browser. I tried to debug the issues but
|
|
|
+ultimately ended up just rewriting it to use WebAudio instead.</p>
|
|
|
+
|
|
|
+<p>For the game, I needed to simulate the source of the sound in 2D/3D space. Flash
|
|
|
+only really gives you stereo panning and volume control. With some maths, we can
|
|
|
+actually get an acceptable solution. Less importantly, I needed to be able to
|
|
|
+get frequency data of the currently playing &ldquo;sound&rdquo; to pulse the background. For
|
|
|
+this, I actually had to implement the feature in the Flash library I was using.</p>
|
|
|
+
|
|
|
+<p>With WebAudio, spatial audio is already built-in and you can simply give it the
|
|
|
+coordinates of the sounds and the listener. There are some other options to
|
|
|
+tweak, but for the most part, no complex math is needed. Getting frequency data
|
|
|
+for a sound is also actually built-in and didn&rsquo;t take too long to integrate.</p>
|
|
|
+
|
|
|
+<p>Overall, I was impressed by how much you can do with WebAudio out-of-the-box. I
|
|
|
+kind of understand why it&rsquo;s complicated, but there&rsquo;s some simple functionality
|
|
|
+that I wish was included. For example, there is no API to pause and then resume
|
|
|
+playing an audio buffer. You have to manually save the elapsed time and play
|
|
|
+from there.</p>
|
|
|
+
|
|
|
+<h2 id="other-mini-games">Other mini-games</h2>
|
|
|
+
|
|
|
+<p>So far I&rsquo;ve only actually implemented the sound catcher mini-game. There are
|
|
|
+around 4 different categories with slight variations in between.</p>
|
|
|
+
|
|
|
+<h3 id="sound-catcher-sound-slalom">sound catcher / sound slalom</h3>
|
|
|
+
|
|
|
+<p>I&rsquo;ve explained sound catcher a while ago; sound slalom is a minor variation on
|
|
|
+that. Instead of waiting for the &ldquo;sound&rdquo; to reach you, you now have to guide
|
|
|
+yourself in between 2 &ldquo;poles&rdquo; of sound, as in <a href="https://en.wikipedia.org/wiki/Slalom_skiing">slalom
|
|
|
+skiing</a>. But this time, you can
|
|
|
+also accelerate forward. The goal is to finish the course before the time runs
|
|
|
+out.</p>
|
|
|
+
|
|
|
+<h3 id="sound-drive-sound-chase">sound drive / sound chase</h3>
|
|
|
+
|
|
|
+<p>In sound drive, you&rsquo;re driving against the flow on a 5 lane road. You have to
|
|
|
+avoid oncoming cars, trucks and animals until you reach the end. You&rsquo;re allowed
|
|
|
+to change lanes and accelerate, and the game tracks your best time. Sound chase
|
|
|
+is pretty much the same, except you&rsquo;re trying to catch up to a &ldquo;sound&rdquo;.</p>
|
|
|
+
|
|
|
+<h3 id="sound-cannon">sound cannon</h3>
|
|
|
+
|
|
|
+<p>In sound cannon, you&rsquo;re immobile but can rotate within a 180 degree angle. Your
|
|
|
+goal is too shoot down &ldquo;sounds&rdquo; which are heading your way. If a sound reaches
|
|
|
+you, it&rsquo;s game over. You win when you kill all the sounds.</p>
|
|
|
+
|
|
|
+<h3 id="sound-picker-sound-cock">sound picker / sound cock</h3>
|
|
|
+
|
|
|
+<p>In sound picker, you can move in a giant square field where various sounds are
|
|
|
+scattered around. Your goal is to pick up all the sounds within the time limit.
|
|
|
+Sound cock is similar, except the sounds are chickens and you have to chase them
|
|
|
+around.</p>
|
|
|
+
|
|
|
+<h2 id="source-code">Source Code</h2>
|
|
|
+
|
|
|
+<p>If you want to see the source code, you can check it out
|
|
|
+<a href="https://git.pleasantprogrammer.com/games/audventure">here</a>. The sound files
|
|
|
+aren&rsquo;t in the repo though, since I&rsquo;m not quite sure about the licensing. If you
|
|
|
+want to contribute music or sound effects, I&rsquo;d gladly appreciate it.</p>
|
|
|
+</description>
|
|
|
+ </item>
|
|
|
+
|
|
|
<item>
|
|
|
<title>OpenPrepPad</title>
|
|
|
<link>http://pleasantprogrammer.com/posts/openpreppad.html</link>
|
|
@@ -682,209 +785,6 @@ sed -i .bak <span style="color: #BA2121">&#39;/^72/ s/,600/,60
|
|
|
<p>Philip, a co-worker of mine at By Implication, had suggested that we might want to use a different model than what the GTFS proposes. I have to agree with him. At this point, the GTFS doesn&rsquo;t really fit with our system. But I do think that open data and standards are great. In fact, I applaud the developers who made proposals for the fare system, as those are great first steps towards making the GTFS a more universal standard.</p>
|
|
|
|
|
|
<p>Side note: I&rsquo;d also actually really like to hear about the DOTC developers&rsquo; experience with the project. It would be nice if they had a devblog.</p>
|
|
|
-</description>
|
|
|
- </item>
|
|
|
-
|
|
|
- <item>
|
|
|
- <title>GTFS Editor</title>
|
|
|
- <link>http://pleasantprogrammer.com/posts/gtfs-editor.html</link>
|
|
|
- <pubDate>Wed, 10 Jul 2013 00:00:00 +0000</pubDate>
|
|
|
-
|
|
|
- <guid>http://pleasantprogrammer.com/posts/gtfs-editor.html</guid>
|
|
|
- <description>
|
|
|
-
|
|
|
-<p>Link: <a href="https://github.com/conveyal/gtfs-editor">https://github.com/conveyal/gtfs-editor</a></p>
|
|
|
-
|
|
|
-<p><strong>TL;DR</strong> they really meant under development</p>
|
|
|
-
|
|
|
-<p>When I first saw the source of GTFS Editor, I was ecstatic. They used <a href="http://playframework.com/">Play framework</a>!!! Not only that, they&rsquo;re targeting PostgreSQL as the main database. Those are our favorite tools for building webapps at By Implication. I was a bit sad though, when I saw it was on the 1.x release of Play though. I did have some experience with that release, but not as much compared to 2.x.</p>
|
|
|
-
|
|
|
-<p>Getting it to actually run though, wasn&rsquo;t very pleasant. The initial setup was easy enough. Get <a href="http://www.playframework.com/download">Play 1.2.5</a>, install Postgres with PostGIS, clone the repo and create backing database in Postgres. Some minor additional steps you need are to create the PostGIS extension on the database. The schema is automatically generated and applied by Play so that should be all that&rsquo;s necessary. Wonderful. Then, run play, open a browser, go to <a href="http://localhost:9000">http://localhost:9000</a>, compilation error. Fantastic.</p>
|
|
|
-
|
|
|
-<p>If you don&rsquo;t want to go through the technical details, you can just jump to the <a href="#conclusion">conclusion</a>.</p>
|
|
|
-
|
|
|
-<h2 id="let-s-debug">Let&rsquo;s Debug!</h2>
|
|
|
-
|
|
|
-<p>I&rsquo;ll be splitting the next section up into 2 parts. In the first pass, I&rsquo;ll talk about what I did to just get the app to run but I won&rsquo;t try hard to fix any bugs. This generally is what I do when I try to get apps to run. I&rsquo;ll also be dropping enough information so that you can actually figure out what the real problem is. In the second pass, I&rsquo;ll explain what the problems were and how I fixed them.</p>
|
|
|
-
|
|
|
-<h3 id="first-pass">First Pass</h3>
|
|
|
-
|
|
|
-<p>A thing to note about Play (and one of the reasons it&rsquo;s a lovely Java framework) is that you don&rsquo;t need to do manual compilation. Just edit some source files, refresh your browser and it will automatically do the compilation for you. One less argument for using PHP. It even shows you (in the browser!) the source and which line of code caused the compilation error. So that&rsquo;s what I saw, <code>Error: type Check already defined</code></p>
|
|
|
-<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #AA22FF">@Retention</span><span style="color: #666666">(</span>RetentionPolicy<span style="color: #666666">.</span><span style="color: #7D9029">RUNTIME</span><span style="color: #666666">)</span>
|
|
|
-<span style="color: #AA22FF">@Target</span><span style="color: #666666">({</span>ElementType<span style="color: #666666">.</span><span style="color: #7D9029">METHOD</span><span style="color: #666666">,</span> ElementType<span style="color: #666666">.</span><span style="color: #7D9029">TYPE</span><span style="color: #666666">})</span>
|
|
|
-<span style="color: #008000; font-weight: bold">public</span> <span style="color: #AA22FF">@interface</span> Check <span style="color: #666666">{</span> <span style="color: #408080; font-style: italic">// error here</span>
|
|
|
-
|
|
|
- String<span style="color: #666666">[]</span> <span style="color: #0000FF">value</span><span style="color: #666666">();</span>
|
|
|
-<span style="color: #666666">}</span>
|
|
|
-</pre></div>
|
|
|
-
|
|
|
-<p>You also know that typical behavior among programmers where your program doesn&rsquo;t compile, but you keep trying to compile it anyway hoping that it will magically just work. That&rsquo;s what I did, and it actually ran. I couldn&rsquo;t really just let this pass, so I decided to try deleting <code>Check.java</code>. I got another compilation error, <code>Error: type Secure already defined</code></p>
|
|
|
-<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">Secure</span> <span style="color: #008000; font-weight: bold">extends</span> Controller <span style="color: #666666">{</span> <span style="color: #408080; font-style: italic">// error here</span>
|
|
|
-
|
|
|
- <span style="color: #AA22FF">@Before</span><span style="color: #666666">(</span>unless<span style="color: #666666">={</span><span style="color: #BA2121">&quot;login&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;authenticate&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;logout&quot;</span><span style="color: #666666">})</span>
|
|
|
-
|
|
|
- <span style="color: #008000; font-weight: bold">static</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">checkAccess</span><span style="color: #666666">()</span> <span style="color: #008000; font-weight: bold">throws</span> Throwable <span style="color: #666666">{</span>
|
|
|
-</pre></div>
|
|
|
-
|
|
|
-<p>At that point, I just decided to just debug it later. It works by just forcing it anyway. So I put <code>Check.java</code> back in and proceeded to just refresh until it compiled and ran.</p>
|
|
|
-
|
|
|
-<p>The next problem is a sort of common thing most webapp developers have to solve one way or another. How do you set up the initial admin account? Phrased a different way, how do I login to this thing? The first thing I tried was just add a user into the <code>account</code> table directly. One problem though was how to set the password correctly. Plaintext obviously wouldn&rsquo;t work.</p>
|
|
|
-
|
|
|
-<p>Another note regarding Play 1.x, it provides the <a href="http://www.playframework.com/documentation/1.2.5/secure">secure module</a> which handles logins and keeping state, you simply need to implement the method <code>boolean authenticate(String username, String password)</code>. It leaves the actual process of verifying the login to the programmer. This can be exploited by just making the method return <code>true</code> and then any login would work. No need to actually set the password. Excellent.</p>
|
|
|
-
|
|
|
-<p>And we&rsquo;re logged in, just in time to encounter a runtime exception. This also works much like compilation errors in Play. It shows a page with the error and the relevant source lines. Now we get, <code>IndexOutOfBoundsException occured : Index: 0, Size: 0</code></p>
|
|
|
-<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">if</span><span style="color: #666666">(</span>session<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;agencyId&quot;</span><span style="color: #666666">)</span> <span style="color: #666666">==</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">)</span> <span style="color: #666666">{</span>
|
|
|
-
|
|
|
- Agency agency <span style="color: #666666">=</span> agencies<span style="color: #666666">.</span><span style="color: #7D9029">get</span><span style="color: #666666">(0);</span> <span style="color: #408080; font-style: italic">// error here</span>
|
|
|
-
|
|
|
- session<span style="color: #666666">.</span><span style="color: #7D9029">put</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;agencyId&quot;</span><span style="color: #666666">,</span> agency<span style="color: #666666">.</span><span style="color: #7D9029">id</span><span style="color: #666666">);</span>
|
|
|
- session<span style="color: #666666">.</span><span style="color: #7D9029">put</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;agencyName&quot;</span><span style="color: #666666">,</span> agency<span style="color: #666666">.</span><span style="color: #7D9029">name</span><span style="color: #666666">);</span>
|
|
|
-</pre></div>
|
|
|
-
|
|
|
-<p>Apparently, we need to have an agency. That&rsquo;s generally simple enough. You just manually insert an agency into the <code>agency</code> table. After that&rsquo;s done, we finally have a view of the actual application. It&rsquo;s very Bootstrap-y, but that&rsquo;s just fine. The workflow though, is not perfectly intuitive, but I&rsquo;ll talk about that some other day.</p>
|
|
|
-
|
|
|
-<p>That&rsquo;s not the end of it though, we still have to fix these bugs. The developer obviously didn&rsquo;t have to put up with this when they were working, so what happened? Also, the log is showing some weird things,</p>
|
|
|
-<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>~ _ _
|
|
|
-~ _ __ | | __ _ _ _| |
|
|
|
-~ | &#39;_ \| |/ _&#39; | || |_|
|
|
|
-~ | __/|_|\____|\__ (_)
|
|
|
-~ |_| |__/
|
|
|
-~
|
|
|
-~ play! 1.2.5, http://www.playframework.org
|
|
|
-~
|
|
|
-~ Ctrl+C to stop
|
|
|
-~
|
|
|
-CompilerOracle: exclude jregex/Pretokenizer.next
|
|
|
-Listening for transport dt_socket at address: 8000
|
|
|
-23:32:14,943 INFO ~ Starting /Users/thomas/Workspace/maps/gtfs-editor
|
|
|
-23:32:14,948 WARN ~ Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.secure)
|
|
|
-23:32:14,948 INFO ~ Module secure is available (/Users/thomas/.root/opt/play-1.2.5/modules/secure)
|
|
|
-23:32:15,830 WARN ~ You&#39;re running Play! in DEV mode
|
|
|
-23:32:15,952 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
|
|
|
-23:32:28,792 ERROR ~
|
|
|
-
|
|
|
-@6f02fa9dd
|
|
|
-Internal Server Error (500) for request GET /
|
|
|
-
|
|
|
-Compilation error (In /app/controllers/Check.java around line 10)
|
|
|
-The file /app/controllers/Check.java could not be compiled. Error raised is : The type Check is already defined
|
|
|
-
|
|
|
-play.exceptions.CompilationException: The type Check is already defined
|
|
|
- at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246)
|
|
|
- at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:672)
|
|
|
- at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:516)
|
|
|
- at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:282)
|
|
|
- at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:426)
|
|
|
- at play.Play.start(Play.java:516)
|
|
|
- at play.Play.detectChanges(Play.java:630)
|
|
|
- at play.Invoker$Invocation.init(Invoker.java:198)
|
|
|
- at Invocation.HTTP Request(Play!)
|
|
|
-23:32:31,551 INFO ~ Connected to jdbc:postgresql://127.0.0.1/gtfs_editor
|
|
|
-SLF4J: Class path contains multiple SLF4J bindings.
|
|
|
-SLF4J: Found binding in [jar:file:/Users/thomas/Workspace/maps/gtfs-editor/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
|
|
|
-SLF4J: Found binding in [jar:file:/Users/thomas/.root/opt/play-1.2.5/framework/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
|
|
|
-SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
|
|
|
-23:32:32,490 INFO ~ Initializing HBSpatialExtension
|
|
|
-23:32:32,492 INFO ~ Attempting to load Hibernate Spatial Provider org.hibernatespatial.postgis.DialectProvider
|
|
|
-23:32:32,494 INFO ~ Checking for default configuration file.
|
|
|
-23:32:32,496 INFO ~ No configuration file hibernate-spatial.cfg.xml on the classpath.
|
|
|
-23:32:34,077 INFO ~ Application &#39;gtfs-editor&#39; is now started !
|
|
|
-23:32:34,151 INFO ~ Bootstrapping Database...
|
|
|
-23:32:34,297 DEBUG ~ select count(*) as col_0_0_ from Agency agency0_ limit ?
|
|
|
-play.exceptions.UnexpectedException: Unexpected Error
|
|
|
- at play.vfs.VirtualFile.contentAsString(VirtualFile.java:180)
|
|
|
- at play.templates.TemplateLoader.load(TemplateLoader.java:78)
|
|
|
- at play.test.Fixtures.loadModels(Fixtures.java:174)
|
|
|
- at jobs.BootstrapDatabase.doJob(BootstrapDatabase.java:57)
|
|
|
- at play.jobs.Job.doJobWithResult(Job.java:50)
|
|
|
- at play.jobs.Job.call(Job.java:146)
|
|
|
- at play.jobs.Job.run(Job.java:132)
|
|
|
- at play.jobs.JobsPlugin.afterApplicationStart(JobsPlugin.java:116)
|
|
|
- at play.plugins.PluginCollection.afterApplicationStart(PluginCollection.java:531)
|
|
|
- at play.Play.start(Play.java:547)
|
|
|
- at play.Play.detectChanges(Play.java:630)
|
|
|
- at play.Invoker$Invocation.init(Invoker.java:198)
|
|
|
- at play.server.PlayHandler$NettyInvocation.init(PlayHandler.java:189)
|
|
|
- at play.Invoker$Invocation.run(Invoker.java:276)
|
|
|
- at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:229)
|
|
|
- at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
|
|
|
- at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
|
|
|
- at java.util.concurrent.FutureTask.run(FutureTask.java:138)
|
|
|
- at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
|
|
|
- at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
|
|
|
- at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
|
|
|
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
|
|
|
- at java.lang.Thread.run(Thread.java:680)
|
|
|
-Caused by: play.exceptions.UnexpectedException: Unexpected Error
|
|
|
- at play.vfs.VirtualFile.inputstream(VirtualFile.java:111)
|
|
|
- at play.vfs.VirtualFile.contentAsString(VirtualFile.java:178)
|
|
|
- ... 22 more
|
|
|
-Caused by: java.io.FileNotFoundException: /Users/thomas/.root/opt/play-1.2.5/modules/docviewer/app/initial-agencies-data.yml (No such file or directory)
|
|
|
- at java.io.FileInputStream.open(Native Method)
|
|
|
- at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120)
|
|
|
- at play.vfs.VirtualFile.inputstream(VirtualFile.java:109)
|
|
|
- ... 23 more
|
|
|
-23:32:34,316 ERROR ~ java.lang.RuntimeException: Cannot load fixture initial-agencies-data.yml: Unexpected Error
|
|
|
-23:32:40,989 DEBUG ~ select account0_.id as id15_, account0_.active as active15_, account0_.admin as admin15_, account0_.agency_id as agency9_15_, account0_.email as email15_, account0_.lastLogin as lastLogin15_, account0_.password as password15_, account0_.passwordChangeToken as password7_15_, account0_.username as username15_ from Account account0_ where account0_.username=? limit ?
|
|
|
-23:32:40,994 DEBUG ~ select count(*) as col_0_0_ from Account account0_ limit ?
|
|
|
-23:32:40,999 DEBUG ~ select nextval (&#39;hibernate_sequence&#39;)
|
|
|
-23:32:41,051 DEBUG ~ insert into Account (active, admin, agency_id, email, lastLogin, password, passwordChangeToken, username, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
|
-23:32:41,061 DEBUG ~ select agency0_.id as id24_, agency0_.color as color24_, agency0_.defaultLat as defaultLat24_, agency0_.defaultLon as defaultLon24_, agency0_.defaultRouteType_id as default12_24_, agency0_.gtfsAgencyId as gtfsAgen5_24_, agency0_.lang as lang24_, agency0_.name as name24_, agency0_.phone as phone24_, agency0_.systemMap as systemMap24_, agency0_.timezone as timezone24_, agency0_.url as url24_ from Agency agency0_ order by agency0_.name
|
|
|
-23:32:41,175 ERROR ~
|
|
|
-
|
|
|
-@6f02fa9dg
|
|
|
-Internal Server Error (500) for request GET /
|
|
|
-
|
|
|
-Execution exception (In /app/controllers/Application.java around line 57)
|
|
|
-IndexOutOfBoundsException occured : Index: 0, Size: 0
|
|
|
-
|
|
|
-play.exceptions.JavaExecutionException: Index: 0, Size: 0
|
|
|
- at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237)
|
|
|
- at Invocation.HTTP Request(Play!)
|
|
|
-Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
|
|
|
- at java.util.ArrayList.RangeCheck(ArrayList.java:547)
|
|
|
- at java.util.ArrayList.get(ArrayList.java:322)
|
|
|
- at controllers.Application.initSession(Application.java:57)
|
|
|
- at play.mvc.ActionInvoker.invoke(ActionInvoker.java:510)
|
|
|
- at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
|
|
|
- at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
|
|
|
- at play.mvc.ActionInvoker.handleBefores(ActionInvoker.java:328)
|
|
|
- at play.mvc.ActionInvoker.invoke(ActionInvoker.java:142)
|
|
|
- ... 1 more
|
|
|
-</pre></div>
|
|
|
-
|
|
|
-<p>After <code>23:32:34</code> is when I get the login page. <code>23:32:40</code> is after I&rsquo;ve logged in.</p>
|
|
|
-
|
|
|
-<h3 id="second-pass">Second Pass</h3>
|
|
|
-
|
|
|
-<p>So how did you do? First, the error that <code>type Check already defined</code> usually does mean that <code>Check</code> was already defined elsewhere. Looking in the app folder though, there was nothing of the sort. It&rsquo;s the only one there that was <code>Check.java</code>. But remember the secure module? Modules work by providing source files and Play just compiles them all together. Bingo, <code>Check.java</code>. Doing a diff shows nothing was changed. So the solution really was just simply delete <code>Check.java</code> and also <code>Secure.java</code>. No more compilation errors!</p>
|
|
|
-
|
|
|
-<p>The next question is, how do you get the initial user? There actually is some code that looks like it creates the default admin user,</p>
|
|
|
-<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">if</span><span style="color: #666666">(</span>Security<span style="color: #666666">.</span><span style="color: #7D9029">isConnected</span><span style="color: #666666">())</span> <span style="color: #666666">{</span>
|
|
|
- <span style="color: #666666">...</span>
|
|
|
- Account account <span style="color: #666666">=</span> Account<span style="color: #666666">.</span><span style="color: #7D9029">find</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;username = ?&quot;</span><span style="color: #666666">,</span> Security<span style="color: #666666">.</span><span style="color: #7D9029">connected</span><span style="color: #666666">()).</span><span style="color: #7D9029">first</span><span style="color: #666666">();</span>
|
|
|
- <span style="color: #666666">...</span>
|
|
|
- <span style="color: #008000; font-weight: bold">if</span><span style="color: #666666">(</span>account <span style="color: #666666">==</span> <span style="color: #008000; font-weight: bold">null</span> <span style="color: #666666">&amp;&amp;</span> Account<span style="color: #666666">.</span><span style="color: #7D9029">count</span><span style="color: #666666">()</span> <span style="color: #666666">==</span> <span style="color: #666666">0)</span> <span style="color: #666666">{</span>
|
|
|
- account <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> Account<span style="color: #666666">(</span><span style="color: #BA2121">&quot;admin&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;admin&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;admin@test.com&quot;</span><span style="color: #666666">,</span> <span style="color: #008000; font-weight: bold">true</span><span style="color: #666666">,</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">);</span>
|
|
|
- account<span style="color: #666666">.</span><span style="color: #7D9029">save</span><span style="color: #666666">();</span>
|
|
|
- <span style="color: #666666">}</span>
|
|
|
- <span style="color: #666666">...</span>
|
|
|
-<span style="color: #666666">}</span>
|
|
|
-</pre></div>
|
|
|
-
|
|
|
-<p>You can actually see this in action at <code>23:32:41,051</code> in the log. So what&rsquo;s wrong with all of this? The account creation happened after I&rsquo;ve already logged in. In fact, <code>Security.isConnected()</code> checks whether the user is already logged in or not. How does this even make sense?</p>
|
|
|
-
|
|
|
-<p>Lastly, we have the problem of the agencies. Just by looking at the log, you can safely say we&rsquo;re missing a file called <code>initial-agencies-data.yml</code>. Ok, apparently it&rsquo;s a <a href="http://www.playframework.com/documentation/1.2.5/test#fixtures">fixture</a> like you would use for testing. It&rsquo;s easy enough to infer what the file&rsquo;s contents should be. We just copy it over from the GTFS data.</p>
|
|
|
-
|
|
|
-<p>But then where do you put the file? If you look at the log, it says <code>/Users/thomas/.root/opt/play-1.2.5/modules/docviewer/app/initial-agencies-data.yml</code> but that doesn&rsquo;t look right. That&rsquo;s in the Play distribution directory, probably not somewhere something app-specific should go into. Well, a fixture is used for testing, so maybe the <code>test/</code> directory? No, that doesn&rsquo;t work either since we&rsquo;re not running a test.</p>
|
|
|
-
|
|
|
-<p>What I ended up doing was just looking at the sources for <code>Fixtures.load</code>. If you follow the stack trace, you end up finding <code>Play.javaPath</code> which sort of works like PATH for Fixtures and some other things. So where can we put the file? <code>app/</code> and <code>conf/</code>. And with that, we&rsquo;re done.</p>
|
|
|
-
|
|
|
-<h3 id="conclusion">Conclusion</h3>
|
|
|
-
|
|
|
-<p>GTFS Editor is very much in development. Just getting it to run was problematic. There also seem to be a lot of missing issues judging from the Github Issues page. If you want to try it out for yourself, I suggest you clone <a href="https://github.com/thatsmydoing/gtfs-editor">my branch</a> as I&rsquo;ve fixed the issues discussed earlier. The default login is <code>admin:admin</code>.</p>
|
|
|
-
|
|
|
-<p>Even after getting it to run, it&rsquo;s still not quite usable. Not in the UX sense, but you really can&rsquo;t do much with it. There is no way to import the GTFS data into the webapp. There is something like import from TransitWand but even that is unclear to me. And even if we do get that running as well, we still don&rsquo;t have any data we can play around with. We would need database dumps from the already running tools for these to be of any use right now.</p>
|
|
|
</description>
|
|
|
</item>
|
|
|
|