diff --git a/package.json b/package.json index d4814d6e..2c4d48f5 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,14 @@ "type": "git", "url": "git+https://github.com/zoff-music/zoff.git" }, - "author": "", - "license": "ISC", - "bugs": { - "url": "https://github.com/zoff-music/zoff/issues" - }, "author": { "name": "Kasper Rynning Tønnesen", "email": "kasper@kasperrt.no" }, + "license": "ISC", + "bugs": { + "url": "https://github.com/zoff-music/zoff/issues" + }, "devDependencies": { "gulp-util": "~3.0.6", "gulp": "~3.9.0", @@ -28,10 +27,6 @@ }, "homepage": "https://github.com/zoff-music/zoff#readme", "dependencies": { - "gulp": "^3.9.1", - "gulp-concat": "^2.6.1", - "gulp-uglifyjs": "^0.6.2", - "gulp-util": "^3.0.8", "bad-words": "^1.5.1", "body-parser": "^1.17.1", "cookie-parser": "^1.4.3", @@ -40,7 +35,12 @@ "express": "^4.15.2", "express-handlebars": "^3.0.0", "express-subdomain": "^1.0.5", + "gulp": "^3.9.1", + "gulp-concat": "^2.6.1", + "gulp-uglifyjs": "^0.6.2", + "gulp-util": "^3.0.8", "jimp": "^0.2.27", + "mobile-detect": "^1.3.7", "mongodb": "^2.0.27", "mongojs": "^2.4.0", "node-cryptojs-aes": "^0.4.0", diff --git a/server/public/layouts/channel.handlebars b/server/public/layouts/channel.handlebars index 3fa85093..a6411faa 100755 --- a/server/public/layouts/channel.handlebars +++ b/server/public/layouts/channel.handlebars @@ -1,322 +1,14 @@
-
- - - - - -
+ {{> channel/header}}
-
- -
-
-
-
-
- cast -
-
-
-
- Waiting for Video -
-
-
- play_arrow - pause -
-
- volume_off - volume_mute - volume_down - volume_up -
-
-
-
- -
- play_arrow - pause -
- -
-
- fullscreen -
- -
- volume_off - volume_mute - volume_down - volume_up -
-
-
-
-
-
-
+ {{> channel/players}} + {{> channel/tabs}}
-
-
- - -
-
- -
- 0/0 +
- clear - -
-
-
-
-
- - - - - 01:00 - - - - - - -  votes - - -
- -
DELETE
-
-
-
- - -
-
-
-
-
+
diff --git a/server/public/layouts/frontpage.handlebars b/server/public/layouts/frontpage.handlebars index e62e225c..2efbe1d3 100755 --- a/server/public/layouts/frontpage.handlebars +++ b/server/public/layouts/frontpage.handlebars @@ -1,117 +1,7 @@
-
- - - - - -
- -
-
-
Create a radio channel, collaborate and listen
-
-
-

zoff.me/

- - -
-
-
-
Live & democratic playlists with YouTube Music
-
Play everywhere — No login required
-
-
- - + {{> frontpage/header}} + {{> frontpage/search/desktop}} + {{> frontpage/search/mobile}}
@@ -131,37 +21,7 @@
-
- - -
+ {{> frontpage/channels}}
diff --git a/server/public/layouts/remote.handlebars b/server/public/layouts/remote.handlebars index f9725edd..3ab69f89 100644 --- a/server/public/layouts/remote.handlebars +++ b/server/public/layouts/remote.handlebars @@ -1,93 +1,12 @@ -
- - - -
- +{{> remote/header}}

Remote Controller

-
-
- - -
-
- - - -
-
- volume_up -
- + {{> remote/input}} + {{> remote/buttons}} + {{> remote/volume}}
diff --git a/server/public/partials/channel/chat.handlebars b/server/public/partials/channel/chat.handlebars new file mode 100644 index 00000000..0ed03347 --- /dev/null +++ b/server/public/partials/channel/chat.handlebars @@ -0,0 +1,28 @@ + diff --git a/server/public/partials/channel/header.handlebars b/server/public/partials/channel/header.handlebars new file mode 100644 index 00000000..a1f3f201 --- /dev/null +++ b/server/public/partials/channel/header.handlebars @@ -0,0 +1,162 @@ +
+ + + + + +
diff --git a/server/public/partials/panel.handlebars b/server/public/partials/channel/panel.handlebars similarity index 100% rename from server/public/partials/panel.handlebars rename to server/public/partials/channel/panel.handlebars diff --git a/server/public/partials/channel/players.handlebars b/server/public/partials/channel/players.handlebars new file mode 100644 index 00000000..db4aea35 --- /dev/null +++ b/server/public/partials/channel/players.handlebars @@ -0,0 +1,57 @@ +
+
+
+
+
+
+
+ cast +
+
+
+
+ Waiting for Video +
+
+
+ play_arrow + pause +
+
+ volume_off + volume_mute + volume_down + volume_up +
+
+
+
+ +
+ play_arrow + pause +
+ +
+
+ fullscreen +
+ +
+ volume_off + volume_mute + volume_down + volume_up +
+
+
+
+
+
+
+
+
diff --git a/server/public/partials/channel/playlist.handlebars b/server/public/partials/channel/playlist.handlebars new file mode 100644 index 00000000..e36a0558 --- /dev/null +++ b/server/public/partials/channel/playlist.handlebars @@ -0,0 +1,30 @@ +
+
+
+
+ + + + + 01:00 + + + + + + +  votes + + +
+ +
DELETE
+
+
+
diff --git a/server/public/partials/channel/suggestions.handlebars b/server/public/partials/channel/suggestions.handlebars new file mode 100644 index 00000000..b4f4a1ba --- /dev/null +++ b/server/public/partials/channel/suggestions.handlebars @@ -0,0 +1,8 @@ + diff --git a/server/public/partials/channel/tabs.handlebars b/server/public/partials/channel/tabs.handlebars new file mode 100644 index 00000000..529c1e70 --- /dev/null +++ b/server/public/partials/channel/tabs.handlebars @@ -0,0 +1,23 @@ +
+ + +
+
+ +
+ 0/0 +
+ clear +
+
+ {{> channel/playlist}} + {{> channel/suggestions}} + {{> channel/chat}} +
diff --git a/server/public/partials/frontpage/channel.handlebars b/server/public/partials/frontpage/channel.handlebars new file mode 100644 index 00000000..79b01006 --- /dev/null +++ b/server/public/partials/frontpage/channel.handlebars @@ -0,0 +1,26 @@ +
  • + +
  • diff --git a/server/public/partials/frontpage/channels.handlebars b/server/public/partials/frontpage/channels.handlebars new file mode 100644 index 00000000..2aaadd3c --- /dev/null +++ b/server/public/partials/frontpage/channels.handlebars @@ -0,0 +1,5 @@ +
    +
      + {{> frontpage/channel}} +
    +
    diff --git a/server/public/partials/frontpage/header.handlebars b/server/public/partials/frontpage/header.handlebars new file mode 100644 index 00000000..839ad90d --- /dev/null +++ b/server/public/partials/frontpage/header.handlebars @@ -0,0 +1,64 @@ +
    + + + + + +
    diff --git a/server/public/partials/frontpage/search/desktop.handlebars b/server/public/partials/frontpage/search/desktop.handlebars new file mode 100644 index 00000000..f92a0647 --- /dev/null +++ b/server/public/partials/frontpage/search/desktop.handlebars @@ -0,0 +1,28 @@ +
    +
    +
    Create a radio channel, collaborate and listen
    +
    +
    +

    zoff.me/

    + + +
    +
    +
    +
    Live & democratic playlists with YouTube Music
    +
    Play everywhere — No login required
    +
    +
    diff --git a/server/public/partials/frontpage/search/mobile.handlebars b/server/public/partials/frontpage/search/mobile.handlebars new file mode 100644 index 00000000..46a0f1b3 --- /dev/null +++ b/server/public/partials/frontpage/search/mobile.handlebars @@ -0,0 +1,19 @@ + diff --git a/server/public/partials/remote/buttons.handlebars b/server/public/partials/remote/buttons.handlebars new file mode 100644 index 00000000..6bb3c484 --- /dev/null +++ b/server/public/partials/remote/buttons.handlebars @@ -0,0 +1,11 @@ + diff --git a/server/public/partials/remote/header.handlebars b/server/public/partials/remote/header.handlebars new file mode 100644 index 00000000..065f7056 --- /dev/null +++ b/server/public/partials/remote/header.handlebars @@ -0,0 +1,50 @@ +
    + + + +
    diff --git a/server/public/partials/remote/input.handlebars b/server/public/partials/remote/input.handlebars new file mode 100644 index 00000000..065939f2 --- /dev/null +++ b/server/public/partials/remote/input.handlebars @@ -0,0 +1,16 @@ +
    +
    + + +
    +
    diff --git a/server/public/partials/remote/volume.handlebars b/server/public/partials/remote/volume.handlebars new file mode 100644 index 00000000..39fb355e --- /dev/null +++ b/server/public/partials/remote/volume.handlebars @@ -0,0 +1,4 @@ +
    +
    + volume_up +
    diff --git a/server/routing/router.js b/server/routing/router.js index 74cf9663..04d9c6b3 100644 --- a/server/routing/router.js +++ b/server/routing/router.js @@ -12,38 +12,7 @@ router.use(function(req, res, next) { }); router.route('/:channel_name').get(function(req, res, next){ - try{ - var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0]; - var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split("."); - if(url != "zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") { - res.redirect("https://zoff.me"); - return; - } - if(subdomain[0] == "remote") { - var data = { - year: 2017, - javascript_file: "remote.min.js" - } - res.render('layouts/remote', data); - } else if(subdomain.length >= 2 && subdomain[0] == "www") { - res.redirect("https://zoff.me"); - } else { - if(req.params.channel_name == "_embed") { - res.sendFile(path.join(pathThumbnails, '/public/assets/html/embed.html')); - } else if(req.params.channel_name == "o_callback") { - res.sendFile(path.join(pathThumbnails, '/public/assets/html/callback.html')); - } else { - var data = { - list_name: capitalizeFirstLetter(req.params.channel_name), - year: 2017, - javascript_file: "main.min.js" - } - res.render('layouts/channel', data); - } - } - } catch(e) { - res.redirect("https://zoff.me"); - } + channel(req, res, next); }); router.route('/api/frontpages').get(function(req, res) { @@ -120,46 +89,6 @@ router.route('/api/imageblob').post(function(req, res) { }); }); -/* - * - * TODO: - * - * Add custom userplaylists, only visible for those with that specific cookie - * - * -router.route('/:user_name/:channel_name').get(function(req, res, next){ - var protocol = req.protocol; - var subdomain = req.headers['x-forwarded-host'].split("."); - - if((subdomain[0] != 'localhost' && !(subdomain.length >= 2 && subdomain[1] == 'localhost')) && protocol != "https") { - res.redirect("https://zoff.me"); - return; - } - if(subdomain[0] == "remote") { - var data = { - year: 2017, - javascript_file: "remote.min.js" - } - res.render('layouts/remote', data); - } else if(subdomain.length >= 2 && subdomain[0] == "www") { - res.redirect("https://zoff.me"); - } else { - if(req.params.channel_name == "_embed") { - res.sendFile(path.join(__dirname, '/public/assets/html/embed.html')); - } else if(req.params.channel_name == "o_callback") { - res.sendFile(path.join(__dirname, '/public/assets/html/callback.html')); - } else { - var data = { - list_name: capitalizeFirstLetter(req.params.channel_name), - year: 2017, - javascript_file: "main.min.js" - } - res.render('layouts/channel', data); - } - } -}); -*/ - router.route('/api/mail').post(function(req, res) { let transporter = nodemailer.createTransport(mailconfig); @@ -191,35 +120,15 @@ router.route('/api/mail').post(function(req, res) { }); router.route('/').get(function(req, res, next){ - try{ - var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0]; - var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split("."); - if(url != "zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") { - res.redirect("https://zoff.me"); - return; - } - if(subdomain[0] == "remote") { - var data = { - year: 2017, - javascript_file: "remote.min.js" - } - res.render('layouts/remote', data); - } else if(subdomain[0] == "www") { - res.redirect("https://zoff.me"); - } else { - var data = { - year: 2017, - javascript_file: "main.min.js" - } - res.render('layouts/frontpage', data); - } - } catch(e) { - //console.log(e); - //res.redirect("https://zoff.me"); - } + root(req, res, next); }); + router.route('/').post(function(req, res, next){ + root(req, res, next); +}); + +function root(req, res, next) { try{ var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0]; var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split("."); @@ -238,7 +147,7 @@ router.route('/').post(function(req, res, next){ } else { var data = { year: 2017, - javascript_file: "main.min.js" + javascript_file: "main.min.js", } res.render('layouts/frontpage', data); } @@ -246,9 +155,9 @@ router.route('/').post(function(req, res, next){ //console.log(e); //res.redirect("https://zoff.me"); } -}); +} -router.route('/:channel_name').post(function(req, res, next){ +function channel(req, res, next) { try{ var url = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'] : req.headers.host.split(":")[0]; var subdomain = req.headers['x-forwarded-host'] ? req.headers['x-forwarded-host'].split(".") : req.headers.host.split(":")[0].split("."); @@ -281,9 +190,7 @@ router.route('/:channel_name').post(function(req, res, next){ } catch(e) { res.redirect("https://zoff.me"); } -}); - - +} function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1);