Skip to content

Commit

Permalink
hacky hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Davies committed Aug 26, 2013
1 parent bd8a4fc commit 0494fea
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ standard-app-packages
insecure
preserve-inputs
coffeescript
accounts-ui
npm
accounts-facebook
accounts-password
router
accounts-ui-unstyled
32 changes: 20 additions & 12 deletions client/music.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Meteor.subscribe("songs");
# Songs = new Meteor.Collection("song")
# Meteor.startup ->
# Template.songList.songs = ()->
# return Songs.find({},{limit:10})# {artist:{$regex: 'Big', $options: 'i'}})
Template.header.events =
Meteor.subscribe("allsongs")
Meteor.subscribe("usersongs")
Songs = new Meteor.Collection("song")
# Users = new Meteor.Collection("users")
console.log Meteor.users.find({},{limit:50})
Template.songs.songs = ()->
return Songs.find({},{limit:50})# {artist:{$regex: 'Big', $options: 'i'}})
Template.songs.users = ()->
return Meteor.users.find({},{limit:50,transform: (user)->
user.sngs = Songs.find({user:user.services?.facebook?.email},{limit:5})
# console.log "user.songs", user.sngs

return user
})# {artist:{$regex: 'Big', $options: 'i'}})
Template.songs.events =
'click #pause' : (ev)->
soundManager.pauseAll()
false
Expand All @@ -13,18 +22,17 @@ Template.header.events =
'click #progress' : (ev)->
player.progressClick(ev.layerX)
false
Template.songList.events =
'click tr' : (ev)->
# Template.songs.events =
'click a.play-song' : (ev)->
loading = $(ev.currentTarget).children(".loading-song")
loading.css {opacity: 0.5}
song =
title: ev.currentTarget.getAttribute('data-title')
artist: ev.currentTarget.getAttribute('data-artist')
Meteor.call 'getSong', song, (err, url) ->
song.url = url
player.create song
# console.log "return getsong", err, url
# document.getElementById('player').setAttribute('src', url)
# document.getElementById('player').play()
# Session.set('serverSimpleResponse', response);
loading.css {opacity: 0}
false

soundManager.setup
Expand Down
60 changes: 60 additions & 0 deletions client/music.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,64 @@
#loaded-bar {
background-color: #eee;
z-index: 2;
}

.loading-song {
opacity: 0;
}

.login-button {
-webkit-align-items: flex-start;
-webkit-appearance: none;
-webkit-user-select: none;
-webkit-writing-mode: horizontal-tb;
background-color: #4877e5;
background-image: none;
border-bottom-color: #2964cf;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-style: solid;
border-bottom-width: 1px;
border-image-outset: 0px;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: #2964cf;
border-left-style: solid;
border-left-width: 1px;
border-right-color: #2964cf;
border-right-style: solid;
border-right-width: 1px;
border-top-color: #2964cf;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-top-style: solid;
border-top-width: 1px;
box-sizing: border-box;
color: #FFF;
cursor: pointer;
display: inline-block;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight: normal;
height: 34px;
letter-spacing: normal;
line-height: 20px;
margin-bottom: 5px;
margin-left: 0px;
margin-right: 0px;
margin-top: 5px;
padding-bottom: 6px;
padding-left: 12px;
padding-right: 12px;
padding-top: 6px;
text-align: center;
text-indent: 0px;
text-shadow: none;
text-transform: none;
vertical-align: middle;
white-space: nowrap;
word-spacing: 0px;
writing-mode: lr-tb;
}
175 changes: 88 additions & 87 deletions client/music.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,114 +6,115 @@
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.no-icons.min.css" rel="stylesheet" type="text/css">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body></body>
<body>
{{#isolate}} {{renderPage}} {{/isolate}}
</body>

<template name="layout">
<template name="header">
</template>

<template name="songs">
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
<div class="container">
{{yield 'header'}}
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse"><span class="sr-only">Toggle navigation</span></button> <a href="../" class="navbar-brand">Music</a>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li>
<a id='play'><i class='icon-play'></i></a>
</li>
<li>
<a id='pause'><i class='icon-pause'></i></a>
</li>
<li>
<a id='progress'><b id='loaded-bar'></b><b id='progress-bar'></b></a>
</li>
<li>
<a href="/signin" onclick="Meteor.Router.to('/signin'); return false;">Sign In Page</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a>{{loginButtons}}</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="jumbotron">
{{greeting}}
</div>
<div class="container bs-docs-container">
<div class="row">
<!-- <div class="col-md-3">
<!--
<div class="col-md-3">
<div class=" hidden-print affix-top" role="complementary">
</div>
</div> -->
<div class="col-md-12" role="main">

{{{yield}}}
<div class="bs-docs-section">
<div class="page-header">
<h1>Users</h1>
</div>
{{#each users}}
<h4>{{profile.name}}</h4>{{now}}
{{#each sngs}}
{{title}}<br>
{{/each}}
{{/each}}

<table class="table table-striped">
<thead>
<tr>
<th>Name</th><th>Artist</th><th>Album</th><th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<h1>Songs</h1>
<table class="table table-striped">
<thead>
<tr>
<th>Title</th><th>Artist</th><th>Album</th><th></th>
</tr>
</thead>
<tbody>
{{#each songs}}
<tr>
<td><a class='play-song' href="#" data-artist="{{artist}}" data-title="{{title}}">{{title}} <i class="loading-song icon-refresh icon-spin"></i></a></td>
<td>{{artist}}</td>
<td>{{album}}</td>
<td>{{rating}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</div>

<footer>
{{yield 'footer'}}
</footer>
</template>



<template name="header">

<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse"><span class="sr-only">Toggle navigation</span></button> <a href="../" class="navbar-brand">Music</a>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li>
<a id='play'><i class='icon-play'></i></a>
</li>
<li>
<a id='pause'><i class='icon-pause'></i></a>
</li>
<li>
<a id='progress'><b id='loaded-bar'></b><b id='progress-bar'></b></a>
</li>
<li>
<a href="{{pathFor 'home'}}">Home</a>
</li>
<li>
<a href="{{pathFor 'about'}}">About</a>
</li>
<li>
<a>{{loginButtons}}</a>
</li>
</ul>
</nav>

</template>

<template name="songs">
<div class="bs-docs-section">
<div class="page-header">
<h1 id="download">
Songs {{test}}
</h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>Title</th>
<th>Artist</th>
<th>Album</th>
<th></th>
</tr>
</thead>
<tbody>

{{> songList}}

</tbody>
</table>
</div>
</template>
<template name="songList">

{{#each songs}}
<tr data-artist="{{artist}}" data-title="{{title}}">
<td>{{title}}</td>
<td>{{artist}}</td>
<td>{{album}}</td>
<td>{{rating}}</td>
</tr>
<tr data-artist="{{artist}}" data-title="{{title}}">
<td>{{title}}</td>
<td>{{artist}}</td>
<td>{{album}}</td>
<td>{{rating}}</td>
</tr>
{{/each}}

</template>

<template name="home">
<h1>Home</h1>
</template>

<template name="about">
<h1>About</h1>
</template>

<template name="footer">
Footer
<template name="signin">
<div class="container bs-docs-container">
<div class="row">
<div class="col-md-12" role="main">
<h1>Sign In</h1>
{{loginButtons}}
</div>
</div>
</div>
</template>

16 changes: 6 additions & 10 deletions client/router.coffee
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
Meteor.Router.add
"/songs": ->
if Meteor.userId()
"songs"
else
"signin"

"/": "songs"
"/songs": "songs"
"/signin": "signin"
"*": "not_found"




Meteor.Router.filters isSignedIn: (page) ->
if Meteor.loggingIn()
"loading"
else if Meteor.user() and page == "signin"
"songs"
else if Meteor.user()
page
else
"signin"



Meteor.Router.filter('isSignedIn', {except: 'signin'})
Meteor.Router.filter('isSignedIn')



Expand Down
3 changes: 3 additions & 0 deletions packages/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ router
page-js-ie-support
HTML5-History-API
iron-router
accounts-ui-bootstrap-3
accounts-ui-bootstrap-dropdown
publish-with-relations
21 changes: 19 additions & 2 deletions server/songs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,25 @@ Meteor.startup ->
for s in songs
Songs.insert(s)

Meteor.publish "songs", ()->


Meteor.publish "allsongs", ()->
if @userId
return Songs.find({}) # {artist:{$regex: 'Big', $options: 'i'}})
else
return undefined
return false


Meteor.publish "usersongs", (id) ->
if @userId
users = Meteor.users.find({}, {
transform: (user)->
user.now = new Date()
console.log "transform user", user
return user
# Songs.find({})

})
return users
else
return false
Loading

0 comments on commit 0494fea

Please sign in to comment.