From 6f9f8e42c13870d016590d540b4e3565075d3795 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Thu, 17 Nov 2016 23:07:22 +0100 Subject: [PATCH] first commit --- README.md | 6 +++ ajax/seturl.php | 14 +++++++ appinfo/app.php | 34 ++++++++++++++++ appinfo/database.xml | 38 ++++++++++++++++++ appinfo/info.xml | 10 +++++ appinfo/routes.php | 12 ++++++ appinfo/version | 1 + css/main.css | 26 ++++++++++++ db/stream.php | 21 ++++++++++ img/radio.png | Bin 0 -> 1037 bytes img/radio.svg | 87 +++++++++++++++++++++++++++++++++++++++++ index.php | 33 ++++++++++++++++ js/admin.js | 15 +++++++ js/main.js | 33 ++++++++++++++++ settings.php | 11 ++++++ templates/main.php | 22 +++++++++++ templates/settings.php | 8 ++++ 17 files changed, 371 insertions(+) create mode 100644 README.md create mode 100755 ajax/seturl.php create mode 100755 appinfo/app.php create mode 100755 appinfo/database.xml create mode 100755 appinfo/info.xml create mode 100644 appinfo/routes.php create mode 100755 appinfo/version create mode 100644 css/main.css create mode 100644 db/stream.php create mode 100644 img/radio.png create mode 100644 img/radio.svg create mode 100755 index.php create mode 100755 js/admin.js create mode 100644 js/main.js create mode 100755 settings.php create mode 100755 templates/main.php create mode 100755 templates/settings.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..dbdf9af --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +* https://doc.owncloud.org/server/9.0/developer_manual/app/tutorial.html +* https://github.com/owncloud/app-tutorial#tutorial +* http://127.0.0.1/index.php/settings/apps + +* https://mvigil-cs263-technology-project.readthedocs.io/en/latest/apptutorial.html +* docker run -v /home/onny/projects/owncloud-app-radio:/var/www/html/apps/radio -d -p 80:80 owncloud:latestdocker run -v /home/onny/projects/owncloud-app-radio:/var/www/html/apps/radio -d -p 80:80 owncloud:latest diff --git a/ajax/seturl.php b/ajax/seturl.php new file mode 100755 index 0000000..c2bcabe --- /dev/null +++ b/ajax/seturl.php @@ -0,0 +1,14 @@ + + * Copyright (c) 2012, Florian Hülsmann + * This file is licensed under the Affero General Public License version 3 or later. + * See the COPYING-README file. + */ + +OCP\User::checkAdminUser(); +OCP\JSON::callCheck(); + +OCP\Config::setSystemValue( 'somesetting', $_GET['somesetting'] ); + +echo 'true'; diff --git a/appinfo/app.php b/appinfo/app.php new file mode 100755 index 0000000..c8963fe --- /dev/null +++ b/appinfo/app.php @@ -0,0 +1,34 @@ +. +* +*/ + +OCP\App::registerAdmin( 'radio', 'settings' ); + +OCP\App::addNavigationEntry( array( + 'id' => 'radio', + 'order' => 74, + 'href' => OCP\Util::linkTo( 'radio', 'index.php' ), + 'icon' => OCP\Util::imagePath( 'radio', 'radio.png' ), + 'name' => 'Radio' +)); diff --git a/appinfo/database.xml b/appinfo/database.xml new file mode 100755 index 0000000..f8f8243 --- /dev/null +++ b/appinfo/database.xml @@ -0,0 +1,38 @@ + + + *dbname* + true + false + utf8 + + *dbprefix*radio_streams + + + id + integer + 0 + true + 1 + 4 + + + name + text + true + 64 + + + url + text + true + 100 + + + image + text + true + 100 + + +
+
diff --git a/appinfo/info.xml b/appinfo/info.xml new file mode 100755 index 0000000..90b07f2 --- /dev/null +++ b/appinfo/info.xml @@ -0,0 +1,10 @@ + + + radio + Radio + Listening to your favorite radio stations in NextCloud + 0.1 + MIT + Jonas Heinrich + 9 + diff --git a/appinfo/routes.php b/appinfo/routes.php new file mode 100644 index 0000000..eefb4fc --- /dev/null +++ b/appinfo/routes.php @@ -0,0 +1,12 @@ + + * This file is licensed under the Affero General Public License version 3 or later. + * See the COPYING-README file. + */ + +/** @var $this \OCP\Route\IRouter */ +$this->create('radio_index', '/') + ->actionInclude('radio/index.php'); +$this->create('radio_ajax_seturl', 'ajax/seturl.php') + ->actionInclude('radio/ajax/seturl.php'); diff --git a/appinfo/version b/appinfo/version new file mode 100755 index 0000000..49d5957 --- /dev/null +++ b/appinfo/version @@ -0,0 +1 @@ +0.1 diff --git a/css/main.css b/css/main.css new file mode 100644 index 0000000..5cdad3b --- /dev/null +++ b/css/main.css @@ -0,0 +1,26 @@ +body { + padding: 20px; +} + +input { + width: 100%; + margin-bottom: 20px; +} + +table { + width: 100%; +} + +td{ + border-right: none; + border-left: none; +} + +tr{ + padding: 5px; +} + +tr:hover { + background-color: edeff2; + transition: all 0.1s ease; +} diff --git a/db/stream.php b/db/stream.php new file mode 100644 index 0000000..d4cd495 --- /dev/null +++ b/db/stream.php @@ -0,0 +1,21 @@ + $this->name, + 'url' => $this->url, + 'image' => $this->image + ]; + } +} diff --git a/img/radio.png b/img/radio.png new file mode 100644 index 0000000000000000000000000000000000000000..aa1d24ee7c4dc97e4330f0cc6af9cbddccd6ca77 GIT binary patch literal 1037 zcmV+o1oHcdP)oTG%4!;!c#Nz^HJcL_{fph)q`{CDR$_;#``3E#CL!=b1Az zXU>c>fA~1xd;35C_xYaZdEWyI0Cktzul}H}UI+nKs!w<+UIHl3gYgZ(1Hgko7a%YU zEC$AbqnFEYv-+s|u6jZpQa@E+R&P`z&v{I}c`glyx2uqF@x z3hc|z!H5`}t$>?ayEi5;60oAG^DST*&<1=y1LI@B2f%F+(H0R~Bcg*; z>~@f1a5Ahw?JZ=%BH}~fg&G`7QAexPeWc#4KCT|C!yB*U-Imoh({WJi zSy}MR-YSj})PL$QHW~WW#cGTCXC3pqvyg37{bOYsJb^R5jELb(z6MyH`&+Achk?O} z=*#WHq=I%$ZbvO4CxBg~%-LC(TnoQv5naHYxo-)R#Fh%MFCq@9Jq7MknN+STVn#`U zS21uJ_;?B-mGa#VY{~)_k?KYh&{AW~_xX3csIfX&d#ZM@ahh+wX9|&1LOoUB87*gJ zl?u8}-5wEN=k{~c@a<5W^7`Gt?LaAyEhEK7#cM;rR}t~5x&>HO;2Fns(<)*_{Y?F) zjx11pv9QY)^=fsk7t?la?rSZ~d%ucfAk;oCMtdXZ1v(?*=WJvZ>3pdeJ_j6&h@m|G zFsa;^3LJeUE)AMS&iK zyVdbY)}9LWD6n~!UMXS__>pu5m4O>b={*&Wlz~HYETozA4`3!Z9O`wz5hmVC<_l+l zt(D93I?{#cR?_j^JjKFF<(v+Kq)J^27l6NjZ-KWX;*b9T`QGrs#a8Qp00000NkvXX Hu0mjfw{+eD literal 0 HcmV?d00001 diff --git a/img/radio.svg b/img/radio.svg new file mode 100644 index 0000000..1ee1f01 --- /dev/null +++ b/img/radio.svg @@ -0,0 +1,87 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/index.php b/index.php new file mode 100755 index 0000000..ca97156 --- /dev/null +++ b/index.php @@ -0,0 +1,33 @@ +. +* +*/ + +// Check if we are a user +OCP\User::checkLoggedIn(); + +$somesetting = OCP\Config::getSystemValue( "somesetting", '' ); +OCP\App::setActiveNavigationEntry( 'radio' ); +$tmpl = new OCP\Template( 'radio', 'main', 'user' ); +$tmpl->assign( 'somesetting', $somesetting ); +$tmpl->printPage(); diff --git a/js/admin.js b/js/admin.js new file mode 100755 index 0000000..cfe81a5 --- /dev/null +++ b/js/admin.js @@ -0,0 +1,15 @@ +$(document).ready(function(){ + + + + $('#somesetting').blur(function(event){ + event.preventDefault(); + var post = $( "#somesetting" ).serialize(); + $.post( OC.filePath('radio', 'ajax', 'seturl.php') , post, function(data){ + $('#radio .msg').text('Finished saving: ' + data); + }); + }); + + + +}); diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..f9a23b4 --- /dev/null +++ b/js/main.js @@ -0,0 +1,33 @@ +$(window).on('load', function(){ + + $('body').on('click', 'tr', function() { + var sourceUrl = $(this).attr('src'); + $("#player").attr("src", sourceUrl); + $('#player').trigger('play'); + }); + + function show_result(data){ + $("tbody > tr").remove(); + $.each(data, function(i, station) { + $('tbody').append(''+station['name']+''); + }); + } + + function search(query){ + $.ajax({ + method: "POST", + url: 'http://www.radio-browser.info/webservice/json/stations/search', + data: { + name: query + }, + dataType: 'json', + success: show_result + }); + }; + + $('form').submit(function() { + var query = $('input').val(); + search(query); + return false; + }); +}); diff --git a/settings.php b/settings.php new file mode 100755 index 0000000..24c07ee --- /dev/null +++ b/settings.php @@ -0,0 +1,11 @@ +assign('url', OCP\Config::getSystemValue( "somesetting", '' )); + +return $tmpl->fetchPage(); diff --git a/templates/main.php b/templates/main.php new file mode 100755 index 0000000..04d2d8f --- /dev/null +++ b/templates/main.php @@ -0,0 +1,22 @@ + + + +
+ +
+ + + + + + + + + + +
TestTestTestTest
+ + diff --git a/templates/settings.php b/templates/settings.php new file mode 100755 index 0000000..ffe05fb --- /dev/null +++ b/templates/settings.php @@ -0,0 +1,8 @@ +
+
+

t('App Template'));?>

+ +
+ +
+