Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Blade #216

Open
wants to merge 8 commits into
base: soundtrack.io
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- '0.10'
- '8'
services:
- mongodb
- redis-server
after_script: istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
after_script: istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --exit && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
3 changes: 3 additions & 0 deletions controllers/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var async = require('async');
var _ = require('underscore');

module.exports = {
reset: function (req, res, next) {
res.render('forgot-password');
},
profile: function(req, res, next) {
Person.findOne({ slug: req.param('usernameSlug') }).exec(function(err, person) {
if (!person) return next();
Expand Down
2 changes: 1 addition & 1 deletion models/Person.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var PersonSchema = new Schema({
, preferences: {
scrobble: { type: Boolean, default: true }
}
, _playlists: [ { type: ObjectId , ref: 'Playlist' } ]
, _playlists: [ { type: ObjectId , ref: 'Playlist', required: true } ]
});

PersonSchema.plugin(passportLocalMongoose);
Expand Down
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"name": "soundtrack.io",
"version": "0.0.0",
"name": "@fabric/soundtrack",
"version": "0.1.0-pre",
"description": "soundtrack.io is a collaborative online jukebox.",
"main": "soundtrack.js",
"scripts": {
"test": "mocha",
"coverage": "NODE_ENV=test istanbul cover _mocha -- --recursive",
"test": "mocha --exit",
"coverage": "NODE_ENV=test istanbul cover _mocha -- --recursive --exit",
"start": "node ./soundtrack.js"
},
"repository": "[email protected]:martindale/soundtrack.io.git",
"author": "Eric Martindale",
"license": "MIT",
"dependencies": {
"async": "~0.2.9",
"body-parser": "^1.11.0",
"blade": "^3.3.1",
"body-parser": "^1.18.3",
"connect-redis": "^2.2.0",
"escape-html": "^1.0.3",
"express": "^4.11.2",
"express-session": "^1.10.2",
"express": "^4.16.3",
"express-session": "^1.15.6",
"flashify": "~0.1.2",
"heapdump": "^0.3.5",
"jade": "~0.32.0",
"lastfmapi": "git://github.com/martindale/node-lastfmapi#https-redirect-fix",
"marked": "~0.2.9",
"moment": "^2.10.2",
"marked": "^0.4.0",
"moment": "^2.22.2",
"mongoose": "~3.6.14",
"mongoose-agency": "0.0.0",
"mongoose-slug": "~1.3.0",
Expand All @@ -35,14 +35,13 @@
"passport-spotify": "^0.1.0",
"redis": "^0.12.1",
"restler": "git+http://github.com/danwrong/restler.git",
"sockjs": "^0.3.12",
"sockjs": "^0.3.19",
"speakingurl": "~0.9.0",
"underscore": "~1.4.4",
"validator": "~1.3.0"
"underscore": "~1.4.4"
},
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.5",
"mocha": "^2.1.0"
"coveralls": "^3.0.2",
"istanbul": "^0.4.5",
"mocha": "^5.2.0"
}
}
6 changes: 5 additions & 1 deletion soundtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var app = express();
var http = require('http');
var rest = require('restler');
var async = require('async');
var blade = require('blade');
var redis = require('redis');
var sockjs = require('sockjs');

Expand Down Expand Up @@ -46,8 +47,9 @@ if (config.jobs && config.jobs.enabled) {
});
}

app.use(blade.middleware(__dirname + '/views'));
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view engine', 'blade');
app.set('strict routing', true);
app.use(express.static(__dirname + '/public'));

Expand Down Expand Up @@ -182,6 +184,7 @@ var lexers = {
};
lexers.chat.rules.link = /^\[((?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*)\]\(\s*<?([^\s]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*\)/;

app.locals.includeSource = true;
app.locals.pretty = true;
app.locals.moment = require('moment');
app.locals.marked = otherMarked;
Expand Down Expand Up @@ -705,6 +708,7 @@ app.get('/', function(req, res, next) {
}, pages.index );
app.get('/about', redirectToMainSite , pages.about );
app.get('/help', redirectToMainSite , pages.help );
app.get('/forgot-password', redirectToMainSite , people.reset);

app.get('/playlist.json', requireRoom , function(req, res) {
res.send( app.rooms[ req.room ].playlist );
Expand Down
5 changes: 5 additions & 0 deletions views/404.blade
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include "layout"
block content
.well.content-well
h1 404 lol
p Where'd you get <em>that</em> link from?
35 changes: 35 additions & 0 deletions views/artist.blade
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
extends layout

block content
.well.content-well
img.avatar-large.pull-left(src="#{artist.image.url}")

.pull-right
strong Last Updated:
abbr(title="#{artist.tracking.tracks.updated}") #{artist.tracking.tracks.updated}

if (user && user.roles.indexOf('editor') >= 0)
a.btn(href="#", onclick="$('form#edit-artist-form').slideDown(); return false;") edit

h1 #{artist.name}
.artist-bio !{artist.bio}

form#edit-artist-form.hide(action="/#{artist.slug}", method="POST")
input(type="hidden", name="artistID", value="#{artist._id}")
input(type="text", name="name", value="#{artist.name}")
textarea(type="text", name="bio") #{artist.bio}

input.btn(type="submit", value="Submit")

h5 #{trackCount} known tracks
table.table.tablesorter
thead
tr
th Artist
th Title
th Length
th Plays
th Controls
tbody
for track in tracks
include partials/track-row
4 changes: 4 additions & 0 deletions views/forgot-password.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends layout
block content
h2 Reset Keys
p Join <a href="https://chat.fabric.pub/#/room/#soundtrack:fabric.pub"><code>#soundtrack:fabric.pub</code></a> and request an operator.
23 changes: 23 additions & 0 deletions views/iframe.blade
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extends layouts-iframe

block content
h1 hello, iframe

script(src="/js/jquery.min.js")

script.
window.onload = function() {
window.addEventListener('message', function(e) {
var message = JSON.parse(e.data);
console.log('cross-frame message', message );

switch (message.method) {
case 'queue':
$.post('/playlist', message.data , function(result) {
console.log(result);
});
break;
}

});
}
4 changes: 4 additions & 0 deletions views/index.blade
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include "layout"
replace block content
audio#player
maki-shoutbox(src="/messages")
9 changes: 9 additions & 0 deletions views/layout.blade
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!!! 5
html(lang="en")
head
title soundtrack
body
#site
block content
script(src="bundle.js")
script(src="/blade/plugins/liveui.js")
12 changes: 12 additions & 0 deletions views/login.blade
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
include "layout.jade"
block content
.well.content-well
h1 Login
form(action="/login", method="post")
label(for="username") Username
input(type="text", name="username", placeholder="Username")
label(for="password") Password
input(type="password", name="password")
p
input.btn.btn-primary(type="submit")
a(href="/forgot-password", style="margin-left: 2em") Forgot Password?
2 changes: 1 addition & 1 deletion views/partials/message.jade
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
span.message-content !{sanitize(lexers.chat.output(message.message.substring(4))).xss()}
- else
strong(data-role="author", data-user-username="#{message._author.username}") #{message._author.username}:
span.message-content !{sanitize(lexers.chat.output(message.message)).xss()}
span.message-content !{lexers.chat.output(message.message)}
Loading