pig-media-server 2 → 100

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.
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
data/package.json CHANGED
@@ -1,23 +1,18 @@
1
1
  {
2
2
  "main": "javascript/main.js",
3
- "description": "music",
3
+ "description": "pig",
4
4
  "dependencies": {
5
- "react": "",
6
- "react-dom": "",
7
- "moment": "",
8
- "moment-timezone": "",
9
- "jquery": ""
10
- },
11
- "devDependencies": {
12
- "browser-sync": "",
13
- "browserify": "",
14
- "babelify": "",
15
- "gulp-webserver": "",
16
- "gulp": "3.9.0",
17
- "gulp-babel": "",
18
- "vinyl-source-stream": "",
19
- "vinyl-buffer": "",
20
- "babel": "",
21
- "gulp-uglify": ""
5
+ "react": "0.14.7",
6
+ "react-dom": "0.14.7",
7
+ "react-router": "2.0.1",
8
+ "jquery": "2.2.2",
9
+ "webpack": "1.12.14",
10
+ "babel-preset-es2016-node5": "1.1.2",
11
+ "babel-preset-es2015": "6.6.0",
12
+ "babel-preset-react": "6.5.0",
13
+ "babel-loader": "6.2.4",
14
+ "babel-core": "6.7.0",
15
+ "css-loader": "0.23.1",
16
+ "style-loader": "0.13.0"
22
17
  }
23
18
  }
data/webpack.build.js ADDED
@@ -0,0 +1,25 @@
1
+ var webpack = require('webpack');
2
+ module.exports = {
3
+ entry: "./front/application.js",
4
+ output: {
5
+ path: "./lib/pig-media-server/views/",
6
+ filename: "bundle.js"
7
+ },
8
+ module: {
9
+ loaders: [
10
+ {
11
+ test: /\.css$/,
12
+ loader: "style!css"
13
+ },
14
+ {
15
+ test: /.js?$/,
16
+ loader: 'babel-loader',
17
+ exclude: /node_modules/,
18
+ query: {
19
+ presets: ['es2016-node5', 'react', 'es2015']
20
+ }
21
+ }
22
+ ]
23
+ },
24
+ plugins: [new webpack.optimize.UglifyJsPlugin()]
25
+ };
data/webpack.config.js ADDED
@@ -0,0 +1,30 @@
1
+ module.exports = {
2
+ entry: "./front/application.js",
3
+ output: {
4
+ path: "./lib/pig-media-server/views/",
5
+ filename: "bundle.js"
6
+ },
7
+ module: {
8
+ loaders: [
9
+ {
10
+ test: /\.css$/,
11
+ loader: "style!css"
12
+ },
13
+ {
14
+ test: /.js?$/,
15
+ loader: 'babel-loader',
16
+ exclude: /node_modules/,
17
+ query: {
18
+ presets: ['es2016-node5', 'react', 'es2015']
19
+ }
20
+ }
21
+ ]
22
+ },
23
+ devtool: "inline-source-map",
24
+ module: {
25
+ loaders: [
26
+ {test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"},
27
+ { test: /\.css$/, loader: "style!css" },
28
+ ]
29
+ }
30
+ };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pig-media-server
3
3
  version: !ruby/object:Gem::Version
4
- version: '2'
4
+ version: '100'
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssig33
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-14 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rroonga
@@ -298,28 +298,40 @@ executables:
298
298
  extensions: []
299
299
  extra_rdoc_files: []
300
300
  files:
301
+ - ".babelrc"
301
302
  - ".gitignore"
302
303
  - Gemfile
303
304
  - LICENSE.txt
304
305
  - README.md
305
306
  - Rakefile
306
307
  - bin/pig-media-server
307
- - gulpfile.js
308
- - javascripts/application.js
309
- - javascripts/chromecast.js
310
- - javascripts/components/head.js
311
- - javascripts/components/list.js
312
- - javascripts/components/new_flag.js
313
- - javascripts/components/player.js
314
- - javascripts/components/query_list.js
315
- - javascripts/components/sort.js
316
- - javascripts/components/watch.js
317
- - javascripts/controller.js
318
- - javascripts/custom_list.js
319
- - javascripts/event_dispatcher.js
320
- - javascripts/recent.js
321
- - javascripts/utils.js
322
- - javascripts/video.js
308
+ - front/application.js
309
+ - front/chromecast.js
310
+ - front/components/custom.js
311
+ - front/components/head.js
312
+ - front/components/index.js
313
+ - front/components/item.js
314
+ - front/components/latest.js
315
+ - front/components/new_flag.js
316
+ - front/components/no_match.js
317
+ - front/components/pager.js
318
+ - front/components/player.js
319
+ - front/components/query_list.js
320
+ - front/components/recommend.js
321
+ - front/components/search.js
322
+ - front/components/search_box.js
323
+ - front/components/watch.js
324
+ - front/controller.js
325
+ - front/models/base.js
326
+ - front/models/config.js
327
+ - front/models/custom.js
328
+ - front/models/custom_list.js
329
+ - front/models/latest.js
330
+ - front/models/list.js
331
+ - front/models/playing.js
332
+ - front/models/recent.js
333
+ - front/models/recommend.js
334
+ - front/models/session.js
323
335
  - lib/pig-media-server.rb
324
336
  - lib/pig-media-server/api.rb
325
337
  - lib/pig-media-server/aspect.rb
@@ -330,6 +342,7 @@ files:
330
342
  - lib/pig-media-server/kindle_send.rb
331
343
  - lib/pig-media-server/model/comic.rb
332
344
  - lib/pig-media-server/model/data.rb
345
+ - lib/pig-media-server/model/data_use_rdb.rb
333
346
  - lib/pig-media-server/model/migrate.rb
334
347
  - lib/pig-media-server/model/pig.rb
335
348
  - lib/pig-media-server/script.rb
@@ -374,6 +387,8 @@ files:
374
387
  - lib/pig-media-server/web.rb
375
388
  - package.json
376
389
  - pig-media-server.gemspec
390
+ - webpack.build.js
391
+ - webpack.config.js
377
392
  homepage: http://github.com/ssig33/pig-media-server
378
393
  licenses:
379
394
  - MIT
@@ -394,7 +409,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
394
409
  version: '0'
395
410
  requirements: []
396
411
  rubyforge_project:
397
- rubygems_version: 2.2.2
412
+ rubygems_version: 2.5.1
398
413
  signing_key:
399
414
  specification_version: 4
400
415
  summary: Pig Media Server
data/gulpfile.js DELETED
@@ -1,33 +0,0 @@
1
- var gulp = require('gulp');
2
- var browserify = require('browserify');
3
- var babelify = require('babelify');
4
- var source = require('vinyl-source-stream');
5
- var uglify = require('gulp-uglify');
6
- var buffer = require('vinyl-buffer');
7
- var cssDir = 'stylesheets'
8
-
9
- gulp.task('browserify', function() {
10
- browserify('./javascripts/application.js', { debug: true })
11
- .transform(babelify)
12
- .bundle()
13
- .on("error", function (err) { console.log("Error : " + err.message); })
14
- .pipe(source('bundle.js'))
15
- .pipe(gulp.dest('./lib/pig-media-server/views/'))
16
- });
17
-
18
- gulp.task('build', function(){
19
- browserify('./javascripts/application.js', { debug: true })
20
- .transform(babelify)
21
- .bundle()
22
- .on("error", function (err) { console.log("Error : " + err.message); })
23
- .pipe(source('bundle.js'))
24
- .pipe(buffer())
25
- .pipe(uglify())
26
- .pipe(gulp.dest('./lib/pig-media-server/views/'))
27
-
28
- });
29
-
30
-
31
- gulp.task('watch', ['browserify'], function(){
32
- gulp.watch('./javascripts/**/*.js', ['browserify']);
33
- });
@@ -1,117 +0,0 @@
1
- window.React = require('react');
2
- window.ReactDOM = require('react-dom');
3
- window.$ = window.jQuery = require('jquery');
4
- window.moment = require('moment-timezone');
5
-
6
- require('./chromecast.js');
7
-
8
- require('./utils.js');
9
- require('./controller.js');
10
-
11
- require('./event_dispatcher.js');
12
-
13
- require('./recent.js');
14
- require('./video.js');
15
- require('./custom_list.js');
16
-
17
- require('./components/head.js');
18
- require('./components/sort.js');
19
- require('./components/list.js');
20
- require('./components/query_list.js');
21
- require('./components/new_flag.js');
22
- require('./components/watch.js');
23
- require('./components/player.js');
24
-
25
- class Application extends React.Component {
26
- constructor(props){
27
- super(props);
28
- this.controller = new Controller();
29
- this.recent = new Recent(this);
30
- this.video = new Video();
31
- this.custom_list = new CustomList(this);
32
-
33
- this.state = {
34
- config: {},
35
- session: {},
36
- items: [],
37
- recent: {},
38
- video: null,
39
-
40
- open: (link)=>{this.open(link)},
41
- initialize: ()=>{this.initialize()},
42
- update_state: ()=>{this.update_state()},
43
-
44
- controller: this.controller,
45
-
46
- models: {video: this.video, recent: this.recent, custom_list: this.custom_list}
47
- }
48
-
49
- this.state.models.video.addEventListener('videoUpdated', ()=>{ this.setState(this.state); });
50
-
51
- window.addEventListener('popstate',(ev)=>{ this.initialize(); },false);
52
- }
53
-
54
- open(link){
55
- history.pushState('', '', link);
56
- this.initialize();
57
- }
58
-
59
- update_state(){ this.setState(this.state); }
60
-
61
- load_from_api(url){
62
- if(!!url){
63
- $.get(url).done((data)=>{ this.state.items = data; this.update_state(); });
64
- } else {
65
- this.state.items = [];
66
- this.update_state();
67
- }
68
- }
69
-
70
- load_config(){ $.get("/api/r/config").done((data)=>{ this.state.config = data; this.update_state(); })}
71
- load_session(){
72
- $.get("/api/r/session").done((data)=>{
73
- this.state.session = data;
74
- this.update_state();
75
- this.load_recent();
76
- })
77
- }
78
-
79
- load_recent(){ this.recent.load() }
80
-
81
- routing(){
82
- var route = this.controller.route();
83
- switch(route.page){
84
- case "list":
85
- this.load_from_api(this.controller.route().api_url);
86
- this.state.active_page = 'list';
87
- this.update_state();
88
- break;
89
- }
90
- }
91
-
92
- initialize(){
93
- this.load_config();
94
- this.load_session();
95
- this.custom_list.load();
96
- this.routing()
97
- }
98
-
99
- componentDidMount(){ this.initialize() }
100
-
101
- render(){
102
- return <div>
103
- <Player state={this.state} />
104
- <div id='all'>
105
- <Head state={this.state} />
106
- <SearchBox state={this.state}/>
107
- <List state={this.state}/>
108
- <QueryList state={this.state}/>
109
- </div>
110
- </div>
111
- }
112
- }
113
-
114
- ReactDOM.render(<Application />, document.querySelector("#application"));
115
-
116
-
117
-
@@ -1,106 +0,0 @@
1
- class LoginAs extends React.Component {
2
- render(){
3
- return <span>Login as {this.props.user_id}</span>
4
- }
5
- }
6
-
7
- class LoginLink extends React.Component {
8
- render(){
9
- return <a href='/sessions'>Login</a>
10
- }
11
- }
12
-
13
- class Session extends React.Component {
14
- render(){
15
- return <div>
16
- {this.props.state.session.user_id ?
17
- <LoginAs user_id={this.props.state.session.user_id} /> :
18
- <LoginLink />
19
- }
20
- </div>
21
- }
22
- }
23
-
24
- class Head extends React.Component {
25
- click(){
26
- this.props.state.open('/');
27
- }
28
- render(){
29
- return <div>
30
- <Session state={this.props.state} />
31
- <h2>
32
- <a href='javascript:void(0)' onClick={()=> this.click()}>
33
- {this.props.state.config.page_title}
34
- </a>
35
- </h2>
36
- </div>
37
- }
38
- }
39
-
40
- class CustomList extends React.Component{
41
- click(){
42
- this.props.state.open(`/custom?name=${encodeURIComponent(this.props.name)}`)
43
- }
44
- render(){
45
- return <a href='javascript:void(0)' onClick={()=> this.click()}>{this.props.name}</a>
46
- }
47
- }
48
-
49
- class Recommend extends React.Component{
50
- click(){ this.props.state.open(`/recommend?name=${localStorage.user_id}`) }
51
- render(){
52
- return <span>
53
- {!!localStorage.user_id ? <a href='javascript:void(0)' onClick={()=> this.click()}><b>Recommend</b></a> : null}
54
- </span>
55
- }
56
- }
57
-
58
- class SearchBox extends React.Component {
59
- submit(event){
60
- event.preventDefault();
61
- var query = this.refs.input.value;
62
- var url = `/?query=${encodeURIComponent(query)}`
63
- history.pushState(url, '', url);
64
- this.props.state.initialize();
65
- }
66
- click(e){ this.props.state.open(e.target.dataset.url); }
67
-
68
- full_screen(){
69
- var elem = document.querySelector("body");
70
- if (elem.requestFullScreen) {
71
- elem.requestFullScreen();
72
- } else if (elem.mozRequestFullScreen) {
73
- elem.mozRequestFullScreen();
74
- } else if (elem.webkitRequestFullScreen) {
75
- elem.webkitRequestFullScreen();
76
- }
77
- }
78
-
79
- componentDidUpdate(){
80
- var query = decodeURIComponent(this.props.state.controller.query());
81
- if(query == 'undefined' || query == 'null' || !query){query = ''}
82
- this.refs.input.value = query;
83
- }
84
-
85
-
86
-
87
- change(){ }
88
-
89
- render(){
90
- var query = decodeURIComponent(this.props.state.controller.query());
91
- if(query == 'undefined' || query == 'null' || !query){query = ''}
92
- var custom_list = $.map(this.props.state.models.custom_list.list, (v,k)=>{return <CustomList key={k} name={k} state={this.props.state}/>});
93
- return <form onSubmit={(e)=> this.submit(e)}>
94
- <input ref='input' defaultValue={query} onChange={()=>{this.change()}}/><button>Search</button>
95
- <a href='javascript:void(0)' onClick={(e)=>this.click(e)} data-url='/latest'>Latest</a>
96
- <a href='/config'>Config</a>
97
- <a href='javascript:void(0)' onClick={()=> this.full_screen()}>Full Screen</a>
98
- <Recommend state={this.props.state} />
99
- <br />
100
- {custom_list}
101
- </form>
102
- }
103
- }
104
-
105
- window.Head = Head;
106
- window.SearchBox = SearchBox;
@@ -1,104 +0,0 @@
1
- class CustomLinks extends React.Component{
2
- render(){
3
- return <span dangerouslySetInnerHTML={{__html: this.props.item.custom_links}}/>
4
- }
5
- }
6
-
7
- class Item extends React.Component {
8
- mtime(){
9
- //moment(this.props.item.mtime)
10
- return this.props.item.mtime;
11
- }
12
-
13
- render(){
14
- var item = this.props.item;
15
- var meta = `/meta/${this.props.item.key}`;
16
- var sub = `/sub/${this.props.item.key}`;
17
- return <span className='main_span'>
18
- <NewFlag
19
- item={this.props.item}
20
- state={this.props.state}
21
- />
22
- <a href={item.url} className='main_link'>{item.name}</a>&nbsp;
23
-
24
- <Watch
25
- item={this.props.item}
26
- state={this.props.state}
27
- />
28
- <ChromeCast
29
- item={this.props.item}
30
- state={this.props.state}
31
- />
32
- <span className='mtime'>{this.mtime()}</span>&nbsp;
33
- <span className='size'>{size_pretty(item.size)}</span>&nbsp;
34
- <a className='meta' href={meta}>Meta</a>
35
- <a className='meta' href={sub}>Sub</a>
36
- <CustomLinks item={this.props.item} />
37
- </span>
38
- }
39
- }
40
-
41
- class Pager extends React.Component {
42
- constructor(props){
43
- super(props);
44
- this.page = 1;
45
- var page = this.props.state.controller.params().page;
46
- if(page){ this.page = parseInt(page)}
47
- this.bind();
48
- }
49
-
50
- bind(){
51
- $(window).on("scroll",()=>{
52
- var scrollHeight = $(document).height();
53
- var scrollPosition = $(window).height() + $(window).scrollTop();
54
- if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
55
- if(this.props.state.controller.can_sort_and_paging()|| location.pathname == '/latest'){
56
- this.click();
57
- }
58
- }
59
- });
60
- }
61
- click(){
62
- this.page ++;
63
- if(location.pathname == '/latest'){
64
- var url = this.props.state.controller.route().api_url += `?page=${this.page}`;
65
- } else {
66
- var url = this.props.state.controller.route().api_url += `&page=${this.page}`;
67
- }
68
- $.get(url).done((data)=>{
69
- this.props.state.items = this.props.state.items.concat(data);
70
- this.props.state.update_state();
71
- if(location.pathname == '/latest'){
72
- var new_url = `/latest?page=${this.page}`;
73
- } else {
74
- var new_url = `/?query=${this.props.state.controller.query()}&page=${this.page}`;
75
- }
76
- history.pushState('', '', new_url);
77
- });
78
- }
79
-
80
- render(){ return <a href='javascript:void(0)' onClick={()=> this.click()}>Next</a> }
81
- }
82
-
83
-
84
- class List extends React.Component {
85
- can_sort(){ return this.props.state.controller.can_sort_and_paging()}
86
- render(){
87
-
88
- var items = $.map(this.props.state.items, (item)=>{
89
- return <Item
90
- key={item.key}
91
- state={this.props.state}
92
- item={item}
93
- />
94
- });
95
-
96
- return <div>
97
- {this.can_sort() ? <Sort state={this.props.state} /> : null }
98
- <p>{items}</p>
99
- <p>{this.can_sort() || location.pathname == '/latest' ? <Pager state={this.props.state} /> : null }</p>
100
- </div>
101
- }
102
- }
103
-
104
- window.List = List;
@@ -1,23 +0,0 @@
1
- class NewFlag extends React.Component{
2
- is_new(){
3
- if(!!this.props.state.recents){
4
- var ext = window.ext(this.props.item.name);
5
- if(ext == 'mp4' || ext == 'flv'){
6
- var result = true;
7
- $.each(this.props.state.recents, (k,v)=>{ if(k == `movie/${this.props.item.key}`){ result = false } });
8
- return result
9
- } else {
10
- return false;
11
- }
12
- } else {
13
- return false;
14
- }
15
- }
16
-
17
- render(){
18
- var is_new = this.is_new();
19
- return <span>{is_new ? <span className='new_flag' style={{color:'lime', "fontWeight":'bold'}}>New</span> : null }</span>
20
- }
21
- }
22
-
23
- window.NewFlag = NewFlag;
@@ -1,64 +0,0 @@
1
- class QuerySave extends React.Component{
2
- constructor(props){
3
- super(props);
4
- this.controller = new Controller();
5
- }
6
-
7
- click(){
8
- var query = decodeURIComponent(this.controller.query());
9
- $.post("/api/r/query_list", {query: query})
10
- }
11
- render(){
12
- return <span>
13
- <a href='javascript:void(0)' onClick={()=> this.click()}>Save Query</a>
14
- </span>
15
- }
16
- }
17
-
18
- class Sort extends React.Component{
19
- constructor(props){
20
- super(props);
21
- this.controller = new Controller();
22
- }
23
-
24
- sort_by_date(){
25
- var query = this.controller.query();
26
- var new_url = `/?query=${query}&sort=date&order=descending`
27
- history.pushState("", "", new_url);
28
- this.props.state.initialize();
29
- }
30
-
31
- sort_by_name(){
32
- var query = this.controller.query();
33
- var new_url = `/?query=${query}&sort=name&order=ascending`
34
- history.pushState("", "", new_url);
35
- this.props.state.initialize();
36
- }
37
-
38
- change_order(order){
39
- var query = this.controller.query();
40
- var sort = this.controller.params().sort;
41
- var new_url = `/?query=${query}&sort=${sort}&order=${order}`
42
- history.pushState("", "", new_url);
43
- this.props.state.initialize();
44
-
45
- }
46
-
47
- can_change_order(){ return !!this.controller.params().sort; }
48
- render(){
49
- return <p>
50
- <a href="javascript:void(0)" onClick={()=> this.sort_by_date()}>Sort By Date</a>
51
- <a href="javascript:void(0)" onClick={()=> this.sort_by_name()}>Sort By Name</a>
52
- {this.can_change_order() ?
53
- <span>
54
- <a href="javascript:void(0)" onClick={()=> this.change_order('ascending')}>Ascending</a>
55
- <a href="javascript:void(0)" onClick={()=> this.change_order('descending')}>Descending</a>
56
- </span>
57
- : null
58
- }
59
- <QuerySave />
60
- </p>
61
- }
62
- }
63
-
64
- window.Sort = Sort;