pig-media-server 2 → 100

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.babelrc +3 -0
  3. data/Gemfile +1 -0
  4. data/front/application.js +71 -0
  5. data/front/components/custom.js +35 -0
  6. data/front/components/head.js +38 -0
  7. data/front/components/index.js +23 -0
  8. data/front/components/item.js +63 -0
  9. data/front/components/latest.js +32 -0
  10. data/front/components/new_flag.js +29 -0
  11. data/front/components/no_match.js +10 -0
  12. data/front/components/pager.js +38 -0
  13. data/{javascripts → front}/components/player.js +7 -11
  14. data/{javascripts → front}/components/query_list.js +6 -23
  15. data/front/components/recommend.js +41 -0
  16. data/front/components/search.js +87 -0
  17. data/front/components/search_box.js +56 -0
  18. data/{javascripts → front}/components/watch.js +8 -5
  19. data/front/controller.js +22 -0
  20. data/{javascripts/event_dispatcher.js → front/models/base.js} +1 -5
  21. data/front/models/config.js +12 -0
  22. data/front/models/custom.js +41 -0
  23. data/front/models/custom_list.js +12 -0
  24. data/front/models/latest.js +60 -0
  25. data/front/models/list.js +76 -0
  26. data/front/models/playing.js +11 -0
  27. data/front/models/recent.js +34 -0
  28. data/front/models/recommend.js +13 -0
  29. data/front/models/session.js +16 -0
  30. data/lib/pig-media-server/api.rb +35 -3
  31. data/lib/pig-media-server/backup.rb +3 -7
  32. data/lib/pig-media-server/model/comic.rb +1 -1
  33. data/lib/pig-media-server/model/data.rb +85 -81
  34. data/lib/pig-media-server/model/data_use_rdb.rb +124 -0
  35. data/lib/pig-media-server/version.rb +1 -1
  36. data/lib/pig-media-server/views/bundle.js +48 -13
  37. data/package.json +13 -18
  38. data/webpack.build.js +25 -0
  39. data/webpack.config.js +30 -0
  40. metadata +34 -19
  41. data/gulpfile.js +0 -33
  42. data/javascripts/application.js +0 -117
  43. data/javascripts/components/head.js +0 -106
  44. data/javascripts/components/list.js +0 -104
  45. data/javascripts/components/new_flag.js +0 -23
  46. data/javascripts/components/sort.js +0 -64
  47. data/javascripts/controller.js +0 -62
  48. data/javascripts/custom_list.js +0 -14
  49. data/javascripts/recent.js +0 -34
  50. data/javascripts/utils.js +0 -22
  51. data/javascripts/video.js +0 -10
  52. /data/{javascripts → front}/chromecast.js +0 -0
@@ -0,0 +1,124 @@
1
+ #coding:utf-8
2
+ require 'fileutils'
3
+ require 'digest/md5'
4
+ require 'pig-media-server/model/migrate'
5
+
6
+ require 'active_record'
7
+
8
+ ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
9
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
10
+
11
+ tables = ActiveRecord::Base.connection.tables
12
+
13
+ unless tables.index('app_datas')
14
+ ActiveRecord::Migration.create_table :app_datas do |t|
15
+ t.string :key
16
+ t.string :original_key
17
+ t.text :value
18
+ t.timestamps null: false
19
+ end
20
+ end
21
+
22
+ unless tables.index('stars')
23
+ ActiveRecord::Migration.create_table :stars do |t|
24
+ t.string :user_id
25
+ t.string :key
26
+ t.timestamps null: false
27
+ end
28
+ end
29
+
30
+ unless tables.index('recents')
31
+ ActiveRecord::Migration.create_table :recents do |t|
32
+ t.string :user_id
33
+ t.string :key
34
+ t.timestamps null: false
35
+ end
36
+ end
37
+
38
+ class AppData < ActiveRecord::Base
39
+ def self.find key
40
+ key = Digest::MD5.hexdigest(key)
41
+ a = self.where(key: key).first
42
+ if a
43
+ a.parse
44
+ else
45
+ nil
46
+ end
47
+ end
48
+
49
+ def self.set key, value
50
+ a_key = Digest::MD5.hexdigest(key)
51
+ a = self.find_or_create_by(key: a_key)
52
+ a.value = value.to_json
53
+ a.original_key = key
54
+ a.save!
55
+ end
56
+
57
+ def self.all
58
+ super.map{|x| {key: x.original_key, value: x.parse}}
59
+ end
60
+
61
+ def parse
62
+ val = self.value
63
+ case val
64
+ when 'true'
65
+ true
66
+ when 'false'
67
+ false
68
+ else
69
+ JSON.parse val
70
+ end
71
+
72
+ rescue
73
+ if val.class == String
74
+ val.gsub(/^"|"$/, '')
75
+ else
76
+ val
77
+ end
78
+ end
79
+ end
80
+
81
+ class Star < ActiveRecord::Base
82
+ end
83
+
84
+ class Stars
85
+ def self.list user
86
+ Pig.find Star.where(user_id: user).map{|x| x.key}
87
+ end
88
+
89
+ def self.star? user, key
90
+ !!Star.where(user_id: user, key: key).first
91
+ end
92
+
93
+ def self.star user, key
94
+ Star.find_or_create_by(user_id: user, key: key)
95
+ end
96
+
97
+ def self.unstar user, key
98
+ s = Star.where(user_id: user, key: key).first
99
+ s.destroy if s
100
+ end
101
+ end
102
+
103
+ class Recent < ActiveRecord::Base
104
+ end
105
+
106
+ class Recents
107
+ def self.list user
108
+ hash = {}
109
+ Recent.where(user_id: user).each{|r|
110
+ hash[r.key] = {}
111
+ }
112
+ hash
113
+ end
114
+
115
+ def self.recent? user, key
116
+ !!Recent.where(user_id: user, key: key).first
117
+ rescue
118
+ nil
119
+ end
120
+
121
+ def self.recent user, key
122
+ Recent.find_or_create_by(user_id: user, key: key)
123
+ end
124
+ end
@@ -1,3 +1,3 @@
1
1
  module PigMediaServer
2
- VERSION = "2"
2
+ VERSION = "100"
3
3
  end