Browse Source

Merge pull request #112 from mrquatsch/runeaudio

enhanced runeaudio app - displays artist and song
pull/118/head
KodeStar 7 years ago
committed by GitHub
parent
commit
eccd6056bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 94
      app/SupportedApps/Runeaudio.php
  2. 57
      public/css/app.css
  3. 2
      public/mix-manifest.json
  4. 15
      resources/assets/sass/_rune.scss
  5. 1
      resources/assets/sass/app.scss
  6. 21
      resources/views/supportedapps/runeaudio.blade.php
  7. BIN
      storage/app/public/supportedapps/runeaudio.png

94
app/SupportedApps/Runeaudio.php

@ -0,0 +1,94 @@
<?php namespace App\SupportedApps;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
class Runeaudio implements Contracts\Applications, Contracts\Livestats {
public function defaultColour()
{
return '#05A';
}
public function icon()
{
return 'supportedapps/runeaudio.png';
}
public function configDetails()
{
return 'runeaudio';
}
public function testConfig()
{
$res = $this->buildRequest('status');
switch($res->getStatusCode()) {
case 200:
echo 'Successfully connected to the API';
break;
case 401:
echo 'Failed: Invalid credentials';
break;
case 404:
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash';
break;
default:
echo 'Something went wrong... Code: '.$res->getStatusCode();
break;
}
}
public function executeConfig()
{
$output = '';
$artist = '';
$song_title = '';
$res = $this->buildRequest('currentsong');
$array = explode("\n", $res->getBody());
foreach($array as $item) {
$item_array = explode(": ", $item);
if ($item_array[0] == 'Artist') {
$artist = $item_array[1];
} elseif ($item_array[0] == 'Title') {
$song_title = $item_array[1];
}
}
$output = '<ul class="livestats">';
if (strlen($artist) > 12) {
$output = $output.'<li><span class="title-marquee"><span>'.$artist.'</span></span></li>';
} else {
$output = $output.'<li><span class="title">'.$artist.'</span></li>';
}
$output = $output.'</ul><ul class="livestats">';
if (strlen($song_title) > 12) {
$output = $output.'<li><span class="title-marquee"><span>'.$song_title.'</span></span></li>';
} else {
$output = $output.'<li><span class="title">'.$song_title.'</span></li>';
}
$output = $output.'</ul>';
return $output;
}
public function buildRequest($endpoint)
{
$config = $this->config;
$url = $config->url;
$url = rtrim($url, '/');
$api_url = $url.'/command/?cmd='.$endpoint;
//die( $api_url.' --- ');
$client = new Client(['http_errors' => false]);
$res = $client->request('GET', $api_url);
return $res;
}
}

57
public/css/app.css

@ -1169,6 +1169,63 @@ select:-webkit-autofill:focus {
color: #2f313a !important;
}
.title-marquee {
width: 125px;
overflow: hidden;
}
.title-marquee span {
white-space: nowrap;
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
-webkit-animation: marquee 8s linear;
animation: marquee 8s linear;
}
@-webkit-keyframes marquee {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
20% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
95% {
-webkit-transform: translate(-200%, 0);
transform: translate(-200%, 0);
}
100% {
-webkit-transform: translate(-200%, 0);
transform: translate(-200%, 0);
}
}
@keyframes marquee {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
20% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
95% {
-webkit-transform: translate(-200%, 0);
transform: translate(-200%, 0);
}
100% {
-webkit-transform: translate(-200%, 0);
transform: translate(-200%, 0);
}
}
/*! Huebee v2.0.0
http://huebee.buzz
---------------------------------------------- */

2
public/mix-manifest.json

@ -1,4 +1,4 @@
{
"/css/app.css": "/css/app.css?id=353c513dd97a5fa0607d",
"/css/app.css": "/css/app.css?id=7e76b8c135b6dbd38363",
"/js/app.js": "/js/app.js?id=24ea5e5c1fbea3461a14"
}

15
resources/assets/sass/_rune.scss

@ -0,0 +1,15 @@
.title-marquee {
width: 125px;
overflow: hidden;
span {
white-space: nowrap;
transform: translate(0, 0);
animation: marquee 8s linear;
}
@keyframes marquee {
0% { transform: translate(0, 0); }
20% { transform: translate(0, 0); }
95% { transform: translate(-200%, 0); }
100% { transform: translate(-200%, 0); }
}
}

1
resources/assets/sass/app.scss

@ -10,6 +10,7 @@
// Bootstrap
@import "app";
@import "rune";
// Huebee
@import "huebee";

21
resources/views/supportedapps/runeaudio.blade.php

@ -0,0 +1,21 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Runeaudio" />
<input type="hidden" data-config="dataonly" class="config-item" name="config[dataonly]" value="1" />
<div class="input">
<label>{{ __('app.apps.enable') }}</label>
{!! Form::hidden('config[enabled]', '0') !!}
<label class="switch">
<?php
$checked = false;
if(isset($item->config->enabled) && (bool)$item->config->enabled === true) $checked = true;
$set_checked = ($checked) ? ' checked="checked"' : '';
?>
<input type="checkbox" name="config[enabled]" value="1"<?php echo $set_checked;?> />
<span class="slider round"></span>
</label>
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

BIN
storage/app/public/supportedapps/runeaudio.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Loading…
Cancel
Save