Browse Source

chiarisci quale casella stiamo usando

boyska 4 years ago
parent
commit
145f30485f
4 changed files with 17 additions and 10 deletions
  1. 6 3
      app.py
  2. 2 0
      static/js/upload.js
  3. 0 6
      static/zerbino.css
  4. 9 1
      templates/index.htm

+ 6 - 3
app.py

@@ -46,13 +46,16 @@ def read_config():
 
 @app.route("/")
 def home():
-    # TODO: redirect to /default, meglio che render
-    return render_template("index.htm", site="default")
+    return 'casella di destinazione non specificata'
 
 
 @app.route("/<site>")
 def site(site):
-    return render_template("index.htm", site=site)
+    try:
+        sitedata = read_config()["sites"][site]
+    except KeyError:
+        sitedata = {}
+    return render_template("index.htm", siteid=site, sitedata=sitedata)
 
 
 @app.route("/upload/<site>", methods=["POST"])

+ 2 - 0
static/js/upload.js

@@ -39,11 +39,13 @@ $(function guiFunctions() {
   $('#stop_record').hide()
   $('#visualizer').hide()
   $('body').on('recording-start-ok', function() {
+    $('#help').hide()
     $('#record_audio').hide()
     $('#stop_record').show()
     $('#visualizer').show()
   })
   $('body').on('recording-start-fail', function(evt, err) {
+    $('#help').hide()
     $('#content').hide()
     $('#container').text('Errore! apri il microfono')
   })

+ 0 - 6
static/zerbino.css

@@ -32,12 +32,6 @@ html,body {
 	margin: 0.3em;
 }
 
-#help {
-	margin: 0.3em;
-	margin-left: 0.5em;
-	float:left;
-}
-
 #bar {
 	margin:0.5em;
 	float: left;

+ 9 - 1
templates/index.htm

@@ -15,7 +15,15 @@
 
 <div id="content">
 <!-- <div id="image"><a href="/"><img alt="logo" src="logo" height="80"/></a></div> -->
-<section id="help"></section>
+<section id="help">
+    {% if siteid %}
+    {% if sitedata['intro'] %}
+    {{sitedata.intro}}
+    {% else %}
+    Questo sito ti permette di lasciare un audio a {{siteid}}
+    {% endif %}
+    {% endif %}
+</section>
 
 <div id="buttons">
 <button id="record_audio" type="button">Registra</button>