Mass move to root

This commit is contained in:
magnolia-fan
2011-04-09 17:41:24 +04:00
parent 0640e2424e
commit 62ff3f277f
484 changed files with 0 additions and 3 deletions
@@ -0,0 +1,6 @@
class ApplicationController < ActionController::Base
protect_from_forgery
require 'beatdb'
require 'pp'
#require 'cobravsmongoose'
end
+13
View File
@@ -0,0 +1,13 @@
# encoding: utf-8
class ArtistController < ApplicationController
require 'open-uri'
def view
if params[:name].nil?
name = ''
else
name = params[:name].gsub('+', ' ').gsub('%20', ' ')
end
@artist = Artist.getByName(name)
end
end
+5
View File
@@ -0,0 +1,5 @@
class MainController < ApplicationController
def index
end
end
+7
View File
@@ -0,0 +1,7 @@
class TrackController < ApplicationController
require 'net/http'
require 'uri'
def listen
end
end
+15
View File
@@ -0,0 +1,15 @@
module ApplicationHelper
end
class Numeric
def toSeconds
(self / 1000).round
end
def toTime
s = self.toSeconds
m = (s / 60).floor
s -= m * 60
m.to_s << ':' << (s < 10 ? '0' : '') << s.to_s
end
end
+2
View File
@@ -0,0 +1,2 @@
module ArtistHelper
end
+2
View File
@@ -0,0 +1,2 @@
module MainHelper
end
+2
View File
@@ -0,0 +1,2 @@
module TrackHelper
end
+19
View File
@@ -0,0 +1,19 @@
module Vkontakte
@@accounts = YAML.load_file("#{RAILS_ROOT}/config/vk_accounts.yml")
def get artist, track, length
end
def getHtml q
end
def parseHtml html
end
def calcWeight files
end
end
+35
View File
@@ -0,0 +1,35 @@
# 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)
unless covers.empty?
covers.first.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.new(
album_id: id,
small: m[0][1],
medium: m[1][1],
large: m[2][1],
extralarge: m[3][1],
mega: m[4][1]
)
m[3][1]
end
end
end
+11
View File
@@ -0,0 +1,11 @@
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
+8
View File
@@ -0,0 +1,8 @@
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
end
+33
View File
@@ -0,0 +1,33 @@
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
+9
View File
@@ -0,0 +1,9 @@
class Invite
include Mongoid::Document
store_in :invites
key :referer, Integer
key :email, String
key :code, String
key :senton, Date
end
+5
View File
@@ -0,0 +1,5 @@
class Release < ActiveRecord::Base
set_table_name 'musicbrainz.bh_release'
belongs_to :album
has_many :tracks, :order => 'position ASC'
end
+8
View File
@@ -0,0 +1,8 @@
class Track < ActiveRecord::Base
set_table_name 'musicbrainz.bh_track'
belongs_to :release
def inDb
! TrackData.where(id: id.to_s).empty?
end
end
+10
View File
@@ -0,0 +1,10 @@
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
+12
View File
@@ -0,0 +1,12 @@
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
end
+30
View File
@@ -0,0 +1,30 @@
<% 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"><%= @artist.name %></h1>
<% @artist.albums.each do |album| %>
<% unless album.releases.empty? %>
<div class="album">
<div class="pic"><img src="<%= album.cover(@artist.name) %>" width="250" height="250" alt=""/></div>
<h3 class="name"><%= album.name %> <%= (album.year ? album.year : '') %></h3>
<%
releases = album.releases
first_release = releases.first
%>
<ul class="tracks">
<% first_release.tracks.each do |track| %>
<li id="<%= track.id %>">
<span class="play<%= (track.inDb ? '' : ' disabled') %>"></span>
<span class="track-name"><%= track.name %></span>
<span class="duration"><%= track.length.toTime %></span>
</li>
<% end %>
</ul>
</div>
<% end %>
<% end %>
<% end %>
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>BeatHaven</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :all %>
<%= csrf_meta_tag %>
</head>
<body>
<div id="contents">
<div class="inner-1">
<div id="player">
<span id="artist"></span>
<span id="dash"> - </span>
<span id="title"></span>
<audio controls preload style="width:1000px;"></audio>
</div>
<%= yield %>
</div>
</div>
</body>
</html>
+6
View File
@@ -0,0 +1,6 @@
<div class="search">
<h1>SEARCH</h1>
<%= form_tag('/artist', :method => 'post') %>
<%= text_field_tag 'name', nil %>
</div>