cleanup
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
# encoding: utf-8
|
||||
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
|
||||
# Dirty auth block END
|
||||
if params[:name].nil?
|
||||
name = ''
|
||||
else
|
||||
if request.request_method == 'POST'
|
||||
redirect_to :action => 'view', :name => params[:name].gsub(' ', '+')
|
||||
end
|
||||
name = params[:name].gsub('+', ' ')
|
||||
end
|
||||
@artist = Artist.getByName(name)
|
||||
if @artist.nil?
|
||||
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
|
||||
else
|
||||
@albums = []
|
||||
@artist.albums.each do |album|
|
||||
unless album.releases.empty?
|
||||
tracks = album.tracksInDb()
|
||||
@albums << {
|
||||
:object => album,
|
||||
:tracks => tracks
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def autocomplete
|
||||
autocomplete = Artist.getLastFmAutocomplete(params[:query])
|
||||
return render :nothing => true if autocomplete.nil?
|
||||
suggestions = []
|
||||
autocomplete["response"]["docs"].each do |doc|
|
||||
suggestions << doc["artist"] unless suggestions.include?(doc["artist"])
|
||||
end
|
||||
|
||||
render :json => {
|
||||
:query => params[:query],
|
||||
:suggestions => suggestions
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
class BotController < ApplicationController
|
||||
require 'daemons'
|
||||
|
||||
PIDS_PATH = "#{Rails.root.to_s}/tmp/pids"
|
||||
|
||||
@@accounts = YAML.load_file("#{Rails.root.to_s}/config/vk_accounts.yml")
|
||||
@error = ""
|
||||
|
||||
def list
|
||||
@bots = []
|
||||
@@accounts.each do |bot_name, data|
|
||||
bot = Bot.new(bot_name)
|
||||
@bots << {
|
||||
:name => bot_name,
|
||||
:started => bot.running?,
|
||||
:current_track => bot.getCurrentTrack,
|
||||
:started_at => bot.running? ? bot.startedAt : nil
|
||||
}
|
||||
end
|
||||
pp @bots
|
||||
end
|
||||
|
||||
def stats
|
||||
end
|
||||
|
||||
|
||||
def queue
|
||||
bot_name = params['bot_name']
|
||||
group_by_artist = params['group_by_artist']
|
||||
limit = params['limit']
|
||||
|
||||
if not bot_name.nil?
|
||||
if not @@accounts.include?(bot_name)
|
||||
throw "Wrong bot name."
|
||||
end
|
||||
end
|
||||
if not group_by_artist.nil?
|
||||
group_by_artist = true
|
||||
end
|
||||
if params['limit'].to_i != 0
|
||||
limit = params['limit'].to_i
|
||||
end
|
||||
|
||||
statuses = [0, 1, 4]
|
||||
data = ParseQueue.any_in(status: statuses)
|
||||
if not bot_name.nil?
|
||||
data = data.where(:bot_name => bot_name)
|
||||
end
|
||||
# if group_by_artist
|
||||
# data = data.only(:artist_name).group
|
||||
# end
|
||||
if not limit.nil?
|
||||
data = data.limit(limit)
|
||||
end
|
||||
@queue = []
|
||||
unless data.nil?
|
||||
data.each do |track|
|
||||
@queue << track
|
||||
end
|
||||
end
|
||||
pp @queue
|
||||
end
|
||||
|
||||
def start
|
||||
name = params['name']
|
||||
begin
|
||||
if name.nil? or name.strip.empty?
|
||||
throw "Empty bot name"
|
||||
end
|
||||
|
||||
bot = Bot.new(name)
|
||||
bot.start
|
||||
rescue
|
||||
return render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
def stop
|
||||
name = params['name']
|
||||
begin
|
||||
if name.nil? or name.strip.empty?
|
||||
throw "Empty bot name"
|
||||
end
|
||||
bot = Bot.new(name)
|
||||
bot.stop
|
||||
rescue
|
||||
return render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
|
||||
end
|
||||
end
|
||||
|
||||
# Add artist to parse_queue
|
||||
def add
|
||||
name = params['name']
|
||||
if name.nil? or name.strip.empty?
|
||||
redirect_to '/'
|
||||
end
|
||||
|
||||
artist = Artist.getByName(name)
|
||||
if artist.nil?
|
||||
@error = "There is no such artist."
|
||||
else
|
||||
data = ParseQueue.where(:artist_id => artist.id).first
|
||||
if not data.nil?
|
||||
throw "This artist already exist in queue."
|
||||
else
|
||||
tracks = []
|
||||
artist.albums.each do |album|
|
||||
unless album.releases.empty?
|
||||
album.releases.first.tracks.each do |track|
|
||||
tracks << track
|
||||
end
|
||||
end
|
||||
end
|
||||
tracks.each do |track|
|
||||
ParseQueue.collection.insert({
|
||||
:track_id => track.id,
|
||||
:artist_id => artist.id,
|
||||
:artist_name => artist.name,
|
||||
:track_name => track.name,
|
||||
:bot_name => nil,
|
||||
:status => 0,
|
||||
:date => nil,
|
||||
:times_failed => 0
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
class MainController < ApplicationController
|
||||
def index
|
||||
# unless User.logged_in
|
||||
# redirect_to '/login'
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
class TrackController < ApplicationController
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
@@token_salt = '8FW*W#dWOH*FHW4j:Q@RQ{Qo[qF;fw0`0w4fkl'
|
||||
|
||||
def listen
|
||||
pp track = Track.where(:id => params[:id].to_i).first
|
||||
|
||||
data = Vkontakte.get(track.artist_name, track.name, (track.length / 1000).round)
|
||||
# data = Vkontakte.get(1, 1, 1)
|
||||
url = URI.parse(data['url'])
|
||||
token = Digest::SHA256.hexdigest(params[:id] << @@token_salt)
|
||||
nginx_url = '/proxy-stream/' << token << '/' << data['remixsid'] << '/' << '5' << '/' << url.host << url.path
|
||||
|
||||
headers['Content-Type'] = 'audio/mpeg'
|
||||
headers['X-Accel-Redirect'] = nginx_url
|
||||
render :nothing => true
|
||||
end
|
||||
end
|
||||
@@ -1,92 +0,0 @@
|
||||
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?
|
||||
user_data = User.collection.find({email: params[:email], password: Digest::SHA256.hexdigest(params[:password])}).first
|
||||
unless user_data.nil?
|
||||
user_data['session_key'] = Digest::SHA256.hexdigest(request.session['session_id'])
|
||||
User.collection.update({_id: user_data._id}, user_data.attributes)
|
||||
redirect_to '/'
|
||||
else
|
||||
redirect_to '/login'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def register
|
||||
@hide_player = 1
|
||||
data = Invite.where(:email => params[:email], :code => params[:code]).first
|
||||
unless data.nil?
|
||||
@code = data.code
|
||||
@email = data.email
|
||||
else
|
||||
redirect_to '/login'
|
||||
end
|
||||
end
|
||||
|
||||
def complete
|
||||
@hide_player = 1
|
||||
data = Invite.where(:email => params[:invite_email], :code => params[:invite_code]).first
|
||||
unless data.nil?
|
||||
if params[:email].match(@@email_regex).nil? or
|
||||
params[:password].length < 6 or
|
||||
params[:password] != params[:password_c]
|
||||
redirect_to '/'
|
||||
end
|
||||
|
||||
User.collection.insert({
|
||||
email: params[:email],
|
||||
password: Digest::SHA256.hexdigest(params[:password]),
|
||||
name: '',
|
||||
regdate: Time.now(),
|
||||
referer: data.referer,
|
||||
lastvisit: Time.now(),
|
||||
invites: 0
|
||||
})
|
||||
|
||||
Invite.collection.remove({email: params[:invite_email], code: params[:invite_code]})
|
||||
else
|
||||
redirect_to '/login'
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
@@ -1,2 +0,0 @@
|
||||
module ArtistHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module MainHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module TrackHelper
|
||||
end
|
||||
@@ -1,61 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
class Album < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_release_group'
|
||||
belongs_to :artist
|
||||
has_many :releases, :conditions => "release_type = 1", :order => 'date ASC, id ASC'
|
||||
|
||||
require 'iconv'
|
||||
|
||||
def cover artist
|
||||
covers = AlbumPic.where(album_id: id).first
|
||||
unless covers.nil?
|
||||
covers.extralarge
|
||||
else
|
||||
q_artist = CGI::escape(artist)
|
||||
q_album = CGI::escape(name)
|
||||
path = open(
|
||||
'http://ws.audioscrobbler.com/2.0/' <<
|
||||
'?method=album.getinfo' <<
|
||||
'&api_key=04fda005dbf61a50af5abc3e90f111f2' <<
|
||||
'&artist=' << q_artist <<
|
||||
'&album=' << q_album
|
||||
).read
|
||||
m = path.scan(/<image\ssize=\"(.*)\">(.*)<\/image>/i)
|
||||
AlbumPic.where(
|
||||
album_id: id,
|
||||
small: m[0][1],
|
||||
medium: m[1][1],
|
||||
large: m[2][1],
|
||||
extralarge: m[3][1],
|
||||
mega: m[4][1]
|
||||
).create
|
||||
m[3][1]
|
||||
end
|
||||
end
|
||||
|
||||
def tracksInDb
|
||||
tracks = []
|
||||
result = []
|
||||
tracks_in_db = []
|
||||
track_ids = []
|
||||
|
||||
self.releases.first.tracks.each do |track|
|
||||
tracks << track
|
||||
track_ids << track.id.to_s
|
||||
end
|
||||
in_db = TrackData.any_in(id: track_ids).only("id")
|
||||
unless in_db.nil?
|
||||
in_db.each do |track|
|
||||
tracks_in_db << track["id"].to_i;
|
||||
end
|
||||
end
|
||||
tracks.each do |track|
|
||||
result << {
|
||||
:object => track,
|
||||
:in_db => tracks_in_db.include?(track.id) ? nil : true
|
||||
}
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
class AlbumPic
|
||||
include Mongoid::Document
|
||||
store_in :album_pics
|
||||
|
||||
key :album_id, Integer
|
||||
key :small, String
|
||||
key :medium, String
|
||||
key :large, String
|
||||
key :extralarge, String
|
||||
key :mega, String
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
class Artist < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_artist'
|
||||
has_many :albums, :conditions => "release_type = 1", :order => 'year ASC, id ASC'
|
||||
|
||||
def self.getByName(name)
|
||||
Artist.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
|
||||
end
|
||||
|
||||
def self.getLastFmAutocomplete(query)
|
||||
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 json.empty? ? nil : json
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
class BeatDB
|
||||
@@db_root = '/www/beatdb'
|
||||
|
||||
def self.get key
|
||||
unless self.exists(key) || File.readable?(self.filePathByKey(key))
|
||||
return false
|
||||
end
|
||||
h = File.open(self.filePathByKey(key), 'r')
|
||||
JSON.decode(h.readline)
|
||||
end
|
||||
|
||||
def self.set key, data
|
||||
unless self.exists(key) || File.writable?(self.filePathByKey(key))
|
||||
return false
|
||||
end
|
||||
h = File.open(self.filePathByKey(key), 'w')
|
||||
h.puts(JSON.encode(data))
|
||||
end
|
||||
|
||||
def self.delete key
|
||||
|
||||
end
|
||||
|
||||
def self.exists key
|
||||
File.exists?(self.filePathByKey(key))
|
||||
end
|
||||
|
||||
def self.filePathByKey key
|
||||
path = ''
|
||||
key.to_s.each_char {|c| path << '/' + c}
|
||||
@@db_root + path[0..(path.length-2)] << key.to_s + '.json'
|
||||
end
|
||||
end
|
||||
@@ -1,54 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
class Bot < Daemons::PidFile
|
||||
require "daemons"
|
||||
|
||||
PIDS_PATH = "#{Rails.root.to_s}/tmp/pids"
|
||||
DAEMON_PATH = "#{Rails.root.to_s}/lib/daemons"
|
||||
@@accounts = YAML.load_file("#{Rails.root.to_s}/config/vk_accounts.yml")
|
||||
|
||||
def initialize(name)
|
||||
unless @@accounts.include?(name)
|
||||
throw "Empty bot name."
|
||||
end
|
||||
|
||||
@dir = File.expand_path(PIDS_PATH)
|
||||
@progname = name
|
||||
@multiple = false
|
||||
@number = nil
|
||||
end
|
||||
|
||||
def getCurrentTrack
|
||||
current_track = ParseQueue.where(:status => 4, :bot_name => @progname).first
|
||||
end
|
||||
|
||||
def startedAt
|
||||
unless self.running?
|
||||
return false
|
||||
end
|
||||
ts = eval('`date -d "\`ps -p ' + self.pid.to_s + ' -o lstart=\`" +"%Y-%m-%d %H:%M:%S"`')
|
||||
ts = ts.strip
|
||||
end
|
||||
|
||||
def start
|
||||
if bot.running?
|
||||
throw "This bot already started."
|
||||
end
|
||||
eval('`ruby ' + DAEMON_PATH + '/parse_controller.rb ' + Rails.root.to_s + ' ' + name + '`')
|
||||
end
|
||||
|
||||
def stop
|
||||
if not self.running?
|
||||
throw "This bot already stopped."
|
||||
end
|
||||
|
||||
signal = (RUBY_PLATFORM =~ /win32/ ? 'KILL' : 'TERM')
|
||||
pid = self.pid
|
||||
begin
|
||||
Process.kill(signal, self.pid)
|
||||
self.cleanup
|
||||
rescue Errno::ESRCH => e
|
||||
throw "#{e} #{pid}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class Invite
|
||||
include Mongoid::Document
|
||||
store_in :invites
|
||||
|
||||
key :referer, Integer
|
||||
key :email, String
|
||||
key :code, String
|
||||
key :date, Date
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
class ParseQueue
|
||||
include Mongoid::Document
|
||||
store_in :bot_parse_queue
|
||||
|
||||
key :track_id, Integer
|
||||
key :artist_id, Integer
|
||||
key :artist_name, String
|
||||
key :track_name, String
|
||||
key :bot_name, String
|
||||
key :status, Integer
|
||||
key :date, Array
|
||||
key :times_failed, Integer
|
||||
end
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class Release < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_release'
|
||||
belongs_to :album
|
||||
has_many :tracks, :order => 'position ASC'
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class Track < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_track'
|
||||
belongs_to :release
|
||||
end
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
class TrackData
|
||||
include Mongoid::Document
|
||||
store_in :track_data
|
||||
|
||||
key :id, Integer
|
||||
key :artist, String
|
||||
key :title, String
|
||||
key :length, Integer
|
||||
key :files, Array
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
class User
|
||||
include Mongoid::Document
|
||||
store_in :users
|
||||
|
||||
key :name, String
|
||||
key :password, String
|
||||
key :email, String
|
||||
key :regdate, Date
|
||||
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
|
||||
@@ -1,36 +0,0 @@
|
||||
<% if @artist.nil? %>
|
||||
<div class="search">
|
||||
<h1>We don`t know such artist yet..</h1>
|
||||
<%= link_to "Try again", main_path %>
|
||||
</div>
|
||||
<% else %>
|
||||
<h1 class="artist">
|
||||
<span>
|
||||
<span><%= @artist.name %></span>
|
||||
<span class="play"><img src="/images/player/add.svg" alt="play" /></span>
|
||||
</span>
|
||||
</h1>
|
||||
<% @albums.each do |album| %>
|
||||
<div class="album">
|
||||
<div class="pic"><img src="<%= album[:object].cover(@artist.name) %>" width="250" height="250" alt=""/></div>
|
||||
<h3 class="name">
|
||||
<span><%= album[:object].name %> <%= (album[:object].year ? album[:object].year : '') %></span>
|
||||
<span class="play"><img src="/images/player/add.svg" alt="play" /></span>
|
||||
</h3>
|
||||
<ul class="tracks">
|
||||
<% album[:tracks].each do |track| %>
|
||||
<li id="<%= track[:object].id %>">
|
||||
<span class="play<%= (track[:in_db].nil? ? '' : ' disabled') %>">
|
||||
<img src="/images/player/add.svg" alt="play" />
|
||||
</span>
|
||||
<span class="track-name"><%= track[:object].name %></span>
|
||||
<% unless track[:object].length.nil? %>
|
||||
<span class="duration" data-length="<%= track[:object].length %>"><%= track[:object].length.toTime %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<h1>Bot#list</h1>
|
||||
<p>Find me in app/views/bot/list.html.erb</p>
|
||||
@@ -1,2 +0,0 @@
|
||||
<h1>Bot#stats</h1>
|
||||
<p>Find me in app/views/bot/stats.html.erb</p>
|
||||
@@ -1,19 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
jQuery(function(){
|
||||
var ac = $('#name').autocomplete({
|
||||
serviceUrl: 'search/autocomplete', // Страница для обработки запросов автозаполнения
|
||||
minChars: 2, // Минимальная длина запроса для срабатывания автозаполнения
|
||||
delimiter: /(,|;)\s*/, // Разделитель для нескольких запросов, символ или регулярное выражение
|
||||
maxHeight: 400, // Максимальная высота списка подсказок, в пикселях
|
||||
width: 300, // Ширина списка
|
||||
zIndex: 9999, // z-index списка
|
||||
deferRequestBy: 150, // Задержка запроса (мсек)
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="search">
|
||||
<%= form_tag('/artist', :method => 'post') %>
|
||||
<%= text_field_tag 'name', nil %>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<div id="nav">
|
||||
<ul>
|
||||
<li><a href="/">Search</a></li>
|
||||
<li><a href="/user/profile">Profile</a></li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div id="registration">
|
||||
<h1>Welcome aboard, friend!</h1>
|
||||
</div>
|
||||
@@ -1,23 +0,0 @@
|
||||
<div id="registration">
|
||||
<h1>Help BeatHaven dominate those lousy humans!</h1>
|
||||
<%= form_tag('/reg/complete', :method => 'post') do -%>
|
||||
<%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @email %><div id="email_error"></div>
|
||||
<div class="complete">
|
||||
<%= submit_tag 'I wanna get this guy in!' %>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$(function(){
|
||||
$('#email').focus();
|
||||
$('form').submit(function(){
|
||||
$('#email, #email_error').html('');
|
||||
if (! $('#email').val().match(/^[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]$/)) {
|
||||
$('#email_error').html('* Invalid email');
|
||||
$('#email').focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@@ -1,24 +0,0 @@
|
||||
<div id="registration">
|
||||
<h1>Do BeatHaven know you?</h1>
|
||||
<%= form_tag('/login', :method => 'post') do -%>
|
||||
<%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', nil %>
|
||||
<%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %><div id="password_error"></div>
|
||||
<div class="complete">
|
||||
<%= submit_tag 'Let me in!' %>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$(function(){
|
||||
$('#email').focus();
|
||||
$('form').submit(function(){
|
||||
$('#password_error, #password_c_error').html('');
|
||||
if ($('#password').val().length < 6) {
|
||||
$('#password_error').html('* You must be kidding?');
|
||||
$('#password').focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@@ -1,31 +0,0 @@
|
||||
<div id="registration">
|
||||
<h1>Greetings from BeatHaven!</h1>
|
||||
<%= form_tag('/reg/complete', :method => 'post') do -%>
|
||||
<%= hidden_field_tag 'invite_code', @code %>
|
||||
<%= hidden_field_tag 'invite_email', @email %>
|
||||
<%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @email %>
|
||||
<%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %><div id="password_error"></div>
|
||||
<%= label_tag 'password_c', 'Confirm' %><%= password_field_tag 'password_c', nil %><div id="password_c_error"></div>
|
||||
<div class="complete">
|
||||
<%= submit_tag 'Complete' %>
|
||||
</div>
|
||||
<% end -%>
|
||||
</div>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$(function(){
|
||||
$('#password').focus();
|
||||
$('form').submit(function(){
|
||||
$('#password_error, #password_c_error').html('');
|
||||
if ($('#password').val().length < 6) {
|
||||
$('#password_error').html('* Password must be 6+ characters length');
|
||||
$('#password').focus();
|
||||
return false;
|
||||
} else if ($('#password').val() != $('#password_c').val()) {
|
||||
$('#password_c_error').html('* Password and confirmation doesn\'t match');
|
||||
$('#password_c').focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@@ -1,31 +0,0 @@
|
||||
<div id="registration">
|
||||
<h1>Update ur profile!</h1>
|
||||
<%= 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 %><div id="password_error"></div>
|
||||
<%= label_tag 'password_c', 'Confirm' %><%= password_field_tag 'password_c', nil %><div id="password_c_error"></div>
|
||||
<div class="complete">
|
||||
<%= submit_tag 'I\'m done!' %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
</div>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$(function(){
|
||||
$('#password').focus();
|
||||
$('form').submit(function(){
|
||||
$('#password_error, #password_c_error').html('');
|
||||
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().length > 0 && $('#password').val() != $('#password_c').val()) {
|
||||
$('#password_c_error').html('* Password and confirmation doesn\'t match');
|
||||
$('#password_c').focus();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user