Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: yhara/afpray
base: e35171639c
...
head fork: yhara/afpray
compare: 55b4d05d46
  • 6 commits
  • 14 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 24, 2012
Yutaka HARA new: expand=1 9f34b7a
Commits on Jun 26, 2012
Yutaka HARA fix: SongsController raised error when referer not set b66880c
Yutaka HARA change: set 'expand' by default 634fdb5
Yutaka HARA new: show breadcrumbs 3efdce6
Yutaka HARA new: shuffle 7f7bd95
Yutaka HARA new: Added icons 55b4d05
View
40 README.mkd
@@ -0,0 +1,40 @@
+Afpray
+======
+
+Afpray is a browser-gui wrapper of the afplay command
+installed on Mac.
+
+You can browse your mp3s in browser and play them with afplay.
+
+Requirements
+------------
+
+* afplay
+* Ruby >= 1.9
+
+Install
+=======
+
+Afpray is bulit with Ruby on Rails, but designed to
+run on your localhost.
+
+* git clone
+* bundle install
+* rails server
+* open http://localhost:3000/
+
+License
+=======
+
+MIT
+
+Icons: http://www.famfamfam.com/lab/icons/silk/
+
+Contact
+=======
+
+https://github.com/yhara/afpray
+
+Yutaka HARA (yhara)
+
+twitter: @yhara_en
View
BIN  app/assets/images/arrow_switch.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/cd_go.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/control_fastforward_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/control_pause_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/control_play_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/control_rewind_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/control_stop_blue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
22 app/controllers/songs_controller.rb
@@ -8,6 +8,7 @@ class SongsController < ApplicationController
N = 5
def index
+ @expand = (params[:expand] == "0" ? false : true)
@dir = File.expand_path(params[:dir] || ROOT_DIR)
@queue = player.queue.first(N).map{|x| x and File.basename(x)}
@queue.push("...") if player.queue.size > N
@@ -17,29 +18,34 @@ def play_all
@dir = File.expand_path(params[:dir] || ROOT_DIR)
player.play_files(Dir["#{@dir}/**/*.{mp3,m4a}"])
- redirect_to :back
+ redirect_back_or_index
end
def prev_song
player.prev_song
player.resume
- redirect_to :back
+ redirect_back_or_index
end
def pause
player.pause
- redirect_to :back
+ redirect_back_or_index
end
def resume
player.resume
- redirect_to :back
+ redirect_back_or_index
+ end
+
+ def shuffle
+ player.play_files(player.queue.shuffle)
+ redirect_back_or_index
end
def next_song
player.next_song
player.resume
- redirect_to :back
+ redirect_back_or_index
end
private
@@ -47,4 +53,10 @@ def next_song
def player
SongsController.player ||= Player::AFPlay.new(root_url())
end
+
+ def redirect_back_or_index
+ redirect_to :back
+ rescue ActionController::RedirectBackError
+ redirect_to action: index
+ end
end
View
9 app/helpers/songs_helper.rb
@@ -0,0 +1,9 @@
+module SongsHelper
+ def breadcrumb_paths(dir)
+ dirnames = dir.split(%r{/})
+ dirnames.map.with_index{|dirname, i|
+ path = dirnames[0, i+1].join('/')
+ [dirname, path]
+ }
+ end
+end
View
41 app/views/songs/index.html.slim
@@ -6,12 +6,31 @@
ul
- li= link_to "[Play all]", action: :play_all, dir: @dir
- li=
- li= link_to "[Prev]", action: :prev_song
- li= link_to "[Pause]", action: :pause
- li= link_to "[Resume]", action: :resume
- li= link_to "[Next]", action: :next_song
+ li
+ = image_tag "cd_go.png"
+ = link_to "[Play all]", action: :play_all, dir: @dir
+ li
+ li
+ = image_tag "control_rewind_blue.png"
+ = link_to "[Prev]", action: :prev_song
+ li
+ = image_tag "control_stop_blue.png"
+ = link_to "[Pause]", action: :pause
+ li
+ = image_tag "control_play_blue.png"
+ = link_to "[Resume]", action: :resume
+ li
+ = image_tag "control_fastforward_blue.png"
+ = link_to "[Next]", action: :next_song
+ li
+ = image_tag "arrow_switch.png"
+ = link_to "[Shuffle]", action: :shuffle
+
+// breadcrumbs
+
+- breadcrumb_paths(@dir).each do |name, path|
+ = link_to name, songs_index_path(dir: path)
+ | /
ul
- unless @dir == "/"
@@ -25,3 +44,13 @@ ul
= link_to File.basename(path), songs_index_path(dir: path)
'
= link_to "[>]", songs_play_all_path(dir: path)
+
+ - if @expand
+ ul
+ - Dir["#{path}/*"].each do |sub|
+ li
+ = link_to File.basename(sub), songs_index_path(dir: sub)
+ '
+ = link_to "[>]", songs_play_all_path(dir: sub)
+
+
View
2  config/routes.rb
@@ -1,7 +1,7 @@
Afpray::Application.routes.draw do
root :to => redirect("/songs/index")
- %w(index play_all pause resume prev_song next_song).each do |name|
+ %w(index play_all pause resume shuffle prev_song next_song).each do |name|
get "songs/#{name}"
end
View
2  lib/player.rb
@@ -72,6 +72,8 @@ def kill_thread
# Issue HTTP GET to @ping_url.
# Used for running afpray with pow,
# because pow terminates the app in 15min
+ # This prevents pow to restart afplay
+ # (unless you have a song longer than 15min!).
def ping!
if @ping_url
logger.info("[player] ping #{@ping_url}")
View
BIN  public/favicon.ico 100644 → 100755
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.