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

Merge branch 'assets-css' of bui/taiko-web into master

Bui 2 months ago
parent
commit
566813363f
5 changed files with 28 additions and 14 deletions
  1. 13
    4
      app.py
  2. 1
    4
      public/src/js/about.js
  3. 4
    0
      public/src/js/assets.js
  4. 7
    1
      public/src/js/loader.js
  5. 3
    5
      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))

+ 4
- 0
public/src/js/assets.js View File

@@ -37,6 +37,10 @@ var assets = {
37 37
 		"debug.css",
38 38
 		"songbg.css"
39 39
 	],
40
+	"assetsCss": [
41
+		"fonts/fonts.css",
42
+		"img/img.css"
43
+	],
40 44
 	"img": [
41 45
 		"title-screen.png",
42 46
 		"notes.png",

+ 7
- 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")
@@ -40,6 +40,12 @@ class Loader{
40 40
 				stylesheet.href = "/src/css/" + name + queryString
41 41
 				document.head.appendChild(stylesheet)
42 42
 			})
43
+			assets.assetsCss.forEach(name => {
44
+				var stylesheet = document.createElement("link")
45
+				stylesheet.rel = "stylesheet"
46
+				stylesheet.href = gameConfig.assets_baseurl + name + queryString
47
+				document.head.appendChild(stylesheet)
48
+			})
43 49
 			var checkStyles = () => {
44 50
 				if(document.styleSheets.length >= cssCount){
45 51
 					resolve()

+ 3
- 5
templates/index.html View File

@@ -8,9 +8,7 @@
8 8
 	<meta name="description" content="パソコンとスマホのブラウザ向けの太鼓の達人シミュレータ 🥁 Taiko no Tatsujin rhythm game simulator for desktop and mobile browsers">
9 9
 
10 10
 	<link rel="stylesheet" href="/src/css/loader.css?{{version.commit_short}}">
11
-	<link rel="stylesheet" href="{{config.assets_baseurl}}fonts/fonts.css?{{version.commit_short}}">
12
-	<link rel="stylesheet" href="{{config.assets_baseurl}}img/img.css?{{version.commit_short}}">
13
-	
11
+
14 12
 	<script src="/src/js/assets.js?{{version.commit_short}}"></script>
15 13
 	<script src="/src/js/strings.js?{{version.commit_short}}"></script>
16 14
 	<script src="/src/js/pageevents.js?{{version.commit_short}}"></script>
@@ -21,10 +19,10 @@
21 19
 	<div id="assets"></div>
22 20
 	<div id="screen" class="pattern-bg"></div>
23 21
 	<div id="version">
24
-		{% if version %}
22
+		{% if version.version and version.commit_short and version.commit %}
25 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>
26 24
 		{% else %}
27
-			<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>
28 26
 		{% endif %}
29 27
 	</div>
30 28
 	<script src="/src/js/browsersupport.js?{{version.commit_short}}"></script>

Loading…
Cancel
Save