From 1b135c8ad7bf7d690482c1bcad1efacfbca39a1c Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Thu, 14 Apr 2011 22:34:52 +0400 Subject: [PATCH 01/15] Added repeat icon, fiexed shuffle and playlist icons. closes #37 --- app/views/layouts/application.html.erb | 2 +- public/images/player/playlist.svg | 15 +++++++-------- public/images/player/repeat.svg | 5 +++++ public/images/player/shuffle.svg | 8 ++++---- 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 public/images/player/repeat.svg diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1457fec..98c9e20 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -29,7 +29,7 @@
0:00
shu
-
rep
+
rep
pls
0
diff --git a/public/images/player/playlist.svg b/public/images/player/playlist.svg index 696f99a..aee908f 100644 --- a/public/images/player/playlist.svg +++ b/public/images/player/playlist.svg @@ -1,10 +1,9 @@ - - - - - - - - + + + + + + + \ No newline at end of file diff --git a/public/images/player/repeat.svg b/public/images/player/repeat.svg new file mode 100644 index 0000000..a9a3db3 --- /dev/null +++ b/public/images/player/repeat.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/public/images/player/shuffle.svg b/public/images/player/shuffle.svg index 4f1e016..4d00bca 100644 --- a/public/images/player/shuffle.svg +++ b/public/images/player/shuffle.svg @@ -14,7 +14,7 @@ 450 150 500 150 - L600 150 + L560 150 M100 150 @@ -31,11 +31,11 @@ 450 400 500 400 - L600 400 + L560 400 " style="stroke:rgb(200,200,200);stroke-width:70;" /> - - + + \ No newline at end of file From be7f9000f3965602490fa27f826e07c67bc8bc62 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Thu, 14 Apr 2011 22:55:39 +0400 Subject: [PATCH 02/15] Added buffering --- app/views/layouts/application.html.erb | 2 +- public/javascripts/player.js | 20 +++++++++++++++++++- public/stylesheets/player.css | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 98c9e20..4a0e809 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,7 +13,7 @@
<% if @hide_player.nil? -%>
- +
ply
diff --git a/public/javascripts/player.js b/public/javascripts/player.js index 7d742bb..0ba1029 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -1,4 +1,6 @@ var audio; +var prev_audio; +var next_audio; var utid; $(function(){ $.extend($.fn.disableTextSelect = function() { @@ -69,6 +71,11 @@ function updatePlayer() { progress = Math.round((cur_time / duration) * 390); $('#player .progress-loaded').css('width', loaded +'px') $('#player .progress-point').css('margin-left', progress +'px') + + /* Starting buffering next track */ + if (Math.round(cur_time / duration * 100) > 70) { + addAudio(next_audio); + } } utid = window.setTimeout(updatePlayer, 100); } @@ -79,7 +86,7 @@ function formatTime(sec) { return m +':'+ (s < 10 ? '0' : '') +s; } function playTrack(artist, track, id) { - $(audio).attr('src', '/listen/'+ id +'.mp3'); + switchAudio(id); $('#player .track-title').html(artist +' — '+ track); $('#player .time-played').html('0:00'); $('#player .time-left').html('0:00'); @@ -130,3 +137,14 @@ function addToPlaylist(artist, track, length, id) { } $('#player .playlist .count').html($('#playlist ul.list li').length); } +function addAudio(id) { + if ($('#audio_'+ id).length == 0) { + $('#audiobox').append(''); + } +} +function switchAudio(id) { + if ($('#audio_'+ id).length == 0) { + addAudio(id); + } + audio = document.getElementById('audio_'+ id); +} \ No newline at end of file diff --git a/public/stylesheets/player.css b/public/stylesheets/player.css index 2fbf50d..2afca94 100644 --- a/public/stylesheets/player.css +++ b/public/stylesheets/player.css @@ -1,3 +1,10 @@ +audio { + width: 0; + height: 0; + position: absolute; + top: -1000px; + left: -1000px; +} #player { position: fixed; width: 750px; From e5237b5fab8ea71a83c93618096e780411a8d7f7 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Fri, 15 Apr 2011 00:24:24 +0400 Subject: [PATCH 03/15] Progress bar click moves track position --- public/javascripts/player.js | 42 ++++++++++++++++++++++++----------- public/stylesheets/player.css | 4 ++++ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/public/javascripts/player.js b/public/javascripts/player.js index 0ba1029..a9007d6 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -46,7 +46,7 @@ $(function(){ playPrev(); }).disableTextSelect(); $('#player .next').click(function(){ - playNext(false); + playNext(); }).disableTextSelect(); $('#player .shuffle, #player .repeat').click(function(){ $(this).toggleClass('on'); @@ -55,13 +55,19 @@ $(function(){ $('#playlist').toggle(); //$('#playlist').data('jsp').reinitialise(); }) + $('#player .progress-bar').click(function(e){ + if (typeof(audio) !== 'undefined' && typeof(audio.duration) !== 'undefined') { + desired_progress = Math.abs(e.pageX - $(this).offset().left) / $('#player .progress-bar').innerWidth(); + audio.currentTime = Math.round(audio.duration * desired_progress); + } + }) $('#playlist').hide(); }) function updatePlayer() { duration = audio.duration; cur_time = audio.currentTime; if (cur_time == duration) { - playNext(true); + playNext(); } loaded = 0; if ((audio.buffered != undefined) && (audio.buffered.length != 0)) { @@ -73,7 +79,7 @@ function updatePlayer() { $('#player .progress-point').css('margin-left', progress +'px') /* Starting buffering next track */ - if (Math.round(cur_time / duration * 100) > 70) { + if (Math.round(cur_time / duration * 100) > 10) { addAudio(next_audio); } } @@ -87,6 +93,7 @@ function formatTime(sec) { } function playTrack(artist, track, id) { switchAudio(id); + setNext(); $('#player .track-title').html(artist +' — '+ track); $('#player .time-played').html('0:00'); $('#player .time-left').html('0:00'); @@ -94,27 +101,31 @@ function playTrack(artist, track, id) { $('#player .progress-point').css('margin-left', 0 +'px') $('#player .play').trigger('click'); } -function playPrev() { +function setPrev() { if ($('#playlist ul.list li').length == 0) return false; - if ($('#playlist ul.list li.now-playing').prev().length == 0) { - $('#playlist ul.list li:last').dblclick(); - } else { - $('#playlist ul.list li.now-playing').prev().dblclick(); + if (!audio) { + prev_audio = $(audio).attr('data-id'); } } -function playNext(auto) { +function setNext() { if ($('#playlist ul.list li').length == 0) return false; if ($('#player .shuffle').hasClass('on')) { - $('#playlist ul.list li').rand().dblclick(); + next_audio = $('#playlist ul.list li').rand().attr('data-id'); } if ($('#playlist ul.list li.now-playing').next().length == 0) { - if ((auto && $('#player .repeat').hasClass('on')) || !auto) { - $('#playlist ul.list li:first').dblclick(); + if ($('#player .repeat').hasClass('on')) { + next_audio = $('#playlist ul.list li:first').attr('data-id'); } } else { - $('#playlist ul.list li.now-playing').next().dblclick(); + next_audio = $('#playlist ul.list li.now-playing').next().attr('data-id'); } } +function playPrev() { + return false; +} +function playNext() { + $('#playlist ul.list li[data-id="'+ next_audio +'"]').dblclick(); +} function addToPlaylist(artist, track, length, id) { $('#playlist ul.list').append($( '
  • '+ @@ -136,6 +147,7 @@ function addToPlaylist(artist, track, length, id) { $('#playlist').jScrollPane(); } $('#player .playlist .count').html($('#playlist ul.list li').length); + setNext(); } function addAudio(id) { if ($('#audio_'+ id).length == 0) { @@ -143,6 +155,10 @@ function addAudio(id) { } } function switchAudio(id) { + if (audio) { + audio.pause(); + audio.currentTime = 0; + } if ($('#audio_'+ id).length == 0) { addAudio(id); } diff --git a/public/stylesheets/player.css b/public/stylesheets/player.css index 2afca94..ce8aa5d 100644 --- a/public/stylesheets/player.css +++ b/public/stylesheets/player.css @@ -90,6 +90,9 @@ audio { width: 390px; height: 3px; } + #player .progress-bar:hover { + cursor: pointer; + } #player .progress-loaded { float: left; width: 0; @@ -185,6 +188,7 @@ audio { } #playlist ul li.now-playing { background-color: #013; + font-weight: bold; } #playlist ul li .length { margin: 0 0.5em; From 5939bbff2c55d67f213befcdb9abbec05bb34070 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Fri, 15 Apr 2011 00:31:16 +0400 Subject: [PATCH 04/15] Player progress point margin fixed --- public/javascripts/player.js | 6 +++--- public/stylesheets/player.css | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/javascripts/player.js b/public/javascripts/player.js index a9007d6..1d90a50 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -76,7 +76,7 @@ function updatePlayer() { $('#player .time-left').html(formatTime(duration - cur_time)); progress = Math.round((cur_time / duration) * 390); $('#player .progress-loaded').css('width', loaded +'px') - $('#player .progress-point').css('margin-left', progress +'px') + $('#player .progress-point').css('margin-left', progress - $('#player .progress-point').width() +'px') /* Starting buffering next track */ if (Math.round(cur_time / duration * 100) > 10) { @@ -97,8 +97,8 @@ function playTrack(artist, track, id) { $('#player .track-title').html(artist +' — '+ track); $('#player .time-played').html('0:00'); $('#player .time-left').html('0:00'); - $('#player .progress-loaded').css('width', 0 +'px') - $('#player .progress-point').css('margin-left', 0 +'px') + $('#player .progress-loaded').css('width', '0px') + $('#player .progress-point').css('margin-left', '-6px') $('#player .play').trigger('click'); } function setPrev() { diff --git a/public/stylesheets/player.css b/public/stylesheets/player.css index ce8aa5d..0034c1f 100644 --- a/public/stylesheets/player.css +++ b/public/stylesheets/player.css @@ -105,7 +105,7 @@ audio { height: 6px; background-color: #013; margin-top: -4px; - margin-left: 0; + margin-left: -6px; border: #FFF 3px solid; border-radius: 6px; cursor: pointer; From 82f2624ed5cac69a0d8cb4cbcaa8875f343f75d2 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Fri, 15 Apr 2011 01:19:58 +0400 Subject: [PATCH 05/15] It fucking works. again. --- public/javascripts/player.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/javascripts/player.js b/public/javascripts/player.js index 1d90a50..355bf27 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -14,7 +14,6 @@ $(function(){ } }); }); - audio = document.getElementsByTagName('audio')[0]; $('#player .play').click(function(){ if (! audio.src) return; audio.play(); @@ -66,7 +65,7 @@ $(function(){ function updatePlayer() { duration = audio.duration; cur_time = audio.currentTime; - if (cur_time == duration) { + if (cur_time > 0 && cur_time == duration) { playNext(); } loaded = 0; @@ -151,11 +150,12 @@ function addToPlaylist(artist, track, length, id) { } function addAudio(id) { if ($('#audio_'+ id).length == 0) { - $('#audiobox').append(''); + $('#audiobox').append(''); + $('#audio_'+ id).attr('src', '/listen/'+ id +'.mp3'); } } function switchAudio(id) { - if (audio) { + if (typeof(audio) != 'undefined') { audio.pause(); audio.currentTime = 0; } From 2dc8b0da490301473cda7463057baa76212b7bb6 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Fri, 15 Apr 2011 02:40:57 +0400 Subject: [PATCH 06/15] Player next fixed --- public/javascripts/player.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/javascripts/player.js b/public/javascripts/player.js index 355bf27..130ac3e 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -15,7 +15,7 @@ $(function(){ }); }); $('#player .play').click(function(){ - if (! audio.src) return; + if (! audio) return; audio.play(); utid = window.setTimeout(updatePlayer, 100); $('#player .pause').show(); @@ -138,6 +138,7 @@ function addToPlaylist(artist, track, length, id) { playTrack(artist, track, id); $('#playlist li').removeClass('now-playing'); $(this).addClass('now-playing'); + setNext(); }) if ($('#playlist ul.list li').length == 1) { $('#playlist ul.list li:first').dblclick(); @@ -155,7 +156,8 @@ function addAudio(id) { } } function switchAudio(id) { - if (typeof(audio) != 'undefined') { + if (typeof(audio) != 'undefined' && audio.buffered.length != 0) { + console.log(audio, audio.buffered.length); audio.pause(); audio.currentTime = 0; } From 8a2780bfe45dc68b42a0aca01b15bc9fecfed9a5 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Fri, 15 Apr 2011 02:54:36 +0400 Subject: [PATCH 07/15] Shuffle and Repeat buttons redefines next track --- public/javascripts/player.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/player.js b/public/javascripts/player.js index 130ac3e..5c44270 100644 --- a/public/javascripts/player.js +++ b/public/javascripts/player.js @@ -49,6 +49,7 @@ $(function(){ }).disableTextSelect(); $('#player .shuffle, #player .repeat').click(function(){ $(this).toggleClass('on'); + setNext(); }).disableTextSelect(); $('#player .playlist').click(function(){ $('#playlist').toggle(); From b3e6a3d1c7a98b412eb61f36b05e21eedda72879 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sat, 16 Apr 2011 00:09:17 +0400 Subject: [PATCH 08/15] User profile update form --- app/controllers/user_controller.rb | 9 +++++++++ app/views/user/update.erb | 31 ++++++++++++++++++++++++++++++ config/routes.rb | 1 + public/stylesheets/register.css | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/views/user/update.erb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index b28b18c..b23ae4e 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -49,4 +49,13 @@ class UserController < ApplicationController redirect_to '/login' end end + + def update + @data = User.collection.find({session_key: Digest::SHA256.hexdigest(request.session['session_id'])}).first + unless @data.nil? + + else + render :json => 'wtf?' + end + end end diff --git a/app/views/user/update.erb b/app/views/user/update.erb new file mode 100644 index 0000000..4683966 --- /dev/null +++ b/app/views/user/update.erb @@ -0,0 +1,31 @@ +
    +

    Update ur profile!

    + <%= form_tag('/reg/complete', :method => 'post') do -%> + <%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @data.email %> + <%= label_tag 'name', 'Name' %><%= text_field_tag 'name', @data.name %> + <%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %>
    + <%= label_tag 'password_c', 'Confirm' %><%= password_field_tag 'password_c', nil %>
    +
    + <%= submit_tag 'I\'m done!' %> +
    + <% end -%> + +
    + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 598c993..3fd96d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ Beathaven::Application.routes.draw do match 'reg/:email/:code' => 'user#register', :constraints => { :email => /[-a-z0-9\._@]+/i, :code => /[a-f0-9]{64}/ } match 'reg/complete' => 'user#complete' match 'login' => 'user#login' + match 'user/profile' => 'user#update' match '*a', :to => 'errors#routing' end diff --git a/public/stylesheets/register.css b/public/stylesheets/register.css index dbe78a5..fc32198 100644 --- a/public/stylesheets/register.css +++ b/public/stylesheets/register.css @@ -23,7 +23,7 @@ font-size: 20px; line-height: 35px; } - #registration input[type="email"], input[type="password"] { + #registration input[type="email"], input[type="password"], input[type="text"] { width: 230px; font-size: 20px; border: #EAEAEA 1px solid; From 00918b93af1a02bbcbc1f6ec64e990f79d97f980 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sat, 16 Apr 2011 00:34:39 +0400 Subject: [PATCH 09/15] Update profile --- app/controllers/user_controller.rb | 7 ++++++- app/views/user/update.erb | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index b23ae4e..ed322ba 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -53,7 +53,12 @@ class UserController < ApplicationController def update @data = User.collection.find({session_key: Digest::SHA256.hexdigest(request.session['session_id'])}).first unless @data.nil? - + if request.request_method == 'POST' + if params[:name] + @data.name = params[:name] + end + User.collection.update({_id: @data._id}, @data.attributes) + end else render :json => 'wtf?' end diff --git a/app/views/user/update.erb b/app/views/user/update.erb index 4683966..dadb5c4 100644 --- a/app/views/user/update.erb +++ b/app/views/user/update.erb @@ -1,6 +1,6 @@

    Update ur profile!

    - <%= form_tag('/reg/complete', :method => 'post') do -%> + <%= form_tag('/user/profile', :method => 'post') do -%> <%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @data.email %> <%= label_tag 'name', 'Name' %><%= text_field_tag 'name', @data.name %> <%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %>
    @@ -16,11 +16,11 @@ $('#password').focus(); $('form').submit(function(){ $('#password_error, #password_c_error').html(''); - if ($('#password').val().length < 6) { + if ($('#password').val().length > 0 && $('#password').val().length < 6) { $('#password_error').html('* Password must be 6+ characters length'); $('#password').focus(); return false; - } else if ($('#password').val() != $('#password_c').val()) { + } else if ($('#password').val().length > 0 && $('#password').val() != $('#password_c').val()) { $('#password_c_error').html('* Password and confirmation doesn\'t match'); $('#password_c').focus(); return false; From b241ece155b24db9ed8a33cf640247d70268b6f5 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sat, 16 Apr 2011 12:31:47 +0400 Subject: [PATCH 10/15] Invites beta --- app/controllers/user_controller.rb | 28 +++++++++++++++++++++++++++- app/views/user/invite.erb | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 app/views/user/invite.erb diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index ed322ba..782c5c9 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,4 +1,8 @@ class UserController < ApplicationController + + @@invite_salt = 'Gouranga gives a fuck?!' + @@email_regex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/ + def login @hide_player = 1 unless params[:email].nil? or params[:password].nil? @@ -28,7 +32,7 @@ class UserController < ApplicationController @hide_player = 1 data = Invite.where(:email => params[:invite_email], :code => params[:invite_code]).first unless data.nil? - if params[:email].match(/\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\z/).nil? or + if params[:email].match(@@email_regex).nil? or params[:password].length < 6 or params[:password] != params[:password_c] redirect_to '/' @@ -63,4 +67,26 @@ class UserController < ApplicationController render :json => 'wtf?' end end + + def invite + @data = User.collection.find({session_key: Digest::SHA256.hexdigest(request.session['session_id'])}).first + unless @data.nil? + if @data.invites > 0 + pp 1 + if request.request_method == 'POST' + unless params[:email].nil? + if params[:email].match(@@email_regex) + Invite.collection.insert({email: params[:email], code: Digest::SHA256.hexdigest(params[:email] << @@invite_salt), referer: @data._id}) + @data.invites -= 1 + User.collection.update({_id: @data._id}, @data.attributes) + @ok = true + end + end + end + pp 2 + else + render :json => 'wtf?' + end + end + end end diff --git a/app/views/user/invite.erb b/app/views/user/invite.erb new file mode 100644 index 0000000..2ad90a3 --- /dev/null +++ b/app/views/user/invite.erb @@ -0,0 +1,23 @@ +
    +

    Help BeatHaven dominate those lousy humans!

    + <%= form_tag('/reg/complete', :method => 'post') do -%> + <%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @email %>
    +
    + <%= submit_tag 'I wanna get this guy in!' %> +
    + <% end -%> +
    + \ No newline at end of file From 40a51c2c513173e301d347bc170a9ceb7b9b0c57 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sat, 16 Apr 2011 13:05:30 +0400 Subject: [PATCH 11/15] Some site navigation & gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bf3418 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tmp/ +log/ From 3a90336e7c31d15ac7b60e2723cb4afbfb4225d2 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sat, 16 Apr 2011 13:06:23 +0400 Subject: [PATCH 12/15] Fuck, missed some files --- app/views/layouts/application.html.erb | 65 +++++++++++++++----------- config/routes.rb | 1 + public/stylesheets/beathaven.css | 49 +++++++++++++++++++ public/stylesheets/player.css | 9 ++-- 4 files changed, 92 insertions(+), 32 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4a0e809..30d0d20 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,36 +9,45 @@ <%= csrf_meta_tag %> + + <% if @hide_player.nil? -%> +
    +
    + +
    ply
    + + +
    0:00
    +
    +
    No track
    +
    +
    +
    +
    +
    +
    +
    0:00
    +
    shu
    +
    rep
    +
    + pls +
    0
    +
    +
    +
    +
      +
      +
      +
      + <%- end %>
      - <% if @hide_player.nil? -%> -
      -
      - -
      ply
      - - -
      0:00
      -
      -
      No track
      -
      -
      -
      -
      -
      -
      -
      0:00
      -
      shu
      -
      rep
      -
      - pls -
      0
      -
      -
      -
      -
        -
        - <%- end %> <%= yield %>
        diff --git a/config/routes.rb b/config/routes.rb index 3fd96d2..facd8b7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,7 @@ Beathaven::Application.routes.draw do match 'reg/complete' => 'user#complete' match 'login' => 'user#login' match 'user/profile' => 'user#update' + match 'user/invite' => 'user#invite' match '*a', :to => 'errors#routing' end diff --git a/public/stylesheets/beathaven.css b/public/stylesheets/beathaven.css index cdbb7db..bbf7180 100644 --- a/public/stylesheets/beathaven.css +++ b/public/stylesheets/beathaven.css @@ -132,3 +132,52 @@ h1.artist > span > span.play { padding: 0.2em; } + +#nav { + position: fixed; + z-index: 2; + top: 0; + left: 50%; + margin-left: -375px; + width: 750px; + height: 25px; + background-color: #000; + border-bottom: #222 1px solid; +} + #nav ul { + margin: 0 5px; + padding: 0; + list-style: none; + } + #nav ul li { + display: inline-block; + width: auto; + margin: 0 5px; + } + #nav ul li a { + color: #CCC; + line-height: 25px; + font-size: 12px; + text-decoration: none; + font-weight: bold; + } + #nav ul li a:hover { + color: #DDD; + } + +.corner-fix { + position: fixed; + width: 8px; + height: 8px; + background-color: #000; + top: 25px; + left: 50%; +} + +.corner-fix.left { + margin-left: -375px; +} + +.corner-fix.right { + margin-left: 367px; +} \ No newline at end of file diff --git a/public/stylesheets/player.css b/public/stylesheets/player.css index 0034c1f..722be5f 100644 --- a/public/stylesheets/player.css +++ b/public/stylesheets/player.css @@ -10,10 +10,11 @@ audio { width: 750px; height: 50px; left: 50%; - top: 0; + top: 25px; margin-left: -375px; background-color: #000; font-size: 12px; + border-radius: 8px; } #player .prev, #player .next, #player .play, #player .pause { float: left; @@ -155,10 +156,10 @@ audio { } #playlist { position: fixed; - top: 50px; + top: 75px; left: 50%; - width: 750px; - margin-left: -375px; + width: 734px; + margin-left: -367px; background-color: #000; opacity: 0.9; -moz-opacity: 0.9; From cd9e0f41fa899ed9d55b5ffc61bf928e82ddcb66 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sun, 17 Apr 2011 13:11:01 +0400 Subject: [PATCH 13/15] Database config --- config/database.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config/database.yml b/config/database.yml index 15e28ff..7eb1fe2 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,10 +1,14 @@ -# PostgreSQL version 9.0 -# gem install pg -development: +defaults: &defaults adapter: postgresql database: beathaven host: 192.168.0.128 username: postgres password: password pool: 5 - timeout: 5000 \ No newline at end of file + timeout: 5000 + +development: + <<: *defaults + +production: + <<: *defaults \ No newline at end of file From 84251686382226369602a3125b59e23f9e045873 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Wed, 20 Apr 2011 09:06:04 +0400 Subject: [PATCH 14/15] Style fixes --- public/javascripts/jquery.carousel.min.js | 5 +++++ public/javascripts/jquery.jcarousel.min.js | 16 ++++++++++++++++ public/stylesheets/beathaven.css | 3 ++- public/stylesheets/player.css | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 public/javascripts/jquery.carousel.min.js create mode 100755 public/javascripts/jquery.jcarousel.min.js diff --git a/public/javascripts/jquery.carousel.min.js b/public/javascripts/jquery.carousel.min.js new file mode 100644 index 0000000..cad7235 --- /dev/null +++ b/public/javascripts/jquery.carousel.min.js @@ -0,0 +1,5 @@ +/* jQuery Carousel 0.9.8 +Copyright 2010 Thomas Lanciaux and Pierre Bertet. +This software is licensed under the CC-GNU LGPL +*/ +(function(g){g.fn.carousel=function(q){var q=g.extend({direction:"horizontal",loop:false,dispItems:1,pagination:false,paginationPosition:"inside",nextBtn:'',prevBtn:'',btnsPosition:"inside",nextBtnInsert:"insertAfter",prevBtnInsert:"insertBefore",nextBtnInsertFn:false,prevBtnInsertFn:false,autoSlide:false,autoSlideInterval:3000,delayAutoSlide:false,combinedClasses:false,effect:"slide",slideEasing:"swing",animSpeed:300,equalWidths:"true",verticalMargin:0,callback:function(){},useAddress:false,adressIdentifier:"carousel",tabLabel:function(r){return r},showEmptyItems:true,ajaxMode:false,ajaxUrl:"",stopSlideBtn:false,stopSlideTextPause:"Pause",stopSlideTextPlay:"Play"},q);if(q.btnsPosition=="outside"){q.prevBtnInsert="insertBefore";q.nextBtnInsert="insertAfter"}q.delayAutoSlide=0+q.delayAutoSlide;return this.each(function(){var r={$elts:{},params:q,launchOnLoad:[]};r.$elts.carousel=g(this).addClass("js");r.$elts.content=g(this).children().css({position:"absolute",top:0});r.$elts.wrap=r.$elts.content.wrap('').parent().css({overflow:"hidden",position:"relative"});r.steps={first:0,count:r.$elts.content.children().length};r.$elts.loader=g('
        ').css({position:"absolute"});r.steps.last=r.steps.count-1;if(r.params.pagination){o(r)}if(g.isFunction(r.params.prevBtnInsertFn)){r.$elts.prevBtn=r.params.prevBtnInsertFn(r.$elts)}else{if(q.btnsPosition=="outside"){r.$elts.prevBtn=g(q.prevBtn)[q.prevBtnInsert](r.$elts.carousel)}else{r.$elts.prevBtn=g(q.prevBtn)[q.prevBtnInsert](r.$elts.wrap)}}if(g.isFunction(r.params.nextBtnInsertFn)){r.$elts.nextBtn=r.params.nextBtnInsertFn(r.$elts)}else{if(q.btnsPosition=="outside"){r.$elts.nextBtn=g(q.nextBtn)[q.nextBtnInsert](r.$elts.carousel)}else{r.$elts.nextBtn=g(q.nextBtn)[q.nextBtnInsert](r.$elts.wrap)}}r.$elts.nextBtn.addClass("carousel-control next carousel-next");r.$elts.prevBtn.addClass("carousel-control previous carousel-previous");r.lastItemsToLoad;d(r);r.$elts.carousel.attr("tabindex",0).add(r.$elts.carousel.children()).bind({focus:function(s){g(document).bind("keypress",function(t){switch(t.keyCode){case 39:r.$elts.nextBtn.click();break;case 37:r.$elts.prevBtn.click();break}switch(t.charCode){case 110:r.$elts.nextBtn.click();break;case 112:r.$elts.prevBtn.click();break}})},blur:function(){g(document).unbind("keypress")}});n(r);g(function(){c(r);g.each(r.launchOnLoad,function(s,t){t()});if(r.params.autoSlide){f(r)}if(q.stopSlideBtn==true){r.$elts.stopSlideBtn=g('");a(r)}})})};function c(s){var t=s.$elts.content.children();var r=0;t.each(function(){$item=g(this);$itemHeight=$item.outerHeight();if($itemHeight>r){r=$itemHeight}});if(s.params.verticalMargin>0){r=r+s.params.verticalMargin}t.height(r);var q=s.$elts.content.children(":first");s.itemWidth=q.outerWidth();if(s.params.direction=="vertical"){s.contentWidth=s.itemWidth}else{if(s.params.equalWidths){s.contentWidth=s.itemWidth*s.steps.count}else{s.contentWidth=(function(){var u=0;s.$elts.content.children().each(function(){u+=g(this).outerWidth()});return u})()}}s.$elts.content.width(s.contentWidth);s.itemHeight=r;if(s.params.direction=="vertical"){s.$elts.content.css({height:s.itemHeight*s.steps.count+"px"});s.$elts.content.parent().css({height:s.itemHeight*s.params.dispItems+"px"})}else{s.$elts.content.parent().css({height:s.itemHeight+"px"})}i(s)}function d(q){q.$elts.nextBtn.add(q.$elts.prevBtn).bind("enable",function(){var r=g(this).unbind("click").bind("click",function(){if(q.params.ajaxMode&&r.is(".next")&&b(q)==(p(q)-1)&&!q.lastItemsToLoad){h(q);q.$elts.content.ajaxSuccess(function(){})}else{e(q,j(q,(r.is(".next")?"next":"prev")));if(q.params.stopSlideBtn==true){q.$elts.stopSlideBtn.trigger("pause")}else{m(q)}}}).removeClass("disabled").removeAttr("disabled");if(q.params.combinedClasses){r.removeClass("next-disabled previous-disabled").removeAttr("disabled")}}).bind("disable",function(){var r=g(this).unbind("click").addClass("disabled").attr("disabled","disabled");if(q.params.combinedClasses){if(r.is(".next")){r.addClass("next-disabled")}else{if(r.is(".previous")){r.addClass("previous-disabled")}}}}).hover(function(){g(this).toggleClass("hover")})}function o(q){q.$elts.pagination=g('
        ')[((q.params.paginationPosition=="outside")?"insertAfter":"appendTo")](q.$elts.carousel).find("p");q.$elts.paginationBtns=g([]);q.$elts.content.find("li").each(function(r){if(r%q.params.dispItems==0){k(q,r)}})}function k(r,q){if(r.params.pagination){r.$elts.paginationBtns=r.$elts.paginationBtns.add(g(''+r.params.tabLabel(r.$elts.paginationBtns.length+1)+"").data("firstStep",q)).appendTo(r.$elts.pagination);r.$elts.paginationBtns.slice(0,1).addClass("active");r.$elts.paginationBtns.click(function(s){e(r,g(this).data("firstStep"));if(r.params.stopSlideBtn==true){r.$elts.stopSlideBtn.trigger("pause")}else{m(r)}})}}function n(q){if(q.params.useAddress&&g.isFunction(g.fn.address)){g.address.init(function(s){var r=g.address.pathNames();if(r[0]===q.params.adressIdentifier&&!!r[1]){e(q,r[1]-1)}else{g.address.value("/"+q.params.adressIdentifier+"/1")}}).change(function(s){var r=g.address.pathNames();if(r[0]===q.params.adressIdentifier&&!!r[1]){e(q,r[1]-1)}})}else{q.params.useAddress=false}}function e(q,r){q.params.callback(r);l(q,r);q.steps.first=r;i(q);if(q.params.useAddress){g.address.value("/"+q.params.adressIdentifier+"/"+(r+1))}}function j(r,q){if(q=="prev"){if(!r.params.showEmptyItems){if(r.steps.first==0){return((r.params.loop)?(r.steps.count-r.params.dispItems):false)}else{return Math.max(0,r.steps.first-r.params.dispItems)}}else{if((r.steps.first-r.params.dispItems)>=0){return r.steps.first-r.params.dispItems}else{return((r.params.loop)?(r.steps.count-r.params.dispItems):false)}}}else{if(q=="next"){if((r.steps.first+r.params.dispItems)
        ",buttonPrevHTML:"
        ",buttonNextEvent:"click",buttonPrevEvent:"click", buttonNextCallback:null,buttonPrevCallback:null,itemFallbackDimension:null},m=!1;g(window).bind("load.jcarousel",function(){m=!0});g.jcarousel=function(a,c){this.options=g.extend({},q,c||{});this.autoStopped=this.locked=!1;this.buttonPrevState=this.buttonNextState=this.buttonPrev=this.buttonNext=this.list=this.clip=this.container=null;if(!c||c.rtl===void 0)this.options.rtl=(g(a).attr("dir")||g("html").attr("dir")||"").toLowerCase()=="rtl";this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical? this.options.rtl?"right":"left":"top";for(var b="",d=a.className.split(" "),f=0;f
      • ").parent();if(this.container.size()===0)this.container=this.clip.wrap("
        ").parent();b!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1&&this.container.wrap('
        ');this.buttonPrev=g(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null)this.buttonPrev=g(this.options.buttonPrevHTML).appendTo(this.container);this.buttonPrev.addClass(this.className("jcarousel-prev"));this.buttonNext= g(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null)this.buttonNext=g(this.options.buttonNextHTML).appendTo(this.container);this.buttonNext.addClass(this.className("jcarousel-next"));this.clip.addClass(this.className("jcarousel-clip")).css({position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden",position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"}); !this.options.vertical&&this.options.rtl&&this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null,b=this.list.children("li"),e=this;if(b.size()>0){var h=0,i=this.options.offset;b.each(function(){e.format(this,i++);h+=e.dimension(this,j)});this.list.css(this.wh,h+100+"px");if(!c||c.size===void 0)this.options.size=b.size()}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display", "block");this.funcNext=function(){e.next()};this.funcPrev=function(){e.prev()};this.funcResize=function(){e.resizeTimer&&clearTimeout(e.resizeTimer);e.resizeTimer=setTimeout(function(){e.reload()},100)};this.options.initCallback!==null&&this.options.initCallback(this,"init");!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):this.setup()};var f=g.jcarousel;f.fn=f.prototype={jcarousel:"0.2.8"};f.fn.extend=f.extend=g.extend;f.fn.extend({setup:function(){this.prevLast= this.prevFirst=this.last=this.first=null;this.animating=!1;this.tail=this.resizeTimer=this.timer=null;this.inTail=!1;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,!0);this.prevFirst=this.prevLast=null;this.animate(a,!1);g(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize);this.options.setupCallback!==null&&this.options.setupCallback(this)}},reset:function(){this.list.empty();this.list.css(this.lt, "0px");this.list.css(this.wh,"10px");this.options.initCallback!==null&&this.options.initCallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.inTail&&this.list.css(this.lt,f.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=!1;this.options.reloadCallback!==null&&this.options.reloadCallback(this);if(this.options.visible!==null){var a=this,c=Math.ceil(this.clipping()/this.options.visible),b=0,d=0;this.list.children("li").each(function(f){b+=a.dimension(this, c);f+1this.options.size)c=this.options.size;for(var b=a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasClass("jcarousel-item-placeholder"))return!1}return!0}, get:function(a){return g(">.jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,p=g(c);if(b.length===0)for(var j,e=f.intval(a),b=this.create(a);;){if(j=this.get(--e),e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}else d=this.dimension(b);p.get(0).nodeName.toUpperCase()=="LI"?(b.replaceWith(p),b=p):b.empty().append(c);this.format(b.removeClass(this.className("jcarousel-item-placeholder")),a);p=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible): null;d=this.dimension(b,p)-d;a>0&&a=this.first&&a<=this.last)){var b=this.dimension(c);athis.options.size?this.options.size:a);for(var d=this.first>a,g=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(g): this.get(this.last),e=d?g:g-1,h=null,i=0,k=!1,l=0;d?--e>=a:++ethis.options.size)))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)));j=h;l=this.dimension(h);k&&(i+=l);if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<= this.options.size)))b=d?b+l:b-l}for(var g=this.clipping(),m=[],o=0,n=0,j=this.get(a-1),e=a;++o;){h=this.get(e);k=!h.length;if(h.length===0){h=this.create(e).addClass(this.className("jcarousel-item-placeholder"));if(j.length===0)this.list.prepend(h);else j[d?"before":"after"](h);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)))}j=h;l=this.dimension(h);if(l===0)throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting..."); this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size?m.push(h):k&&(i+=l);n+=l;if(n>=g)break;e++}for(h=0;h0&&(this.list.css(this.wh,this.dimension(this.list)+i+"px"),d&&(b-=i,this.list.css(this.lt,f.intval(this.list.css(this.lt))-i+"px")));i=a+o-1;if(this.options.wrap!="circular"&&this.options.size&&i>this.options.size)i=this.options.size;if(e>i){o=0;e=i;for(n=0;++o;){h=this.get(e--);if(!h.length)break;n+=this.dimension(h);if(n>=g)break}}e=i-o+ 1;this.options.wrap!="circular"&&e<1&&(e=1);if(this.inTail&&d)b+=this.tail,this.inTail=!1;this.tail=null;if(this.options.wrap!="circular"&&i==this.options.size&&i-o+1>=1&&(d=f.intval(this.get(i).css(!this.options.vertical?"marginRight":"marginBottom")),n-d>g))this.tail=n-g-d;if(c&&a===this.options.size&&this.tail)b-=this.tail,this.inTail=!0;for(;a-- >e;)b+=this.dimension(this.get(a));this.prevFirst=this.first;this.prevLast=this.last;this.first=e;this.last=i;return b},animate:function(a,c){if(!this.locked&& !this.animating){this.animating=!0;var b=this,d=function(){b.animating=!1;a===0&&b.list.css(b.lt,0);!b.autoStopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last=b.first&&c<=b.last)&&(c<1||c>b.options.size)&&b.remove(c)}; this.notify("onBeforeAnimation");if(!this.options.animation||c===!1)this.list.css(this.lt,a+"px"),d();else{var f=!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},d={duration:this.options.animation,easing:this.options.easing,complete:d};if(g.isFunction(this.options.animationStepCallback))d.step=this.options.animationStepCallback;this.list.animate(f,d)}}},startAuto:function(a){if(a!==void 0)this.options.auto=a;if(this.options.auto===0)return this.stopAuto();if(this.timer===null){this.autoStopped= !1;var c=this;this.timer=window.setTimeout(function(){c.next()},this.options.auto*1E3)}},stopAuto:function(){this.pauseAuto();this.autoStopped=!0},pauseAuto:function(){if(this.timer!==null)window.clearTimeout(this.timer),this.timer=null},buttons:function(a,c){if(a==null&&(a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last=this.options.size))a=this.tail!==null&&!this.inTail;if(c==null&&(c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1),!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1))c=this.tail!==null&&this.inTail;var b=this;this.buttonNext.size()>0?(this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext),a&&this.buttonNext.bind(this.options.buttonNextEvent+".jcarousel",this.funcNext), this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?!1:!0),this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a&&this.buttonNext.each(function(){b.options.buttonNextCallback(b,this,a)}).data("jcarouselstate",a)):this.options.buttonNextCallback!==null&&this.buttonNextState!=a&&this.options.buttonNextCallback(b,null,a);this.buttonPrev.size()>0?(this.buttonPrev.unbind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev), c&&this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev),this.buttonPrev[c?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",c?!1:!0),this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=c&&this.buttonPrev.each(function(){b.options.buttonPrevCallback(b,this,c)}).data("jcarouselstate",c)):this.options.buttonPrevCallback!==null&&this.buttonPrevState!=c&&this.options.buttonPrevCallback(b,null,c);this.buttonNextState= a;this.buttonPrevState=c},notify:function(a){var c=this.prevFirst===null?"init":this.prevFirst=j&&k<=e)&&a(k)}}},create:function(a){return this.format("
      • ",a)},format:function(a,c){for(var a=g(a),b=a.get(0).className.split(" "),d=0;d span > span.play { #nav { position: fixed; - z-index: 2; + z-index: 6; top: 0; left: 50%; margin-left: -375px; @@ -167,6 +167,7 @@ h1.artist > span > span.play { .corner-fix { position: fixed; + z-index: 4; width: 8px; height: 8px; background-color: #000; diff --git a/public/stylesheets/player.css b/public/stylesheets/player.css index 722be5f..2171890 100644 --- a/public/stylesheets/player.css +++ b/public/stylesheets/player.css @@ -7,6 +7,7 @@ audio { } #player { position: fixed; + z-index: 5; width: 750px; height: 50px; left: 50%; @@ -156,6 +157,7 @@ audio { } #playlist { position: fixed; + z-index: 5; top: 75px; left: 50%; width: 734px; From f6b34b39605b6a2354745b022c14f070596c60dc Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Thu, 21 Apr 2011 03:05:32 +0400 Subject: [PATCH 15/15] Tons of fixes --- app/controllers/artist_controller.rb | 18 ++++++------ app/controllers/main_controller.rb | 22 ++------------ app/controllers/track_controller.rb | 10 ++----- app/helpers/application_helper.rb | 3 ++ app/helpers/vkontakte.rb | 40 +++++++------------------- app/models/artist.rb | 8 +++--- app/models/user.rb | 12 ++++++++ app/views/layouts/application.html.erb | 2 ++ app/views/main/navigation.html.erb | 7 +++++ 9 files changed, 54 insertions(+), 68 deletions(-) create mode 100644 app/views/main/navigation.html.erb diff --git a/app/controllers/artist_controller.rb b/app/controllers/artist_controller.rb index 547b086..94fba43 100644 --- a/app/controllers/artist_controller.rb +++ b/app/controllers/artist_controller.rb @@ -3,15 +3,15 @@ class ArtistController < ApplicationController require 'open-uri' def view # Dirty auth block START - unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] - redirect_to '/login' - return - else - if request.session['session_id'].nil? - redirect_to '/login' - return - end - end + # unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] + # redirect_to '/login' + # return + # else + # if request.session['session_id'].nil? + # redirect_to '/login' + # return + # end + # end # Dirty auth block END if params[:name].nil? name = '' diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 3e3d473..948a6ec 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,23 +1,7 @@ class MainController < ApplicationController def index - # Dirty auth block START - unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] - redirect_to '/login' - else - if request.session['session_id'].nil? - redirect_to '/login' - end - end - # Dirty auth block END - end - def self.logged_in session_id - user_data = User.collection.find({session_key: Digest::SHA256.hexdigest(session_id)}).first - unless user_data.nil? - user_data['lastvisit'] = Time.now() - User.collection.update({_id: user_data._id}, user_data.attributes) - return true - else - return false - end + # unless User.logged_in + # redirect_to '/login' + # end end end \ No newline at end of file diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index da74a75..4d5b17f 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -3,18 +3,14 @@ class TrackController < ApplicationController require 'uri' def listen pp track = Track.where(:id => params[:id].to_i).first - pp release = Release.where(:id => track.release_id).first - pp album = Album.where(:id => release.album_id).first - pp artist = Artist.where(:id => album.artist_id).first - data = Vkontakte.get(artist.name, track.name, (track.length / 1000).round) - + data = Vkontakte.get(track.artist_name, track.name, (track.length / 1000).round) + # data = Vkontakte.get(1, 1, 1) url = URI.parse(data['url']) nginx_url = '/proxy-stream/no-token/' << data['remixsid'] << '/' << '5' << '/' << url.host << url.path - #render :inline => nginx_url + headers['Content-Type'] = 'audio/mpeg' headers['X-Accel-Redirect'] = nginx_url - headers['Connection'] = 'close' render :nothing => true end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a5d2739..32a0bfe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,7 @@ module ApplicationHelper + def navigation + + end end class Numeric diff --git a/app/helpers/vkontakte.rb b/app/helpers/vkontakte.rb index a462a58..700ed6f 100644 --- a/app/helpers/vkontakte.rb +++ b/app/helpers/vkontakte.rb @@ -2,38 +2,34 @@ module Vkontakte require 'uri' require 'net/http' require 'erb' + require 'pp' #require 'nokogiri' @@accounts = YAML.load_file("#{Rails.root.to_s}/config/vk_accounts.yml") @@bot = nil - def self.get artist, track, length - self.randomBot + def self.get(artist, track, length) + self.randomBot() html = self.getHtml(artist << ' - ' << track).force_encoding("WINDOWS-1251").encode("UTF-8") - #pp html.encoding - #File.open('/Users/chez/Sites/beathaven/tmp/vkres1.html', 'w') {|f| f.write(html) } - #html = open('/Users/chez/Sites/beathaven/tmp/vkres1.html').read files = self.parseHtml(html) - files = self.calcWeight(files, artist, track, length) - #self.stream files.first['url'] - + files = self.calcWeight(files, artist, track, length) return { - 'url' => files.first['url'], - 'remixsid' => @@bot['remixsid'], - 'remixchk' => @@bot['remixchk'] + 'url' => files.first['url'], + 'remixsid' => @@bot['remixsid'], + 'remixchk' => @@bot['remixchk'] } end private - def self.randomBot + def self.randomBot() botname = @@accounts.keys[rand(@@accounts.keys.length - 1)] @@bot = @@accounts[botname] pp 'Using bot ' << botname end - def self.getHtml q + def self.getHtml(q) headers = { 'Cookie' => 'remixsid='+ @@bot['remixsid'] + ';remixchk='+ @@bot['remixchk'].to_s, 'Referer' => 'http://vkontakte.ru/audio?album_id=0', @@ -60,7 +56,7 @@ module Vkontakte data end - def self.parseHtml html + def self.parseHtml(html) files = [] html .scan(/.*?(.*?)<\/div>.*?.*?selectPerformer\(event\,\s\'(.*?)\'\).*?(.*?)<\/span><\/div>.*?<\/table>/mi) @@ -76,7 +72,7 @@ module Vkontakte files end - def self.calcWeight files, artist, track, length + def self.calcWeight(files, artist, track, length) files.each do |file| weight = 0 @@ -99,18 +95,4 @@ module Vkontakte files.sort_by{|file| file['weight']}.reverse end - - def self.stream url - headers = { - 'Cookie' => 'remixsid='+ @@bot['remixsid'] + ';remixchk='+ @@bot['remixchk'].to_s, - 'Referer' => 'http://vkontakte.ru/audio?album_id=0', - 'User-Agent' => @@bot['user_agent'], - } - - uri = URI.parse(url) - http = Net::HTTP.new(uri.host, 80) - resp, data = http.get2(uri.path, headers) - - data - end end diff --git a/app/models/artist.rb b/app/models/artist.rb index ba3292e..c972e5d 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -10,10 +10,10 @@ class Artist < ActiveRecord::Base return nil if query.nil? or query.strip.empty? json = ActiveSupport::JSON.decode(open( - 'http://www.last.fm/search/autocomplete' << - '?q=' << URI.escape(query) - ).read) - return nil if json.empty? else return json + 'http://www.last.fm/search/autocomplete' << + '?q=' << URI.escape(query) + ).read) + return json.empty? ? nil : json end end diff --git a/app/models/user.rb b/app/models/user.rb index 5ec3bb8..7789a16 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,4 +9,16 @@ class User key :invites, Integer key :referer, Integer key :active, Integer + + def logged_in + unless request.session['session_id'].nil? or MainController.logged_in session['session_id'] + redirect_to '/login' + return + else + if request.session['session_id'].nil? + redirect_to '/login' + return + end + end + end end \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 30d0d20..00a6e36 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,6 +9,7 @@ <%= csrf_meta_tag %> + + <% if @hide_player.nil? -%>
        diff --git a/app/views/main/navigation.html.erb b/app/views/main/navigation.html.erb new file mode 100644 index 0000000..716afed --- /dev/null +++ b/app/views/main/navigation.html.erb @@ -0,0 +1,7 @@ + \ No newline at end of file