From 82eba9d9e3efbd9fd31058965d53b7f22a3451b1 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Sat, 16 Aug 2014 20:46:32 -0500 Subject: [PATCH 1/1] Initial working version --- .gitignore | 3 +++ .gitmodules | 24 ++++++++++++++++++++ config.json.example | 5 +++++ debug.html | 20 +++++++++++++++++ deploy.json | 6 +++++ enyo | 1 + index.html | 21 +++++++++++++++++ lib/layout | 1 + lib/moonstone | 1 + lib/spotlight | 1 + package.js | 5 +++++ source/App.js | 27 ++++++++++++++++++++++ source/data/ShowCollection.js | 5 +++++ source/data/ShowModel.js | 12 ++++++++++ source/data/package.js | 4 ++++ source/nettv/EpisodeItem.js | 9 ++++++++ source/nettv/EpisodeListing.js | 19 ++++++++++++++++ source/nettv/Main.js | 35 +++++++++++++++++++++++++++++ source/nettv/ShowItem.js | 9 ++++++++ source/nettv/ShowListing.js | 33 +++++++++++++++++++++++++++ source/nettv/Util.js | 8 +++++++ source/nettv/package.js | 8 +++++++ source/package.js | 9 ++++++++ source/style/nettv.less | 0 source/style/package.js | 3 +++ tools/deploy.bat | 40 +++++++++++++++++++++++++++++++++ tools/deploy.sh | 41 ++++++++++++++++++++++++++++++++++ 27 files changed, 350 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 config.json.example create mode 100644 debug.html create mode 100644 deploy.json create mode 160000 enyo create mode 100644 index.html create mode 160000 lib/layout create mode 160000 lib/moonstone create mode 160000 lib/spotlight create mode 100644 package.js create mode 100644 source/App.js create mode 100644 source/data/ShowCollection.js create mode 100644 source/data/ShowModel.js create mode 100644 source/data/package.js create mode 100644 source/nettv/EpisodeItem.js create mode 100644 source/nettv/EpisodeListing.js create mode 100644 source/nettv/Main.js create mode 100644 source/nettv/ShowItem.js create mode 100644 source/nettv/ShowListing.js create mode 100644 source/nettv/Util.js create mode 100644 source/nettv/package.js create mode 100644 source/package.js create mode 100644 source/style/nettv.less create mode 100644 source/style/package.js create mode 100755 tools/deploy.bat create mode 100755 tools/deploy.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5bc681 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +deploy/ +config.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9a5e2ed --- /dev/null +++ b/.gitmodules @@ -0,0 +1,24 @@ +[submodule "www/enyo"] + path = www/enyo + url = https://github.com/enyojs/enyo.git +[submodule "www/lib/onyx"] + path = www/lib/onyx + url = https://github.com/enyojs/onyx.git +[submodule "www/lib/layout"] + path = www/lib/layout + url = https://github.com/enyojs/layout.git +[submodule "enyo"] + path = enyo + url = https://github.com/enyojs/enyo.git +[submodule "lib/onyx"] + path = lib/onyx + url = https://github.com/enyojs/onyx.git +[submodule "lib/layout"] + path = lib/layout + url = https://github.com/enyojs/layout.git +[submodule "lib/moonstone"] + path = lib/moonstone + url = https://github.com/enyojs/moonstone.git +[submodule "lib/spotlight"] + path = lib/spotlight + url = https://github.com/enyojs/spotlight.git diff --git a/config.json.example b/config.json.example new file mode 100644 index 0000000..e4df7a2 --- /dev/null +++ b/config.json.example @@ -0,0 +1,5 @@ +{ + "mediaURL": "http://server.example.com/media/audio/", + "mediaPath": "/media/audio/", + "listing": "http://server.example.com/nettv/listing.js" +} diff --git a/debug.html b/debug.html new file mode 100644 index 0000000..2eadb57 --- /dev/null +++ b/debug.html @@ -0,0 +1,20 @@ + + + + + NetTV (Debug) + + + + + + + + + + + + + + + diff --git a/deploy.json b/deploy.json new file mode 100644 index 0000000..1fa92c5 --- /dev/null +++ b/deploy.json @@ -0,0 +1,6 @@ +{ + "enyo": "./enyo", + "packagejs": "./package.js", + "assets": ["./icon.png", "./index.html", "./assets"], + "libs": ["./lib/moonstone", "./lib/layout"] +} diff --git a/enyo b/enyo new file mode 160000 index 0000000..4e7164b --- /dev/null +++ b/enyo @@ -0,0 +1 @@ +Subproject commit 4e7164be9532ce77beffd0afa5b604c055068dda diff --git a/index.html b/index.html new file mode 100644 index 0000000..d71f0c4 --- /dev/null +++ b/index.html @@ -0,0 +1,21 @@ + + + + + NetTV + + + + + + + + + + + + + + + + diff --git a/lib/layout b/lib/layout new file mode 160000 index 0000000..11002ee --- /dev/null +++ b/lib/layout @@ -0,0 +1 @@ +Subproject commit 11002ee2dfb85ec77961196679204791f2fca3dd diff --git a/lib/moonstone b/lib/moonstone new file mode 160000 index 0000000..d5b21ce --- /dev/null +++ b/lib/moonstone @@ -0,0 +1 @@ +Subproject commit d5b21ce2a2583e81a86392b1bdddc2b7402fcfd5 diff --git a/lib/spotlight b/lib/spotlight new file mode 160000 index 0000000..2b26937 --- /dev/null +++ b/lib/spotlight @@ -0,0 +1 @@ +Subproject commit 2b26937692ed0bdaf25e223300c92b16d69c774c diff --git a/package.js b/package.js new file mode 100644 index 0000000..ac5ed78 --- /dev/null +++ b/package.js @@ -0,0 +1,5 @@ +/* + == DO NOT EDIT THIS FILE! == + This is necessary to keep paths correct for the minification process +*/ +enyo.depends("source"); diff --git a/source/App.js b/source/App.js new file mode 100644 index 0000000..899260c --- /dev/null +++ b/source/App.js @@ -0,0 +1,27 @@ +config = {}; + +enyo.kind({ + name: "App", + kind: "enyo.Application", + view: "nettv.Main" +}); + +enyo.ready(function () { + new App(); + + var req = new enyo.Ajax({ + url: "config.json" + }); + req.response(this, function(inSender, inResponse) { + config = inResponse; + enyo.Signals.send('onConfigReceived'); + }); + req.error(this, function() { + enyo.log("Could not fetch config.json. Trying reasonable defaults."); + config = { + mediaURL: window.location + 'media/' + } + enyo.Signals.send('onConfigReceived'); + }); + req.go(); +}); diff --git a/source/data/ShowCollection.js b/source/data/ShowCollection.js new file mode 100644 index 0000000..5ffdb0d --- /dev/null +++ b/source/data/ShowCollection.js @@ -0,0 +1,5 @@ +enyo.kind({ + name: "ShowCollection", + kind: "enyo.Collection", + model: "ShowModel" +}); diff --git a/source/data/ShowModel.js b/source/data/ShowModel.js new file mode 100644 index 0000000..1f8289f --- /dev/null +++ b/source/data/ShowModel.js @@ -0,0 +1,12 @@ +enyo.kind({ + name: "ShowModel", + kind: "enyo.Model", + computed: { + thumbURL: ["thumb"] + }, + attributes: { + thumbURL: function() { + return nettv.Util.addBase(this.get('thumb')); + } + } +}); diff --git a/source/data/package.js b/source/data/package.js new file mode 100644 index 0000000..09e33f4 --- /dev/null +++ b/source/data/package.js @@ -0,0 +1,4 @@ +enyo.depends( + "ShowModel.js", + "ShowCollection.js" +); diff --git a/source/nettv/EpisodeItem.js b/source/nettv/EpisodeItem.js new file mode 100644 index 0000000..d5ed82b --- /dev/null +++ b/source/nettv/EpisodeItem.js @@ -0,0 +1,9 @@ +enyo.kind({ + name: "nettv.EpisodeItem", + kind: "moon.LabeledTextItem", + spotlight: true, + bindings: [ + {from: ".model.number", to: ".label", transform: function(n) { return "Episode " + n; }}, + {from: ".model.title", to: ".text"} + ] +}); diff --git a/source/nettv/EpisodeListing.js b/source/nettv/EpisodeListing.js new file mode 100644 index 0000000..14755f5 --- /dev/null +++ b/source/nettv/EpisodeListing.js @@ -0,0 +1,19 @@ +enyo.kind({ + name: "nettv.EpisodeListing", + kind: "moon.Panel", + smallHeader: true, + published: { + collection: null + }, + components: [ + {name: "episodeList", kind: "moon.DataList", components: [ + {kind: "nettv.EpisodeItem", ontap: "playEpisode"} + ]} + ], + bindings: [ + {from: ".collection", to: ".$.episodeList.collection"} + ], + playEpisode: function(inSender, inEvent) { + this.bubble('onPlayEpisode', this.collection.at(inEvent.index)); + } +}); diff --git a/source/nettv/Main.js b/source/nettv/Main.js new file mode 100644 index 0000000..fd79f82 --- /dev/null +++ b/source/nettv/Main.js @@ -0,0 +1,35 @@ +enyo.kind({ + name: "nettv.Main", + classes: "moon", + handlers: { + onShowEpisodes: "showEpisodes", + onPlayEpisode: "playEpisode" + }, + components: [ + {name: "navigationPanels", kind: "moon.Panels", pattern: "activity", classes: "enyo-fit", components: [ + {name: "showListing", kind: "nettv.ShowListing"} + ]}, + {name: "player", kind: "moon.VideoPlayer", classes: "enyo-fit", showing: false, + shakeAndWake: true, components: [ + {kind: "moon.IconButton", icon: "closex", ontap: "closePlayer", small: false} + ]} + ], + showEpisodes: function(inSender, inEvent) { + this.$.navigationPanels.popPanels(1); + this.$.navigationPanels.pushPanel({name: "episodeListing", kind: "nettv.EpisodeListing"}, { + title: inEvent.get('name'), + titleBelow: inEvent.get('description'), + collection: new enyo.Collection(inEvent.get('episodes')), + headerBackgroundSrc: inEvent.get('thumbURL') + }); + }, + playEpisode: function(inSender, inEvent) { + this.$.player.show(); + this.$.player.set('src', nettv.Util.addBase(inEvent.get('file'))); + this.$.player.play(); + }, + closePlayer: function(inSender, inEvent) { + this.$.player.unload(); + this.$.player.hide(); + } +}); diff --git a/source/nettv/ShowItem.js b/source/nettv/ShowItem.js new file mode 100644 index 0000000..d8e7bfb --- /dev/null +++ b/source/nettv/ShowItem.js @@ -0,0 +1,9 @@ +enyo.kind({ + name: "nettv.ShowItem", + kind: "moon.ImageItem", + bindings: [ + {from: ".model.thumbURL", to: ".source"}, + {from: ".model.name", to: ".label"}, + {from: ".model.description", to: ".text"} + ] +}); diff --git a/source/nettv/ShowListing.js b/source/nettv/ShowListing.js new file mode 100644 index 0000000..e6a002b --- /dev/null +++ b/source/nettv/ShowListing.js @@ -0,0 +1,33 @@ +enyo.kind({ + name: "nettv.ShowListing", + kind: "moon.Panel", + title: "Shows", + titleBelow: "Pick a show, bro", + smallHeader: true, + published: { + collection: null + }, + components: [ + {kind: "Signals", + onConfigReceived: "config"}, + {name: "showList", kind: "moon.DataList", components: [ + {kind: "nettv.ShowItem", ontap: "showEpisodes"} + ]} + ], + bindings: [ + {from: ".collection", to: ".$.showList.collection"} + ], + create: enyo.inherit(function(sup) { + return function() { + this.collection = new ShowCollection(); + sup.apply(this, arguments); + } + }), + config: function(inSender, inEvent) { + this.collection.set('url', config.listing || "shows.json"); + this.collection.fetch(); + }, + showEpisodes: function(inSender, inEvent) { + this.bubble('onShowEpisodes', this.collection.at(inEvent.index)); + } +}); diff --git a/source/nettv/Util.js b/source/nettv/Util.js new file mode 100644 index 0000000..acbbefb --- /dev/null +++ b/source/nettv/Util.js @@ -0,0 +1,8 @@ +enyo.kind({ + name: "nettv.Util", + statics: { + addBase: function(s) { + return config.mediaURL + s; + } + } +}); diff --git a/source/nettv/package.js b/source/nettv/package.js new file mode 100644 index 0000000..81f2e49 --- /dev/null +++ b/source/nettv/package.js @@ -0,0 +1,8 @@ +enyo.depends( + "Util.js", + "ShowItem.js", + "ShowListing.js", + "EpisodeItem.js", + "EpisodeListing.js", + "Main.js" +); diff --git a/source/package.js b/source/package.js new file mode 100644 index 0000000..31cc331 --- /dev/null +++ b/source/package.js @@ -0,0 +1,9 @@ +enyo.depends( + "$lib/layout", + "$lib/moonstone", + "$lib/spotlight", + "style", + "data", + "nettv", + "App.js" +); diff --git a/source/style/nettv.less b/source/style/nettv.less new file mode 100644 index 0000000..e69de29 diff --git a/source/style/package.js b/source/style/package.js new file mode 100644 index 0000000..da352a5 --- /dev/null +++ b/source/style/package.js @@ -0,0 +1,3 @@ +enyo.depends( + "nettv.less" +); diff --git a/tools/deploy.bat b/tools/deploy.bat new file mode 100755 index 0000000..8247ad7 --- /dev/null +++ b/tools/deploy.bat @@ -0,0 +1,40 @@ +@REM don't watch the sausage being made +@ECHO OFF + +REM the folder this script is in (*/bootplate/tools) +SET TOOLS=%~DP0 + +REM application source location +SET SRC=%TOOLS%\.. + +REM enyo location +SET ENYO=%SRC%\enyo + +REM deploy script location +SET DEPLOY=%ENYO%\tools\deploy.js + +REM node location +SET NODE=node.exe + +REM use node to invoke deploy.js with imported parameters +ECHO %NODE% "%DEPLOY%" -T -s "%SRC%" -o "%SRC%\deploy" %* +%NODE% "%DEPLOY%" -T -s "%SRC%" -o "%SRC%\deploy" %* + +REM copy files and package if deploying to cordova webos +:again +if not "%1" == "" ( + + if "%1" == "--cordova-webos" ( + REM copy appinfo.json and cordova*.js files + for %%A in ("%~dp0./..") do SET DEST=%TOOLS%..\deploy\%%~nA + copy %SRC%\appinfo.json %DEST% + copy %SRC%\cordova*.js %DEST% + + REM package it up + if not exist %SRC%\bin mkdir %SRC%\bin + palm-package.bat %DEST% --outdir=%SRC%\bin + ) + + shift + goto again +) diff --git a/tools/deploy.sh b/tools/deploy.sh new file mode 100755 index 0000000..da2328a --- /dev/null +++ b/tools/deploy.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# the folder this script is in (*/bootplate/tools) +TOOLS=$(cd `dirname $0` && pwd) + +# application root +SRC="$TOOLS/.." + +# enyo location +ENYO="$SRC/enyo" + +# deploy script location +DEPLOY="$ENYO/tools/deploy.js" + +# check for node, but quietly +if command -v node >/dev/null 2>&1; then + # use node to invoke deploy with imported parameters + echo "node $DEPLOY -T -s $SRC -o $SRC/deploy $@" + node "$DEPLOY" -T -s "$SRC" -o "$SRC/deploy" $@ +else + echo "No node found in path" + exit 1 +fi + +# copy files and package if deploying to cordova webos +while [ "$1" != "" ]; do + case $1 in + -w | --cordova-webos ) + # copy appinfo.json and cordova*.js files + DEST="$TOOLS/../deploy/"${PWD##*/} + + cp "$SRC"/appinfo.json "$DEST" -v + cp "$SRC"/cordova*.js "$DEST" -v + + # package it up + mkdir -p "$DEST/bin" + palm-package "$DEST/bin" + ;; + esac + shift +done -- 2.34.1