taiko-web development has returned to GitHub. This Gitea instance will be shut down soon.
If your taiko-web fork is unavailable due to DMCA takedown, you can contact GitHub Support and ask for it to be deleted.
Browse Source

solidify default git repo

Bui 1 week ago
parent
commit
dc3d5319ed
4 changed files with 17 additions and 11 deletions
  1. 13
    4
      app.py
  2. 1
    4
      public/src/js/about.js
  3. 1
    1
      public/src/js/loader.js
  4. 2
    2
      templates/index.html

+ 13
- 4
app.py View File

@@ -11,6 +11,7 @@ from ffmpy import FFmpeg
11 11
 
12 12
 app = Flask(__name__)
13 13
 DATABASE = 'taiko.db'
14
+DEFAULT_URL = 'https://github.com/bui/taiko-web/'
14 15
 
15 16
 
16 17
 def get_db():
@@ -119,9 +120,17 @@ def get_tja_preview(tja):
119 120
 
120 121
 
121 122
 def get_version():
122
-    version = None
123
+    version = {'commit': None, 'commit_short': '', 'version': None, 'url': DEFAULT_URL}
123 124
     if os.path.isfile('version.json'):
124
-        version = json.load(open('version.json', 'r'))
125
+        try:
126
+            ver = json.load(open('version.json', 'r'))
127
+        except ValueError:
128
+            print('Invalid version.json file')
129
+            return version
130
+
131
+        for key in version.keys():
132
+            if ver.get(key):
133
+                version[key] = ver.get(key)
125 134
 
126 135
     return version
127 136
 
@@ -213,10 +222,10 @@ def make_preview(song_id, song_type):
213 222
     if os.path.isfile(song_path) and not os.path.isfile(prev_path):
214 223
         preview = get_preview(song_id, song_type) / 1000
215 224
         if not preview or preview <= 0.1:
216
-            print 'Skipping #%s due to no preview' % song_id
225
+            print('Skipping #%s due to no preview' % song_id)
217 226
             return False
218 227
 
219
-        print 'Making preview.mp3 for song #%s' % song_id
228
+        print('Making preview.mp3 for song #%s' % song_id)
220 229
         ff = FFmpeg(inputs={song_path: '-ss %s' % preview},
221 230
                     outputs={prev_path: '-codec:a libmp3lame -ar 32000 -b:a 92k -y -loglevel panic'})
222 231
         ff.run()

+ 1
- 4
public/src/js/about.js View File

@@ -29,10 +29,7 @@
29 29
 		this.endButton.innerText = strings.tutorial.ok
30 30
 		this.endButton.setAttribute("alt", strings.tutorial.ok)
31 31
 		
32
-		var versionUrl = "https://github.com/bui/taiko-web/"
33
-		if(gameConfig._version){
34
-			versionUrl = gameConfig._version.url
35
-		}
32
+		var versionUrl = gameConfig._version.url
36 33
 		this.getLink(this.linkIssues).href = versionUrl + "issues"
37 34
 		
38 35
 		pageEvents.add(this.linkIssues, ["click", "touchend"], this.linkButton.bind(this))

+ 1
- 1
public/src/js/loader.js View File

@@ -23,7 +23,7 @@ class Loader{
23 23
 		this.loaderPercentage = document.querySelector("#loader .percentage")
24 24
 		this.loaderProgress = document.querySelector("#loader .progress")
25 25
 		
26
-		var queryString = gameConfig._version ? "?" + gameConfig._version.commit_short : ""
26
+		var queryString = gameConfig._version.commit_short ? "?" + gameConfig._version.commit_short : ""
27 27
 		
28 28
 		assets.js.forEach(name => {
29 29
 			var script = document.createElement("script")

+ 2
- 2
templates/index.html View File

@@ -19,10 +19,10 @@
19 19
 	<div id="assets"></div>
20 20
 	<div id="screen" class="pattern-bg"></div>
21 21
 	<div id="version">
22
-		{% if version %}
22
+		{% if version.version and version.commit_short and version.commit %}
23 23
 			<a href="{{version.url}}commit/{{version.commit}}" target="_blank" id="version-link" class="stroke-sub" alt="taiko-web ver.{{version.version}} ({{version.commit_short}})">taiko-web ver.{{version.version}} ({{version.commit_short}})</a>
24 24
 		{% else %}
25
-			<a href="https://github.com/bui/taiko-web" target="_blank" id="version-link" class="stroke-sub" alt="taiko-web (unknown version)">taiko-web (unknown version)</a>
25
+			<a href="{{version.url}}" target="_blank" id="version-link" class="stroke-sub" alt="taiko-web (unknown version)">taiko-web (unknown version)</a>
26 26
 		{% endif %}
27 27
 	</div>
28 28
 	<script src="/src/js/browsersupport.js?{{version.commit_short}}"></script>

Loading…
Cancel
Save