pig-media-server 0.3.2 → 2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/bin/pig-media-server +4 -1
  4. data/gulpfile.js +33 -0
  5. data/javascripts/application.js +117 -0
  6. data/javascripts/chromecast.js +57 -0
  7. data/javascripts/components/head.js +106 -0
  8. data/javascripts/components/list.js +104 -0
  9. data/javascripts/components/new_flag.js +23 -0
  10. data/javascripts/components/player.js +171 -0
  11. data/javascripts/components/query_list.js +68 -0
  12. data/javascripts/components/sort.js +64 -0
  13. data/javascripts/components/watch.js +48 -0
  14. data/javascripts/controller.js +62 -0
  15. data/javascripts/custom_list.js +14 -0
  16. data/javascripts/event_dispatcher.js +21 -0
  17. data/javascripts/recent.js +34 -0
  18. data/javascripts/utils.js +22 -0
  19. data/javascripts/video.js +10 -0
  20. data/lib/pig-media-server/api.rb +96 -0
  21. data/lib/pig-media-server/aspect.rb +10 -5
  22. data/lib/pig-media-server/backup.rb +69 -0
  23. data/lib/pig-media-server/cli.rb +60 -25
  24. data/lib/pig-media-server/crawl.rb +41 -5
  25. data/lib/pig-media-server/kindle_send.rb +31 -24
  26. data/lib/pig-media-server/model/data.rb +106 -0
  27. data/lib/pig-media-server/model/migrate.rb +34 -0
  28. data/lib/pig-media-server/model/pig.rb +11 -2
  29. data/lib/pig-media-server/version.rb +1 -1
  30. data/lib/pig-media-server/views/_custom_links.haml +4 -0
  31. data/lib/pig-media-server/views/_ft_flv.haml +1 -0
  32. data/lib/pig-media-server/views/_ft_pdf.haml +0 -0
  33. data/lib/pig-media-server/views/_ft_video.haml +9 -4
  34. data/lib/pig-media-server/views/_link.haml +4 -1
  35. data/lib/pig-media-server/views/_new_flag.haml +1 -1
  36. data/lib/pig-media-server/views/app.scss +10 -1
  37. data/lib/pig-media-server/views/bundle.js +13 -0
  38. data/lib/pig-media-server/views/chromecast.coffee +54 -0
  39. data/lib/pig-media-server/views/config.coffee +13 -1
  40. data/lib/pig-media-server/views/config.haml +27 -4
  41. data/lib/pig-media-server/views/feed.builder +3 -2
  42. data/lib/pig-media-server/views/flv.coffee +33 -0
  43. data/lib/pig-media-server/views/index.haml +11 -5
  44. data/lib/pig-media-server/views/meta.haml +4 -4
  45. data/lib/pig-media-server/views/movie.coffee +65 -39
  46. data/lib/pig-media-server/views/react.haml +22 -0
  47. data/lib/pig-media-server/views/remote.haml +2 -2
  48. data/lib/pig-media-server/views/session.coffee +5 -0
  49. data/lib/pig-media-server/views/storage.coffee +5 -16
  50. data/lib/pig-media-server/views/sub.haml +5 -6
  51. data/lib/pig-media-server/views/subview.coffee +109 -19
  52. data/lib/pig-media-server/views/tv.coffee +97 -0
  53. data/lib/pig-media-server/views/tv.haml +33 -0
  54. data/lib/pig-media-server/views/unread.coffee +10 -0
  55. data/lib/pig-media-server/web.rb +102 -37
  56. data/package.json +23 -0
  57. data/pig-media-server.gemspec +5 -0
  58. metadata +123 -38
@@ -0,0 +1,54 @@
1
+ currentMedia = null
2
+ currentVolume = 0.5
3
+ progressFlag = 1
4
+ mediaCurrentTime = 0
5
+ session = null
6
+
7
+ null_func = (obj)-> ''
8
+
9
+ sessionListener = (e)->
10
+ console.log('New session ID: ' + e.sessionId)
11
+ session = e
12
+
13
+ onRequestSessionSuccess = (e)->
14
+ console.log("session success: " + e.sessionId)
15
+ session = e
16
+ onMediaDiscovered('onRequestSession', session.media[0]) if (session.media.length != 0)
17
+ session.addMediaListener(
18
+ onMediaDiscovered.bind(this, 'addMediaListener'))
19
+
20
+ onMediaDiscovered = (how, media)->
21
+ console.log("new media session ID:" + media.mediaSessionId)
22
+ currentMedia = media
23
+ mediaCurrentTime = currentMedia.currentTime
24
+
25
+ initializeCastApi = ->
26
+ sessionRequest = new chrome.cast.SessionRequest(chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID)
27
+ apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, null_func)
28
+ chrome.cast.initialize(apiConfig, null_func, null_func)
29
+
30
+ console.log("launching app...")
31
+ chrome.cast.requestSession(onRequestSessionSuccess, null_func)
32
+ $('a.chromecast').show()
33
+
34
+ window.chrome_cast = (mediaURL, key)->
35
+ mediaInfo = new chrome.cast.media.MediaInfo(mediaURL)
36
+ mediaInfo.contentType = 'video/mp4'
37
+ request = new chrome.cast.media.LoadRequest(mediaInfo)
38
+ request.autoplay = true
39
+ request.currentTime = 0
40
+ session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), null_func)
41
+
42
+ get_recents (recents)->
43
+ recents["movie/#{key}"] = {time: parseInt((new Date)/1000), type: 'movie'}
44
+ window.save_recents recents
45
+ $('.new_flag').text('')
46
+ $('.main_span').attr('data-new': '')
47
+ unless $('#action').text() == 'remote'
48
+ setTimeout ->
49
+ window.set_new()
50
+ ,2000
51
+
52
+ window['__onGCastApiAvailable'] = (loaded, errorInfo)->
53
+ if loaded
54
+ initializeCastApi()
@@ -1,7 +1,14 @@
1
1
  save = ->
2
2
  localStorage.gyazo = $('#gyazo').val()
3
3
  if $('#kindle_to').get(0)
4
- save_to_pig({kindle_to: $('#kindle_to').val(), kindle_from: $('#kindle_from').val(),remote: $('#remote').prop('checked')})
4
+ save_to_pig('kindle_to', $('#kindle_to').val())
5
+ save_to_pig('kindle_from', $('#kindle_from').val())
6
+ save_to_pig('token_secret', $('#token_secret').val())
7
+ save_to_pig('token', $('#token').val())
8
+ save_to_pig('consumer_secret', $('#consumer_secret').val())
9
+ save_to_pig('consumer_key', $('#consumer_key').val())
10
+ save_to_pig('remote', $('#remote').prop('checked'))
11
+ save_to_pig('animetick', $('#animetick').val())
5
12
 
6
13
 
7
14
  $ ->
@@ -13,4 +20,9 @@ $ ->
13
20
 
14
21
  get_from_pig('kindle_to', (data)-> $('#kindle_to').val(data))
15
22
  get_from_pig('kindle_from', (data)-> $('#kindle_from').val(data))
23
+ get_from_pig('consumer_key', (data)-> $('#consumer_key').val(data))
24
+ get_from_pig('consumer_secret', (data)-> $('#consumer_secret').val(data))
25
+ get_from_pig('token', (data)-> $('#token').val(data))
26
+ get_from_pig('token_secret', (data)-> $('#token_secret').val(data))
27
+ get_from_pig('animetick', (data)-> $('#animetick').val(data))
16
28
 
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  %meta{charset: 'UTF-8'}
3
- %title Config - Pig Media Server
4
- %script{src: 'http://code.jquery.com/jquery.min.js'}
3
+ %title Config - #{config['page_title']}
4
+ %script{src: 'https://code.jquery.com/jquery.min.js'}
5
5
  %script{src: '/config.js'}
6
6
  %script{src: '/storage.js'}
7
7
  %link{href: '/app.css', rel: 'stylesheet', type: 'text/css'}
@@ -13,7 +13,7 @@
13
13
  Login as
14
14
  %span#user_id=session[:user_id]
15
15
  %a{href: '/sessions'} Logout
16
- %h1 Pig Media Server
16
+ %h1 #{config['page_title']}
17
17
  %form{method: 'GET', action: '/'}
18
18
  %input{name: 'query', value: params[:query]}
19
19
  %button Search
@@ -29,7 +29,7 @@
29
29
  %tr
30
30
  %th Use Remote?
31
31
  %td
32
- -if hash()['remote']
32
+ -if remote?
33
33
  %input#remote{type: :checkbox}(checked)
34
34
  -else
35
35
  %input#remote{type: :checkbox}
@@ -41,7 +41,30 @@
41
41
  %th Kindle From
42
42
  %td
43
43
  %input#kindle_from{size: 60}
44
+ %tr
45
+ %th Consumer Key
46
+ %td
47
+ %input#consumer_key
48
+ %tr
49
+ %th Consumer Secret
50
+ %td
51
+ %input#consumer_secret
52
+ %tr
53
+ %th Token
54
+ %td
55
+ %input#token
56
+ %tr
57
+ %th Token Secret
58
+ %td
59
+ %input#token_secret
60
+ %tr
61
+ %th Animetick User Name
62
+ %td
63
+ %input#animetick
44
64
 
45
65
  %tr
46
66
  %td
47
67
  %button#save Save
68
+
69
+ :css
70
+ table input{width:600px}
@@ -1,9 +1,9 @@
1
1
  xml.instruct! :xml, :version => '1.0'
2
2
  xml.rss :version => "2.0" do
3
3
  xml.channel do
4
- xml.title "Pig Media Server - feed - '#{h params[:query]}'"
4
+ xml.title "#{config['page_title']} - feed - '#{h params[:query]}'"
5
5
  xml.description "pig feed"
6
- xml.link "http://#{config['hostname']}/feed?query=#{CGI.escape params[:query]}"
6
+ xml.link "http://#{config['hostname']}/?query=#{CGI.escape params[:query]}"
7
7
 
8
8
  @list.each do |p|
9
9
  xml.item do
@@ -12,6 +12,7 @@ xml.rss :version => "2.0" do
12
12
  xml.description p.name
13
13
  xml.pubDate p.mtime.rfc822
14
14
  xml.guid p.url
15
+ xml.key p.key
15
16
  xml.enclosure url: p.url, title: 'Podcast'
16
17
  end
17
18
  end
@@ -0,0 +1,33 @@
1
+ flv = (link)->
2
+ $link = $(link)
3
+ key = $(link).attr 'key'
4
+ url = $("##{key} .main_link").attr('href')
5
+ $link.click ->
6
+ $('#area').html('')
7
+ $('#area').css 'min-height', 0
8
+ width = $('body').width()
9
+ $('<embed>').attr(src: "/OSplayer.swf?movie=#{url}&autoload=on&autoplay=on&volume=200", allowFullScreen: true, type: 'application/x-shockwave-flash', width: '800', height: 600).appendTo('#area')
10
+ $('<br>').appendTo('#area')
11
+ $('<a>close video</a>').attr('href', 'javascript:void(0)').click(->
12
+ $('#area').html('')
13
+ $('#area').css 'min-height', 0
14
+ ).appendTo('#area')
15
+
16
+ window.get_recents (recents)->
17
+ recents['movie/'+key] = {time: parseInt((new Date)/1000), type: 'movie'}
18
+ window.save_recents recents
19
+ $('.new_flag').text('')
20
+ $('.main_span').attr('data-new': '')
21
+ unless $('#action').text() == 'remote'
22
+ setTimeout ->
23
+ window.set_new()
24
+ ,2000
25
+
26
+ window.watch_flv = flv
27
+
28
+ initialize_flv = ->
29
+ $.each $('a.flv'), -> flv(this)
30
+
31
+ $ ->
32
+ initialize_flv() if $('#action').text() == 'list' or $('#action').text() == 'others'
33
+
@@ -1,8 +1,9 @@
1
1
  !!!
2
- %title Pig Media Server
2
+ %title= title
3
3
  %meta(content='width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' name='viewport')
4
- %script{src: 'http://code.jquery.com/jquery.min.js'}
5
- -%w{storage session movie unread book book2 swipe}.each do |js|
4
+ %script(type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js")
5
+ %script{src: 'https://code.jquery.com/jquery.min.js'}
6
+ -%w{flv storage session movie unread book book2 swipe chromecast}.each do |js|
6
7
  %script{src: "/#{js}.js"}
7
8
 
8
9
  %link{href: '/app.css', rel: 'stylesheet', type: 'text/css'}
@@ -15,18 +16,23 @@
15
16
  -else
16
17
  Login as
17
18
  %span#user_id=session[:user_id]
18
- %a{href: '/sessions'} Logout
19
+ %a{href: 'javascript:void(0)', onclick: 'logout()'} Logout
19
20
  %p=flash[:notice]
20
- %h1 Pig Media Server
21
+ %h1 #{config['page_title']}
21
22
  %form{method: 'GET', action: '/'}
22
23
  %input{name: 'query', value: params[:query]}
23
24
  %button Search
24
25
  %a{href: '/latest'} Latest
25
26
  %a{href: '/config'} Config
27
+ -if session[:user_id]
28
+ %a{href: '/stars'} Stars
29
+ %a{href: '/tv'} Cast
26
30
  %a#only-new{href: 'javascript:void(0)'} Only New
27
31
  -if config['custom_list'].class == Hash
28
32
  -config['custom_list'].each do |k,v|
29
33
  %a{href: "/custom?name=#{CGI.escape k}"}=k
34
+ -if remote?
35
+ %a(href='javascript:void(0)' onclick='save_to_pig("remote_key", "")') Stop Remote
30
36
  -if @page
31
37
  -if params[:query] and params[:query].empty? == false
32
38
  %p
@@ -1,13 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  %meta{charset: 'UTF-8'}
3
- %title Pig Media Server
4
- %script{src: 'http://code.jquery.com/jquery.min.js'}
3
+ %title= title
4
+ %script{src: 'https://code.jquery.com/jquery.min.js'}
5
5
  %script{src: '/meta.js'}
6
6
 
7
7
  %link{href: '/app.css', rel: 'stylesheet', type: 'text/css'}
8
8
  <meta content='width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' name='viewport' />
9
9
  #all
10
- %h1 pig.ssig33.com
10
+ %h1 #{config['page_title']}
11
11
  %p=flash[:notice]
12
12
  %form{method: 'GET', action: '/'}
13
13
  %input{name: 'query', value: params[:query]}
@@ -29,7 +29,7 @@
29
29
  %p
30
30
  %video{src: @p.url, controls: :controls, style: 'max-width:50%;max-height:50%'}
31
31
  %p
32
- -if hash()['remote']
32
+ -if remote?
33
33
  %a.remote{href: 'javascript:void(0)', key: @p.record.key} remote
34
34
  -if @p.metadata
35
35
  %h4 Data
@@ -1,4 +1,4 @@
1
- watch = (link)->
1
+ window.watch = (link)->
2
2
  $link = $(link)
3
3
  key = $(link).attr 'key'
4
4
  url = $("##{key} .main_link").attr('href')
@@ -9,8 +9,7 @@ watch = (link)->
9
9
  $('#area').html('')
10
10
  $('#area').css 'min-height', 0
11
11
  width = $('body').width()
12
- $('<div>').attr('class', 'space').appendTo('#area')
13
- $('<video>').attr(id: 'play', src: url, key: key, controls: 'controles').css('width', '98%').css('max-height', '98%').appendTo('#area')
12
+ $('<video>').click(-> pause()).attr(id: 'play', src: url, key: key, controls: 'controles').css('width', '98%').css('max-height', '98%').appendTo('#area')
14
13
  $('<br>').appendTo('#area')
15
14
  $('<a href="javascript:void(0)">Gyazo</a>').click(-> gyazo()).appendTo('#area')
16
15
  $('<span>&nbsp;&nbsp;&nbsp;</span>').appendTo('#area')
@@ -71,6 +70,7 @@ movie_size = (origin_height)->
71
70
  setTimeout ->
72
71
  if $('#play').length > 0
73
72
  space_height = parseInt(($('#area').height() - $('#play').height())/4)
73
+ space_height = space_height *2
74
74
  if origin_height != space_height
75
75
  $('#area').css 'min-height', $(window).height()
76
76
  $('.space').css 'height', space_height if space_height != origin_height
@@ -78,41 +78,28 @@ movie_size = (origin_height)->
78
78
  movie_size(origin_height)
79
79
  , 20
80
80
 
81
- gyazo = ->
82
- c = document.querySelector '#canvas'
83
- v = document.querySelector '#play'
84
- context = c.getContext '2d'
85
- c.width = v.videoWidth
86
- c.height = v.videoHeight
87
- context.drawImage(v, 0, 0)
88
- url = c.toDataURL()
89
- $.post('/gyazo', {url: url, point: localStorage.gyazo}).success((data)->
90
- window.open(data.url, "", "width=500,height=400")
91
- copyArea = $("<textarea/>")
92
- copyArea.text(data.url)
93
- $("body").append(copyArea)
94
- copyArea.select()
95
- document.execCommand("copy")
96
- copyArea.remove()
97
- )
98
-
99
81
  next_loop = ->
100
82
  setTimeout ->
101
83
  if $('video')[0]
102
84
  v = document.querySelector 'video'
103
85
  if v.currentTime== v.duration
104
- key = $(v).attr 'key'
105
- keys = $.map($('.watch'), (n,i)-> $(n).attr('key'))
106
- index = keys.indexOf key
107
- next = keys[index-1]
108
- if next
109
- $('.watch[key="'+next+'"]').click()
110
- else
111
- next = keys[keys.length-1]
112
- $('.watch[key="'+next+'"]').click()
86
+ next_movie()
113
87
  next_loop()
114
88
  ,200
115
89
 
90
+ next_movie = ->
91
+ if $('video')[0]
92
+ v = document.querySelector 'video'
93
+ key = $(v).attr 'key'
94
+ keys = $.map($('.watch'), (n,i)-> $(n).attr('key'))
95
+ index = keys.indexOf key
96
+ if $('#tv').text() == 'true'
97
+ next = keys[index+1]
98
+ else
99
+ next = keys[index-1]
100
+ if next
101
+ $('.watch[key="'+next+'"]').click()
102
+
116
103
  seek = (count)->
117
104
  node = document.querySelector '#play'
118
105
  node.currentTime = node.currentTime + count
@@ -123,22 +110,55 @@ pause = ->
123
110
  node.play()
124
111
  else
125
112
  node.pause()
113
+ window.gyazo = ->
114
+ c = document.querySelector '#canvas'
115
+ v = document.querySelector 'video'
116
+ context = c.getContext '2d'
117
+ c.width = v.videoWidth
118
+ c.height = v.videoHeight
119
+ context.drawImage(v, 0, 0)
120
+ url = c.toDataURL()
121
+ $.post('/gyazo', {url: url, point: localStorage.gyazo}).success((data)->
122
+ window.open(data.url, "", "width=500,height=400")
123
+ )
126
124
 
127
- key_func_j = ->
128
- seek (15) if $('video')[0]
125
+ window.tweet = ->
126
+ c = document.querySelector '#canvas'
127
+ v = document.querySelector 'video'
128
+ context = c.getContext '2d'
129
+ c.width = v.videoWidth
130
+ c.height = v.videoHeight
131
+ context.drawImage(v, 0, 0)
132
+ url = c.toDataURL()
133
+ $.post('/gyazo/tweet', {url: url}).success((data)->
134
+ true
135
+ )
129
136
 
130
- key_func_k = ->
131
- seek (-15) if $('video')[0]
137
+ window.tweet_with_comment = ->
138
+ c = document.querySelector '#canvas'
139
+ v = document.querySelector 'video'
140
+ context = c.getContext '2d'
141
+ c.width = v.videoWidth
142
+ c.height = v.videoHeight
143
+ context.drawImage(v, 0, 0)
144
+ url = c.toDataURL()
145
+ comment = prompt 'Tweet'
146
+ $.post('/gyazo/tweet', {url: url, comment: comment}).success((data)->
147
+ true
148
+ )
132
149
 
133
- key_func_g = ->
134
- gyazo() if $('video')[0]
135
150
 
136
- key_func_p = ->
137
- pause() if $('video')[0]
151
+ key_func_j = -> seek (15) if $('video')[0]
152
+ key_func_k = -> seek (-15) if $('video')[0]
153
+ key_func_g = -> gyazo() if $('video')[0]
154
+ key_func_t = -> tweet() if $('video')[0]
155
+ key_func_c = -> tweet_with_comment() if $('video')[0]
156
+ key_func_p = -> pause() if $('video')[0]
157
+ key_func_n = -> next_movie()
138
158
 
139
159
  remote = ->
140
160
  $('a.remote').click ->
141
- save_to_pig remote_key: $(this).attr('key')
161
+ save_to_pig 'remote_key', $(this).attr('key')
142
162
 
143
163
 
144
164
  $ ->
@@ -148,6 +168,10 @@ $ ->
148
168
  remote()
149
169
  $(window).keyup (e)->
150
170
  switch e.keyCode
171
+ when 67
172
+ key_func_c()
173
+ when 84
174
+ key_func_t()
151
175
  when 74
152
176
  key_func_j()
153
177
  when 75
@@ -156,5 +180,7 @@ $ ->
156
180
  key_func_p()
157
181
  when 71
158
182
  key_func_g()
183
+ when 78
184
+ key_func_n()
159
185
 
160
186
  # vim: set ft=coffee:
@@ -0,0 +1,22 @@
1
+ !!!
2
+ %title Pig Media Server
3
+ %meta(content='width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' name='viewport')
4
+ %script(src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js")
5
+ %link{href: '/app.css', rel: 'stylesheet', type: 'text/css'}
6
+ %script{src: 'https://code.jquery.com/jquery.min.js'}
7
+
8
+ %span.none#user_id=session[:user_id]
9
+
10
+ #application
11
+
12
+ :javascript
13
+ var user_id = document.querySelector('#user_id').textContent
14
+ if(user_id == ''){
15
+ if(localStorage.user_id != undefined && localStorage.user_id != ''){
16
+ $.post('/sessions', {user_id: localStorage.user_id}).done(function(){location.reload()});
17
+ }
18
+ } else {
19
+ if(user_id != ''){ localStorage.user_id = user_id }
20
+ }
21
+
22
+ %script(src="/bundle.js")
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  %meta{charset: 'UTF-8'}
3
- %title Remote - Pig Media Server
4
- %script{src: 'http://code.jquery.com/jquery.min.js'}
3
+ %title Remote - #{config['page_title']}
4
+ %script{src: 'https://code.jquery.com/jquery.min.js'}
5
5
  -%w{movie storage remote unread session}.each do |js|
6
6
  %script{src: "/#{js}.js"}
7
7
  %meta(content='width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' name='viewport')
@@ -4,3 +4,8 @@ $ ->
4
4
  if localStorage.user_id != undefined and localStorage.user_id != ''
5
5
  if user_id == ''
6
6
  $.post('/sessions', user_id: localStorage.user_id).success(-> location.reload())
7
+
8
+ window.logout = ->
9
+ console.log 'Logout'
10
+ delete localStorage.user_id
11
+ location.pathname = '/sessions'
@@ -1,12 +1,7 @@
1
1
  window.get_recents = (func)->
2
2
  if $('#user_id').text() and $('#user_id').text() != ''
3
3
  dd = new Date()
4
- $.get('/hash', stamp: dd.getTime()).success((data)->
5
- if data['recents']
6
- func data['recents']
7
- else
8
- func {}
9
- )
4
+ $.get('/recents', stamp: dd.getTime()).success((data)-> func data)
10
5
  else
11
6
  try
12
7
  recents = JSON.parse window.localStorage['recents']
@@ -16,17 +11,11 @@ window.get_recents = (func)->
16
11
 
17
12
  window.save_recents = (recents)->
18
13
  if $('#user_id').text() and $('#user_id').text() != ''
19
- $.get('/hash').success((data)->
20
- data['recents'] = recents
21
- $.post('/hash', json: JSON.stringify(data))
22
- )
23
-
14
+ $.post("/recents", data: JSON.stringify(recents))
24
15
  else
25
16
  window.localStorage['recents'] = JSON.stringify recents
26
17
 
27
- window.save_to_pig = (hash)->
28
- $.get('/hash').success((data)->
29
- data = $.extend data, hash
30
- $.post('/hash', json: JSON.stringify(data)))
31
- window.get_from_pig = (key, func)-> $.get('/hash').success((data)-> func(data[key]))
18
+ window.save_to_pig = (key, value)->
19
+ $.post('/data', key: key, value: value)
20
+ window.get_from_pig = (key, func)-> $.get('/data', key: key).success((data)-> func(data))
32
21
 
@@ -1,14 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  %meta{charset: 'UTF-8'}
3
- %title Pig Media Server
3
+ %title #{config['page_title']}
4
4
  %link{href: '/app.css', rel: 'stylesheet', type: 'text/css'}
5
- %script{src: 'http://code.jquery.com/jquery.min.js'}
6
-
5
+ %script{src: 'https://code.jquery.com/jquery.min.js'}
7
6
  %script{src: '/sub.js'}
8
7
  %script{src: '/subview.js'}
9
8
  %meta{content: 'width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=no', name: 'viewport'}
10
9
  #all
11
- %h1 pig.ssig33.com
10
+ %h1 #{config['page_title']}
12
11
  %form{method: 'GET', action: '/'}
13
12
  %input{name: 'query', value: params[:query]}
14
13
  %button Search
@@ -27,6 +26,6 @@
27
26
  %a{href: "/nosub/#{params[:key]}"} Edit
28
27
  .none
29
28
  %span#key=params[:key]
30
- %span#url="/data/#{@p.path}"
29
+ %span#url=@p.url
31
30
  %span#path
32
- %canvas
31
+ %canvas#canvas