Browse Source

Add controls for adding a label.

parisminton 8 years ago
parent
commit
75f5ea9bdb
6 changed files with 58 additions and 5 deletions
  1. 24 3
      client/index.js
  2. 4 0
      editor/index.html
  3. 5 1
      lib/settings/index.js
  4. 13 0
      lib/settings/validate-labels.js
  5. 1 1
      server/index.js
  6. 11 0
      settings/labels.json

+ 24 - 3
client/index.js View File

@@ -4,6 +4,23 @@ var d3 = require("d3"),
4 4
     video = require("./video.js"),
5 5
     audio = require("./audio.js");
6 6
 
7
+d3.json("/settings/labels.json", function(err, labels){
8
+
9
+  // Populate labels menu
10
+  d3.select("#input-label")
11
+    .on("change", updateLabel)
12
+    .selectAll("option")
13
+    .data(labels.podcasts)
14
+    .enter()
15
+    .append("option")
16
+      .text(function(l){
17
+        return l;
18
+      });
19
+
20
+  d3.select("#input-label").each(updateLabel);
21
+
22
+}); // end label ingestion
23
+
7 24
 d3.json("/settings/themes.json", function(err, themes){
8 25
 
9 26
   var errorMessage;
@@ -134,13 +151,13 @@ function error(msg) {
134 151
 }
135 152
 
136 153
 // Once images are downloaded, set up listeners
137
-function initialize(err, themesWithImages) {
154
+function initialize(err, results) {
138 155
 
139
-  // Populate dropdown menu
156
+  // Populate themes menu
140 157
   d3.select("#input-theme")
141 158
     .on("change", updateTheme)
142 159
     .selectAll("option")
143
-    .data(themesWithImages)
160
+    .data(results) // themes with images
144 161
     .enter()
145 162
     .append("option")
146 163
       .text(function(d){
@@ -226,6 +243,10 @@ function updateTheme() {
226 243
   preview.theme(d3.select(this.options[this.selectedIndex]).datum());
227 244
 }
228 245
 
246
+function updateLabel() {
247
+  // updating logic
248
+}
249
+
229 250
 function preloadImages(themes) {
230 251
 
231 252
   // preload images

+ 4 - 0
editor/index.html View File

@@ -29,6 +29,10 @@
29 29
           <label for="input-theme">Theme</label>
30 30
           <select id="input-theme" name="theme"></select>
31 31
         </div>
32
+        <div class="row form-row" id="row-label">
33
+          <label for="input-label">Label</label>
34
+          <select id="input-label" name="label"></select>
35
+        </div>
32 36
         <div class="row form-row" id="row-caption">
33 37
           <label for="input-caption">
34 38
             Caption

+ 5 - 1
lib/settings/index.js View File

@@ -4,7 +4,8 @@ var _ = require("underscore"),
4 4
     load = require("./load.js");
5 5
 
6 6
 var settings = load("settings/index.js"),
7
-    themes = load("settings/themes.json");
7
+    themes = load("settings/themes.json"),
8
+    labels = load("settings/labels.json");
8 9
 
9 10
 // Validate settings
10 11
 settings = require("./validate-settings.js")(settings);
@@ -12,4 +13,7 @@ settings = require("./validate-settings.js")(settings);
12 13
 // Validate themes
13 14
 themes = require("./validate-themes.js")(themes);
14 15
 
16
+// Validate labels
17
+labels = require("./validate-labels.js")(labels);
18
+
15 19
 module.exports = settings;

+ 13 - 0
lib/settings/validate-labels.js View File

@@ -0,0 +1,13 @@
1
+var path = require("path"),
2
+    _ = require("underscore"),
3
+    fs = require("fs");
4
+
5
+module.exports = function(labels) {
6
+
7
+  if (!labels || labels.podcasts.length === 0) {
8
+    return console.warn("No labels found in settings/labels.json.");
9
+  }
10
+
11
+  return labels;
12
+
13
+};

+ 1 - 1
server/index.js View File

@@ -72,7 +72,7 @@ app.get("/healthcheck/", function(req, res, next) {
72 72
 app.use("/settings/", function(req, res, next) {
73 73
 
74 74
   // Limit to themes.json and bg images
75
-  if (req.url.match(/^\/?themes.json$/i) || req.url.match(/^\/?backgrounds\/[^/]+$/i)) {
75
+  if (req.url.match(/^\/?themes.json$|\/?labels.json$/i) || req.url.match(/^\/?backgrounds\/[^/]+$/i)) {
76 76
     return next();
77 77
   }
78 78
 

+ 11 - 0
settings/labels.json View File

@@ -0,0 +1,11 @@
1
+{
2
+  "podcasts" : [
3
+    "Generic",
4
+    "The Daily",
5
+    "Still Processing",
6
+    "Popcast",
7
+    "Modern Love",
8
+    "The Book Review",
9
+    "- Other:"
10
+  ]
11
+}