mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Moved api-keys out of 'sight', and added analytics as optional
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ server/config/api_key.js
|
|||||||
server/config/mongo_config.js
|
server/config/mongo_config.js
|
||||||
server/config/cert_config.js
|
server/config/cert_config.js
|
||||||
server/config/recaptcha.js
|
server/config/recaptcha.js
|
||||||
|
server/config/analytics.js
|
||||||
server/public/assets/dist/callback.min.js
|
server/public/assets/dist/callback.min.js
|
||||||
server/public/assets/dist/embed.min.js
|
server/public/assets/dist/embed.min.js
|
||||||
server/public/assets/dist/main.min.js
|
server/public/assets/dist/main.min.js
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ mongo_config.js
|
|||||||
|
|
||||||
in ```/server/config```. There are ```*.example.js``` files for all the ones mentioned above. If you're going to deploy the server with a certificate, you also need to create the ```cert_config.js``` in ```/server/config/```. If you want the mailing to work, take a look at ```mailconfig.example.js``` and ```recaptcha.example.js```. You'll need ```mailconfig.js``` and ```recaptcha.js``` for this to work.
|
in ```/server/config```. There are ```*.example.js``` files for all the ones mentioned above. If you're going to deploy the server with a certificate, you also need to create the ```cert_config.js``` in ```/server/config/```. If you want the mailing to work, take a look at ```mailconfig.example.js``` and ```recaptcha.example.js```. You'll need ```mailconfig.js``` and ```recaptcha.js``` for this to work.
|
||||||
|
|
||||||
|
If you want to use Google Analytics, have a look at ```analytics.example.js``` in ```server/config/```.
|
||||||
|
|
||||||
Use ```$ npm start``` to start the server.
|
Use ```$ npm start``` to start the server.
|
||||||
|
|
||||||
### About
|
### About
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ var gulp = require('gulp'),
|
|||||||
concat = require('gulp-concat');
|
concat = require('gulp-concat');
|
||||||
|
|
||||||
gulp.task('js', function () {
|
gulp.task('js', function () {
|
||||||
gulp.src(['server/VERSION.js', 'server/public/assets/js/*.js', '!server/public/assets/js/embed*', '!server/public/assets/js/remotecontroller.js', '!server/public/assets/js/callback.js'])
|
gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/*.js', '!server/public/assets/js/embed*', '!server/public/assets/js/remotecontroller.js', '!server/public/assets/js/callback.js'])
|
||||||
.pipe(uglify({
|
.pipe(uglify({
|
||||||
mangle: true,
|
mangle: true,
|
||||||
compress: true,
|
compress: true,
|
||||||
@@ -15,7 +15,7 @@ gulp.task('js', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('embed', function () {
|
gulp.task('embed', function () {
|
||||||
gulp.src(['server/VERSION.js', 'server/public/assets/js/player.js', 'server/public/assets/js/helpers.js', 'server/public/assets/js/playercontrols.js', 'server/public/assets/js/list.js', 'server/public/assets/js/embed.js', '!server/public/assets/js/frontpage*', '!server/public/assets/js/remotecontroller.js', 'server/public/assets/js/hostcontroller.js'])
|
gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/player.js', 'server/public/assets/js/helpers.js', 'server/public/assets/js/playercontrols.js', 'server/public/assets/js/list.js', 'server/public/assets/js/embed.js', '!server/public/assets/js/frontpage*', '!server/public/assets/js/remotecontroller.js', 'server/public/assets/js/hostcontroller.js'])
|
||||||
.pipe(uglify({
|
.pipe(uglify({
|
||||||
mangle: true,
|
mangle: true,
|
||||||
compress: true,
|
compress: true,
|
||||||
@@ -26,7 +26,7 @@ gulp.task('embed', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('callback', function () {
|
gulp.task('callback', function () {
|
||||||
gulp.src(['server/VERSION.js', 'server/public/assets/js/callback.js'])
|
gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/callback.js'])
|
||||||
.pipe(uglify({
|
.pipe(uglify({
|
||||||
mangle: true,
|
mangle: true,
|
||||||
compress: true,
|
compress: true,
|
||||||
@@ -41,7 +41,7 @@ gulp.task('build', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('remotecontroller', function () {
|
gulp.task('remotecontroller', function () {
|
||||||
gulp.src(['server/VERSION.js', 'server/public/assets/js/remotecontroller.js'])
|
gulp.src(['server/VERSION.js', 'server/config/api_key.js', 'server/public/assets/js/remotecontroller.js'])
|
||||||
.pipe(uglify({
|
.pipe(uglify({
|
||||||
mangle: true,
|
mangle: true,
|
||||||
compress: true,
|
compress: true,
|
||||||
|
|||||||
3
server/config/analytics.example.js
Normal file
3
server/config/analytics.example.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
var analytics = "xxxx";
|
||||||
|
|
||||||
|
module.exports = analytics;
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
var key = "xxxx";
|
var api_key = "xxxx";
|
||||||
|
|
||||||
module.exports = key;
|
try {
|
||||||
|
module.exports = api_key;
|
||||||
|
} catch(e) {}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ var w_p = true;
|
|||||||
var hasadmin = 0;
|
var hasadmin = 0;
|
||||||
var list_html = $("#list-song-html").html();
|
var list_html = $("#list-song-html").html();
|
||||||
var unseen = false;
|
var unseen = false;
|
||||||
var api_key = "***REMOVED***";
|
|
||||||
var searching = false;
|
var searching = false;
|
||||||
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
|
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
|
||||||
var conf = [];
|
var conf = [];
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ var Search = {
|
|||||||
if(search_input !== ""){
|
if(search_input !== ""){
|
||||||
searching = true;
|
searching = true;
|
||||||
var keyword= encodeURIComponent(search_input);
|
var keyword= encodeURIComponent(search_input);
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id&type=video&order=viewCount&safeSearch=none&maxResults=25";
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id&type=video&order=relevance&safeSearch=none&maxResults=25";
|
||||||
yt_url+="&q="+keyword;
|
yt_url+="&q="+keyword;
|
||||||
if(music)yt_url+="&videoCategoryId=10";
|
if(music)yt_url+="&videoCategoryId=10";
|
||||||
if(pagination) yt_url += "&pageToken=" + pagination;
|
if(pagination) yt_url += "&pageToken=" + pagination;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
ga('create', '***REMOVED***', 'auto');
|
ga('create', '{{{ analytics }}}', 'auto');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
|
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ var router = express.Router();
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
var year = new Date().getYear()+1900;
|
var year = new Date().getYear()+1900;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var analytics = "xx";
|
||||||
|
try {
|
||||||
|
analytics = require(path.join(path.join(__dirname, '../../config/'), 'analytics.js'));
|
||||||
|
} catch(e) {
|
||||||
|
console.log("No analytics-id found");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
var Recaptcha = require('express-recaptcha');
|
var Recaptcha = require('express-recaptcha');
|
||||||
var recaptcha_config = require(path.join(path.join(__dirname, '../../config/'), 'recaptcha.js'));
|
var recaptcha_config = require(path.join(path.join(__dirname, '../../config/'), 'recaptcha.js'));
|
||||||
@@ -52,7 +57,8 @@ function root(req, res, next) {
|
|||||||
var data = {
|
var data = {
|
||||||
year: year,
|
year: year,
|
||||||
javascript_file: "remote.min.js",
|
javascript_file: "remote.min.js",
|
||||||
captcha: res.recaptcha
|
captcha: res.recaptcha,
|
||||||
|
analytics: analytics
|
||||||
}
|
}
|
||||||
res.render('layouts/client/remote', data);
|
res.render('layouts/client/remote', data);
|
||||||
} else if(subdomain[0] == "www") {
|
} else if(subdomain[0] == "www") {
|
||||||
@@ -61,7 +67,8 @@ function root(req, res, next) {
|
|||||||
var data = {
|
var data = {
|
||||||
year: year,
|
year: year,
|
||||||
javascript_file: "main.min.js",
|
javascript_file: "main.min.js",
|
||||||
captcha: res.recaptcha
|
captcha: res.recaptcha,
|
||||||
|
analytics: analytics
|
||||||
}
|
}
|
||||||
res.render('layouts/client/frontpage', data);
|
res.render('layouts/client/frontpage', data);
|
||||||
}
|
}
|
||||||
@@ -83,7 +90,8 @@ function channel(req, res, next) {
|
|||||||
var data = {
|
var data = {
|
||||||
year: year,
|
year: year,
|
||||||
javascript_file: "remote.min.js",
|
javascript_file: "remote.min.js",
|
||||||
captcha: res.recaptcha
|
captcha: res.recaptcha,
|
||||||
|
analytics: analytics
|
||||||
}
|
}
|
||||||
res.render('layouts/client/remote', data);
|
res.render('layouts/client/remote', data);
|
||||||
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
|
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
|
||||||
@@ -100,6 +108,7 @@ function channel(req, res, next) {
|
|||||||
year: year,
|
year: year,
|
||||||
javascript_file: "main.min.js",
|
javascript_file: "main.min.js",
|
||||||
captcha: res.recaptcha,
|
captcha: res.recaptcha,
|
||||||
|
analytics: analytics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user