cessna 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cessna.rb +29 -6
- data/lib/cessna/version.rb +1 -1
- data/views/play.haml +2 -2
- metadata +1 -1
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
|
44
|
-
@current_folder = location
|
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
|
65
|
-
@video_name = location
|
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?
|
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?
|
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
|
data/lib/cessna/version.rb
CHANGED
data/views/play.haml
CHANGED
@@ -9,9 +9,9 @@
|
|
9
9
|
%h4
|
10
10
|
="Playing: #{@video_name}"
|
11
11
|
|
12
|
-
-
|
12
|
+
- unless format_is_supported?(@video_name)
|
13
13
|
%div{class: 'alert alert-info'}
|
14
|
-
="The playback of
|
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'}
|