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
     video = require("./video.js"),
4
     video = require("./video.js"),
5
     audio = require("./audio.js");
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
 d3.json("/settings/themes.json", function(err, themes){
24
 d3.json("/settings/themes.json", function(err, themes){
8
 
25
 
9
   var errorMessage;
26
   var errorMessage;
134
 }
151
 }
135
 
152
 
136
 // Once images are downloaded, set up listeners
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
   d3.select("#input-theme")
157
   d3.select("#input-theme")
141
     .on("change", updateTheme)
158
     .on("change", updateTheme)
142
     .selectAll("option")
159
     .selectAll("option")
143
-    .data(themesWithImages)
160
+    .data(results) // themes with images
144
     .enter()
161
     .enter()
145
     .append("option")
162
     .append("option")
146
       .text(function(d){
163
       .text(function(d){
226
   preview.theme(d3.select(this.options[this.selectedIndex]).datum());
243
   preview.theme(d3.select(this.options[this.selectedIndex]).datum());
227
 }
244
 }
228
 
245
 
246
+function updateLabel() {
247
+  // updating logic
248
+}
249
+
229
 function preloadImages(themes) {
250
 function preloadImages(themes) {
230
 
251
 
231
   // preload images
252
   // preload images

+ 4 - 0
editor/index.html View File

29
           <label for="input-theme">Theme</label>
29
           <label for="input-theme">Theme</label>
30
           <select id="input-theme" name="theme"></select>
30
           <select id="input-theme" name="theme"></select>
31
         </div>
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
         <div class="row form-row" id="row-caption">
36
         <div class="row form-row" id="row-caption">
33
           <label for="input-caption">
37
           <label for="input-caption">
34
             Caption
38
             Caption

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

4
     load = require("./load.js");
4
     load = require("./load.js");
5
 
5
 
6
 var settings = load("settings/index.js"),
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
 // Validate settings
10
 // Validate settings
10
 settings = require("./validate-settings.js")(settings);
11
 settings = require("./validate-settings.js")(settings);
12
 // Validate themes
13
 // Validate themes
13
 themes = require("./validate-themes.js")(themes);
14
 themes = require("./validate-themes.js")(themes);
14
 
15
 
16
+// Validate labels
17
+labels = require("./validate-labels.js")(labels);
18
+
15
 module.exports = settings;
19
 module.exports = settings;

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

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
 app.use("/settings/", function(req, res, next) {
72
 app.use("/settings/", function(req, res, next) {
73
 
73
 
74
   // Limit to themes.json and bg images
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
     return next();
76
     return next();
77
   }
77
   }
78
 
78
 

+ 11 - 0
settings/labels.json View File

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