Skip to content

Commit

Permalink
iron-router version
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Davies committed Aug 24, 2013
0 parents commit bd8a4fc
Show file tree
Hide file tree
Showing 27 changed files with 661 additions and 0 deletions.
1 change: 1 addition & 0 deletions .meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
14 changes: 14 additions & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

standard-app-packages
insecure
preserve-inputs
coffeescript
accounts-ui
npm
accounts-facebook
accounts-password
router
1 change: 1 addition & 0 deletions .meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.6.5
81 changes: 81 additions & 0 deletions client/_soundmanager2-nodebug-jsmin.js

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions client/music.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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 =
'click #pause' : (ev)->
soundManager.pauseAll()
false
'click #play' : (ev)->
player.play()
false
'click #progress' : (ev)->
player.progressClick(ev.layerX)
false
Template.songList.events =
'click tr' : (ev)->
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);
false

soundManager.setup
url: '/swf/'
flashVersion: 9
onready: ()->
# // Ready to use; soundManager.createSound() etc. can now be called.

player =
list: []
current: null
pause: ()->
soundManager.pause()
play: ()->
@current.play()
progressClick: (prog)->
position = @duration() * (prog / $("#progress").width())
@current.setPosition(position)
duration: ()->
duration = if @current.bytesLoaded < @current.bytesTotal then @current.durationEstimate else @current.duration
return duration
create: (song)->
sound = soundManager.createSound
id: song.SongID
url: song.url
autoLoad: true
autoPlay: true
onload: ()->
console.log('The sound '+@id+' loaded!', song)
whileplaying: ()->
duration = if @bytesLoaded < @bytesTotal then @durationEstimate else @duration
width = (@position/duration)*100
$("#progress-bar").width(width+"%")
whileloading: ()->
width = (@bytesLoaded / @bytesTotal)*100
$("#loaded-bar").width(width+"%")


# console.log('at pos: '+@position, @)
volume: 50
@list.push sound
@current = sound
27 changes: 27 additions & 0 deletions client/music.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#progress {
height: 10px;
width: 200px;
background-color: #ccc;
position: relative;
padding: 0;
margin: 20px 0 0 0;
display: inline-block;

}
#progress b {
position: absolute;
width: 0;
display: block;
left: 0;
height: 10px;
top: 0;
}
#progress-bar {
background-color: #666;
z-index: 3;
}

#loaded-bar {
background-color: #eee;
z-index: 2;
}
119 changes: 119 additions & 0 deletions client/music.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<head>
<title>
music
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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>

<template name="layout">
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
<div class="container">
{{yield 'header'}}
</div>
</header>
<div class="jumbotron">
{{greeting}}
</div>
<div class="container bs-docs-container">
<div class="row">
<!-- <div class="col-md-3">
<div class=" hidden-print affix-top" role="complementary">
</div>
</div> -->
<div class="col-md-12" role="main">

{{{yield}}}
</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>
{{/each}}

</template>

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

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

<template name="footer">
Footer
</template>

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

"*": "not_found"




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



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





# iron router version
# Router.map ->
# @route 'home', path: '/'
# @route 'about'
# @route 'songs',
# waitOn: songsSub
# data: ()->
# songs: Songs.find({},{limit:10})# {artist:{$regex: 'Big', $options: 'i'}})


# Router.configure layout: 'layout'
# songsSub = Meteor.subscribe("songs")
# Songs = new Meteor.Collection("song")

# class @SongsController extends RouteController
# template: 'songs'

# renderTemplates:
# 'header': to: 'header'
# 'footer': to: 'footer'

# data: ->
# songs: Songs.find({},{limit:10})# {artist:{$regex: 'Big', $options: 'i'}})

# run: ->
# console.log 'running'#, @data()
# super

3 changes: 3 additions & 0 deletions packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"grooveshark": "0.0.3"
}
4 changes: 4 additions & 0 deletions packages/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
router
page-js-ie-support
HTML5-History-API
iron-router
1 change: 1 addition & 0 deletions packages/npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.build*
1 change: 1 addition & 0 deletions packages/npm/.npm/package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions packages/npm/.npm/package/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This directory and the files immediately inside it are automatically generated
when you change this package's NPM dependencies. Commit the files in this
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
so that others run the same versions of sub-dependencies.

You should NOT check in the node_modules directory that Meteor automatically
creates; if you are using git, the .gitignore file tells git to ignore it.
12 changes: 12 additions & 0 deletions packages/npm/.npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions packages/npm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var Future = Npm.require('fibers/future');

Meteor.require = function(moduleName) {
var module = Npm.require(moduleName);
return module;
};

Meteor.sync = function(asynFunction) {
var future = new Future();
var sent = false;
var payload;

setTimeout(function() {
asynFunction(done);
function done(err, result) {
if(!sent) {
payload = {
result: result,
error: err
};

if(future.ret) {
//for 0.6.4.1 and older
future.ret();
} else {
//for 0.6.5 and newer
future.return();
}
}
}
}, 0);

future.wait();
sent = true;

return payload;
};
Loading

0 comments on commit bd8a4fc

Please sign in to comment.