cessna 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cessna.rb CHANGED
@@ -12,6 +12,12 @@ module Cessna
12
12
 
13
13
  enable :sessions
14
14
 
15
+ helpers do
16
+ def format_is_supported?(video_name)
17
+ video_name.end_with?('.mp4') || video_name.end_with?('.m4v') || video_name.end_with?('.mov')
18
+ end
19
+ end
20
+
15
21
  before /^(\/browse*)|(\/play*)/ do
16
22
  check_session
17
23
  end
@@ -40,8 +46,8 @@ module Cessna
40
46
 
41
47
  get '/browse/:folder_location' do
42
48
  location = Base64.decode64(params[:folder_location])
43
- @parent_location = location.split('/')[0..-2].join('/')
44
- @current_folder = location.split('/').last
49
+ @parent_location = parent_location(location)
50
+ @current_folder = item_name(location)
45
51
 
46
52
  items = fetch_items(location)
47
53
  @folders = collect_folders(items)
@@ -61,8 +67,8 @@ module Cessna
61
67
  get '/play/:video_location' do
62
68
  location = Base64.decode64(params[:video_location])
63
69
  client = airvideo_client
64
- @parent_location = location.split('/')[0..-2].join('/')
65
- @video_name = location.split('/').last
70
+ @parent_location = parent_location(location)
71
+ @video_name = item_name(location)
66
72
 
67
73
  client.cd(@parent_location)
68
74
  video = client.ls.select{|item| item.name == @video_name}.first
@@ -90,11 +96,28 @@ module Cessna
90
96
  end
91
97
 
92
98
  def collect_folders(items)
93
- items.select{|item| item.is_a? AirVideo::Client::FolderObject}
99
+ items.select{ |item| item.is_a?(AirVideo::Client::FolderObject) }
94
100
  end
95
101
 
96
102
  def collect_videos(items)
97
- items.select{|item| item.is_a? AirVideo::Client::VideoObject}
103
+ items.select{ |item| item.is_a?(AirVideo::Client::VideoObject) }
104
+ end
105
+
106
+ def parent_location(location)
107
+ # The path of a Windows AirVideo Server uses \\ as a path seperator...
108
+ if location.include?('\\')
109
+ location.split('\\')[0..-2].join('\\')
110
+ else
111
+ location.split('/')[0..-2].join('/')
112
+ end
113
+ end
114
+
115
+ def item_name(location)
116
+ if location.include?('\\')
117
+ location.split('\\').last
118
+ else
119
+ location.split('/').last
120
+ end
98
121
  end
99
122
  end
100
123
  end
@@ -1,3 +1,3 @@
1
1
  module Cessna
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/views/play.haml CHANGED
@@ -9,9 +9,9 @@
9
9
  %h4
10
10
  ="Playing: #{@video_name}"
11
11
 
12
- - if @video_name.end_with?('.mkv')
12
+ - unless format_is_supported?(@video_name)
13
13
  %div{class: 'alert alert-info'}
14
- ="The playback of the MKV format ist not really supported by HTML5 video and therefore the playback is disabled."
14
+ ="The playback of this video format ist not really supported by HTML5 video and therefore the playback is disabled."
15
15
  - else
16
16
  %div
17
17
  %video{ width: 640, controls: true, autoplay: true, class: 'img-polaroid'}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cessna
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: